[ctypes-commit] ctypes/source exec_malloc.c,1.1,1.2
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-20 17:30:30
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25156 Modified Files: exec_malloc.c Log Message: Windows code separate from *nix/bsd code. Index: exec_malloc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/exec_malloc.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** exec_malloc.c 20 Oct 2004 16:53:19 -0000 1.1 --- exec_malloc.c 20 Oct 2004 17:30:20 -0000 1.2 *************** *** 4,15 **** --- 4,39 ---- #include "ctypes.h" + #ifndef MS_WIN32 + + #include <sys/mman.h> + # if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) + # define MAP_ANONYMOUS MAP_ANON + # endif + + #endif + void FreeExecMem(void *p) { + #ifdef MS_WIN32 PyMem_Free(p); + #endif } void *MallocExecMem(int size) { + #ifdef MS_WIN32 return PyMem_Malloc(size); + #else + void *page; + page = mmap(NULL, + size, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, + 0); + if (page == (void *)MAP_FAILED) + return NULL; + return page; + #endif } |