changeset 5530:e91dacb8d57f

7155300: Include pthread.h on all POSIX platforms except Solaris to improve portability Reviewed-by: alanb, dholmes
author zhangshj
date Thu, 22 Mar 2012 12:30:43 +0800
parents a76bc4fefb36
children 3e4d5111a45e
files src/solaris/bin/java_md_solinux.c src/solaris/bin/java_md_solinux.h src/solaris/transport/socket/socket_md.c
diffstat 3 files changed, 18 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/bin/java_md_solinux.c	Mon Aug 06 16:44:35 2012 +0400
+++ b/src/solaris/bin/java_md_solinux.c	Thu Mar 22 12:30:43 2012 +0800
@@ -982,7 +982,18 @@
 int
 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#ifdef __linux__
+#ifdef __solaris__
+    thread_t tid;
+    long flags = 0;
+    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
+      void * tmp;
+      thr_join(tid, NULL, &tmp);
+      rslt = (int)tmp;
+    } else {
+      /* See below. Continue in current thread if thr_create() failed */
+      rslt = continuation(args);
+    }
+#else /* ! __solaris__ */
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
@@ -1007,18 +1018,7 @@
     }
 
     pthread_attr_destroy(&attr);
-#else /* ! __linux__ */
-    thread_t tid;
-    long flags = 0;
-    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
-      void * tmp;
-      thr_join(tid, NULL, &tmp);
-      rslt = (int)tmp;
-    } else {
-      /* See above. Continue in current thread if thr_create() failed */
-      rslt = continuation(args);
-    }
-#endif /* __linux__ */
+#endif /* __solaris__ */
     return rslt;
 }
 
--- a/src/solaris/bin/java_md_solinux.h	Mon Aug 06 16:44:35 2012 +0400
+++ b/src/solaris/bin/java_md_solinux.h	Thu Mar 22 12:30:43 2012 +0800
@@ -54,10 +54,10 @@
 #endif
 
 #include <dlfcn.h>
-#ifdef __linux__
+#ifdef __solaris__
+#include <thread.h>
+#else
 #include <pthread.h>
-#else
-#include <thread.h>
 #endif
 
 #define JVM_DLL         "libjvm.so"
--- a/src/solaris/transport/socket/socket_md.c	Mon Aug 06 16:44:35 2012 +0400
+++ b/src/solaris/transport/socket/socket_md.c	Thu Mar 22 12:30:43 2012 +0800
@@ -35,8 +35,7 @@
 #include <sys/time.h>
 #ifdef __solaris__
 #include <thread.h>
-#endif
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#else
 #include <pthread.h>
 #include <sys/poll.h>
 #endif
@@ -306,9 +305,7 @@
     return r;
 }
 
-#endif
-
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#else
 int
 dbgsysTlsAlloc() {
     pthread_key_t key;