$OpenBSD: patch-jdk_src_solaris_native_java_net_Inet6AddressImpl_c,v 1.3 2011/01/11 15:47:50 kurt Exp $
--- jdk/src/solaris/native/java/net/Inet6AddressImpl.c.orig	Fri Aug 13 03:22:13 2010
+++ jdk/src/solaris/native/java/net/Inet6AddressImpl.c	Mon Oct 25 18:15:59 2010
@@ -33,6 +33,9 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <ctype.h>
+#ifdef _ALLBSD_SOURCE
+#include <unistd.h> /* gethostname */
+#endif
 
 #include "jvm.h"
 #include "jni_util.h"
@@ -68,10 +71,18 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
-#ifdef __linux__
-        /* On Linux gethostname() says "host.domain.sun.com".  On
+#if defined(__linux__) && defined(_ALLBSD_SOURCE)
+	/* On Linux/FreeBSD gethostname() says "host.domain.sun.com".  On
          * Solaris gethostname() says "host", so extra work is needed.
          */
+        /*
+         * XXXBSD: Though on FreeBSD it's possible case then hostname does
+         * not contain '.' (depends on previous sethostname() call).  Maybe
+         * we need to proceed with Solaris way, but using getnameinfo()
+         * in conjunction with gethostby*() breaks thread-safeness, so
+         * we need to protect all calls to gethostby*() and getnameinfo()
+         * using same mutex.
+         */
 #else
         /* Solaris doesn't want to give us a fully qualified domain name.
          * We do a reverse lookup to try and get one.  This works
@@ -107,7 +118,7 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv
             }
         }
 #endif /* AF_INET6 */
-#endif /* __linux__ */
+#endif /* __linux__ || _ALLBSD_SOURCE */
     }
     return (*env)->NewStringUTF(env, hostname);
 }
