[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] libjit ChangeLog jit/jit-alloc.c
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] libjit ChangeLog jit/jit-alloc.c |
Date: |
Tue, 22 Aug 2006 18:02:55 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: libjit
Changes by: Klaus Treichel <ktreichel> 06/08/22 18:02:55
Modified files:
. : ChangeLog
jit : jit-alloc.c
Log message:
2006-08-22 Klaus treichel <address@hidden>
* jit/jit-alloc.c: Use mmap and munmap to allocate executable
memory
where available because memory allocated with malloc is not
executable
on some archs/distros.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libjit/ChangeLog?cvsroot=dotgnu-pnet&r1=1.253&r2=1.254
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/jit-alloc.c?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/libjit/ChangeLog,v
retrieving revision 1.253
retrieving revision 1.254
diff -u -b -r1.253 -r1.254
--- ChangeLog 22 Aug 2006 17:30:09 -0000 1.253
+++ ChangeLog 22 Aug 2006 18:02:55 -0000 1.254
@@ -1,3 +1,9 @@
+2006-08-22 Klaus treichel <address@hidden>
+
+ * jit/jit-alloc.c: Use mmap and munmap to allocate executable memory
+ where available because memory allocated with malloc is not executable
+ on some archs/distros.
+
2006-08-23 Aleksey Demakov <address@hidden>
* jit/jit-reg-alloc.c: improve handling of three-address op codes.
Index: jit/jit-alloc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/libjit/jit/jit-alloc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- jit/jit-alloc.c 7 Jun 2004 22:07:11 -0000 1.4
+++ jit/jit-alloc.c 22 Aug 2006 18:02:55 -0000 1.5
@@ -40,6 +40,21 @@
#include <windows.h>
#include <io.h>
#endif
+#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
+/*
+ * Make sure that "MAP_ANONYMOUS" is correctly defined, because it
+ * may not exist on some variants of Unix.
+ */
+#ifndef MAP_ANONYMOUS
+ #ifdef MAP_ANON
+ #define MAP_ANONYMOUS MAP_ANON
+ #endif
+#endif
+#ifdef MAP_ANONYMOUS
+#define JIT_USE_MMAP
+#endif
+#endif
+
/*@
* @section Memory allocation
@@ -126,7 +141,18 @@
@*/
void *jit_malloc_exec(unsigned int size)
{
+#ifdef JIT_USE_MMAP
+ void *ptr = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE |
MAP_ANONYMOUS, -1, 0);
+
+ if(ptr == (void *)-1)
+ {
+ return (void *)0;
+ }
+ return ptr;
+#else
return malloc(size);
+#endif
}
/*@
@@ -141,7 +167,11 @@
{
if(ptr)
{
+ #ifdef JIT_USE_MMAP
+ munmap(ptr, size);
+ #else
free(ptr);
+ #endif
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] libjit ChangeLog jit/jit-alloc.c,
Klaus Treichel <=