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.deha...@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/jni_x86.h
> > #if defined(SOLARIS) || defined(LINUX) || defined(_ALLBSD_SOURCE)
> >
> > #if defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4) &&
> > (__GNUC_MINOR__ > 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 __GNUC_MINOR__ 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-
>
>

Reply via email to