Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com>
---
 Makefile                 |    2 +-
 include/lib/guard-page.h |    9 +++++
 include/vm/guard-page.h  |    9 -----
 jit/exception.c          |    2 +-
 lib/guard-page.c         |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 test/arch-x86/Makefile   |    2 +-
 test/jit/Makefile        |    2 +-
 vm/gc.c                  |    2 +-
 vm/guard-page.c          |   90 ----------------------------------------------
 vm/jni-interface.c       |    3 +-
 vm/stack-trace.c         |    3 +-
 vm/static.c              |    3 +-
 12 files changed, 110 insertions(+), 107 deletions(-)
 create mode 100644 include/lib/guard-page.h
 delete mode 100644 include/vm/guard-page.h
 create mode 100644 lib/guard-page.c
 delete mode 100644 vm/guard-page.c

diff --git a/Makefile b/Makefile
index d623810..5f7a5f5 100644
--- a/Makefile
+++ b/Makefile
@@ -105,7 +105,6 @@ VM_OBJS = \
        vm/fault-inject.o       \
        vm/field.o              \
        vm/gc.o                 \
-       vm/guard-page.o         \
        vm/itable.o             \
        vm/jar.o                \
        vm/jato.o               \
@@ -130,6 +129,7 @@ VM_OBJS = \
 LIB_OBJS = \
        lib/bitset.o            \
        lib/buffer.o            \
+       lib/guard-page.o        \
        lib/list.o              \
        lib/pqueue.o            \
        lib/radix-tree.o        \
diff --git a/include/lib/guard-page.h b/include/lib/guard-page.h
new file mode 100644
index 0000000..0d20254
--- /dev/null
+++ b/include/lib/guard-page.h
@@ -0,0 +1,9 @@
+#ifndef _LIB_GUARD_PAGE_
+#define _LIB_GUARD_PAGE_
+
+void *alloc_guard_page(void);
+void *alloc_offset_guard(unsigned long valid_size, unsigned long 
overflow_size);
+int hide_guard_page(void *page_ptr);
+int unhide_guard_page(void *page_ptr);
+
+#endif /* _LIB_GUARD_PAGE_ */
diff --git a/include/vm/guard-page.h b/include/vm/guard-page.h
deleted file mode 100644
index a779b02..0000000
--- a/include/vm/guard-page.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _VM_GUARD_PAGE_
-#define _VM_GUARD_PAGE_
-
-void *alloc_guard_page(void);
-void *alloc_offset_guard(unsigned long valid_size, unsigned long 
overflow_size);
-int hide_guard_page(void *page_ptr);
-int unhide_guard_page(void *page_ptr);
-
-#endif /* _VM_GUARD_PAGE_ */
diff --git a/jit/exception.c b/jit/exception.c
index f99291d..6fa7055 100644
--- a/jit/exception.c
+++ b/jit/exception.c
@@ -34,8 +34,8 @@
 #include "jit/compiler.h"
 
 #include "lib/buffer.h"
+#include "lib/guard-page.h"
 
-#include "vm/guard-page.h"
 #include "vm/preload.h"
 #include "vm/method.h"
 #include "vm/object.h"
diff --git a/lib/guard-page.c b/lib/guard-page.c
new file mode 100644
index 0000000..40764e6
--- /dev/null
+++ b/lib/guard-page.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2009 Tomasz Grabiec
+ *
+ * This file is released under the GPL version 2 with the following
+ * clarification and special exception:
+ *
+ *     Linking this library statically or dynamically with other modules is
+ *     making a combined work based on this library. Thus, the terms and
+ *     conditions of the GNU General Public License cover the whole
+ *     combination.
+ *
+ *     As a special exception, the copyright holders of this library give you
+ *     permission to link this library with independent modules to produce an
+ *     executable, regardless of the license terms of these independent
+ *     modules, and to copy and distribute the resulting executable under terms
+ *     of your choice, provided that you also meet, for each linked independent
+ *     module, the terms and conditions of the license of that module. An
+ *     independent module is a module which is not derived from or based on
+ *     this library. If you modify this library, you may extend this exception
+ *     to your version of the library, but you are not obligated to do so. If
+ *     you do not wish to do so, delete this exception statement from your
+ *     version.
+ *
+ * Please refer to the file LICENSE for details.
+ */
+
+#include "lib/guard-page.h"
+#include "vm/alloc.h"
+#include "vm/die.h"
+
+#include <sys/mman.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+
+/**
+ * alloc_offset_guard - allocates a memory region with two
+ *   sub-regions. The first one contains addresses from [0:valid_size[
+ *   with access allowed. The second region contains addresses
+ *   [valid_size:valid_size + overflow_size[ and access to this region
+ *   triggers SIGSEGV.
+ */
+void *alloc_offset_guard(unsigned long valid_size, unsigned long overflow_size)
+{
+       int valid_pages, overflow_pages;
+       int page_size;
+       void *result;
+
+       assert(overflow_size > 0);
+
+       page_size = getpagesize();
+
+       valid_pages = (valid_size + page_size - 1) / page_size;
+       overflow_pages = (overflow_size + page_size - 1) / page_size;
+
+       result = alloc_pages(valid_pages + overflow_pages);
+
+       mprotect(result + valid_pages * page_size,
+                overflow_pages * page_size,
+                PROT_NONE);
+
+       unsigned long offset = page_size - valid_size % page_size;
+       if (offset == (unsigned long) page_size)
+               offset = 0;
+
+       return result + offset;
+}
+
+void *alloc_guard_page(void)
+{
+       void *p = alloc_pages(1);
+
+       if (p == NULL)
+               return NULL;
+
+       if (hide_guard_page(p))
+               return NULL;
+
+       return p;
+}
+
+int hide_guard_page(void *page_ptr)
+{
+       return mprotect(page_ptr, getpagesize(), PROT_NONE);
+}
+
+int unhide_guard_page(void *page_ptr)
+{
+       return mprotect(page_ptr, getpagesize(), PROT_READ|PROT_WRITE);
+}
diff --git a/test/arch-x86/Makefile b/test/arch-x86/Makefile
index eb387cb..72bf355 100644
--- a/test/arch-x86/Makefile
+++ b/test/arch-x86/Makefile
@@ -52,6 +52,7 @@ TOPLEVEL_OBJS := \
        jit/vtable.o \
        lib/buffer.o \
        lib/list.o \
+       lib/guard-page.o \
        lib/radix-tree.o \
        lib/string.o \
        vm/bytecode.o \
@@ -60,7 +61,6 @@ TOPLEVEL_OBJS := \
        vm/class.o \
        vm/die.o \
        vm/field.o \
-       vm/guard-page.o \
        vm/itable.o \
        vm/jni-interface.o \
        vm/method.o \
diff --git a/test/jit/Makefile b/test/jit/Makefile
index 8c64ba8..724d575 100644
--- a/test/jit/Makefile
+++ b/test/jit/Makefile
@@ -47,6 +47,7 @@ TOPLEVEL_OBJS := \
        lib/bitset.o \
        lib/buffer.o \
        lib/list.o \
+       lib/guard-page.o \
        lib/pqueue.o \
        lib/radix-tree.o \
        lib/string.o \
@@ -54,7 +55,6 @@ TOPLEVEL_OBJS := \
        vm/bytecode.o \
        vm/bytecodes.o \
        vm/die.o \
-       vm/guard-page.o \
        vm/stack.o \
        vm/trace.o \
        vm/types.o \
diff --git a/vm/gc.c b/vm/gc.c
index f6c156a..f182eb6 100644
--- a/vm/gc.c
+++ b/vm/gc.c
@@ -1,6 +1,6 @@
+#include "lib/guard-page.h"
 #include "vm/die.h"
 #include "vm/gc.h"
-#include "vm/guard-page.h"
 
 void *gc_safepoint_page;
 
diff --git a/vm/guard-page.c b/vm/guard-page.c
deleted file mode 100644
index f47c936..0000000
--- a/vm/guard-page.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2009 Tomasz Grabiec
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- *     Linking this library statically or dynamically with other modules is
- *     making a combined work based on this library. Thus, the terms and
- *     conditions of the GNU General Public License cover the whole
- *     combination.
- *
- *     As a special exception, the copyright holders of this library give you
- *     permission to link this library with independent modules to produce an
- *     executable, regardless of the license terms of these independent
- *     modules, and to copy and distribute the resulting executable under terms
- *     of your choice, provided that you also meet, for each linked independent
- *     module, the terms and conditions of the license of that module. An
- *     independent module is a module which is not derived from or based on
- *     this library. If you modify this library, you may extend this exception
- *     to your version of the library, but you are not obligated to do so. If
- *     you do not wish to do so, delete this exception statement from your
- *     version.
- *
- * Please refer to the file LICENSE for details.
- */
-
-#include "vm/guard-page.h"
-#include "vm/alloc.h"
-#include "vm/die.h"
-
-#include <sys/mman.h>
-#include <unistd.h>
-#include <assert.h>
-#include <stdio.h>
-
-/**
- * alloc_offset_guard - allocates a memory region with two
- *   sub-regions. The first one contains addresses from [0:valid_size[
- *   with access allowed. The second region contains addresses
- *   [valid_size:valid_size + overflow_size[ and access to this region
- *   triggers SIGSEGV.
- */
-void *alloc_offset_guard(unsigned long valid_size, unsigned long overflow_size)
-{
-       int valid_pages, overflow_pages;
-       int page_size;
-       void *result;
-
-       assert(overflow_size > 0);
-
-       page_size = getpagesize();
-
-       valid_pages = (valid_size + page_size - 1) / page_size;
-       overflow_pages = (overflow_size + page_size - 1) / page_size;
-
-       result = alloc_pages(valid_pages + overflow_pages);
-
-       mprotect(result + valid_pages * page_size,
-                overflow_pages * page_size,
-                PROT_NONE);
-
-       unsigned long offset = page_size - valid_size % page_size;
-       if (offset == (unsigned long) page_size)
-               offset = 0;
-
-       return result + offset;
-}
-
-void *alloc_guard_page(void)
-{
-       void *p = alloc_pages(1);
-
-       if (p == NULL)
-               return NULL;
-
-       if (hide_guard_page(p))
-               return NULL;
-
-       return p;
-}
-
-int hide_guard_page(void *page_ptr)
-{
-       return mprotect(page_ptr, getpagesize(), PROT_NONE);
-}
-
-int unhide_guard_page(void *page_ptr)
-{
-       return mprotect(page_ptr, getpagesize(), PROT_READ|PROT_WRITE);
-}
diff --git a/vm/jni-interface.c b/vm/jni-interface.c
index 5766af6..193a601 100644
--- a/vm/jni-interface.c
+++ b/vm/jni-interface.c
@@ -30,11 +30,12 @@
 
 #include "jit/exception.h"
 
+#include "lib/guard-page.h"
+
 #include "vm/call.h"
 #include "vm/class.h"
 #include "vm/classloader.h"
 #include "vm/die.h"
-#include "vm/guard-page.h"
 #include "vm/jni.h"
 #include "vm/method.h"
 #include "vm/object.h"
diff --git a/vm/stack-trace.c b/vm/stack-trace.c
index 9383333..c0c1ca1 100644
--- a/vm/stack-trace.c
+++ b/vm/stack-trace.c
@@ -24,11 +24,12 @@
  * Please refer to the file LICENSE for details.
  */
 
+#include "lib/guard-page.h"
+
 #include "vm/backtrace.h"
 #include "vm/call.h"
 #include "vm/class.h"
 #include "vm/classloader.h"
-#include "vm/guard-page.h"
 #include "vm/jni.h"
 #include "vm/object.h"
 #include "vm/method.h"
diff --git a/vm/static.c b/vm/static.c
index 69551fb..d28a01c 100644
--- a/vm/static.c
+++ b/vm/static.c
@@ -1,8 +1,9 @@
 #include "jit/cu-mapping.h"
 #include "jit/exception.h"
 
+#include "lib/guard-page.h"
+
 #include "vm/class.h"
-#include "vm/guard-page.h"
 #include "vm/object.h"
 #include "vm/signal.h"
 
-- 
1.6.0.6


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to