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/05 19:40:31 UTC

svn commit: r811686 - in /commons/sandbox/runtime/trunk: ./ src/main/native/ src/main/native/include/ src/main/native/os/linux/ src/main/native/test/ src/test/org/apache/commons/runtime/

Author: mturk
Date: Sat Sep  5 17:40:31 2009
New Revision: 811686

URL: http://svn.apache.org/viewvc?rev=811686&view=rev
Log:
Use TLSD for unix exceptions

Modified:
    commons/sandbox/runtime/trunk/build.xml
    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_tlsd.h
    commons/sandbox/runtime/trunk/src/main/native/os/linux/execmem.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java

Modified: commons/sandbox/runtime/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/build.xml?rev=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/build.xml (original)
+++ commons/sandbox/runtime/trunk/build.xml Sat Sep  5 17:40:31 2009
@@ -260,7 +260,7 @@
                     <attribute name="Library" value="${runtime.libname}.so"/>
                 </section>
             </manifest>
-            <!-- Include native libraries. (Naming will change) 
+            <!-- Include native libraries. (Naming will change)
             <metainf dir="${runtime.natives.path}/">
                 <include name=".libs"/>
                 <include name=".libs/**"/>

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Sat Sep  5 17:40:31 2009
@@ -85,6 +85,7 @@
 has_dso_test=no
 has_jni=yes
 has_64_bit=no
+has_32_bit=no
 has_test=no
 has_maintainer_mode=no
 has_native_threads=no
@@ -328,6 +329,7 @@
 host=`uname -s 2>/dev/null | tr '[A-Z]' '[a-z]'` || host="unknown"
 
 test ".$has_64_bit" = .yes && bits=64
+test ".$has_32_bit" = .yes && bits=32
 
 case "$host" in
     hp-ux   )
@@ -375,6 +377,15 @@
     ;;
 esac
 
+case "$host-$mach" in
+    linux-x86_64    )
+        test ".$bits" = . && bits=64
+    ;;
+    linux-ia64      )
+        test ".$bits" = . && bits=64
+    ;;
+esac
+
 case "$host-$cc" in
     linux-gcc )
         varadds cppopts -DLINUX=2 -D_GNU_SOURCE
@@ -526,6 +537,11 @@
         varadds shflags -m64
         varadds exflags -m64
         ;;
+    *32-*        )
+        varadds ccflags -m32
+        varadds shflags -m32
+        varadds exflags -m32
+        ;;
 esac
 
 # Common defines
@@ -781,7 +797,11 @@
     have_uuid_uuid=`have_include uuid/uuid`
     if [ ".$have_uuid_uuid" = .1 ]; then
         ok=`have_library uuid`
-        test ".$ok" = .1 && varadds ldflags -luuid
+        if [ ".$ok" = .1 ]; then
+            varadds ldflags -luuid
+        else
+            have_uuid_uuid=0
+        fi
     fi
     ok=`have_library resolv`
     test ".$ok" = .1 && varadds ldflags -lresolv

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=811686&r1=811685&r2=811686&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 Sat Sep  5 17:40:31 2009
@@ -79,20 +79,21 @@
 #define SEH_DOJUMP(E, V)     longjmp((E), (V))
 #define SEH_JMPBUF           jmp_buf
 #endif
-static SEH_JMPBUF _seh_catch;
-static void       _seh_handler(int val)
+static void _seh_handler(int val)
 {
-    if (val == SIGSEGV || val == SIGBUS) {
-        SEH_DOJUMP(_seh_catch, val);
+    acr_thread_local_t *tlsd = ACR_GetTLSD();
+    if (tlsd && (val == SIGSEGV || val == SIGBUS)) {
+        SEH_DOJUMP(tlsd->seh_jump, val);
     }
 }
 
 #define ACR_TRY                                                               \
     int _seh_error = 0;                                                       \
     {                                                                         \
+    acr_thread_local_t *_tlsd = ACR_GetTLSD();                                \
     void* _org_sigseg_handler = signal(SIGSEGV, _seh_handler);                \
     void* _org_sigbus_handler = signal(SIGBUS,  _seh_handler);                \
-    if ((_seh_error = SEH_SETJMP(_seh_catch)))                                \
+    if (_tlsd && (_seh_error = SEH_SETJMP(_tlsd->seh_jump)))                  \
             goto _seh_catch_block;
 
 #define ACR_CATCH()                                                           \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h?rev=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h Sat Sep  5 17:40:31 2009
@@ -19,6 +19,12 @@
 
 #include "acr.h"
 #include "acr_ring.h"
+#if defined(WIN32)
+
+#else
+#include <signal.h>
+#include <setjmp.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -44,6 +50,15 @@
     ACR_RING_HEAD(tlsd_data_t, acr_tlsd_data_t)  data_ring;
     JNIEnv  *env;
     int     jvm_attached;
+#if defined(WIN32)
+
+#else
+#if HAVE_SIGSETJMP
+    sigjmp_buf  seh_jump;
+#else
+    jmp_buf     seh_jump;
+#endif
+#endif
 };
 
 /**

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/execmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/execmem.c?rev=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/execmem.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/execmem.c Sat Sep  5 17:40:31 2009
@@ -29,7 +29,6 @@
 #endif
 
 extern acr_size_t acr_page_size;
-static int acr_exec_file = -1;
 #define EXEC_PAGE_OFF(M, L) *((ptrdiff_t *)((char *)(M) + (L) - sizeof(ptrdiff_t)))
 /**
  * Linux executable memory functions
@@ -49,6 +48,8 @@
         return ACR_EISNULL;
     }
 }
+#if HAVE_SELINUX_H
+static int acr_exec_file = -1;
 
 static const char *tmp_envs[] = {
     "TMP",
@@ -91,7 +92,7 @@
     }
     return -1;
 }
-
+#endif
 
 ACR_JNI_EXPORT_DECLARE(jobject, ExecutableMemory, malloc0)(ACR_JNISTDARGS,
                                                            jlong siz)

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=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Sat Sep  5 17:40:31 2009
@@ -39,6 +39,9 @@
 #define srandom         srand
 typedef struct stat     struct_stat_t;
 
+#else
+#include <signal.h>
+#include <setjmp.h>
 #endif
 
 #if !defined(WIN32)
@@ -842,6 +845,38 @@
 static const char    *sem_name = "TestSemaphore";
 #endif
 
+#if !defined(WIN32)
+ACR_JNI_EXPORT_DECLARE(jint, TestNative, test001)(ACR_JNISTDARGS, jint v)
+{
+    struct sigaction query_action;
+    fprintf(stdout, "\nDumping signals\n");
+    if (sigaction (SIGINT, NULL, &query_action) < 0)
+       fprintf(stdout, "sigaction returns -1 in case of error.\n");
+    else if (query_action.sa_handler == SIG_DFL)
+       fprintf(stdout, "SIGINT is handled in the default, fatal manner.\n");
+    else if (query_action.sa_handler == SIG_IGN)
+       fprintf(stdout, "SIGINT is ignored.\n");
+    else
+       fprintf(stdout, "A programmer-defined SIGINT signal handler is in effect.\n");
+
+    if (sigaction (SIGSEGV, NULL, &query_action) < 0)
+       fprintf(stdout, "sigaction returns -1 in case of error.\n");
+    else if (query_action.sa_handler == SIG_DFL)
+       fprintf(stdout, "SIGSEGV is handled in the default, fatal manner.\n");
+    else if (query_action.sa_handler == SIG_IGN)
+       fprintf(stdout, "SIGSEGV is ignored.\n");
+    else
+       fprintf(stdout, "A programmer-defined SIGSEGV signal handler is in effect.\n");
+    fflush(stdout);
+    return 0;
+}
+#else
+ACR_JNI_EXPORT_DECLARE(jint, TestNative, test001)(ACR_JNISTDARGS, jint v)
+{
+    return 0;
+}
+
+#endif
 ACR_JNI_EXPORT_DECLARE(jint, TestSemaphore, test001)(ACR_JNISTDARGS, jint v)
 {
 

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java?rev=811686&r1=811685&r2=811686&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestNative.java Sat Sep  5 17:40:31 2009
@@ -26,6 +26,7 @@
 public class TestNative extends TestCase
 {
 
+    private static native int test001(int i);
     public static Test suite() {
         TestSuite suite = new TestSuite(TestNative.class);
         return suite;
@@ -42,6 +43,7 @@
     {
         boolean rv = Native.initialize();
         assertTrue("Not initialized", rv);
+        test001(0);
     }
 
 }