Your message dated Thu, 8 Oct 2015 13:14:31 +0100
with message-id <[email protected]>
and subject line Re: Bug#798123: openjdk-7: FTBFS on kfreebsd
has caused the Debian Bug report #798123,
regarding openjdk-7: FTBFS on kfreebsd
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
798123: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798123
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: openjdk-7
Version: 7u85-2.6.1-2
Severity: important
Tags: patch

Hi!

Attached are refreshed kfreebsd-support-*.diff patches for
IcedTea 2.6.1.

Also some changes to SCTP support in openjdk-7 mean that it sees the
netinet/sctp.h and expects to find libsctp-dev, which is only linux-any
at the moment.  That can be worked around with --disable-system-sctp
as implemented by the attached openjdk-7_7u85-2.6.1.diff

Thanks.

-- System Information:
Debian Release: 7.8
  APT prefers stable-kfreebsd
  APT policy: (500, 'stable-kfreebsd'), (500, 'oldstable-proposed-updates'), 
(500, 'oldstable')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 9.0-2-amd64-xenhvm-ipsec
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Description: Initial GNU/kFreeBSD support for openjdk-7 (JDK part)
 - Alter build system to consider GNU/kFreeBSD like linux
   since this port is libc based.
   openjdk/jdk/make/common/shared/Platform.gmk
 - ENODATA is undefined :
   openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java
   openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
 - sendfile implementation :
   openjdk/jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
   (from bsd-port)
 - BSD network stack usage :
   openjdk/jdk/src/solaris/native/java/net/*
   (from bsd-port)
 - Don't build sctp protocol
   openjdk/jdk/make/com/sun/nio/Makefile
 - Don't build jsoundalsa
   openjdk/jdk/make/javax/sound/Makefile
 - Disable epoll feature and so LinuxWatchService
   openjdk/jdk/make/java/nio/Makefile
Author: Damien Raude-Morvan <[email protected]>
Author: Guido Günther <[email protected]>
Author: Steven Chamberlain <[email protected]>
Last-Update: 2014-07-08
Forwarded: no

--- openjdk/jdk/src/solaris/bin/ergo_i586.c.orig
+++ openjdk/jdk/src/solaris/bin/ergo_i586.c
@@ -106,7 +106,7 @@ ServerClassMachineImpl(void) {
 
 #endif /* __solaris__ */
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 
 /*
  * A utility method for asking the CPU about itself.
--- openjdk/jdk/src/solaris/bin/jexec.c.orig
+++ openjdk/jdk/src/solaris/bin/jexec.c
@@ -76,7 +76,7 @@
 #include <string.h>
 #include <limits.h>
 #include <errno.h>
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #  include <sys/types.h>
 #  include <sys/stat.h>
 #  include <fcntl.h>
@@ -89,7 +89,7 @@ static const int BAD_MAGIC  = ENOEXEC;
 static const char * BAD_EXEC_MSG     = "jexec failed";
 static const char * CRAZY_EXEC_MSG   = "missing args";
 static const char * MISSING_JAVA_MSG = "can't locate java";
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 static const char * BAD_PATHNAME_MSG = "invalid path";
 static const char * BAD_FILE_MSG     = "invalid file";
 static const char * BAD_MAGIC_MSG    = "invalid file (bad magic number)";
@@ -98,7 +98,7 @@ static const char * UNKNOWN_ERROR    = "
 
 /* Define a constant that represents the number of directories to pop off the
  * current location to find the java binary */
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 static const int RELATIVE_DEPTH = 2;
 #else /* Solaris */
 static const int RELATIVE_DEPTH = 3;
@@ -111,7 +111,7 @@ static const char * BIN_PATH = "/bin/jav
 static const char * JAR_FLAG = "-jar";
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 /* largest possible size for a local file header */
 static const size_t CHUNK_SIZE = 65535;
 
@@ -123,7 +123,7 @@ static const ssize_t MIN_SIZE = LOCHDR +
 int main(int argc, const char * argv[]);
 void errorExit(int error, const char * message);
 int getJavaPath(const char * path, char * buf, int depth);
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 const char * isJar(const char * path);
 #endif
 
@@ -172,7 +172,7 @@ int main(int argc, const char * argv[])
     nargv = (const char **) malloc((argc + 2) * (sizeof (const char *)));
     nargv[nargc++] = java;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     /* The "-jar" flag is already in the original args list on Solaris,
      * so it only needs to be added on Linux. */
     nargv[nargc++] = JAR_FLAG;
@@ -182,7 +182,7 @@ int main(int argc, const char * argv[])
         const char * jarfile = argv[argi++];
         const char * message = NULL;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         /* On Linux we also need to make sure argv[1] is really a JAR
          * file (this will also resolve any symlinks, which helps). */
         char jarPath[PATH_MAX + 1];
@@ -291,7 +291,7 @@ int getJavaPath(const char * path, char
 }
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 /*
  * Check if the given file is a JAR file.
  *
--- openjdk/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c.orig
+++ openjdk/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c
@@ -216,7 +216,7 @@ Java_com_sun_management_UnixOperatingSys
 
     JVM_Close(fd);
     return (jlong) psinfo.pr_size * 1024;
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD_kernel__)
     FILE *fp;
     unsigned long vsize = 0;
 
--- openjdk/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
@@ -26,7 +26,7 @@
 /**
  * fstatat in glibc requires _ATFILE_SOURCE to be defined.
  */
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
 #define _ATFILE_SOURCE
 #endif
 
@@ -49,7 +49,7 @@
 #include <strings.h>
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <string.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c
@@ -35,7 +35,7 @@
 #include <strings.h>
 #endif
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
 #include <string.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
@@ -39,7 +39,7 @@
 
 #if defined(__linux__) || defined(__solaris__)
 #include <sys/sendfile.h>
-#elif defined(_ALLBSD_SOURCE)
+#elif defined(_ALLBSD_SOURCE) || defined(__FreeBSD_kernel__)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/uio.h>
@@ -216,6 +216,31 @@ Java_sun_nio_ch_FileChannelImpl_transfer
 
     if (numBytes > 0)
         return numBytes;
+
+    if (result == -1) {
+        if (errno == EAGAIN)
+            return IOS_UNAVAILABLE;
+        if (errno == EOPNOTSUPP || errno == ENOTSOCK || errno == ENOTCONN)
+            return IOS_UNSUPPORTED_CASE;
+        if ((errno == EINVAL) && ((ssize_t)count >= 0))
+            return IOS_UNSUPPORTED_CASE;
+        if (errno == EINTR)
+            return IOS_INTERRUPTED;
+        JNU_ThrowIOExceptionWithLastError(env, "Transfer failed");
+        return IOS_THROWN;
+    }
+
+    return result;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+    off_t numBytes;
+    int result;
+
+    numBytes = count;
+
+    result = sendfile(srcFD, dstFD, position, count, NULL, &numBytes, 0);
+
+    if (numBytes > 0)
+        return numBytes;
 
     if (result == -1) {
         if (errno == EAGAIN)
--- openjdk/jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c
@@ -440,7 +440,7 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_S
             } else if (errno == EINTR) {
                 return IOS_INTERRUPTED;
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
             } else if (errno == ENOTCONN) {
                 /* ENOTCONN when EOF reached */
                 rv = 0;
--- openjdk/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c
@@ -35,7 +35,7 @@
 #include <string.h>
 #include <errno.h>
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #include <netinet/in.h>
 #endif
 
@@ -81,7 +81,7 @@ Java_sun_nio_ch_DatagramChannelImpl_disc
     rv = connect(fd, 0, 0);
 #endif
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(_AIX) || defined(__GLIBC__)
     {
         int len;
         SOCKADDR sa;
--- openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c
@@ -251,7 +251,7 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env,
             return -1;
         }
     }
-#if defined(__linux__) && defined(AF_INET6)
+#if ( defined(__linux__) || defined(__GLIBC__) ) && defined(AF_INET6)
     /* By default, Linux uses the route default */
     if (domain == AF_INET6 && type == SOCK_DGRAM) {
         int arg = 1;
--- openjdk/jdk/src/solaris/native/sun/nio/ch/NativeThread.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/NativeThread.c
@@ -33,7 +33,7 @@
 #include "nio_util.h"
 
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <pthread.h>
 #include <sys/signal.h>
 
@@ -51,7 +51,7 @@ nullHandler(int sig)
 JNIEXPORT void JNICALL
 Java_sun_nio_ch_NativeThread_init(JNIEnv *env, jclass cl)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 
     /* Install the null handler for INTERRUPT_SIGNAL.  This might overwrite the
      * handler previously installed by java/net/linux_close.c, but that's okay
@@ -74,7 +74,7 @@ Java_sun_nio_ch_NativeThread_init(JNIEnv
 JNIEXPORT jlong JNICALL
 Java_sun_nio_ch_NativeThread_current(JNIEnv *env, jclass cl)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     return (long)pthread_self();
 #else
     return -1;
@@ -84,7 +84,7 @@ Java_sun_nio_ch_NativeThread_current(JNI
 JNIEXPORT void JNICALL
 Java_sun_nio_ch_NativeThread_signal(JNIEnv *env, jclass cl, jlong thread)
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     if (pthread_kill((pthread_t)thread, INTERRUPT_SIGNAL))
         JNU_ThrowIOExceptionWithLastError(env, "Thread signal failed");
 #endif
--- openjdk/jdk/src/solaris/native/sun/nio/ch/SocketChannelImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/SocketChannelImpl.c
@@ -31,7 +31,7 @@
 #include <string.h>
 #include <poll.h>
 
-#if __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <netinet/in.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c
@@ -28,7 +28,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#if __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <netinet/in.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/awt/awt_util.h.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_util.h
@@ -200,7 +200,7 @@ Widget awt_util_getXICStatusAreaWindow(W
 
 
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 typedef struct _XmImRefRec {
   Cardinal      num_refs;       /* Number of referencing widgets. */
   Cardinal      max_refs;       /* Maximum length of refs array. */
--- openjdk/jdk/src/solaris/native/sun/awt/awt_util.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_util.c
@@ -603,7 +603,7 @@ awt_WidgetAtXY(Widget root, Position poi
 
   return answer;
 }
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 
 
 #define MAXARGS 10
@@ -674,7 +674,7 @@ awt_util_getXICStatusAreaWindow(Widget w
     return w;
 }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 static XRectangle geometryRect;
 XVaNestedList awt_util_getXICStatusAreaList(Widget w)
 {
--- openjdk/jdk/src/solaris/native/sun/awt/multi_font.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/multi_font.c
@@ -348,7 +348,7 @@ awtJNI_IsMultiFontMetrics(JNIEnv * env,
     return JNI_TRUE;
 }
 #ifndef XAWT
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 XmString
 unicodeXmStringCreate(char* text, char* tag, int len) {
     XmString ret_val;
@@ -433,7 +433,7 @@ awtJNI_MakeMultiFontString(JNIEnv * env,
             char *offsetStringData;
 
             offsetStringData = stringData + (4 * sizeof(char));
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
             len = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
             /* Motif XmStringCreate() API requests "text must be a NULL-terminated
                string" and its implementation uses "strlen()" to calculate the length
--- openjdk/jdk/src/solaris/native/sun/awt/extutil.h.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/extutil.h
@@ -58,7 +58,7 @@ in this Software without prior written a
  */
 /* $XFree86: xc/include/extensions/extutil.h,v 1.5 2001/01/17 17:53:20 dawes Exp $ */
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 
 #ifndef _EXTUTIL_H_
 #define _EXTUTIL_H_
--- openjdk/jdk/src/solaris/native/sun/awt/VDrawingArea.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/VDrawingArea.c
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 /* XXX: Shouldn't be necessary. */
 #include "awt_p.h"
 #endif /* __linux__ */
--- openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -123,7 +123,8 @@ static char *x11GraphicsConfigClassName
  */
 
 #define MAXFRAMEBUFFERS 16
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
+
 typedef struct {
    int   screen_number;
    short x_org;
@@ -439,7 +440,7 @@ getAllConfigs (JNIEnv *env, int screen,
                                       RTLD_LAZY | RTLD_GLOBAL);
         }
 
-#ifndef __linux__ /* SOLARIS */
+#if ! defined(__linux__) && ! defined(__GLIBC__)  /* SOLARIS */
         if (xrenderLibHandle == NULL) {
             xrenderLibHandle = dlopen("/usr/sfw/lib/libXrender.so.1",
                                       RTLD_LAZY | RTLD_GLOBAL);
@@ -652,7 +653,8 @@ void checkNewXineramaScreen(JNIEnv* env,
 #endif /* HEADLESS */
 
 #ifndef HEADLESS
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
+
 static void xinerama_init_linux()
 {
     void* libHandle = NULL;
@@ -703,7 +705,7 @@ static void xinerama_init_linux()
     }
 }
 #endif
-#if !defined(__linux__) && !defined(MACOSX) /* Solaris */
+#if !defined(__linux__) && !defined(MACOSX) && !defined(__GLIBC__) /* Solaris */
 static void xinerama_init_solaris()
 {
     void* libHandle = NULL;
@@ -763,11 +765,11 @@ static void xineramaInit(void) {
     }
 
     DTRACE_PRINTLN("Xinerama extension is available");
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     xinerama_init_linux();
 #else /* Solaris */
     xinerama_init_solaris();
-#endif /* __linux__ || MACOSX */
+#endif /* __linux__ || MACOSX || __GLIBC__ */
 }
 #endif /* HEADLESS */
 
@@ -1644,7 +1646,7 @@ Java_sun_awt_X11GraphicsEnvironment_getX
 {
     jobject point = NULL;
 #ifndef HEADLESS    /* return NULL in HEADLESS, Linux */
-#if !defined(__linux__) && !defined(MACOSX)
+#if !defined(__linux__) && !defined(MACOSX) && !defined(__GLIBC__)
     int x,y;
 
     AWT_LOCK();
--- openjdk/jdk/src/solaris/native/sun/awt/awt_Font.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_Font.c
@@ -334,7 +334,7 @@ loadFont(Display * display, char *name,
             if (strcmp(style, "regular") == 0) {
                 altstyle = "roman";
             }
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
             if (!strcmp(family, "lucidasans")) {
                 family = "lucida";
             }
--- openjdk/jdk/src/solaris/native/sun/awt/awt_InputMethod.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_InputMethod.c
@@ -67,7 +67,7 @@ static void PreeditDrawCallback(XIC, XPo
                                 XIMPreeditDrawCallbackStruct *);
 static void PreeditCaretCallback(XIC, XPointer,
                                  XIMPreeditCaretCallbackStruct *);
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 static void StatusStartCallback(XIC, XPointer, XPointer);
 static void StatusDoneCallback(XIC, XPointer, XPointer);
 static void StatusDrawCallback(XIC, XPointer,
@@ -81,7 +81,7 @@ static void StatusDrawCallback(XIC, XPoi
 #define PreeditDoneIndex        1
 #define PreeditDrawIndex        2
 #define PreeditCaretIndex       3
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 #define StatusStartIndex        4
 #define StatusDoneIndex         5
 #define StatusDrawIndex         6
@@ -99,14 +99,14 @@ static XIMProc callback_funcs[NCALLBACKS
     (XIMProc)PreeditDoneCallback,
     (XIMProc)PreeditDrawCallback,
     (XIMProc)PreeditCaretCallback,
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     (XIMProc)StatusStartCallback,
     (XIMProc)StatusDoneCallback,
     (XIMProc)StatusDrawCallback,
 #endif
 };
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 #define MAX_STATUS_LEN  100
 typedef struct {
     Window   w;                /*status window id        */
@@ -146,7 +146,7 @@ typedef struct _X11InputMethodData {
 #endif /* XAWT */
     jobject     x11inputmethod; /* global ref to X11InputMethod instance */
                                 /* associated with the XIC */
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     StatusWindow *statusWindow; /* our own status window  */
 #else
 #ifndef XAWT
@@ -425,7 +425,7 @@ destroyX11InputMethodData(JNIEnv *env, X
 static void
 freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
 {
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     if (pX11IMData->statusWindow != NULL){
         StatusWindow *sw = pX11IMData->statusWindow;
         XFreeGC(awt_display, sw->lightGC);
@@ -531,7 +531,7 @@ awt_x11inputmethod_lookupString(XKeyPres
     pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
 
     if (pX11IMData == NULL) {
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
         return False;
 #else
         return result;
@@ -539,7 +539,7 @@ awt_x11inputmethod_lookupString(XKeyPres
     }
 
     if ((ic = pX11IMData->current_ic) == (XIC)0){
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
         return False;
 #else
         return result;
@@ -648,7 +648,7 @@ awt_x11inputmethod_lookupString(XKeyPres
     return result;
 }
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 static StatusWindow *createStatusWindow(
 #ifdef XAWT
                                 Window parent) {
@@ -993,7 +993,7 @@ void adjustStatusWindow(Widget shell){
         }
     }
 }
-#endif  /* __linux__ || MACOSX */
+#endif  /* __linux__ || MACOSX || __GLIBC__ */
 /*
  * Creates two XICs, one for active clients and the other for passive
  * clients. All information on those XICs are stored in the
@@ -1050,7 +1050,7 @@ createXIC(Widget w, X11InputMethodData *
         return FALSE ;
     }
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     on_the_spot_styles |= XIMStatusNothing;
 
     /*kinput does not support XIMPreeditCallbacks and XIMStatusArea
@@ -1063,7 +1063,7 @@ createXIC(Widget w, X11InputMethodData *
             break;
         }
     }
-#else /*! __linux__ && !MACOSX */
+#else /*! __linux__ && !MACOSX && !__GLIBC__ */
 #ifdef XAWT
     on_the_spot_styles |= XIMStatusNothing;
 #else /* !XAWT */
@@ -1086,7 +1086,7 @@ createXIC(Widget w, X11InputMethodData *
         on_the_spot_styles |= XIMStatusNothing;
 
 #endif /* XAWT */
-#endif /* __linux__ || MACOSX */
+#endif /* __linux__ || MACOSX || __GLIBC__ */
 
     for (i = 0; i < im_styles->count_styles; i++) {
         active_styles |= im_styles->supported_styles[i] & on_the_spot_styles;
@@ -1134,7 +1134,7 @@ createXIC(Widget w, X11InputMethodData *
                         NULL);
         if (preedit == (XVaNestedList)NULL)
             goto err;
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
         /*always try XIMStatusCallbacks for active client...*/
         {
             status = (XVaNestedList)XVaCreateNestedList(0,
@@ -1156,7 +1156,7 @@ createXIC(Widget w, X11InputMethodData *
             XFree((void *)status);
             XFree((void *)preedit);
         }
-#else /* !__linux__ && !MACOSX */
+#else /* !__linux__ && !MACOSX && !__GLIBC__ */
 #ifndef XAWT
         if (on_the_spot_styles & XIMStatusArea) {
             Widget parent;
@@ -1184,7 +1184,7 @@ createXIC(Widget w, X11InputMethodData *
         }
 #endif /* XAWT */
         XFree((void *)preedit);
-#endif /* __linux__ || MACOSX */
+#endif /* __linux__ || MACOSX || __GLIBC__ */
         pX11IMData->ic_passive = XCreateIC(X11im,
                                            XNClientWindow, w,
                                            XNFocusWindow, w,
@@ -1343,7 +1343,7 @@ PreeditCaretCallback(XIC ic, XPointer cl
 
 }
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 static void
 StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
 {
@@ -1411,7 +1411,7 @@ StatusDrawCallback(XIC ic, XPointer clie
  finally:
     AWT_UNLOCK();
 }
-#endif /* __linux__ || MACOSX */
+#endif /* __linux__ || MACOSX || __GLIBC__ */
 
 static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) {
     JNIEnv *env = GetJNIEnv();
@@ -1517,14 +1517,14 @@ Java_sun_awt_motif_MInputMethod_openXIMN
 /* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
    (4768335)
 */
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
                      NULL, (XIDProc)OpenXIMCallback, NULL);
     if (!registered) {
         /* directly call openXIM callback */
 #endif
         OpenXIMCallback(dpy, NULL, NULL);
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     }
 #endif
 
@@ -1588,13 +1588,13 @@ Java_sun_awt_motif_MInputMethod_createXI
 #endif /* XAWT */
     globalRef = (*env)->NewGlobalRef(env, this);
     pX11IMData->x11inputmethod = globalRef;
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX)  || defined(__GLIBC__)
     pX11IMData->statusWindow = NULL;
-#else /* !__linux__ && !MACOSX */
+#else /* !__linux__ && !MACOSX && !__GLIBC__ */
 #ifndef XAWT
     pX11IMData->statusWidget = (Widget) NULL;
 #endif /* XAWT */
-#endif /* __linux__ || MACOSX */
+#endif /* __linux__ || MACOSX || __GLIBC__ */
 
     pX11IMData->lookup_buf = 0;
     pX11IMData->lookup_buf_len = 0;
@@ -1741,14 +1741,14 @@ Java_sun_awt_X11_XInputMethod_setXICFocu
         setXICFocus(pX11IMData->current_ic, req);
         currentX11InputMethodInstance = pX11IMData->x11inputmethod;
         currentFocusWindow =  w;
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
         if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
             onoffStatusWindow(pX11IMData, w, True);
 #endif
     } else {
         currentX11InputMethodInstance = NULL;
         currentFocusWindow = 0;
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
         onoffStatusWindow(pX11IMData, 0, False);
         if (pX11IMData->current_ic != NULL)
 #endif
@@ -1765,7 +1765,7 @@ JNIEXPORT void JNICALL
 Java_sun_awt_X11InputMethod_turnoffStatusWindow(JNIEnv *env,
                                                 jobject this)
 {
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     X11InputMethodData *pX11IMData;
     StatusWindow *statusWindow;
 
@@ -1862,7 +1862,7 @@ Java_sun_awt_motif_MInputMethod_configur
     X11InputMethodData *pX11IMData;
     XVaNestedList status;
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
       /*do nothing for linux? */
 #else
     AWT_LOCK();
@@ -1968,7 +1968,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_
 JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
   (JNIEnv *env, jobject this, jlong window)
 {
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     AWT_LOCK();
     adjustStatusWindow(window);
     AWT_UNLOCK();
--- openjdk/jdk/src/solaris/native/sun/awt/awt_MToolkit.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_MToolkit.c
@@ -63,7 +63,7 @@
 extern JavaVM *jvm;
 
 #ifndef HEADLESS
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 extern void statusWindowEventHandler(XEvent event);
 Boolean awt_dnd_process_event(XEvent* event);
 #endif
@@ -1643,7 +1643,7 @@ processOneEvent(XtInputMask iMask) {
               */
               Widget widget=XtWindowToWidget(awt_display, xev.xany.window);
               eventNumber++;
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
               statusWindowEventHandler(xev);
 #endif
               xembed_eventHandler(&xev);
--- openjdk/jdk/src/solaris/native/sun/awt/awt_xembed_server.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_xembed_server.c
@@ -35,7 +35,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <Xm/MwmUtil.h>
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <execinfo.h>
 #endif
 #include <stdio.h>
@@ -842,7 +842,7 @@ Java_sun_awt_motif_GrabbedKey_initKeySym
     AWT_UNLOCK();
 }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 void
 print_stack (void)
 {
--- openjdk/jdk/src/solaris/native/sun/awt/fontpath.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/fontpath.c
@@ -23,7 +23,7 @@
  * questions.
  */
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 #include <string.h>
 #endif /* __linux__ */
 #include <stdio.h>
@@ -52,7 +52,7 @@
 #define AWT_UNLOCK()
 #endif /* !HEADLESS */
 
-#if defined(__linux__) && !defined(MAP_FAILED)
+#if !defined(MAP_FAILED)
 #define MAP_FAILED ((caddr_t)-1)
 #endif
 
@@ -132,9 +132,9 @@ static char *full_MACOSX_X11FontPath[] =
     PACKAGE_PATH "/share/fonts/Type1",
     NULL, /* terminates the list */
 };
-#elif defined( __linux__)
+#elif defined( __linux__) || defined(__GLIBC__)
 /* All the known interesting locations we have discovered on
- * various flavors of Linux
+ * various flavors of GNU/Linux
  */
 static char *fullLinuxFontPath[] = {
     "/usr/X11R6/lib/X11/fonts/TrueType",  /* RH 7.1+ */
@@ -396,7 +396,7 @@ static char **getX11FontPath ()
 
 #endif /* !HEADLESS */
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 /* from awt_LoadLibrary.c */
 JNIEXPORT jboolean JNICALL AWTIsHeadless();
 #endif
@@ -521,7 +521,7 @@ static char *getPlatformFontPathChars(JN
      */
     fcdirs = getFontConfigLocations();
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
     knowndirs = fullLinuxFontPath;
 #elif defined(MACOSX)
     knowndirs = full_MACOSX_X11FontPath;
@@ -537,7 +537,7 @@ static char *getPlatformFontPathChars(JN
      * be initialised.
      */
 #ifndef HEADLESS
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     /* There's no headless build on linux ... */
     if (!AWTIsHeadless()) { /* .. so need to call a function to check */
 #endif
@@ -553,7 +553,7 @@ static char *getPlatformFontPathChars(JN
         x11dirs = getX11FontPath();
     }
     AWT_UNLOCK();
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
     }
 #endif
 #endif /* !HEADLESS */
--- openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c.orig
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c
@@ -46,7 +46,7 @@
 #include "wsutils.h"
 #include "list.h"
 #include "multiVis.h"
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 #include <sys/socket.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/java2d/j2d_md.h.orig
+++ openjdk/jdk/src/solaris/native/sun/java2d/j2d_md.h
@@ -30,7 +30,8 @@
 /*
  * Linux and MACOSX's version of <sys/types.h> does not define intptr_t
  */
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
+
 #include <stdint.h>
 #endif /* __linux__ || MACOSX */
 
--- openjdk/jdk/src/solaris/native/sun/java2d/loops/vis_FuncArray.c.orig
+++ openjdk/jdk/src/solaris/native/sun/java2d/loops/vis_FuncArray.c
@@ -804,7 +804,7 @@ static AnyFunc* hash_table_vis[HASH_SIZE
 static int initialized;
 static int usevis = JNI_TRUE;
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 #   define ULTRA_CHIP   "sparc64"
 #else
 #   define ULTRA_CHIP   "sun4u"
--- openjdk/jdk/src/solaris/native/sun/net/dns/ResolverConfigurationImpl.c.orig
+++ openjdk/jdk/src/solaris/native/sun/net/dns/ResolverConfigurationImpl.c
@@ -33,7 +33,7 @@
 #include <strings.h>
 #endif
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #include <string.h>
 #endif
 
--- openjdk/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c.orig
+++ openjdk/jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
@@ -29,7 +29,7 @@
 #include "jlong.h"
 #include "sun_net_spi_DefaultProxySelector.h"
 #include <stdio.h>
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #include <string.h>
 #else
 #include <strings.h>
--- openjdk/jdk/src/solaris/native/sun/xawt/XToolkit.c.orig
+++ openjdk/jdk/src/solaris/native/sun/xawt/XToolkit.c
@@ -27,7 +27,7 @@
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
 #include <X11/Xatom.h>
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <execinfo.h>
 #endif
 
@@ -785,7 +785,7 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X
     return ret;
 }
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 void print_stack(void)
 {
   void *array[10];
--- openjdk/jdk/src/solaris/native/java/nio/MappedByteBuffer.c.orig
+++ openjdk/jdk/src/solaris/native/java/nio/MappedByteBuffer.c
@@ -40,7 +40,7 @@ Java_java_nio_MappedByteBuffer_isLoaded0
     int result = 0;
     int i = 0;
     void *a = (void *) jlong_to_ptr(address);
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     unsigned char *vec = (unsigned char *)malloc(numPages * sizeof(char));
 #else
     char *vec = (char *)malloc(numPages * sizeof(char));
--- openjdk/jdk/src/solaris/native/java/util/TimeZone_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/util/TimeZone_md.c
@@ -49,7 +49,7 @@
 #define fileclose       fclose
 #endif
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 
 
 static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
@@ -124,7 +124,7 @@ findZoneinfoFile(char *buf, size_t size,
         return NULL;
     }
 
-#if defined(AIX) || defined(__linux__) || defined(MACOSX) || (defined(__solaris__) \
+#if defined(AIX) || defined(__linux__) || defined(__GLIBC__) || defined(MACOSX) || (defined(__solaris__) \
     && (defined(_POSIX_PTHREAD_SEMANTICS) || defined(_LP64)))
     while (readdir_r(dirp, entry, &dp) == 0 && dp != NULL) {
 #else
@@ -212,7 +212,7 @@ findZoneinfoFile(char *buf, size_t size,
     return tz;
 }
 
-#if defined(__linux__) || defined(MACOSX)
+#if defined(__linux__) || defined(MACOSX) || defined(__GLIBC__)
 
 /*
  * Performs Linux specific mapping and returns a zone ID
@@ -228,7 +228,7 @@ getPlatformTimeZoneID()
     char *buf;
     size_t size;
 
-#ifdef __linux__
+#ifdef __linux__ || defined(__GLIBC__)
     /*
      * Try reading the /etc/timezone file for Debian distros. There's
      * no spec of the file format available. This parsing assumes that
@@ -698,7 +698,7 @@ findJavaTZ_md(const char *java_home_dir,
 
     tz = getenv("TZ");
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
     if (tz == NULL) {
 #else
 #if defined (__solaris__) || defined(AIX)
@@ -724,7 +724,7 @@ findJavaTZ_md(const char *java_home_dir,
 #endif
 
     if (tz != NULL) {
-#ifdef __linux__
+#if defined(__linux__)  || defined(__GLIBC__)
         /*
          * Ignore "posix/" prefix.
          */
--- openjdk/jdk/src/solaris/native/java/io/io_util_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/io/io_util_md.c
@@ -68,7 +68,7 @@ fileOpen(JNIEnv *env, jobject this, jstr
     WITH_PLATFORM_STRING(env, path, ps) {
         FD fd;
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
         /* Remove trailing slashes, since the kernel won't */
         char *p = (char *)ps + strlen(ps) - 1;
         while ((p > ps) && (*p == '/'))
--- openjdk/jdk/src/solaris/native/java/lang/locale_str.h.orig
+++ openjdk/jdk/src/solaris/native/java/lang/locale_str.h
@@ -48,7 +48,7 @@
     "gl", "gl_ES",
     "he", "iw_IL",
     "hr", "hr_HR",
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "hs", "en_US", // used on Linux, not clear what it stands for
 #endif
     "hu", "hu_HU",
@@ -78,14 +78,14 @@
     "sv", "sv_SE",
     "th", "th_TH",
     "tr", "tr_TR",
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "ua", "en_US", // used on Linux, not clear what it stands for
 #endif
     "uk", "uk_UA",
     "vi", "vi_VN",
     "wa", "wa_BE",
     "zh", "zh_CN",
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "bokmal", "nb_NO",
     "bokm\xE5l", "nb_NO",
     "catalan", "ca_ES",
@@ -146,13 +146,13 @@ static char *language_names[] = {
     "POSIX", "en",
     "cz", "cs",
     "he", "iw",
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "hs", "en", // used on Linux, not clear what it stands for
 #endif
     "id", "in",
     "sh", "sr", // sh is deprecated
     "su", "fi",
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "ua", "en", // used on Linux, not clear what it stands for
     "catalan", "ca",
     "croatian", "hr",
@@ -195,7 +195,7 @@ static char *language_names[] = {
  * Linux/Solaris script string to Java script name mapping table.
  */
 static char *script_names[] = {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "cyrillic", "Cyrl",
     "devanagari", "Deva",
     "iqtelif", "Latn",
@@ -208,7 +208,7 @@ static char *script_names[] = {
  * Linux/Solaris country string to ISO3166 string mapping table.
  */
 static char *country_names[] = {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
     "RN", "US", // used on Linux, not clear what it stands for
 #endif
     "YU", "CS", // YU has been removed from ISO 3166
--- openjdk/jdk/src/solaris/native/java/lang/UNIXProcess_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/lang/UNIXProcess_md.c
@@ -400,7 +400,7 @@ __attribute_noinline__
 #ifdef START_CHILD_USE_CLONE
 static pid_t
 cloneChild(ChildStuff *c) {
-#ifdef __linux__
+#ifdef __linux__ || defined(__GLIBC__)
 #define START_CHILD_CLONE_STACK_SIZE (64 * 1024)
     /*
      * See clone(2).
--- openjdk/jdk/src/solaris/native/java/lang/java_props_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/lang/java_props_md.c
@@ -23,7 +23,7 @@
  * questions.
  */
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #include <stdio.h>
 #include <ctype.h>
 #endif
@@ -57,7 +57,7 @@
 #include "java_props.h"
 
 #if !defined(_ALLBSD_SOURCE)
-#ifdef __linux__
+#ifdef __linux__ || defined(__GLIBC__)
   #ifndef CODESET
   #define CODESET _NL_CTYPE_CODESET_NAME
   #endif
@@ -151,7 +151,7 @@ static int ParseLocale(int cat, char **
     lc = setlocale(cat, NULL);
 #endif
 
-#ifndef __linux__
+#if !defined(__linux__) && !defined(__GLIBC__)
     if (lc == NULL) {
         return 0;
     }
@@ -293,7 +293,7 @@ static int ParseLocale(int cat, char **
          * in order to use optimizations. */
         *std_encoding = (*p != '\0') ? p : "ISO8859-1";
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         /*
          * Remap the encoding string to a different value for japanese
          * locales on linux so that customized converters are used instead
@@ -536,7 +536,7 @@ GetJavaProperties(JNIEnv *env)
      sprops.unicode_encoding = "UnicodeBig";
  #endif
 #else /* !_ALLBSD_SOURCE */
-#ifdef __linux__
+#ifdef __linux__ || defined(__GLIBC__)
 #if __BYTE_ORDER == __LITTLE_ENDIAN
     sprops.unicode_encoding = "UnicodeLittle";
 #else
--- openjdk/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
@@ -33,7 +33,7 @@
 #ifdef __solaris__
 #include <fcntl.h>
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <unistd.h>
 #include <sys/utsname.h>
 #include <netinet/ip.h>
@@ -335,7 +335,7 @@ Java_java_net_PlainDatagramSocketImpl_di
     /* The fdObj'fd */
     jint fd;
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
     SOCKADDR addr;
     int len;
 #endif
@@ -345,7 +345,7 @@ Java_java_net_PlainDatagramSocketImpl_di
     }
     fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #ifdef __linux__
     if (isOldKernel) {
         int t = 1;
@@ -356,14 +356,21 @@ Java_java_net_PlainDatagramSocketImpl_di
 #ifdef AF_INET6
         if (ipv6_available()) {
             struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)&addr;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+            him6->sin6_family = AF_INET6;
+#else
             him6->sin6_family = AF_UNSPEC;
+#endif
             len = sizeof(struct sockaddr_in6);
         } else
 #endif
         {
             struct sockaddr_in *him4 = (struct sockaddr_in*)&addr;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
             him4->sin_family = AF_UNSPEC;
+#else
             len = sizeof(struct sockaddr_in);
+#endif
         }
         JVM_Connect(fd, (struct sockaddr *)&addr, len);
 
--- openjdk/jdk/src/solaris/native/java/net/Inet6AddressImpl.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/Inet6AddressImpl.c
@@ -75,7 +75,7 @@ Java_java_net_Inet6AddressImpl_getLocalH
     } else {
         // ensure null-terminated
         hostname[NI_MAXHOST] = '\0';
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
         /* On Linux/FreeBSD gethostname() says "host.domain.sun.com".  On
          * Solaris gethostname() says "host", so extra work is needed.
          */
@@ -807,7 +807,7 @@ Java_java_net_Inet6AddressImpl_isReachab
         case ENETUNREACH: /* Network Unreachable */
         case EAFNOSUPPORT: /* Address Family not supported */
         case EADDRNOTAVAIL: /* address is not available on  the  remote machine */
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         case EINVAL:
         case EHOSTUNREACH:
           /*
--- openjdk/jdk/src/solaris/native/java/net/Inet4AddressImpl.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
@@ -358,7 +358,7 @@ Java_java_net_Inet4AddressImpl_getLocalH
         /* Something went wrong, maybe networking is not setup? */
         strcpy(hostname, "localhost");
     } else {
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         /* On Linux gethostname() says "host.domain.sun.com".  On
          * Solaris gethostname() says "host", so extra work is needed.
          */
@@ -888,7 +888,7 @@ Java_java_net_Inet4AddressImpl_isReachab
            * EHOSTUNREACH which is not an error, but the answer to our question.
            */
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         case EINVAL:
         case EHOSTUNREACH:
           /*
--- openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c
@@ -63,17 +63,17 @@
 #define _PATH_PROCNET_IFINET6           "/proc/net/if_inet6"
 #endif
 
-#if defined(_ALLBSD_SOURCE)
+#if defined(_ALLBSD_SOURCE) || defined(__FreeBSD_kernel__)
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/sockio.h>
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD_kernel__)
 #include <net/ethernet.h>
 #include <net/if_var.h>
 #include <net/if_dl.h>
 #include <netinet/in_var.h>
-#include <ifaddrs.h>
 #endif
+#include <ifaddrs.h>
 #endif
 
 #include "jvm.h"
@@ -1039,7 +1039,7 @@ static int  openSocket(JNIEnv *env, int
 
 
 /** Linux, AIX **/
-#if !defined(__solaris__)
+#if !defined(__solaris__) && !defined(__FreeBSD_kernel__)
 /* Open socket for further ioct calls, try v4 socket first and
  * if it falls return v6 socket
  */
@@ -1771,7 +1771,11 @@ static int getMacAddress(JNIEnv *env, in
      * try the old way.
      */
     memset(&lif, 0, sizeof(lif));
+#if defined(__FreeBSD_kernel__)
+    strcpy(lif.lifr_name, ifname);
+#else
     strlcpy(lif.lifr_name, ifname, sizeof(lif.lifr_name));
+#endif
 
     if (ioctl(sock, SIOCGLIFHWADDR, &lif) != -1) {
         struct sockaddr_dl *sp;
@@ -1857,7 +1861,7 @@ static int getFlags(int sock, const char
 
 
 /** BSD **/
-#ifdef _ALLBSD_SOURCE
+#if defined(_ALLBSD_SOURCE) || defined(__FreeBSD_kernel__)
 /* Open socket for further ioct calls, try v4 socket first and
  * if it falls return v6 socket
  */
@@ -1986,7 +1990,11 @@ static netif *enumIPv6Interfaces(JNIEnv
             continue;
 
         memset(&ifr6, 0, sizeof(ifr6));
+#if defined(__FreeBSD_kernel__)
+        strcpy(ifr6.ifr_name, ifa->ifa_name);
+#else
         strlcpy(ifr6.ifr_name, ifa->ifa_name, sizeof(ifr6.ifr_name));
+#endif
         memcpy(&ifr6.ifr_addr, ifa->ifa_addr, MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len));
 
         if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
--- openjdk/jdk/src/solaris/native/java/net/net_util_md.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/net_util_md.c
@@ -56,6 +56,11 @@
 #include <net/route.h>
 #include <sys/utsname.h>
 
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
 #ifndef IPV6_FLOWINFO_SEND
 #define IPV6_FLOWINFO_SEND      33
 #endif
--- openjdk/jdk/src/solaris/native/java/net/PlainSocketImpl.c.orig
+++ openjdk/jdk/src/solaris/native/java/net/PlainSocketImpl.c
@@ -32,7 +32,7 @@
 #endif
 #include <netinet/tcp.h>        /* Defines TCP_NODELAY, needed for 2.6 */
 #include <netinet/in.h>
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <netinet/ip.h>
 #endif
 #include <netdb.h>
@@ -41,7 +41,7 @@
 #ifdef __solaris__
 #include <fcntl.h>
 #endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 #include <unistd.h>
 #endif
 
@@ -467,7 +467,7 @@ Java_java_net_PlainSocketImpl_socketConn
     /* report the appropriate exception */
     if (connect_rv < 0) {
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
         /*
          * Linux/GNU distribution setup /etc/hosts so that
          * InetAddress.getLocalHost gets back the loopback address
--- openjdk/jdk/src/solaris/native/java/net/net_util_md.h.orig
+++ openjdk/jdk/src/solaris/native/java/net/net_util_md.h
@@ -46,7 +46,7 @@
    close subroutine does not return until the select call returns.
    ...
 */
-#if defined(__linux__) || defined(MACOSX) || defined (_AIX)
+#if defined(__linux__) || defined(MACOSX) || defined (_AIX) || defined(__GLIBC__)
 extern int NET_Timeout(int s, long timeout);
 extern int NET_Read(int s, void* buf, size_t len);
 extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
@@ -198,7 +198,7 @@ extern jint NET_Wait(JNIEnv *env, jint f
 /************************************************************************
  *  Utilities
  */
-#ifdef __linux__
+#if defined(__linux__)
 extern int kernelIsV22();
 extern int kernelIsV24();
 #endif
--- openjdk/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
@@ -306,7 +306,7 @@ public class FcFontConfiguration extends
 
         super.setOsNameAndVersion();
 
-        if (!osName.equals("Linux")) {
+        if (!(osName.equals("Linux") || osName.equals("GNU/kFreeBSD"))) {
             return;
         }
         try {
--- openjdk/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
@@ -170,6 +170,7 @@ public class UnixPrintServiceLookup exte
 
     static boolean isBSD() {
         return (osname.equals("Linux") ||
+                osname.equals("GNU/kFreeBSD") ||
                 osname.contains("OS X"));
     }
 
--- openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java
@@ -101,9 +101,7 @@ class LinuxFileStore
                 LinuxNativeDispatcher.fgetxattr(fd, "user.java".getBytes(), 0L, 0);
                 return true;
             } catch (UnixException e) {
-                // attribute does not exist
-                if (e.errno() == UnixConstants.ENODATA)
-                    return true;
+                return false;
             } finally {
                 UnixNativeDispatcher.close(fd);
             }
--- openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
@@ -238,9 +238,6 @@ class LinuxDosFileAttributeView
             }
             throw new UnixException("Value of " + DOS_XATTR_NAME + " attribute is invalid");
         } catch (UnixException x) {
-            // default value when attribute does not exist
-            if (x.errno() == ENODATA)
-                return 0;
             throw x;
         } finally {
             buffer.release();
--- openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java
@@ -66,7 +66,7 @@ public class DefaultFileSystemProvider {
             .doPrivileged(new GetPropertyAction("os.name"));
         if (osname.equals("SunOS"))
             return createProvider("sun.nio.fs.SolarisFileSystemProvider");
-        if (osname.equals("Linux"))
+        if (osname.equals("Linux") || osname.equals("GNU/kFreeBSD"))
             return createProvider("sun.nio.fs.LinuxFileSystemProvider");
         if (osname.equals("Darwin") || osname.contains("OS X"))
             return createProvider("sun.nio.fs.MacOSXFileSystemProvider");
--- openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
@@ -48,7 +48,7 @@ public class DefaultAsynchronousChannelP
             .doPrivileged(new GetPropertyAction("os.name"));
         if (osname.equals("SunOS"))
             return new SolarisAsynchronousChannelProvider();
-        if (osname.equals("Linux"))
+        if (osname.equals("Linux") || osname.equals("GNU/kFreeBSD"))
             return new LinuxAsynchronousChannelProvider();
         if (osname.contains("OS X"))
             return new BsdAsynchronousChannelProvider();
--- openjdk/jdk/src/solaris/classes/sun/awt/X11/XScrollbarPeer.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XScrollbarPeer.java
@@ -74,7 +74,7 @@ class XScrollbarPeer extends XComponentP
      * Currently uses hardcoded values
      */
     private int getDefaultDimension() {
-        if (System.getProperty("os.name").equals("Linux")) {
+        if (System.getProperty("os.name").equals("Linux") || System.getProperty("os.name").equals("GNU/kFreeBSD")) {
             return DEFAULT_WIDTH_LINUX;
         } else {
             return DEFAULT_WIDTH_SOLARIS;
--- openjdk/jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h.orig
+++ openjdk/jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h
@@ -61,7 +61,7 @@
 #define log1p   jlog1p
 #define expm1   jexpm1
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #define __ieee754_sqrt          __j__ieee754_sqrt
 #define __ieee754_acos          __j__ieee754_acos
 #define __ieee754_acosh         __j__ieee754_acosh
--- openjdk/jdk/src/share/classes/sun/font/FontUtilities.java.orig
+++ openjdk/jdk/src/share/classes/sun/font/FontUtilities.java
@@ -76,7 +76,7 @@ public final class FontUtilities {
                 String osName = System.getProperty("os.name", "unknownOS");
                 isSolaris = osName.startsWith("SunOS");
 
-                isLinux = osName.startsWith("Linux");
+                isLinux = osName.startsWith("Linux") || osName.equals("GNU/kFreeBSD");
 
                 isMacOSX = osName.contains("OS X"); // TODO: MacOSX
 
--- openjdk/jdk/src/share/classes/sun/print/PSPrinterJob.java.orig
+++ openjdk/jdk/src/share/classes/sun/print/PSPrinterJob.java
@@ -1568,7 +1568,9 @@ public class PSPrinterJob extends Raster
         }
 
        String osname = System.getProperty("os.name");
-       if (osname.equals("Linux") || osname.contains("OS X")) {
+       if (osname.equals("Linux") ||
+           osname.equals("GNU/kFreeBSD") ||
+           osname.contains("OS X")) {
             execCmd = new String[ncomps];
             execCmd[n++] = "/usr/bin/lpr";
             if ((pFlags & PRINTER) != 0) {
--- openjdk/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java.orig
+++ openjdk/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java
@@ -1298,6 +1298,7 @@ public class ExtendedCharsets
         String osName = AccessController.doPrivileged(
             new GetPropertyAction("os.name"));
         if ("SunOS".equals(osName) || "Linux".equals(osName)
+               || "GNU/kFreeBSD".equals(osName)
                || osName.contains("OS X") || osName.contains("AIX")) {
             charset("x-COMPOUND_TEXT", "COMPOUND_TEXT",
                     new String[] {
--- openjdk/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java.orig
+++ openjdk/jdk/src/share/classes/sun/security/jgss/GSSManagerImpl.java
@@ -48,6 +48,7 @@ public class GSSManagerImpl extends GSSM
                     public Boolean run() {
                             String osname = System.getProperty("os.name");
                             if (osname.startsWith("SunOS") ||
+                                osname.startsWith("GNU/kFreeBSD") ||
                                 osname.startsWith("Linux")) {
                                 return new Boolean(System.getProperty
                                     (USE_NATIVE_PROP));
--- openjdk/jdk/src/share/classes/java/awt/GraphicsEnvironment.java.orig
+++ openjdk/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
@@ -178,6 +178,7 @@ public abstract class GraphicsEnvironmen
                             } else {
                                 headless = defaultHeadless =
                                     Boolean.valueOf(("Linux".equals(osName) ||
+                                                     "GNU/kFreeBSD".equals(osName) ||
                                                      "SunOS".equals(osName) ||
                                                      "FreeBSD".equals(osName) ||
                                                      "NetBSD".equals(osName) ||
--- openjdk/jdk/make/com/sun/nio/Makefile.orig
+++ openjdk/jdk/make/com/sun/nio/Makefile
@@ -38,7 +38,7 @@ endif
 
 
 all build clean clobber::
-	$(SUBDIRS-loop)
+#	$(SUBDIRS-loop)
 
 clean clobber::
-	$(RM) -r $(CLASSDESTDIR)/com/sun/nio
+#	$(RM) -r $(CLASSDESTDIR)/com/sun/nio
--- openjdk/jdk/make/java/nio/Makefile.orig
+++ openjdk/jdk/make/java/nio/Makefile
@@ -94,6 +94,70 @@ FILES_export += \
 
 else
 
+ifeq ($(SYSTEM_UNAME),GNU/kFreeBSD)
+
+FILES_java += \
+        sun/nio/ch/AbstractPollSelectorImpl.java \
+        sun/nio/ch/DevPollArrayWrapper.java \
+        sun/nio/ch/DevPollSelectorImpl.java \
+        sun/nio/ch/DevPollSelectorProvider.java \
+        sun/nio/ch/InheritedChannel.java \
+        sun/nio/ch/LinuxAsynchronousChannelProvider.java \
+        sun/nio/ch/PollSelectorProvider.java \
+        sun/nio/ch/PollSelectorImpl.java \
+        sun/nio/ch/Port.java \
+        sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
+        sun/nio/ch/SolarisAsynchronousChannelProvider.java \
+        sun/nio/ch/SolarisEventPort.java \
+        sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+        sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+        \
+        sun/nio/fs/GnomeFileTypeDetector.java \
+        sun/nio/fs/LinuxDosFileAttributeView.java \
+        sun/nio/fs/LinuxFileStore.java \
+        sun/nio/fs/LinuxFileSystem.java \
+        sun/nio/fs/LinuxFileSystemProvider.java \
+        sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
+        sun/nio/fs/LinuxNativeDispatcher.java \
+        sun/nio/fs/PollingWatchService.java \
+        sun/nio/fs/SolarisNativeDispatcher.java \
+        sun/nio/fs/SolarisWatchService.java \
+        sun/nio/fs/UnixChannelFactory.java \
+        sun/nio/fs/UnixCopyFile.java \
+        sun/nio/fs/UnixDirectoryStream.java \
+        sun/nio/fs/UnixException.java \
+        sun/nio/fs/UnixFileAttributeViews.java \
+        sun/nio/fs/UnixFileAttributes.java \
+        sun/nio/fs/UnixFileKey.java \
+        sun/nio/fs/UnixFileModeAttribute.java \
+        sun/nio/fs/UnixFileStore.java \
+        sun/nio/fs/UnixFileStoreAttributes.java \
+        sun/nio/fs/UnixFileSystem.java \
+        sun/nio/fs/UnixFileSystemProvider.java \
+        sun/nio/fs/UnixMountEntry.java \
+        sun/nio/fs/UnixNativeDispatcher.java \
+        sun/nio/fs/UnixPath.java \
+        sun/nio/fs/UnixSecureDirectoryStream.java \
+        sun/nio/fs/UnixUriUtils.java \
+        sun/nio/fs/UnixUserPrincipals.java
+
+FILES_export += \
+        sun/nio/ch/DevPollArrayWrapper.java \
+        sun/nio/ch/InheritedChannel.java \
+        sun/nio/ch/NativeThread.java \
+        sun/nio/ch/SolarisEventPort.java \
+        sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+        sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+        \
+        sun/nio/fs/GnomeFileTypeDetector.java \
+        sun/nio/fs/LinuxNativeDispatcher.java \
+        sun/nio/fs/SolarisNativeDispatcher.java \
+        sun/nio/fs/SolarisWatchService.java \
+        sun/nio/fs/UnixCopyFile.java \
+        sun/nio/fs/UnixNativeDispatcher.java
+
+else
+
 FILES_java += \
         sun/nio/ch/AbstractPollSelectorImpl.java \
 	sun/nio/ch/DevPollArrayWrapper.java \
@@ -164,6 +228,8 @@ FILES_export += \
 	sun/nio/fs/UnixCopyFile.java \
 	sun/nio/fs/UnixNativeDispatcher.java
 
+endif # kFreeBSD
+
 FILES_gen += \
 	sun/nio/fs/UnixConstants.java
 
@@ -172,7 +238,7 @@ FILES_c += \
 	syscalls_fp.c
 endif
 
-endif
+endif # else
 
 ifeq ($(PLATFORM), solaris)
 
@@ -221,6 +287,22 @@ endif # PLATFORM = windows
 
 ifeq ($(PLATFORM), linux)
 
+ifeq ($(SYSTEM_UNAME),GNU/kFreeBSD)
+
+FILES_c += \
+        InheritedChannel.c \
+        NativeThread.c \
+        PollArrayWrapper.c \
+        UnixAsynchronousServerSocketChannelImpl.c \
+        UnixAsynchronousSocketChannelImpl.c \
+        \
+        GnomeFileTypeDetector.c \
+        LinuxNativeDispatcher.c \
+        UnixCopyFile.c \
+        UnixNativeDispatcher.c
+
+else
+
 FILES_c += \
 	EPoll.c \
 	EPollArrayWrapper.c \
@@ -345,6 +427,7 @@ FILES_export += \
 
 endif # PLATFORM = aix
 
+endif # kFreeBSD
 
 ifeq ($(PLATFORM), macosx)
 FILES_java += \
--- openjdk/jdk/make/common/shared/Sanity.gmk.orig
+++ openjdk/jdk/make/common/shared/Sanity.gmk
@@ -114,12 +114,14 @@ ifeq ($(PLATFORM), linux)
     elif [ -f /etc/lsb-release ] ; then \
       $(EGREP) DISTRIB_RELEASE /etc/lsb-release | $(SED) -e 's@.*DISTRIB_RELEASE=\(.*\)@\1@'; \
     fi)
+ifneq ($(SYSTEM_UNAME),GNU/kFreeBSD)
   ALSA_INCLUDE=/usr/include/alsa/version.h
   ALSA_LIBRARY=/usr/lib/libasound.so
   _ALSA_VERSION := $(shell $(EGREP) SND_LIB_VERSION_STR $(ALSA_INCLUDE) | \
            $(SED) -e 's@.*"\(.*\)".*@\1@' )
   ALSA_VERSION := $(call GetVersion,$(_ALSA_VERSION))
 endif
+endif
 
 ifeq ($(PLATFORM), macosx)
   # What kind of system we are using
--- openjdk/jdk/make/common/shared/Defs-versions.gmk.orig
+++ openjdk/jdk/make/common/shared/Defs-versions.gmk
@@ -158,7 +158,9 @@ ifeq ($(PLATFORM), linux)
   REQUIRED_OS_VERSION         = 2.6
   REQUIRED_OS_VARIANT_NAME    = Fedora
   REQUIRED_OS_VARIANT_VERSION = 9
-  REQUIRED_ALSA_VERSION       = 0.9.1
+ifneq ($(SYSTEM_UNAME),GNU/kFreeBSD)
+   REQUIRED_ALSA_VERSION       = 0.9.1
+endif
   REQUIRED_COMPILER_NAME      = GCC4
   REQUIRED_COMPILER_VERSION   = GCC4
   REQUIRED_GCC_VER            = 2.95
--- openjdk/jdk/make/common/shared/Platform.gmk.orig
+++ openjdk/jdk/make/common/shared/Platform.gmk
@@ -162,7 +162,7 @@ endif
 
 
 # Platform settings specific to Linux
-ifeq ($(SYSTEM_UNAME), Linux)
+ifneq (,$(filter Linux GNU/kFreeBSD, $(SYSTEM_UNAME)))
   PLATFORM = linux
   # Arch and OS name/version
   ifdef CROSS_COMPILE_ARCH
--- openjdk/jdk/make/common/shared/Sanity-Settings.gmk.orig
+++ openjdk/jdk/make/common/shared/Sanity-Settings.gmk
@@ -186,8 +186,10 @@ ifeq ($(PLATFORM),windows)
 endif
 ifeq ($(PLATFORM),linux)
   ifdef REQUIRED_ALSA_VERSION
+  ifneq ($(SYSTEM_UNAME),GNU/kFreeBSD)
     ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
   endif
+  endif
 endif
 ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION)
 ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME)
--- openjdk/jdk/make/javax/sound/Makefile.orig
+++ openjdk/jdk/make/javax/sound/Makefile
@@ -105,10 +105,12 @@ ifeq ($(PLATFORM), windows)
 endif # PLATFORM win32
 
 ifeq ($(PLATFORM), linux)
+ifneq ($(SYSTEM_UNAME),GNU/kFreeBSD)
   # ALSA handles directaudio, ports, and MIDI
   SUBDIRS += jsoundalsa
   EXTRA_SOUND_JNI_LIBS += jsoundalsa
   #MXSPP_ADD = $(PLATFORM)-$(ARCH)/
+endif # kFreeBSD
 endif # PLATFORM linux
 
 ifeq ($(PLATFORM), macosx)
--- openjdk/jdk/src/solaris/native/sun/net/portconfig.c.orig
+++ openjdk/jdk/src/solaris/native/sun/net/portconfig.c
@@ -28,7 +28,7 @@
 #include <unistd.h>
 #include <errno.h>
 
-#if defined(_ALLBSD_SOURCE)
+#if defined(_ALLBSD_SOURCE) || defined (__FreeBSD_kernel__)
 #include <sys/sysctl.h>
 #endif
 
@@ -66,7 +66,7 @@ static int getPortRange(struct portrange
         range->higher = net_getParam("/dev/tcp", "tcp_largest_anon_port");
         return 0;
     }
-#elif defined(_ALLBSD_SOURCE)
+#elif defined(_ALLBSD_SOURCE) || defined (__FreeBSD_kernel__)
     {
         int ret;
         size_t size = sizeof(range->lower);
--- openjdk/jdk/src/solaris/classes/sun/net/PortConfig.java.orig
+++ openjdk/jdk/src/solaris/classes/sun/net/PortConfig.java
@@ -62,6 +62,9 @@ public final class PortConfig {
                     } else if (os.contains("OS X")) {
                         defaultLower = 49152;
                         defaultUpper = 65535;
+                    } else if (os.contains("FreeBSD")) {
+                        defaultLower = 10000;
+                        defaultUpper = 65535;
                     } else {
                         throw new InternalError(
                             "sun.net.PortConfig: unknown OS");
Description: Initial GNU/kFreeBSD support for openjdk-7 (Corba part)
 - Alter build system to consider GNU/kFreeBSD like linux
   since this port is libc based.
   openjdk/corba/make/common/shared/Platform.gmk
Author: Damien Raude-Morvan <[email protected]>
Last-Update: 2011-06-28
Forwarded: no
--- openjdk/corba/make/common/shared/Platform.gmk.orig
+++ openjdk/corba/make/common/shared/Platform.gmk
@@ -147,7 +147,7 @@ ifeq ($(SYSTEM_UNAME), SunOS)
 endif
 
 # Platform settings specific to Linux
-ifeq ($(SYSTEM_UNAME), Linux)
+ifneq (,$(filter Linux GNU/kFreeBSD, $(SYSTEM_UNAME)))
   PLATFORM = linux
   OS_NAME = linux
   OS_VERSION := $(shell uname -r)
--- debian/rules.orig	2015-09-04 16:09:00.000000000 +0000
+++ debian/rules	2015-09-05 14:42:27.845213878 +0000
@@ -547,6 +547,11 @@
   CONFIGURE_ARGS += --disable-compile-against-syscalls
 endif
 
+# Only Linux has libsctp-dev currently
+ifneq (,$(filter $(DEB_HOST_ARCH_OS), linux))
+  CONFIGURE_ARGS += --disable-system-sctp
+endif
+
 CONFIGURE_ARGS += --with-pkgversion="$(PKGVERSION)"
 
 # there are problems --with-alt-jar=/usr/bin/fastjar,
Description: 
 - Add iddef TIOCINQ = FIONREAD
 jamvm/src/classlib/openjdk/jvm.c
 - Update configure for kfreebsd-amd64
 jamvm/jamvm/configure.ac
Author: Damien Raude-Morvan <[email protected]>
Last-Update: 2011-08-05
Forwarded: no
--- jamvm/jamvm/configure.ac.orig
+++ jamvm/jamvm/configure.ac
@@ -39,6 +39,7 @@ i386-*-openbsd*) host_os=bsd libdl_neede
 i386-*-freebsd*) host_os=bsd libdl_needed=no ;;
 i386-*-solaris*) host_cpu=x86 host_os=solaris ;;
 x86_64-*-linux*) host_os=linux ;;
+x86_64-*-kfreebsd*) host_os=linux ;;
 hppa*-*-linux*) host_cpu=parisc host_os=linux ;;
 mips*-*-linux*) host_cpu=mips host_os=linux ;;
 x86_64-*-openbsd*) host_os=bsd libdl_needed=no ;;
--- jamvm/jamvm/configure.orig
+++ jamvm/jamvm/configure
@@ -2926,6 +2926,7 @@ i386-*-openbsd*) host_os=bsd libdl_neede
 i386-*-freebsd*) host_os=bsd libdl_needed=no ;;
 i386-*-solaris*) host_cpu=x86 host_os=solaris ;;
 x86_64-*-linux*) host_os=linux ;;
+x86_64-*-kfreebsd*) host_os=linux ;;
 hppa*-*-linux*) host_cpu=parisc host_os=linux ;;
 mips*-*-linux*) host_cpu=mips host_os=linux ;;
 x86_64-*-openbsd*) host_os=bsd libdl_needed=no ;;
--- jamvm/jamvm/src/classlib/openjdk/jvm.c.orig
+++ jamvm/jamvm/src/classlib/openjdk/jvm.c
@@ -63,6 +63,10 @@
 static int have_monotonic_clock;
 #endif
 
+#ifndef TIOCINQ
+#define TIOCINQ FIONREAD
+#endif
+
 static Class *cloneable_class, *constant_pool_class;
 static Class *exception_class, *runtime_excp_class;
 
--- openjdk/hotspot/src/os/posix/launcher/java_md.c.orig
+++ openjdk/hotspot/src/os/posix/launcher/java_md.c
@@ -41,7 +41,7 @@
 #include "version_comp.h"
 #endif
 
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
 #include <pthread.h>
 #else
 #include <thread.h>
@@ -107,7 +107,7 @@ extern char **environ;
  *      A collection of useful strings. One should think of these as #define
  *      entries, but actual strings can be more efficient (with many compilers).
  */
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 static const char *system_dir   = "/usr/java";
 static const char *user_dir     = "/java";
 #else /* Solaris */
@@ -444,7 +444,7 @@ CreateExecutionEnvironment(int *_argcp,
       runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __sun */
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__GLIBC__)
       /*
        * On linux, if a binary is running as sgid or suid, glibc sets
        * LD_LIBRARY_PATH to the empty string for security purposes.  (In
@@ -834,7 +834,7 @@ error:
 jboolean
 GetApplicationHome(char *buf, jint bufsize)
 {
-#if defined(__linux__) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
     char *execname = GetExecname();
     if (execname) {
         strncpy(buf, execname, bufsize-1);
@@ -1003,7 +1003,7 @@ SetExecname(char **argv)
             }
         }
     }
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__GLIBC__)
     {
         const char* self = "/proc/self/exe";
         char buf[PATH_MAX+1];
@@ -1898,7 +1898,7 @@ jlong_format_specifier() {
 int
 ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
     int rslt;
-#if defined(__linux__) || defined(AIX) || defined(_ALLBSD_SOURCE)
+#if defined(__linux__) || defined(AIX) || defined(_ALLBSD_SOURCE) || defined(__GLIBC__)
     pthread_t tid;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
--- openjdk/hotspot/src/os/linux/vm/decoder_linux.cpp.orig
+++ openjdk/hotspot/src/os/linux/vm/decoder_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 #include "prims/jvm.h"
 #include "utilities/decoder_elf.hpp"
 
--- openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp.orig
+++ openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp
@@ -39,6 +39,10 @@
 #define UNIX_PATH_MAX   sizeof(((struct sockaddr_un *)0)->sun_path)
 #endif
 
+#if defined(__FreeBSD_kernel__)
+#include <sys/ucred.h>
+#endif
+
 // The attach mechanism on Linux uses a UNIX domain socket. An attach listener
 // thread is created at startup or is created on-demand via a signal from
 // the client tool. The attach listener creates a socket and binds it to a file
@@ -337,9 +341,15 @@ LinuxAttachOperation* LinuxAttachListene
 
     // get the credentials of the peer and check the effective uid/guid
     // - check with jeff on this.
+#if defined(LOCAL_PEERCRED) /* GNU/kFreeBSD */
+    struct xucred cred_info;
+    socklen_t optlen = sizeof(cred_info);
+    if (::getsockopt(s, SOL_SOCKET, LOCAL_PEERCRED, (void*)&cred_info, &optlen) == -1) {
+#else
     struct ucred cred_info;
     socklen_t optlen = sizeof(cred_info);
     if (::getsockopt(s, SOL_SOCKET, SO_PEERCRED, (void*)&cred_info, &optlen) == -1) {
+#endif
       int res;
       RESTARTABLE(::close(s), res);
       continue;
@@ -347,7 +357,11 @@ LinuxAttachOperation* LinuxAttachListene
     uid_t euid = geteuid();
     gid_t egid = getegid();
 
+#if defined(LOCAL_PEERCRED) /* GNU/kFreeBSD */
+    if (cred_info.cr_uid != euid || cred_info.cr_gid != egid) {
+#else
     if (cred_info.uid != euid || cred_info.gid != egid) {
+#endif
       int res;
       RESTARTABLE(::close(s), res);
       continue;
--- openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp.orig
+++ openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp
@@ -169,7 +169,9 @@ struct siglabel siglabels[] = {
   "WINCH",      SIGWINCH,       /* Window size change (4.3 BSD, Sun).  */
   "POLL",       SIGPOLL,        /* Pollable event occurred (System V).  */
   "IO",         SIGIO,          /* I/O now possible (4.2 BSD).  */
+#ifdef SIGPWR
   "PWR",        SIGPWR,         /* Power failure restart (System V).  */
+#endif
 #ifdef SIGSYS
   "SYS",        SIGSYS          /* Bad system call. Only on some Linuxen! */
 #endif
--- openjdk/hotspot/src/os/linux/vm/os_linux.cpp.orig
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
@@ -114,8 +115,16 @@
 # include <semaphore.h>
 # include <fcntl.h>
 # include <string.h>
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#ifndef ETIME
+# define ETIME ETIMEDOUT
+#endif
+#else
 # include <syscall.h>
 # include <sys/sysinfo.h>
+#endif
 # include <gnu/libc-version.h>
 # include <sys/ipc.h>
 # include <sys/shm.h>
@@ -224,11 +233,22 @@ julong os::available_memory() {
 }
 
 julong os::Linux::available_memory() {
+#ifndef __FreeBSD_kernel__
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
 
   return (julong)si.freeram * si.mem_unit;
+#else
+  int mib[2] = {CTL_HW, HW_USERMEM}, mem;
+  size_t len;
+  len = sizeof(mem);
+  if (sysctl(mib, 2, &mem, &len, NULL, 0) == 0) {
+    return (julong) mem;
+  } else {
+    return 0;
+  }
+#endif
 }
 
 julong os::physical_memory() {
@@ -2325,18 +2345,22 @@ void os::print_memory_info(outputStream*
   st->print("Memory:");
   st->print(" %dk page", os::vm_page_size()>>10);
 
+#ifndef __FreeBSD_kernel__
   // values in struct sysinfo are "unsigned long"
   struct sysinfo si;
   sysinfo(&si);
+#endif
 
   st->print(", physical " UINT64_FORMAT "k",
             os::physical_memory() >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             os::available_memory() >> 10);
+#ifndef __FreeBSD_kernel__
   st->print(", swap " UINT64_FORMAT "k",
             ((jlong)si.totalswap * si.mem_unit) >> 10);
   st->print("(" UINT64_FORMAT "k free)",
             ((jlong)si.freeswap * si.mem_unit) >> 10);
+#endif
   st->cr();
 }
 
@@ -6218,8 +6242,12 @@ int os::fork_and_exec(char* cmd) {
 #if defined(SPARC)
   sparc_fork(__NR_fork, &pid, &is_child);
 #else
+#ifdef __linux__
   pid = NOT_IA64(syscall(__NR_fork);)
               IA64_ONLY(fork();)
+#else
+  pid = fork();
+#endif
 
   // set the is_child flag by checking the pid
   if (pid == 0) {
@@ -6236,6 +6264,7 @@ int os::fork_and_exec(char* cmd) {
   } else if (is_child) {
     // child process
 
+#ifdef __linux__
     // execve() in LinuxThreads will call pthread_kill_other_threads_np()
     // first to kill every thread on the thread list. Because this list is
     // not reset by fork() (see notes above), execve() will instead kill
@@ -6245,6 +6274,9 @@ int os::fork_and_exec(char* cmd) {
     // above.
     NOT_IA64(syscall(__NR_execve, "/bin/sh", argv, environ);)
     IA64_ONLY(execve("/bin/sh", (char* const*)argv, environ);)
+#else
+    execve("/bin/sh", (char* const*)argv, environ);
+#endif
 
     // execve failed
     _exit(-1);
--- openjdk/hotspot/src/os/linux/vm/osThread_linux.cpp.orig
+++ openjdk/hotspot/src/os/linux/vm/osThread_linux.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "runtime/atomic.hpp"
 #include "runtime/handles.inline.hpp"
--- openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp.orig
+++ openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "assembler_x86.inline.hpp"
 #include "classfile/classLoader.hpp"
@@ -75,6 +76,7 @@
 # include <ucontext.h>
 # include <fpu_control.h>
 
+#ifdef __linux__
 #ifdef AMD64
 #define REG_SP REG_RSP
 #define REG_PC REG_RIP
@@ -88,6 +90,54 @@
 #define SPELL_REG_SP "esp"
 #define SPELL_REG_FP "ebp"
 #endif // AMD64
+#endif
+
+#if defined(__FreeBSD_kernel__)
+#define context_trapno uc_mcontext.mc_trapno
+#ifdef AMD64
+#define SPELL_REG_SP "rsp"
+#define SPELL_REG_FP "rbp"
+#define context_sp uc_mcontext.mc_rsp
+#define context_pc uc_mcontext.mc_rip
+#define context_fp uc_mcontext.mc_rbp
+#define context_rip uc_mcontext.mc_rip
+#define context_rsp uc_mcontext.mc_rsp
+#define context_rbp uc_mcontext.mc_rbp
+#define context_flags uc_mcontext.mc_flags
+#define context_err uc_mcontext.mc_err
+#define context_rax uc_mcontext.mc_rax
+#define context_rbx uc_mcontext.mc_rbx
+#define context_rcx uc_mcontext.mc_rcx
+#define context_rdx uc_mcontext.mc_rdx
+#define context_rsi uc_mcontext.mc_rsi
+#define context_rdi uc_mcontext.mc_rdi
+#define context_r8 uc_mcontext.mc_r8
+#define context_r9 uc_mcontext.mc_r9
+#define context_r10 uc_mcontext.mc_r10
+#define context_r11 uc_mcontext.mc_r11
+#define context_r12 uc_mcontext.mc_r12
+#define context_r13 uc_mcontext.mc_r13
+#define context_r14 uc_mcontext.mc_r14
+#define context_r15 uc_mcontext.mc_r15
+#else
+#define SPELL_REG_SP "esp"
+#define SPELL_REG_FP "ebp"
+#define context_sp uc_mcontext.mc_esp
+#define context_pc uc_mcontext.mc_eip
+#define context_fp uc_mcontext.mc_ebp
+#define context_eip uc_mcontext.mc_eip
+#define context_esp uc_mcontext.mc_esp
+#define context_eax uc_mcontext.mc_eax
+#define context_ebx uc_mcontext.mc_ebx
+#define context_ecx uc_mcontext.mc_ecx
+#define context_edx uc_mcontext.mc_edx
+#define context_ebp uc_mcontext.mc_ebp
+#define context_esi uc_mcontext.mc_esi
+#define context_edi uc_mcontext.mc_edi
+#define context_eflags uc_mcontext.mc_eflags
+#define context_trapno uc_mcontext.mc_trapno
+#endif // AMD64
+#endif
 
 address os::current_stack_pointer() {
 #ifdef SPARC_WORKS
@@ -113,15 +163,27 @@ void os::initialize_thread(Thread* thr)
 }
 
 address os::Linux::ucontext_get_pc(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (address)uc->context_pc;
+#else
   return (address)uc->uc_mcontext.gregs[REG_PC];
+#endif
 }
 
 intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (intptr_t*)uc->context_sp;
+#else
   return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
+#endif
 }
 
 intptr_t* os::Linux::ucontext_get_fp(ucontext_t * uc) {
+#if defined(__FreeBSD_kernel__)
+  return (intptr_t*)uc->context_fp;
+#else
   return (intptr_t*)uc->uc_mcontext.gregs[REG_FP];
+#endif
 }
 
 // For Forte Analyzer AsyncGetCallTrace profiling support - thread
@@ -277,12 +339,20 @@ JVM_handle_linux_signal(int sig,
     pc = (address) os::Linux::ucontext_get_pc(uc);
 
     if (pc == (address) Fetch32PFI) {
+#if defined(__FreeBSD_kernel__)
+       uc->context_pc = intptr_t(Fetch32Resume) ;
+#else
        uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ;
+#endif
        return 1 ;
     }
 #ifdef AMD64
     if (pc == (address) FetchNPFI) {
+#if defined(__FreeBSD_kernel__)
+       uc->context_pc = intptr_t (FetchNResume) ;
+#else
        uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ;
+#endif
        return 1 ;
     }
 #endif // AMD64
@@ -433,7 +503,11 @@ JVM_handle_linux_signal(int sig,
   // Furthermore, a false-positive should be harmless.
   if (UnguardOnExecutionViolation > 0 &&
       (sig == SIGSEGV || sig == SIGBUS) &&
+#if defined(__FreeBSD_kernel__)
+      uc->context_trapno == trap_page_fault) {
+#else
       uc->uc_mcontext.gregs[REG_TRAPNO] == trap_page_fault) {
+#endif
     int page_size = os::vm_page_size();
     address addr = (address) info->si_addr;
     address pc = os::Linux::ucontext_get_pc(uc);
@@ -503,7 +577,11 @@ JVM_handle_linux_signal(int sig,
     // save all thread context in case we need to restore it
     if (thread != NULL) thread->set_saved_exception_pc(pc);
 
+#if defined(__FreeBSD_kernel__)
+    uc->context_pc = (intptr_t)stub;
+#else
     uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
+#endif
     return true;
   }
 
@@ -755,6 +833,7 @@ void os::print_context(outputStream *st,
 
   ucontext_t *uc = (ucontext_t*)context;
   st->print_cr("Registers:");
+#ifdef __linux__
 #ifdef AMD64
   st->print(  "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
   st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
@@ -797,6 +876,48 @@ void os::print_context(outputStream *st,
   st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]);
   st->print(", CR2=" INTPTR_FORMAT, uc->uc_mcontext.cr2);
 #endif // AMD64
+#elif defined(__FreeBSD_kernel__)
+#ifdef AMD64
+  st->print(  "RAX=" INTPTR_FORMAT, uc->context_rax);
+  st->print(", RBX=" INTPTR_FORMAT, uc->context_rbx);
+  st->print(", RCX=" INTPTR_FORMAT, uc->context_rcx);
+  st->print(", RDX=" INTPTR_FORMAT, uc->context_rdx);
+  st->cr();
+  st->print(  "RSP=" INTPTR_FORMAT, uc->context_rsp);
+  st->print(", RBP=" INTPTR_FORMAT, uc->context_rbp);
+  st->print(", RSI=" INTPTR_FORMAT, uc->context_rsi);
+  st->print(", RDI=" INTPTR_FORMAT, uc->context_rdi);
+  st->cr();
+  st->print(  "R8 =" INTPTR_FORMAT, uc->context_r8);
+  st->print(", R9 =" INTPTR_FORMAT, uc->context_r9);
+  st->print(", R10=" INTPTR_FORMAT, uc->context_r10);
+  st->print(", R11=" INTPTR_FORMAT, uc->context_r11);
+  st->cr();
+  st->print(  "R12=" INTPTR_FORMAT, uc->context_r12);
+  st->print(", R13=" INTPTR_FORMAT, uc->context_r13);
+  st->print(", R14=" INTPTR_FORMAT, uc->context_r14);
+  st->print(", R15=" INTPTR_FORMAT, uc->context_r15);
+  st->cr();
+  st->print(  "RIP=" INTPTR_FORMAT, uc->context_rip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_flags);
+  st->print(", ERR=" INTPTR_FORMAT, uc->context_err);
+  st->cr();
+  st->print("  TRAPNO=" INTPTR_FORMAT, uc->context_trapno);
+#else
+  st->print(  "EAX=" INTPTR_FORMAT, uc->context_eax);
+  st->print(", EBX=" INTPTR_FORMAT, uc->context_ebx);
+  st->print(", ECX=" INTPTR_FORMAT, uc->context_ecx);
+  st->print(", EDX=" INTPTR_FORMAT, uc->context_edx);
+  st->cr();
+  st->print(  "ESP=" INTPTR_FORMAT, uc->context_esp);
+  st->print(", EBP=" INTPTR_FORMAT, uc->context_ebp);
+  st->print(", ESI=" INTPTR_FORMAT, uc->context_esi);
+  st->print(", EDI=" INTPTR_FORMAT, uc->context_edi);
+  st->cr();
+  st->print(  "EIP=" INTPTR_FORMAT, uc->context_eip);
+  st->print(", EFLAGS=" INTPTR_FORMAT, uc->context_eflags);
+#endif // AMD64
+#endif
   st->cr();
   st->cr();
 
@@ -827,6 +948,7 @@ void os::print_register_info(outputStrea
 
   // this is only for the "general purpose" registers
 
+#ifdef __linux__
 #ifdef AMD64
   st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]);
   st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]);
@@ -854,6 +976,35 @@ void os::print_register_info(outputStrea
   st->print("ESI="); print_location(st, uc->uc_mcontext.gregs[REG_ESI]);
   st->print("EDI="); print_location(st, uc->uc_mcontext.gregs[REG_EDI]);
 #endif // AMD64
+#elif defined(__FreeBSD_kernel__)
+#ifdef AMD64
+  st->print("RAX="); print_location(st, uc->context_rax);
+  st->print("RBX="); print_location(st, uc->context_rbx);
+  st->print("RCX="); print_location(st, uc->context_rcx);
+  st->print("RDX="); print_location(st, uc->context_rdx);
+  st->print("RSP="); print_location(st, uc->context_rsp);
+  st->print("RBP="); print_location(st, uc->context_rbp);
+  st->print("RSI="); print_location(st, uc->context_rsi);
+  st->print("RDI="); print_location(st, uc->context_rdi);
+  st->print("R8 ="); print_location(st, uc->context_r8);
+  st->print("R9 ="); print_location(st, uc->context_r9);
+  st->print("R10="); print_location(st, uc->context_r10);
+  st->print("R11="); print_location(st, uc->context_r11);
+  st->print("R12="); print_location(st, uc->context_r12);
+  st->print("R13="); print_location(st, uc->context_r13);
+  st->print("R14="); print_location(st, uc->context_r14);
+  st->print("R15="); print_location(st, uc->context_r15);
+#else
+  st->print("EAX="); print_location(st, uc->context_eax);
+  st->print("EBX="); print_location(st, uc->context_ebx);
+  st->print("ECX="); print_location(st, uc->context_ecx);
+  st->print("EDX="); print_location(st, uc->context_edx);
+  st->print("ESP="); print_location(st, uc->context_esp);
+  st->print("EBP="); print_location(st, uc->context_ebp);
+  st->print("ESI="); print_location(st, uc->context_esi);
+  st->print("EDI="); print_location(st, uc->context_edi);
+#endif // AMD64
+#endif
 
   st->cr();
 }
--- openjdk/hotspot/src/share/vm/memory/allocation.hpp.orig
+++ openjdk/hotspot/src/share/vm/memory/allocation.hpp
@@ -25,8 +25,8 @@
 #ifndef SHARE_VM_MEMORY_ALLOCATION_HPP
 #define SHARE_VM_MEMORY_ALLOCATION_HPP
 
-#include "runtime/globals.hpp"
 #include "utilities/globalDefinitions.hpp"
+#include "runtime/globals.hpp"
 #ifdef COMPILER1
 #include "c1/c1_globals.hpp"
 #endif
--- openjdk/hotspot/src/share/vm/ci/ciObject.hpp.orig
+++ openjdk/hotspot/src/share/vm/ci/ciObject.hpp
@@ -25,6 +25,7 @@
 #ifndef SHARE_VM_CI_CIOBJECT_HPP
 #define SHARE_VM_CI_CIOBJECT_HPP
 
+#include "utilities/globalDefinitions.hpp"
 #include "ci/ciClassList.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/handles.hpp"
--- openjdk/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp.orig
+++ openjdk/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
@@ -22,6 +22,7 @@
  *
  */
 
+#include "utilities/globalDefinitions.hpp"
 // no precompiled headers
 #include "classfile/vmSymbols.hpp"
 #include "gc_interface/collectedHeap.hpp"
--- openjdk/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp.orig
+++ openjdk/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp
@@ -76,7 +76,7 @@
 # include <sys/procfs.h>
 # endif
 
-#if defined(LINUX) || defined(_ALLBSD_SOURCE)
+#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(__FreeBSD_kernel__)
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
 #endif // __STDC_LIMIT_MACROS
--- openjdk/hotspot/make/defs.make.orig
+++ openjdk/hotspot/make/defs.make
@@ -152,9 +152,6 @@ endif
 # Windows should have OS predefined
 ifeq ($(OS),)
   OS   := $(shell uname -s)
-  ifneq ($(findstring BSD,$(OS)),)
-    OS=bsd
-  endif
   ifeq ($(OS), Darwin)
     OS=bsd
   endif
@@ -180,6 +177,10 @@ else
   OSNAME=linux
 endif
 
+ifeq ($(OS), GNU/kFreeBSD)
+  OSNAME=linux
+endif
+
 # Determinations of default make arguments and platform specific settings
 MAKE_ARGS=
 
--- openjdk/hotspot/make/linux/Makefile.orig
+++ openjdk/hotspot/make/linux/Makefile
@@ -258,6 +258,9 @@ checks: check_os_version check_j2se_vers
 SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4%
 OS_VERSION := $(shell uname -r)
 EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
+ifeq ($(shell uname -s), GNU/kFreeBSD)
+EMPTY_IF_NOT_SUPPORTED = supported
+endif
 
 check_os_version:
 ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
--- openjdk/hotspot/make/linux/makefiles/defs.make.orig
+++ openjdk/hotspot/make/linux/makefiles/defs.make
@@ -91,7 +91,7 @@ ifeq ($(ARCH), x86_64)
 endif
 
 # i686
-ifeq ($(ARCH), i686)
+ifneq (,$(filter i686 i386, $(ARCH)))
   ARCH_DATA_MODEL  = 32
   PLATFORM         = linux-i586
   VM_PLATFORM      = linux_i486
--- openjdk/hotspot/agent/src/os/linux/ps_core.c.orig
+++ openjdk/hotspot/agent/src/os/linux/ps_core.c
@@ -539,11 +539,16 @@ static bool core_handle_prstatus(struct
       return false;
 
    // copy regs
+#if defined(__FreeBSD_kernel__)
+   memcpy(&newthr->regs, &prstat->pr_reg, sizeof(struct user_regs_struct));
+#else
    memcpy(&newthr->regs, prstat->pr_reg, sizeof(struct user_regs_struct));
+#endif
 
    if (is_debug()) {
       print_debug("integer regset\n");
 #ifdef i386
+#ifdef __linux__
       // print the regset
       print_debug("\teax = 0x%x\n", newthr->regs.eax);
       print_debug("\tebx = 0x%x\n", newthr->regs.ebx);
@@ -554,9 +559,21 @@ static bool core_handle_prstatus(struct
       print_debug("\tesi = 0x%x\n", newthr->regs.esi);
       print_debug("\tedi = 0x%x\n", newthr->regs.edi);
       print_debug("\teip = 0x%x\n", newthr->regs.eip);
+#elif defined(__FreeBSD_kernel__)
+      print_debug("\teax = 0x%x\n", newthr->regs.r_eax);
+      print_debug("\tebx = 0x%x\n", newthr->regs.r_ebx);
+      print_debug("\tecx = 0x%x\n", newthr->regs.r_ecx);
+      print_debug("\tedx = 0x%x\n", newthr->regs.r_edx);
+      print_debug("\tesp = 0x%x\n", newthr->regs.r_esp);
+      print_debug("\tebp = 0x%x\n", newthr->regs.r_ebp);
+      print_debug("\tesi = 0x%x\n", newthr->regs.r_esi);
+      print_debug("\tedi = 0x%x\n", newthr->regs.r_edi);
+      print_debug("\teip = 0x%x\n", newthr->regs.r_eip);
+#endif
 #endif
 
 #if defined(amd64) || defined(x86_64)
+#ifdef __linux__
       // print the regset
       print_debug("\tr15 = 0x%lx\n", newthr->regs.r15);
       print_debug("\tr14 = 0x%lx\n", newthr->regs.r14);
@@ -585,6 +602,27 @@ static bool core_handle_prstatus(struct
       print_debug("\tes = 0x%lx\n", newthr->regs.es);
       print_debug("\tfs = 0x%lx\n", newthr->regs.fs);
       print_debug("\tgs = 0x%lx\n", newthr->regs.gs);
+#elif defined(__FreeBSD_kernel__)
+      print_debug("\tr15 = 0x%lx\n", newthr->regs.r_r15);
+      print_debug("\tr14 = 0x%lx\n", newthr->regs.r_r14);
+      print_debug("\tr13 = 0x%lx\n", newthr->regs.r_r13);
+      print_debug("\tr12 = 0x%lx\n", newthr->regs.r_r12);
+      print_debug("\trbp = 0x%lx\n", newthr->regs.r_rbp);
+      print_debug("\trbx = 0x%lx\n", newthr->regs.r_rbx);
+      print_debug("\tr11 = 0x%lx\n", newthr->regs.r_r11);
+      print_debug("\tr10 = 0x%lx\n", newthr->regs.r_r10);
+      print_debug("\tr9 = 0x%lx\n", newthr->regs.r_r9);
+      print_debug("\tr8 = 0x%lx\n", newthr->regs.r_r8);
+      print_debug("\trax = 0x%lx\n", newthr->regs.r_rax);
+      print_debug("\trcx = 0x%lx\n", newthr->regs.r_rcx);
+      print_debug("\trdx = 0x%lx\n", newthr->regs.r_rdx);
+      print_debug("\trsi = 0x%lx\n", newthr->regs.r_rsi);
+      print_debug("\trdi = 0x%lx\n", newthr->regs.r_rdi);
+      print_debug("\trip = 0x%lx\n", newthr->regs.r_rip);
+      print_debug("\tcs = 0x%lx\n", newthr->regs.r_cs);
+      print_debug("\trsp = 0x%lx\n", newthr->regs.r_rsp);
+      print_debug("\tss = 0x%lx\n", newthr->regs.r_ss);
+#endif
 #endif
    }
 
--- openjdk/hotspot/agent/src/os/linux/ps_proc.c.orig
+++ openjdk/hotspot/agent/src/os/linux/ps_proc.c
@@ -40,6 +40,22 @@
 #define __WALL          0x40000000  // Copied from /usr/include/linux/wait.h
 #endif
 
+#ifndef PTRACE_PEEKDATA
+#define PTRACE_PEEKDATA PT_READ_D
+#endif
+
+#ifndef PTRACE_ATTACH
+#define PTRACE_ATTACH PT_ATTACH
+#endif
+
+#ifndef PTRACE_DETACH
+#define PTRACE_DETACH PT_DETACH
+#endif
+
+#ifndef PTRACE_CONT
+#define PTRACE_CONT PT_CONTINUE
+#endif
+
 // This file has the libproc implementation specific to live process
 // For core files, refer to ps_core.c
 
@@ -57,7 +73,11 @@ static inline uintptr_t align(uintptr_t
 // before calling process_read_data.
 
 static bool process_read_data(struct ps_prochandle* ph, uintptr_t addr, char *buf, size_t size) {
+#if defined(__FreeBSD_kernel__)
+  int rslt;
+#else
   long rslt;
+#endif
   size_t i, words;
   uintptr_t end_addr = addr + size;
   uintptr_t aligned_addr = align(addr, sizeof(long));
@@ -65,36 +85,62 @@ static bool process_read_data(struct ps_
   if (aligned_addr != addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
     }
     for (; aligned_addr != addr; aligned_addr++, ptr++);
+#if defined(__FreeBSD_kernel__)
+    for (; ((intptr_t)aligned_addr % sizeof(int)) && aligned_addr < end_addr;
+#else
     for (; ((intptr_t)aligned_addr % sizeof(long)) && aligned_addr < end_addr;
+#endif
         aligned_addr++)
        *(buf++) = *(ptr++);
   }
 
+#if defined(__FreeBSD_kernel__)
+  words = (end_addr - aligned_addr) / sizeof(int);
+#else
   words = (end_addr - aligned_addr) / sizeof(long);
+#endif
 
   // assert((intptr_t)aligned_addr % sizeof(long) == 0);
   for (i = 0; i < words; i++) {
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
     }
+#if defined(__FreeBSD_kernel__)
+    *(int *)buf = rslt;
+    buf += sizeof(int);
+    aligned_addr += sizeof(int);
+#else
     *(long *)buf = rslt;
     buf += sizeof(long);
     aligned_addr += sizeof(long);
+#endif
   }
 
   if (aligned_addr != end_addr) {
     char *ptr = (char *)&rslt;
     errno = 0;
+#if defined(__FreeBSD_kernel__)
+    rslt = ptrace(PTRACE_PEEKDATA, ph->pid, (caddr_t) aligned_addr, 0);
+#else
     rslt = ptrace(PTRACE_PEEKDATA, ph->pid, aligned_addr, 0);
+#endif
     if (errno) {
       print_debug("ptrace(PTRACE_PEEKDATA, ..) failed for %d bytes @ %lx\n", size, addr);
       return false;
@@ -133,7 +179,11 @@ static bool process_get_lwp_regs(struct
 #endif
 
 #ifdef PTRACE_GETREGS_REQ
+#if defined(__FreeBSD_kernel__)
+ if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, (caddr_t) user, 0) < 0) {
+#else
  if (ptrace_getregs(PTRACE_GETREGS_REQ, pid, user, NULL) < 0) {
+#endif
    print_debug("ptrace(PTRACE_GETREGS, ...) failed for lwp %d\n", pid);
    return false;
  }
@@ -205,7 +255,11 @@ static bool ptrace_waitpid(pid_t pid) {
 
 // attach to a process/thread specified by "pid"
 static bool ptrace_attach(pid_t pid) {
+#if defined(__FreeBSD_kernel__)
+  if (ptrace(PTRACE_ATTACH, pid, NULL, 0) < 0) {
+#else
   if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
+#endif
     print_debug("ptrace(PTRACE_ATTACH, ..) failed for %d\n", pid);
     return false;
   } else {
@@ -341,7 +395,11 @@ static bool read_lib_info(struct ps_proc
 
 // detach a given pid
 static bool ptrace_detach(pid_t pid) {
+#if defined(__FreeBSD_kernel__)
+  if (pid && ptrace(PTRACE_DETACH, pid, NULL, 0) < 0) {
+#else
   if (pid && ptrace(PTRACE_DETACH, pid, NULL, NULL) < 0) {
+#endif
     print_debug("ptrace(PTRACE_DETACH, ..) failed for %d\n", pid);
     return false;
   } else {
--- openjdk/hotspot/agent/src/os/linux/libproc.h.orig
+++ openjdk/hotspot/agent/src/os/linux/libproc.h
@@ -28,6 +28,10 @@
 #include <jni.h>
 #include <unistd.h>
 #include <stdint.h>
+#if defined(__FreeBSD_kernel__)
+#include <sys/types.h>
+#include <machine/reg.h>
+#endif
 #include "proc_service.h"
 
 #if defined(arm) || defined(ppc)
@@ -80,6 +84,10 @@ unsigned long   regs[IA64_REG_COUNT];
 #define user_regs_struct  pt_regs
 #endif
 
+#if defined(__FreeBSD_kernel__)
+#define user_regs_struct reg
+#endif
+
 // This C bool type must be int for compatibility with Linux calls and
 // it would be a mistake to equivalence it to C++ bool on many platforms
 
--- openjdk/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c.orig
+++ openjdk/hotspot/agent/src/os/linux/LinuxDebuggerLocal.c
@@ -318,7 +318,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
 
 #ifdef i386
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_x86_X86ThreadContext_##reg
-
+#ifdef __linux__
   regs[REG_INDEX(GS)]  = (uintptr_t) gregs.xgs;
   regs[REG_INDEX(FS)]  = (uintptr_t) gregs.xfs;
   regs[REG_INDEX(ES)]  = (uintptr_t) gregs.xes;
@@ -334,7 +334,23 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
   regs[REG_INDEX(PC)] = (uintptr_t) gregs.eip;
   regs[REG_INDEX(CS)]  = (uintptr_t) gregs.xcs;
   regs[REG_INDEX(SS)]  = (uintptr_t) gregs.xss;
-
+#elif defined(__FreeBSD_kernel__)
+  regs[REG_INDEX(GS)]  = (uintptr_t) gregs.r_gs;
+  regs[REG_INDEX(FS)]  = (uintptr_t) gregs.r_fs;
+  regs[REG_INDEX(ES)]  = (uintptr_t) gregs.r_es;
+  regs[REG_INDEX(DS)]  = (uintptr_t) gregs.r_ds;
+  regs[REG_INDEX(EDI)] = (uintptr_t) gregs.r_edi;
+  regs[REG_INDEX(ESI)] = (uintptr_t) gregs.r_esi;
+  regs[REG_INDEX(FP)] = (uintptr_t) gregs.r_ebp;
+  regs[REG_INDEX(SP)] = (uintptr_t) gregs.r_isp;
+  regs[REG_INDEX(EBX)] = (uintptr_t) gregs.r_ebx;
+  regs[REG_INDEX(EDX)] = (uintptr_t) gregs.r_edx;
+  regs[REG_INDEX(ECX)] = (uintptr_t) gregs.r_ecx;
+  regs[REG_INDEX(EAX)] = (uintptr_t) gregs.r_eax;
+  regs[REG_INDEX(PC)] = (uintptr_t) gregs.r_eip;
+  regs[REG_INDEX(CS)]  = (uintptr_t) gregs.r_cs;
+  regs[REG_INDEX(SS)]  = (uintptr_t) gregs.r_ss;
+#endif
 #endif /* i386 */
 
 #if ia64
@@ -346,7 +362,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
 
 #ifdef amd64
 #define REG_INDEX(reg) sun_jvm_hotspot_debugger_amd64_AMD64ThreadContext_##reg
-
+#ifdef __linux__
   regs[REG_INDEX(R15)] = gregs.r15;
   regs[REG_INDEX(R14)] = gregs.r14;
   regs[REG_INDEX(R13)] = gregs.r13;
@@ -372,7 +388,27 @@ JNIEXPORT jlongArray JNICALL Java_sun_jv
   regs[REG_INDEX(ES)] = gregs.es;
   regs[REG_INDEX(FS)] = gregs.fs;
   regs[REG_INDEX(GS)] = gregs.gs;
-
+#elif defined(__FreeBSD_kernel__)
+  regs[REG_INDEX(R15)] = gregs.r_r15;
+  regs[REG_INDEX(R14)] = gregs.r_r14;
+  regs[REG_INDEX(R13)] = gregs.r_r13;
+  regs[REG_INDEX(R12)] = gregs.r_r12;
+  regs[REG_INDEX(RBP)] = gregs.r_rbp;
+  regs[REG_INDEX(RBX)] = gregs.r_rbx;
+  regs[REG_INDEX(R11)] = gregs.r_r11;
+  regs[REG_INDEX(R10)] = gregs.r_r10;
+  regs[REG_INDEX(R9)] = gregs.r_r9;
+  regs[REG_INDEX(R8)] = gregs.r_r8;
+  regs[REG_INDEX(RAX)] = gregs.r_rax;
+  regs[REG_INDEX(RCX)] = gregs.r_rcx;
+  regs[REG_INDEX(RDX)] = gregs.r_rdx;
+  regs[REG_INDEX(RSI)] = gregs.r_rsi;
+  regs[REG_INDEX(RDI)] = gregs.r_rdi;
+  regs[REG_INDEX(RIP)] = gregs.r_rip;
+  regs[REG_INDEX(CS)] = gregs.r_cs;
+  regs[REG_INDEX(RSP)] = gregs.r_rsp;
+  regs[REG_INDEX(SS)] = gregs.r_ss;
+#endif
 #endif /* amd64 */
 
 #if defined(sparc) || defined(sparcv9)

--- End Message ---
--- Begin Message ---
Source-Version: 7u85-2.6.1-5

Thanks!

Regards,
-- 
Steven Chamberlain
[email protected]

Attachment: signature.asc
Description: Digital signature


--- End Message ---

Reply via email to