changeset 7352:3730487baa2a

. Implement current and signal methods for BSD in sun.nio.ch.NativeThread. Submitted by: jkim@FreeBSD.org
author Greg Lewis <glewis@eyesbeyond.com>
date Sat, 28 Jun 2014 11:04:20 -0700
parents beba30cbaff8
children f9c904f94966
files src/solaris/native/sun/nio/ch/NativeThread.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/nio/ch/NativeThread.c	Sat Jun 07 00:19:05 2014 -0700
+++ b/src/solaris/native/sun/nio/ch/NativeThread.c	Sat Jun 28 11:04:20 2014 -0700
@@ -33,12 +33,19 @@
 #include "nio_util.h"
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 #include <pthread.h>
+#if defined(__linux__)
 #include <sys/signal.h>
 
 /* Also defined in src/solaris/native/java/net/linux_close.c */
 #define INTERRUPT_SIGNAL (__SIGRTMAX - 2)
+#else
+#include <signal.h>
+
+/* Also defined in src/solaris/native/java/net/bsd_close.c */
+#define INTERRUPT_SIGNAL SIGIO
+#endif
 
 static void
 nullHandler(int sig)
@@ -51,7 +58,7 @@
 JNIEXPORT void JNICALL
 Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 
     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
      * handler previously installed by java/net/linux_close.c, but that's okay
@@ -74,7 +81,7 @@
 JNIEXPORT jlong JNICALL
 Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     return (long)pthread_self();
 #else
     return -1;
@@ -84,7 +91,7 @@
 JNIEXPORT void JNICALL
 Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL))
         JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
 #endif