Define JNIEXPORT as visibility default with GCC? (original) (raw)
Martin Buchholz martinrb at google.com
Thu Feb 14 23:00:50 UTC 2013
- Previous message: Define JNIEXPORT as visibility default with GCC?
- Next message: hg: jdk8/tl/jdk: 8007405: Update java.lang.reflect API to replace SYNTHESIZED with MANDATED
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alright, let's use gcc's recommended test, and let's add a test for clang (completely untested):
diff --git a/src/solaris/javavm/export/jni_md.h b/src/solaris/javavm/export/jni_md.h --- a/src/solaris/javavm/export/jni_md.h +++ b/src/solaris/javavm/export/jni_md.h @@ -26,8 +26,14 @@ #ifndef JAVASOFT_JNI_MD_H #define JAVASOFT_JNI_MD_H
-#define JNIEXPORT -#define JNIIMPORT +#if (defined(GNUC) && GNUC >= 4) || (defined(__has_attribute) && __has_attribute(visibility))
- #define JNIEXPORT attribute((visibility("default")))
- #define JNIIMPORT attribute((visibility("default")))
+#else
- #define JNIEXPORT
- #define JNIIMPORT
+#endif + #define JNICALL
typedef int jint;
On Thu, Feb 14, 2013 at 11:07 AM, David DeHaven <david.dehaven at oracle.com>wrote:
> This seems like an obvious improvement. > There are already bunches of places in the jdk sources that do things like: > > ./hotspot/src/cpu/x86/vm/jnix86.h > #if defined(SOLARIS) || defined(LINUX) || defined(ALLBSDSOURCE) > > #if defined(GNUC) && (GNUC > 4) || (GNUC == 4) && > (GNUCMINOR > 2) > #define JNIEXPORT attribute((visibility("default"))) > #define JNIIMPORT attribute((visibility("default"))) > #else > #define JNIEXPORT > #define JNIIMPORT > #endif That version check didn't work for me running on Mac OS X (using llvm-gcc 4.2). If that's what hotspot is using then they may not be getting the desired effect. The problem is GNUCMINOR is 2, so it needs to be changed to >= 2. Gnu recommends just using "#if GNUC >= 4", and everything I've read about it says it's 4.0 and later, so I don't understand why the minor version check is even in there. -DrD-
- Previous message: Define JNIEXPORT as visibility default with GCC?
- Next message: hg: jdk8/tl/jdk: 8007405: Update java.lang.reflect API to replace SYNTHESIZED with MANDATED
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]