You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/18 09:56:32 UTC

svn commit: r785943 - in /commons/sandbox/runtime/trunk/src/main/native: ./ include/ os/darwin/ os/hpux/ os/linux/ os/solaris/ os/unix/ os/win32/ shared/ test/

Author: mturk
Date: Thu Jun 18 07:56:31 2009
New Revision: 785943

URL: http://svn.apache.org/viewvc?rev=785943&view=rev
Log:
Add executable memory allocation native code

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c   (with props)
    commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.in
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
    commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Thu Jun 18 07:56:31 2009
@@ -32,6 +32,7 @@
 LIB=@lib@
 OBJ=@obj@
 EXE=@exe@
+AS=@as@
 AR=@ar@
 ARFLAGS=@arflags@
 RANLIB=@ranlib@
@@ -87,6 +88,7 @@
 	$(SRCDIR)/modules/network/ssl/openssl.$(OBJ)
 
 LINUX_OBJS= \
+	$(SRCDIR)/os/unix/execmem.$(OBJ) \
 	$(SRCDIR)/os/unix/file.$(OBJ) \
 	$(SRCDIR)/os/unix/main.$(OBJ) \
 	$(SRCDIR)/os/unix/group.$(OBJ) \
@@ -101,6 +103,7 @@
 	$(SRCDIR)/os/linux/os.$(OBJ)
 
 SOLARIS_OBJS= \
+	$(SRCDIR)/os/unix/execmem.$(OBJ) \
 	$(SRCDIR)/os/unix/file.$(OBJ) \
 	$(SRCDIR)/os/unix/main.$(OBJ) \
 	$(SRCDIR)/os/unix/group.$(OBJ) \
@@ -114,6 +117,7 @@
 	$(SRCDIR)/os/solaris/os.$(OBJ)
 
 DARWIN_OBJS= \
+	$(SRCDIR)/os/unix/execmem.$(OBJ) \
 	$(SRCDIR)/os/unix/file.$(OBJ) \
 	$(SRCDIR)/os/unix/main.$(OBJ) \
 	$(SRCDIR)/os/unix/group.$(OBJ) \
@@ -127,6 +131,7 @@
 	$(SRCDIR)/os/darwin/os.$(OBJ)
 
 HPUX_OBJS= \
+	$(SRCDIR)/os/unix/execmem.$(OBJ) \
 	$(SRCDIR)/os/unix/file.$(OBJ) \
 	$(SRCDIR)/os/unix/main.$(OBJ) \
 	$(SRCDIR)/os/unix/group.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Thu Jun 18 07:56:31 2009
@@ -29,7 +29,9 @@
 SO=@so@
 OBJ=@obj@
 EXE=@exe@
+AS=@as@
 AR=@ar@
+ARFLAGS=@arflags@
 RANLIB=@ranlib@
 PREFIX=@prefix@
 LIBDIR=@libdir@
@@ -80,6 +82,7 @@
 	$(SRCDIR)/modules/network/ssl/openssl.$(OBJ)
 
 WINDOWS_OBJS= \
+	$(SRCDIR)/os/win32/execmem.$(OBJ) \
 	$(SRCDIR)/os/win32/file.$(OBJ) \
 	$(SRCDIR)/os/win32/main.$(OBJ) \
 	$(SRCDIR)/os/win32/platform.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Thu Jun 18 07:56:31 2009
@@ -44,6 +44,7 @@
 cc="${CC:=gcc}"
 cxx="${CXX:=g++}"
 ar="${AR:=ar}"
+as="${AS:=gcc}"
 arflags="${ARFLAGS:=ru}"
 ranlib="${RANLIB:=ranlib}"
 topdir="${TOPDIR:=.}"
@@ -70,11 +71,14 @@
 has_jni=false
 has_64_bit=false
 has_test=false
+has_memprotect=true
+has_maintainer_mode=false
 is_unix=true
 
 has_openssl=false
 openssl_inc=""
 openssl_lib=""
+cccinc="stdio"
 
 for o
 do
@@ -183,6 +187,8 @@
   --with-cxx=CC           Use C++ compiler instead default one
                               [g++]
 Optional features:
+  --disable-memprotect   Disables exception handling code compilation
+                              [disabled]
   --enable-test           Enables test code compilation
                               [disabled]
   --with-java-home=DIR    Path to the Java SDK
@@ -338,7 +344,7 @@
         ;;
     windows-cl )
         varadds ccflags "-nologo -O2 -Ob2 -Oy- -Zi -D_MD -MD -W3"
-        varadds cppopts "-DWIN32 -D_WIN32 -D_WINDOWS -D_WINNT -DNDEBUG"
+        varadds cppopts "-DWIN32 -DWINNT -D_WIN32 -D_WINDOWS -D_WINNT"
         varadds cppopts "-D_WIN32_WINNT=0x0501 -D_WIN32_IE=0x0600"
         varadds cxxopts "-TP"
         varadds ldflags "kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib"
@@ -351,6 +357,7 @@
         obj="obj"
         nmake=".msc"
         cxx="$cc"
+        cccinc="windows"
         if [ ".$java_pinc" = . ]; then java_pinc="win32"; fi
         ;;
     *       )
@@ -367,10 +374,12 @@
     windows-cl   )
         varadds ccflags "-D_X86_=1"
         varadds shflags "/MACHINE:X86"
+		as="ml.exe"
         ;;
     windows64-cl )
         varadds ccflags "-DWIN64 -D_WIN64 -D_AMD64_=1"
         varadds shflags "/MACHINE:AMD64"
+		as="ml64.exe"
         ;;
     *64-*        )
         varadds ccflags "-m64"
@@ -389,7 +398,14 @@
     varadds includes "-I$topdir/include/arch/unix"
     varadds cppopts  "-D_REENTRANT -D_LARGEFILE64_SOURCE"
 fi
-
+if $has_maintainer_mode; then
+    varadds cppopts  "-DDEBUG -D_DEBUG"
+else
+    varadds cppopts  "-DNDEBUG"
+fi
+if $has_memprotect; then
+    varadds cppopts  "-DACR_ENABLE_SEH"
+fi
 if $has_test; then
     varadds cppopts  "-DACR_ENABLE_TEST"
     testobjs='$(TEST_OBJS)'
@@ -456,6 +472,7 @@
     printf "Checking for %-32s" "<$1.h>" 1>&2
     cat > $test.c << EOF
 #include <stdlib.h>
+#include <$cccinc.h>
 $2
 #include <$1.h>
 int main() {return 0;}
@@ -483,6 +500,7 @@
     printf "Checking for %-32s" "$1 library" 1>&2
     cat > $test.c << EOF
 #include <stdlib.h>
+#include <$cccinc.h>
 $2
 int main() {return 0;}
 EOF
@@ -621,8 +639,8 @@
 fi
 
 if [ ".$host" = ".windows" ]; then
-    have_fileextd=`have_include fileextd '#include <windows.h>'`
-    have_ktmw32=`have_include ktmw32 '#include <windows.h>'`
+    have_fileextd=`have_include fileextd`
+    have_ktmw32=`have_include ktmw32`
     have_aio=0
     have_libaio=0
     have_windows=1
@@ -689,6 +707,7 @@
 #define HAVE_SYS_WAIT_H       `have_include sys/wait`
 #define HAVE_SYS_SYSLIMITS_H  `have_include sys/syslimits`
 #define HAVE_SYS_UIO_H        `have_include sys/uio`
+#define HAVE_SYS_MMAN_H       `have_include sys/mman`
 #define HAVE_LIMITS_H         `have_include limits`
 #define HAVE_CTYPE_H          `have_include ctype`
 #define HAVE_WCHAR_H          `have_include wchar`
@@ -727,12 +746,6 @@
 EOF
 
 if [ ".$host" = ".windows" ]; then
-    cat > $test.c << EOF
-#include <stdio.h>
-#include <stdlib.h>
-int main() {return 0;}
-EOF
-
     printf "Checking for %-32s" "bufferoverflowu.lib"
     cat > $test.c << EOF
 #include <stdlib.h>
@@ -763,6 +776,7 @@
 sed -e "s;=@cc@;=$cc;g" \
     -e "s;=@cpp@;=$cpp;g" \
     -e "s;=@cxx@;=$cxx;g" \
+    -e "s;=@as@;=$as;g" \
     -e "s;=@so@;=$so;g" \
     -e "s;=@lib@;=$lib;g" \
     -e "s;=@obj@;=$obj;g" \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Thu Jun 18 07:56:31 2009
@@ -64,7 +64,7 @@
     ACR_SEH_THROW
 } acr_seh_e;
 
-#ifdef ACR_WANT_MEMPROTECT
+#if defined(ACR_WANT_MEMPROTECT) && defined(ACR_ENABLE_SEH)
 #ifdef _MSC_VER
 #define SEH_ERROR            GetExceptionCode()
 static int _seh_error = 0;
@@ -124,9 +124,9 @@
 #else
 #define ACR_TRY                                                               \
     int _seh_error = 0;                                                       \
-    {                                                                         \
+    {
 #define ACR_CATCH()                                                           \
-    } } if (_seh_error)
+    } if (_seh_error)
 
 #endif /* HAVE_MEMPROTECT */
 

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_pointer.h Thu Jun 18 07:56:31 2009
@@ -36,7 +36,7 @@
  * The cleanup function must chech for data validity.
  * Consecutive invocations will always contain NULL data.
  */
-typedef int (acr_pointer_cleanup_fn_t)(void *);
+typedef int (acr_pointer_cleanup_fn_t)(void *, size_t);
 
 /**
  * Create new Pointer class instance

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c Thu Jun 18 07:56:31 2009
@@ -21,6 +21,7 @@
 #include "acr_platform.h"
 
 static const char unknown[] = "unknown";
+acr_size_t acr_page_size;
 
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
@@ -41,6 +42,8 @@
 #endif
     ia[6]  =   PATH_MAX;
     ia[7]  =   PATH_MAX;
+    acr_page_size = (acr_size_t)getpagesize();
+    ia[8]  =   (jint)acr_page_size;
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c Thu Jun 18 07:56:31 2009
@@ -21,6 +21,7 @@
 #include "acr_platform.h"
 
 static const char unknown[] = "unknown";
+acr_size_t acr_page_size;
 
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
@@ -41,6 +42,8 @@
 #endif
     ia[6]  =   PATH_MAX;
     ia[7]  =   PATH_MAX;
+    acr_page_size = (acr_size_t)getpagesize();
+    ia[8]  =   (jint)acr_page_size;
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c Thu Jun 18 07:56:31 2009
@@ -21,6 +21,7 @@
 #include "acr_platform.h"
 
 static const char unknown[] = "unknown";
+acr_size_t acr_page_size;
 
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
@@ -41,6 +42,8 @@
 #endif
     ia[6]  =   PATH_MAX;
     ia[7]  =   PATH_MAX;
+    acr_page_size = (acr_size_t)getpagesize();
+    ia[8]  =   (jint)acr_page_size;
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c Thu Jun 18 07:56:31 2009
@@ -21,6 +21,7 @@
 #include "acr_platform.h"
 
 static const char unknown[] = "unknown";
+acr_size_t acr_page_size;
 
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
@@ -41,6 +42,8 @@
 #endif
     ia[6]  =   PATH_MAX;
     ia[7]  =   PATH_MAX;
+    acr_page_size = (acr_size_t)getpagesize();
+    ia[8]  =   (jint)acr_page_size;
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]);
 }

Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c?rev=785943&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c Thu Jun 18 07:56:31 2009
@@ -0,0 +1,87 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_memory.h"
+#include "acr_pointer.h"
+#include "acr_error.h"
+
+#if HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#ifndef MAP_ANONYMOUS
+#ifdef  MAP_ANON
+#define MAP_ANONYMOUS    MAP_ANON
+#endif
+#endif
+#ifdef  MAP_ANONYMOUS
+#define ACR_USE_MMAP
+#endif
+#endif
+
+extern acr_size_t acr_page_size;
+/**
+ * Posix executable memory functions
+ *
+ */
+static int execmem_pointer_cleanup(void *mem, size_t len)
+{
+    if (mem && len) {
+#ifdef ACR_USE_MMAP
+        munmap(mem, len);
+#else
+        free(mem);
+#endif
+        return 0;
+    }
+    else {
+        return ACR_EISNULL;
+    }
+}
+
+ACR_JNI_EXPORT_DECLARE(jobject, ExecutableMemory, malloc)(ACR_JNISTDARGS,
+                                                           jlong siz)
+{
+    jobject ptr = NULL;
+    void   *mem;
+    acr_size_t ass = (acr_size_t)ACR_ALIGN(siz, acr_page_size);
+
+    UNREFERENCED_O;
+    if (siz < 1L) {
+        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
+        return NULL;
+    }
+#ifdef ACR_USE_MMAP
+    mem = mmap(0, ass, PROT_READ | PROT_WRITE | PROT_EXEC,
+               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#else
+    mem = ACR_Malloc(_E, THROW_NMARK, ass);
+#endif
+    if (mem) {
+        /* Create the Pointer class with default cleanup.
+         */
+        ptr = ACR_PointerCreate(_E, mem, ass, execmem_pointer_cleanup);
+        if (!ptr) {
+#ifdef ACR_USE_MMAP
+            munmap(mem, ass);
+#else
+            free(mem);
+#endif
+        }
+    }
+    return ptr;
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/execmem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c?rev=785943&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c Thu Jun 18 07:56:31 2009
@@ -0,0 +1,64 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_memory.h"
+#include "acr_pointer.h"
+#include "acr_error.h"
+
+extern acr_size_t acr_page_size;
+/**
+ * Posix executable memory functions
+ *
+ */
+static int execmem_pointer_cleanup(void *mem, size_t len)
+{
+    if (mem && len) {
+        VirtualFree(mem, 0, MEM_RELEASE);
+        return 0;
+    }
+    else {
+        return ACR_EISNULL;
+    }
+}
+
+ACR_JNI_EXPORT_DECLARE(jobject, ExecutableMemory, malloc)(ACR_JNISTDARGS,
+                                                           jlong siz)
+{
+    jobject ptr = NULL;
+    void   *mem;
+    acr_size_t ass = (acr_size_t)ACR_ALIGN(siz, acr_page_size);
+
+    UNREFERENCED_O;
+    if (siz < 1L) {
+        ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
+        return NULL;
+    }
+    mem = VirtalAlloc(NULL, ass,
+                      MEM_COMMIT | MEM_RESERVE,
+                      PAGE_EXECUTE_READWRITE);
+    if (mem) {
+        /* Create the Pointer class with default cleanup.
+         */
+        ptr = ACR_PointerCreate(_E, mem, ass, execmem_pointer_cleanup);
+        if (!ptr) {
+            VirtualFree(mem, 0, MEM_RELEASE);
+        }
+    }
+    return ptr;
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/execmem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Thu Jun 18 07:56:31 2009
@@ -25,6 +25,8 @@
 extern PSID acr_everyone_sid;
 extern PSID acr_adminsgr_sid;
 extern int  acr_ioh_init(int);
+extern LPSYSTEM_INFO acr_osinf;
+acr_size_t  acr_page_size;
 
 ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
                                               jintArray p)
@@ -54,6 +56,8 @@
 #endif
     ia[6]  =   248;
     ia[7]  =   32760;
+    acr_page_size = (acr_size_t)acr_osinf->dwPageSize;
+    ia[8]  =   (jint)acr_page_size;
 
     (*_E)->SetIntArrayRegion(_E, p, 0, 8, &ia[0]);
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Thu Jun 18 07:56:31 2009
@@ -237,7 +237,7 @@
 }
 
 
-static int memory_pointer_cleanup(void *mem)
+static int memory_pointer_cleanup(void *mem, size_t unused)
 {
     if (mem) {
         free(mem);

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Thu Jun 18 07:56:31 2009
@@ -136,15 +136,17 @@
 {
     if (_clazzn.i && J4MID(0000)) {
         acr_pointer_cleanup_fn_t *cleanup;
-        void *pointer;
+        void  *pointer;
+		size_t plength;
 
         pointer = GET_IFIELD_V(0000, _O, void *);
         cleanup = GET_IFIELD_V(0001, _O, acr_pointer_cleanup_fn_t *);
+        plength = GET_IFIELD_I(0002, _O);
         if (pointer) {
             SET_IFIELD_P(0000, _O, NULL);
         }
         if (cleanup) {
-            int rc = (*cleanup)(pointer);
+            int rc = (*cleanup)(pointer, plength);
             if (rc) {
                 /* Throw RuntimeException with errno message */
                 ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ERUNTIME, rc);
@@ -160,15 +162,17 @@
 {
     if (_clazzn.i && J4MID(0000)) {
         acr_pointer_cleanup_fn_t *cleanup;
-        void *pointer;
+        void  *pointer;
+		size_t plength;
 
         pointer = GET_IFIELD_V(0000, _O, void *);
         cleanup = GET_IFIELD_V(0001, _O, acr_pointer_cleanup_fn_t *);
+        plength = GET_IFIELD_I(0002, _O);
         if (pointer) {
             SET_IFIELD_P(0000, _O, NULL);
         }
         if (cleanup) {
-            (*cleanup)(pointer);
+            (*cleanup)(pointer, plength);
         }
     }
 }
@@ -225,7 +229,8 @@
 {
     if (_clazzn.i && J4MID(0000) && _O) {
         acr_pointer_cleanup_fn_t *cleanup;
-        void *pointer;
+        void  *pointer;
+		size_t plength;
 
         if ((*_E)->MonitorEnter(_E, _O)) {
             /* Object locking failed */
@@ -233,6 +238,7 @@
         }
         pointer = GET_IFIELD_V(0000, _O, void *);
         cleanup = GET_IFIELD_V(0001, _O, acr_pointer_cleanup_fn_t *);
+        plength = GET_IFIELD_I(0002, _O);
         if (pointer) {
             SET_IFIELD_P(0000, _O, NULL);
         }
@@ -241,7 +247,7 @@
         }
         (*_E)->MonitorExit(_E, _O);
         if (cleanup) {
-            return (*cleanup)(pointer);
+            return (*cleanup)(pointer, plength);
         }
         else {
             /* Already cleared */

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=785943&r1=785942&r2=785943&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Thu Jun 18 07:56:31 2009
@@ -213,9 +213,9 @@
     return 0;
 }
 
-static int callback(void *p)
+static int callback(void *p, size_t s)
 {
-    fprintf(stderr, "[native] Pointer callback called: %p\n", p);
+    fprintf(stderr, "[native] Pointer callback called: %p - %d\n", p, s);
     fflush(stderr);
     return 0;
 }