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/09/01 18:41:20 UTC

svn commit: r810113 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Native.java native/include/acr_error.h native/shared/error.c native/shared/native.c native/shared/pointer.c

Author: mturk
Date: Tue Sep  1 16:41:19 2009
New Revision: 810113

URL: http://svn.apache.org/viewvc?rev=810113&view=rev
Log:
Add mathod for determing if SEH is enabled

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/shared/native.c
    commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=810113&r1=810112&r2=810113&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java Tue Sep  1 16:41:19 2009
@@ -35,7 +35,8 @@
     private static boolean initialized = false;
     private static native boolean init0()
         throws Throwable;
-    private static native boolean sseh0(boolean on);
+    private static native boolean sseh0();
+    private static native boolean sseh1(boolean on);
 
     /**
      * Initialize Apache Commons Runtime native library.
@@ -67,17 +68,20 @@
         return initialized;
     }
 
+    public static boolean isExceptionHandlerEnabled()
+    {
+        return sseh0();
+    }
+
     public static boolean enableExceptionHandler()
     {
-        return sseh0(true);
+        return sseh1(true);
     }
 
     public static boolean disableExceptionHandler()
     {
-        sseh0(false);
+        sseh1(false);
         // Disable is always success.
         return true;
     }
-
 }
-

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=810113&r1=810112&r2=810113&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 Tue Sep  1 16:41:19 2009
@@ -67,11 +67,11 @@
 } acr_seh_e;
 
 #if defined(ACR_WANT_MEMPROTECT) && defined(ACR_ENABLE_SEH)
+extern acr_seh_e __acr_seh_mode;
 #ifdef _MSC_VER
-#define SEH_ERROR            GetExceptionCode()
 static int _seh_error = 0;
 #define ACR_TRY                                                               \
-    if (ACR_GetExceptionHandlerMode() != ACR_SEH_NONE)                        \
+    if (__acr_seh_mode != ACR_SEH_NONE)                                       \
         _seh_error = 1;                                                       \
     __try
 
@@ -82,7 +82,6 @@
 #else
 #include <signal.h>
 #include <setjmp.h>
-#define SEH_ERROR            _seh_error
 
 #if HAVE_SIGSETJMP
 #define SEH_SETJMP(E)        sigsetjmp((E), 0)
@@ -107,7 +106,7 @@
     void* _org_sigseg_handler = NULL;                                         \
     void* _org_sigbus_handler = NULL;                                         \
     int   _org_setjmp_handler = 0;                                            \
-    if (ACR_GetExceptionHandlerMode() != ACR_SEH_NONE) {                      \
+    if (__acr_seh_mode != ACR_SEH_NONE) {                                     \
         _org_sigseg_handler = signal(SIGSEGV, _seh_handler);                  \
         _org_sigbus_handler = signal(SIGBUS,  _seh_handler);                  \
         _org_setjmp_handler = 1;                                              \

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=810113&r1=810112&r2=810113&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Tue Sep  1 16:41:19 2009
@@ -52,9 +52,9 @@
  * On other platforms default to disabled.
  */
 #if defined(ACR_ENABLE_SEH) && defined(_MSC_VER)
-static acr_seh_e acr_seh_mode = ACR_SEH_THROW;
+acr_seh_e __acr_seh_mode = ACR_SEH_THROW;
 #else
-static acr_seh_e acr_seh_mode = ACR_SEH_NONE;
+acr_seh_e __acr_seh_mode = ACR_SEH_NONE;
 #endif
 
 /*
@@ -701,12 +701,12 @@
 
 ACR_DECLARE(void) ACR_SetExceptionHandlerMode(acr_seh_e mode)
 {
-    acr_seh_mode = mode;
+    __acr_seh_mode = mode;
 }
 
 ACR_DECLARE(acr_seh_e) ACR_GetExceptionHandlerMode()
 {
-    return acr_seh_mode;
+    return __acr_seh_mode;
 }
 
 ACR_JNI_EXPORT_DECLARE(void, io_Status, init0)(ACR_JNISTDARGS,

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/native.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/native.c?rev=810113&r1=810112&r2=810113&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/native.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/native.c Tue Sep  1 16:41:19 2009
@@ -35,7 +35,19 @@
     return rv;
 }
 
-ACR_JNI_EXPORT_DECLARE(jboolean, Native, sseh0)(ACR_JNISTDARGS, jboolean on)
+ACR_JNI_EXPORT_DECLARE(jboolean, Native, sseh0)(ACR_JNISTDARGS)
+{
+#ifdef ACR_ENABLE_SEH
+    if (ACR_GetExceptionHandlerMode() != ACR_SEH_NONE)
+        return JNI_TRUE;
+    else
+        return JNI_FALSE;
+#else
+    return JNI_FALSE;
+#endif
+}
+
+ACR_JNI_EXPORT_DECLARE(jboolean, Native, sseh1)(ACR_JNISTDARGS, jboolean on)
 {
 #ifdef ACR_ENABLE_SEH
     ACR_SetExceptionHandlerMode(on ? ACR_SEH_THROW : ACR_SEH_NONE);
@@ -44,4 +56,3 @@
     return JNI_FALSE;
 #endif
 }
-

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=810113&r1=810112&r2=810113&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Tue Sep  1 16:41:19 2009
@@ -192,7 +192,7 @@
 {
     UNREFERENCED_O;
     ACR_TRY {
-        *(N2P(a, char *)) = (char)v;
+        *(N2P(a, char *)) = (char)(v & 0xFF);
     } ACR_CATCH() {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }