/hg/icedtea8-forest/jdk: 2 new changesets

andrew at icedtea.classpath.org andrew at icedtea.classpath.org
Tue Oct 25 22:38:32 UTC 2016


changeset dc4de5de2743 in /hg/icedtea8-forest/jdk
details: http://icedtea.classpath.org/hg/icedtea8-forest/jdk?cmd=changeset;node=dc4de5de2743
author: andrew
date: Tue Oct 25 22:17:18 2016 +0100

	PR1978: Allow use of system PCSC


changeset 126d20761aa9 in /hg/icedtea8-forest/jdk
details: http://icedtea.classpath.org/hg/icedtea8-forest/jdk?cmd=changeset;node=126d20761aa9
author: andrew
date: Tue Oct 25 23:39:40 2016 +0100

	PR2445: Support system libsctp


diffstat:

 make/lib/NioLibraries.gmk                                      |  14 ++-
 make/lib/SecurityLibraries.gmk                                 |  15 ++-
 src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java       |   2 +-
 src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java  |   2 +-
 src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java |   2 +-
 src/solaris/native/sun/nio/ch/sctp/Sctp.h                      |  25 ++++-
 src/solaris/native/sun/nio/ch/sctp/SctpNet.c                   |   6 +-
 src/solaris/native/sun/security/smartcardio/pcsc_md.c          |   7 +
 src/solaris/native/sun/security/smartcardio/pcsc_md.h          |  40 ++++++++++
 9 files changed, 95 insertions(+), 18 deletions(-)

diffs (298 lines):

diff -r 9185a15650c3 -r 126d20761aa9 make/lib/NioLibraries.gmk
--- a/make/lib/NioLibraries.gmk	Mon Oct 24 05:20:00 2016 +0100
+++ b/make/lib/NioLibraries.gmk	Tue Oct 25 23:39:40 2016 +0100
@@ -169,11 +169,19 @@
 
   ifeq (, $(filter $(OPENJDK_TARGET_OS), macosx aix))
 
+    ifeq ($(USE_EXTERNAL_SCTP), true)
+      J2SCTP_CFLAGS := -DUSE_SYSTEM_SCTP $(SCTP_CFLAGS)
+      J2SCTP_LIBS := $(SCTP_LIBS)
+    else
+      J2SCTP_CFLAGS := 
+      J2SCTP_LIBS := $(LIBDL)
+    endif
+
     # Suppress unused parameters required by exported JNI functions.
     SCTP_WERROR := $(CFLAGS_WARNINGS_ARE_ERRORS)
 
     $(eval $(call SetupNativeCompilation,BUILD_LIBSCTP, \
-        LIBRARY := sctp, \
+        LIBRARY := j2sctp, \
         OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
         SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch/sctp, \
         LANG := C, \
@@ -184,11 +192,11 @@
             -I$(JDK_TOPDIR)/src/share/native/java/net \
             -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/nio/ch \
             -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/java/net, \
-        CFLAGS_linux := $(SCTP_WERROR), \
+        CFLAGS_linux := $(SCTP_WERROR) $(J2SCTP_CFLAGS), \
         MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libsctp/mapfile-vers, \
         LDFLAGS := $(LDFLAGS_JDKLIB) \
             $(call SET_SHARED_LIBRARY_ORIGIN), \
-        LDFLAGS_SUFFIX_linux := -lpthread $(LIBDL) -ljava -ljvm, \
+        LDFLAGS_SUFFIX_linux := -lpthread $(J2SCTP_LIBS) -ljava -ljvm, \
         LDFLAGS_SUFFIX_posix := -lnio -lnet, \
         LDFLAGS_SUFFIX_solaris := -lsocket -ljava -ljvm -lc, \
         LDFLAGS_SUFFIX_macosx := -ljava -ljvm, \
diff -r 9185a15650c3 -r 126d20761aa9 make/lib/SecurityLibraries.gmk
--- a/make/lib/SecurityLibraries.gmk	Mon Oct 24 05:20:00 2016 +0100
+++ b/make/lib/SecurityLibraries.gmk	Tue Oct 25 23:39:40 2016 +0100
@@ -64,6 +64,14 @@
 
 ##########################################################################################
 
+ifeq ($(USE_EXTERNAL_PCSC), true)
+  J2PCSC_CFLAGS := -DUSE_SYSTEM_PCSC $(PCSC_CFLAGS)
+  J2PCSC_LIBS := $(PCSC_LIBS)
+else
+  J2PCSC_CFLAGS := -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio/MUSCLE
+  J2PCSC_LIBS := $(LIBDL)
+endif
+
 $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC, \
     LIBRARY := j2pcsc, \
     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
@@ -72,14 +80,13 @@
     LANG := C, \
     CFLAGS_posix := -D__sun_jdk, \
     OPTIMIZATION := LOW, \
-    CFLAGS := $(CFLAGS_JDKLIB) \
+    CFLAGS := $(CFLAGS_JDKLIB) $(J2PCSC_CFLAGS) \
         -I$(JDK_TOPDIR)/src/share/native/sun/security/smartcardio \
-        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio \
-        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio/MUSCLE, \
+        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/security/smartcardio, \
     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pcsc/mapfile-vers, \
     LDFLAGS := $(LDFLAGS_JDKLIB) \
         $(call SET_SHARED_LIBRARY_ORIGIN), \
-    LDFLAGS_SUFFIX_posix := $(LIBDL), \
+    LDFLAGS_SUFFIX_posix := $(J2PCSC_LIBS), \
     LDFLAGS_SUFFIX_windows := winscard.lib, \
     LDFLAGS_SUFFIX_solaris := -lc, \
     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java
--- a/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Tue Oct 25 23:39:40 2016 +0100
@@ -1113,7 +1113,7 @@
         java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Void>() {
                 public Void run() {
-                    System.loadLibrary("sctp");
+                    System.loadLibrary("j2sctp");
                     return null;
                 }
             });
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java
--- a/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Tue Oct 25 23:39:40 2016 +0100
@@ -998,7 +998,7 @@
         java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Void>() {
                 public Void run() {
-                    System.loadLibrary("sctp");
+                    System.loadLibrary("j2sctp");
                     return null;
                 }
             });
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java
--- a/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Tue Oct 25 23:39:40 2016 +0100
@@ -429,7 +429,7 @@
         java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Void>() {
                 public Void run() {
-                    System.loadLibrary("sctp");
+                    System.loadLibrary("j2sctp");
                     return null;
                 }
             });
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/native/sun/nio/ch/sctp/Sctp.h
--- a/src/solaris/native/sun/nio/ch/sctp/Sctp.h	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/native/sun/nio/ch/sctp/Sctp.h	Tue Oct 25 23:39:40 2016 +0100
@@ -74,19 +74,20 @@
 #include <netinet/in.h>
 #include "jni.h"
 
-//Causes compiler error if not found, should make warning and uncomment
-/*#include <netinet/sctp.h>*/
-
-#ifndef IPPROTO_SCTP
-#define IPPROTO_SCTP    132
-#endif
-
 /* The current version of lksctp does
  * not define the following option that the Java API (optionally) supports */
 #ifndef SCTP_EXPLICIT_EOR
 #define SCTP_EXPLICIT_EOR -1
 #endif
 
+#ifdef USE_SYSTEM_SCTP
+#include <netinet/sctp.h>
+#else
+
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP    132
+#endif
+
 /* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
 #ifndef SCTP_INITMSG
 
@@ -319,15 +320,25 @@
 typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
 typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
 
+#endif
 
 #endif /* __linux__ */
 
+#ifdef USE_SYSTEM_SCTP
+#define nio_sctp_getladdrs sctp_getladdrs
+#define nio_sctp_freeladdrs sctp_freeladdrs
+#define nio_sctp_getpaddrs sctp_getpaddrs
+#define nio_sctp_freepaddrs sctp_freepaddrs
+#define nio_sctp_bindx sctp_bindx
+#define nio_sctp_peeloff sctp_peeloff
+#else
 sctp_getladdrs_func* nio_sctp_getladdrs;
 sctp_freeladdrs_func* nio_sctp_freeladdrs;
 sctp_getpaddrs_func* nio_sctp_getpaddrs;
 sctp_freepaddrs_func* nio_sctp_freepaddrs;
 sctp_bindx_func* nio_sctp_bindx;
 sctp_peeloff_func* nio_sctp_peeloff;
+#endif
 
 jboolean loadSocketExtensionFuncs(JNIEnv* env);
 
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/native/sun/nio/ch/sctp/SctpNet.c
--- a/src/solaris/native/sun/nio/ch/sctp/SctpNet.c	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/native/sun/nio/ch/sctp/SctpNet.c	Tue Oct 25 23:39:40 2016 +0100
@@ -25,7 +25,10 @@
 
 #include <stdlib.h>
 #include <string.h>
+
+#ifndef USE_SYSTEM_SCTP
 #include <dlfcn.h>
+#endif
 
 #include "Sctp.h"
 #include "jni.h"
@@ -58,6 +61,7 @@
  */
 jboolean loadSocketExtensionFuncs
   (JNIEnv* env) {
+#ifndef USE_SYSTEM_SCTP
     if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
         JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
               dlerror());
@@ -105,7 +109,7 @@
               dlerror());
         return JNI_FALSE;
     }
-
+#endif
     funcsLoaded = JNI_TRUE;
     return JNI_TRUE;
 }
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/native/sun/security/smartcardio/pcsc_md.c
--- a/src/solaris/native/sun/security/smartcardio/pcsc_md.c	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/native/sun/security/smartcardio/pcsc_md.c	Tue Oct 25 23:39:40 2016 +0100
@@ -36,6 +36,7 @@
 
 #include "pcsc_md.h"
 
+#ifndef USE_SYSTEM_PCSC
 void *hModule;
 FPTR_SCardEstablishContext scardEstablishContext;
 FPTR_SCardConnect scardConnect;
@@ -47,6 +48,7 @@
 FPTR_SCardBeginTransaction scardBeginTransaction;
 FPTR_SCardEndTransaction scardEndTransaction;
 FPTR_SCardControl scardControl;
+#endif
 
 /*
  * Throws a Java Exception by name
@@ -75,6 +77,7 @@
     throwByName(env, "java/io/IOException", msg);
 }
 
+#ifndef USE_SYSTEM_PCSC
 void *findFunction(JNIEnv *env, void *hModule, char *functionName) {
     void *fAddress = dlsym(hModule, functionName);
     if (fAddress == NULL) {
@@ -85,9 +88,11 @@
     }
     return fAddress;
 }
+#endif
 
 JNIEXPORT void JNICALL Java_sun_security_smartcardio_PlatformPCSC_initialize
         (JNIEnv *env, jclass thisClass, jstring jLibName) {
+#ifndef USE_SYSTEM_PCSC
     const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL);
     if (libName == NULL) {
         throwNullPointerException(env, "PCSC library name is null");
@@ -141,4 +146,6 @@
 #else
     scardControl          = (FPTR_SCardControl)         findFunction(env, hModule, "SCardControl132");
 #endif // __APPLE__
+
+#endif // USE_SYSTEM_PCSC
 }
diff -r 9185a15650c3 -r 126d20761aa9 src/solaris/native/sun/security/smartcardio/pcsc_md.h
--- a/src/solaris/native/sun/security/smartcardio/pcsc_md.h	Mon Oct 24 05:20:00 2016 +0100
+++ b/src/solaris/native/sun/security/smartcardio/pcsc_md.h	Tue Oct 25 23:39:40 2016 +0100
@@ -23,6 +23,8 @@
  * questions.
  */
 
+#ifndef USE_SYSTEM_PCSC
+
 typedef LONG (*FPTR_SCardEstablishContext)(ULONG dwScope,
                 const void *pvReserved1,
                 const void *pvReserved2,
@@ -110,3 +112,41 @@
 extern FPTR_SCardBeginTransaction scardBeginTransaction;
 extern FPTR_SCardEndTransaction scardEndTransaction;
 extern FPTR_SCardControl scardControl;
+
+#else
+
+#define CALL_SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext) \
+    (SCardEstablishContext(dwScope, pvReserved1, pvReserved2, phContext))
+
+#define CALL_SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols) \
+    (SCardConnect(hContext, szReader, dwSharedMode, dwPreferredProtocols, phCard, pdwActiveProtocols))
+
+#define CALL_SCardDisconnect(hCard, dwDisposition) \
+    (SCardDisconnect(hCard, dwDisposition))
+
+#define CALL_SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen) \
+    (SCardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen))
+
+#define CALL_SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders) \
+    (SCardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders))
+
+#define CALL_SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \
+                            pioRecvPci, pbRecvBuffer, pcbRecvLength) \
+    (SCardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, \
+                            pioRecvPci, pbRecvBuffer, pcbRecvLength))
+
+#define CALL_SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders) \
+    (SCardListReaders(hContext, mszGroups, mszReaders, pcchReaders))
+
+#define CALL_SCardBeginTransaction(hCard) \
+    (SCardBeginTransaction(hCard))
+
+#define CALL_SCardEndTransaction(hCard, dwDisposition) \
+    (SCardEndTransaction(hCard, dwDisposition))
+
+#define CALL_SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \
+            pbRecvBuffer, pcbRecvLength, lpBytesReturned) \
+    (SCardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, \
+            pbRecvBuffer, pcbRecvLength, lpBytesReturned))
+
+#endif


More information about the distro-pkg-dev mailing list