forked from PoliEcho-holding-org/kern
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
#ifndef _KMALLOC_H
|
|
#define _KMALLOC_H
|
|
|
|
#include "types.h"
|
|
|
|
// This function allocates size bytes of contiguous memory.
|
|
// Returns a pointer to allocated memory or NULL.
|
|
void* kmalloc(size_t size);
|
|
|
|
// This function allocates size bytes of contiguous, zeroed-out memory.
|
|
// Returns a pointer to allocated memory or NULL.
|
|
void* kzalloc(size_t size);
|
|
|
|
// This function allocates memory for count elements each of size bytes,
|
|
// zeroed-out memory. Returns a pointer to allocated memory or NULL.
|
|
void* kcalloc(size_t count, size_t size);
|
|
|
|
// powers of 2
|
|
#define KMALLOC_MAX_SIZE 17
|
|
|
|
union per_cpu_freelist_cache {
|
|
void* freelists[KMALLOC_MAX_SIZE];
|
|
struct {
|
|
void* kmalloc_8;
|
|
void* kmalloc_16;
|
|
void* kmalloc_32;
|
|
void* kmalloc_64;
|
|
void* kmalloc_128;
|
|
void* kmalloc_256;
|
|
void* kmalloc_512;
|
|
void* kmalloc_1024;
|
|
void* kmalloc_2048;
|
|
void* kmalloc_4096;
|
|
void* kmalloc_8192;
|
|
void* kmalloc_16384;
|
|
void* kmalloc_32768;
|
|
void* kmalloc_65536;
|
|
void* kmalloc_131072;
|
|
};
|
|
};
|
|
|
|
union partial_list {
|
|
void* freelists[KMALLOC_MAX_SIZE];
|
|
struct {
|
|
void* kmalloc_8;
|
|
void* kmalloc_16;
|
|
void* kmalloc_32;
|
|
void* kmalloc_64;
|
|
void* kmalloc_128;
|
|
void* kmalloc_256;
|
|
void* kmalloc_512;
|
|
void* kmalloc_1024;
|
|
void* kmalloc_2048;
|
|
void* kmalloc_4096;
|
|
void* kmalloc_8192;
|
|
void* kmalloc_16384;
|
|
void* kmalloc_32768;
|
|
void* kmalloc_65536;
|
|
void* kmalloc_131072;
|
|
};
|
|
};
|
|
|
|
#endif |