5 * No matter what, try to get clear memory and be non-blocking.
6 * XXX check if 2.4 has a native way to zero memory,
7 * XXX obey to the flags (M_NOWAIT <-> GPF_ATOMIC, M_WAIT <-> GPF_KERNEL)
9 #ifndef _WIN32 /* this is the linux version */
11 #if !defined (LINUX_24) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
12 #define malloc(_size, type, flags) \
13 kmalloc(_size, GFP_ATOMIC | __GFP_ZERO)
14 #else /* LINUX <= 2.6.22 and LINUX_24 */
15 /* linux 2.6.22 does not zero allocated memory */
16 #define malloc(_size, type, flags) \
18 void *_ret = kmalloc(_s, GFP_ATOMIC); \
19 if (_ret) memset(_ret, 0, _s); \
22 #endif /* LINUX <= 2.6.22 */
24 #define calloc(_n, _s) malloc((_n * _s), NULL, GFP_ATOMIC | __GFP_ZERO)
25 #define free(_var, type) kfree(_var)
27 #else /* _WIN32, the windows version */
30 * ntddk.h uses win_malloc() and MmFreeContiguousMemory().
32 * ExAllocatePoolWithTag(, pool, len, tag)
33 * ExFreePoolWithTag(ptr, tag)
35 #define malloc(_size, _type, _flags) my_alloc(_size)
37 void *my_alloc(int _size);
38 /* the 'tag' version does not work without -Gz in the linker */
39 #define free(_var, type) ExFreePool(_var)
40 //#define free(_var, type) ExFreePoolWithTag(_var, 'wfpi')
44 #define M_NOWAIT 0x0001 /* do not block */
45 #define M_ZERO 0x0100 /* bzero the allocation */
46 #endif /* _SYS_MALLOC_H_ */