$OpenBSD: patch-jdk_src_solaris_hpi_src_linker_md_c,v 1.2 2009/01/04 23:25:16 kurt Exp $
--- jdk/src/solaris/hpi/src/linker_md.c.orig	Thu Jul 17 03:43:47 2008
+++ jdk/src/solaris/hpi/src/linker_md.c	Sat Aug  2 17:00:24 2008
@@ -44,11 +44,13 @@
 #include "threads_md.h"
 #endif
 
+#ifndef _ALLBSD_SOURCE
 /*
  * This lock protects the dl wrappers, assuring that two threads aren't
  * in libdl at the same time.
  */
 sys_mon_t _dl_lock;
+#endif
 
 /*
  * Solaris green threads needs to lock around libdl.so.
@@ -57,7 +59,15 @@ sys_mon_t _dl_lock;
     #define NEED_DL_LOCK
 #endif
 
+#ifdef NEED_DL_LOCK
 /*
+ * This lock protects the dl wrappers, assuring that two threads aren't
+ * in libdl at the same time.
+ */
+sys_mon_t _dl_lock;
+#endif
+
+/*
  * create a string for the JNI native function name by adding the
  * appropriate decorations.
  */
@@ -93,7 +103,7 @@ sysBuildLibName(char *holder, int holderlen, char *pna
 }
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(_ALLBSD_SOURCE)
     static int thr_main(void)
     {
         return -1;
@@ -111,10 +121,10 @@ sysLoadLibrary(const char *name, char *err_buf, int er
 
 #ifdef NEED_DL_LOCK
     sysMonitorEnter(sysThreadSelf(), &_dl_lock);
-    result = dlopen(name, RTLD_NOW);
+    result = dlopen(name, RTLD_NOW|RTLD_GLOBAL);
     sysMonitorExit(sysThreadSelf(), &_dl_lock);
 #else
-    result = dlopen(name, RTLD_LAZY);
+    result = dlopen(name, RTLD_LAZY|RTLD_GLOBAL);
 #endif
     /*
      * This is a bit of bulletproofing to catch the commonly occurring
