--- a/jdk/src/solaris/native/sun/nio/ch/NativeThread.c Tue Jan 21 10:52:48 2014 -0500
+++ b/jdk/src/solaris/native/sun/nio/ch/NativeThread.c Wed Jan 22 09:36:11 2014 +0000
@@ -32,27 +32,32 @@
#include "sun_nio_ch_NativeThread.h"
#include "nio_util.h"
-
#ifdef __linux__
-#include <pthread.h>
-#include <sys/signal.h>
-
-/* Also defined in src/solaris/native/java/net/linux_close.c */
-#define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+ #include <pthread.h>
+ #include <sys/signal.h>
+ /* Also defined in net/linux_close.c */
+ #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+#elif __solaris__
+ #include <thread.h>
+ #include <signal.h>
+ #define INTERRUPT_SIGNAL (SIGRTMAX - 2)
+#elif _ALLBSD_SOURCE
+ #include <pthread.h>
+ #include <signal.h>
+ /* Also defined in net/bsd_close.c */
+ #define INTERRUPT_SIGNAL SIGIO
+#else
+ #error "missing platform-specific definition here"
+#endif
static void
nullHandler(int sig)
{
}
-#endif
-
-
JNIEXPORT void JNICALL
Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
{
-#ifdef __linux__
-
/* Install the null handler for INTERRUPT_SIGNAL. This might overwrite the
* handler previously installed by java/net/linux_close.c, but that's okay
* since neither handler actually does anything. We install our own
@@ -67,25 +72,27 @@
sigemptyset(&sa.sa_mask);
if (sigaction(INTERRUPT_SIGNAL, &sa, &osa) < 0)
JNU_ThrowIOExceptionWithLastError(env, "sigaction");
-
-#endif
}
JNIEXPORT jlong JNICALL
Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
{
-#ifdef __linux__
- return (long)pthread_self();
+#ifdef __solaris__
+ return (jlong)thr_self();
#else
- return -1;
+ return (jlong)pthread_self();
#endif
}
JNIEXPORT void JNICALL
Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
{
-#ifdef __linux__
- if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL))
+ int ret;
+#ifdef __solaris__
+ ret = thr_kill((thread_t)thread, INTERRUPT_SIGNAL);
+#else
+ ret = pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL);
+#endif
+ if (ret != 0)
JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
-#endif
}