1 #ifndef __TOOLS_LINUX_VMALLOC_H
2 #define __TOOLS_LINUX_VMALLOC_H
7 #include "linux/slab.h"
8 #include "tools-util.h"
11 #define PAGE_KERNEL_EXEC 1
13 #define vfree(p) free(p)
15 static inline void *__vmalloc(unsigned long size, gfp_t gfp_mask)
21 p = aligned_alloc(PAGE_SIZE, size);
25 if (gfp_mask & __GFP_ZERO)
31 static inline void *vmalloc_exec(unsigned long size, gfp_t gfp_mask)
35 p = __vmalloc(size, gfp_mask);
39 if (mprotect(p, size, PROT_READ|PROT_WRITE|PROT_EXEC)) {
47 static inline void *vmalloc(unsigned long size)
49 return __vmalloc(size, GFP_KERNEL);
52 static inline void *vzalloc(unsigned long size)
54 return __vmalloc(size, GFP_KERNEL|__GFP_ZERO);
57 #endif /* __TOOLS_LINUX_VMALLOC_H */