Bugzilla Bug 261649: added GNU/k*BSD and preliminary GNU/Hurd support. The
authorwtchang%redhat.com
Sat, 24 Dec 2005 08:25:31 +0000
changeset 3520 6d99ad4c70def2cb35fedcab65fd643c4f16704c
parent 3518 2a2b4f745fbc5becb2802b90fe5fa6c055df67c5
child 3521 caf60d9d640f8c27874747efe149d8b387f84d63
push idunknown
push userunknown
push dateunknown
bugs261649
Bugzilla Bug 261649: added GNU/k*BSD and preliminary GNU/Hurd support. The patch is contributed by Robert Millan <rmh@aybabtu.com>. r=wtc. Modified files: configure configure.in _linux.cfg _pth.h _unixos.h prosdep.h pr/src/linking/Makefile.in prlink.c prosdep.c unix.c uxproces.c uxrng.c prnetdb.c ptio.c pr/tests/Makefile.in
configure
configure.in
pr/include/md/_linux.cfg
pr/include/md/_pth.h
pr/include/md/_unixos.h
pr/include/md/prosdep.h
pr/src/linking/Makefile.in
pr/src/linking/prlink.c
pr/src/md/prosdep.c
pr/src/md/unix/unix.c
pr/src/md/unix/uxproces.c
pr/src/md/unix/uxrng.c
pr/src/misc/prnetdb.c
pr/src/pthreads/ptio.c
pr/tests/Makefile.in
--- a/configure
+++ b/configure
@@ -3795,17 +3795,17 @@ EOF
 	    cat >> confdefs.h <<\EOF
 #define _PR_HAVE_SGI_PRDA_PROCMASK 1
 EOF
 
 	    ;;
 	esac
     ;;
 
-*-linux*)
+*-linux*|*-gnu*|*-k*bsd*-gnu)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
         IMPL_STRATEGY=_PTH
     fi
     cat >> confdefs.h <<\EOF
 #define XP_UNIX 1
 EOF
 
@@ -3824,20 +3824,24 @@ EOF
     cat >> confdefs.h <<\EOF
 #define _LARGEFILE64_SOURCE 1
 EOF
 
     cat >> confdefs.h <<\EOF
 #define HAVE_FCNTL_FILE_LOCKING 1
 EOF
 
-    cat >> confdefs.h <<\EOF
+    case "${target_os}" in
+    linux*)
+        cat >> confdefs.h <<\EOF
 #define LINUX 1
 EOF
 
+        ;;
+    esac
     CFLAGS="$CFLAGS -ansi -Wall"
     CXXFLAGS="$CXXFLAGS -ansi -Wall"
     MDCPUCFG_H=_linux.cfg
     PR_MD_CSRCS=linux.c
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
     _OPTIMIZE_FLAGS=-O2
@@ -4407,27 +4411,27 @@ EOF
     if test -z "$GNU_CC"; then
         CC="$CC -std1 -ieee_with_inexact"
         if test "$OS_RELEASE" != "V2.0"; then
             CC="$CC -readonly_strings"
         fi
         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
         ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4416: checking for machine/builtins.h" >&5
+echo "configure:4420: checking for machine/builtins.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4421 "configure"
+#line 4425 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4430: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -4979,63 +4983,63 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 
 
 case $target in
 *-darwin*|*-beos*)
     ;;
 *)
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4988: checking for dlopen in -ldl" >&5
+echo "configure:4992: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4996 "configure"
+#line 5000 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char dlopen();
 
 int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:5007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:5024: checking for dlfcn.h" >&5
+echo "configure:5028: checking for dlfcn.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5029 "configure"
+#line 5033 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5034: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5038: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -5058,23 +5062,23 @@ fi
     ;;
 esac
 
 
 
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5067: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5071: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 5073 "configure"
+#line 5077 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5082,17 +5086,17 @@ else
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 5091 "configure"
+#line 5095 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5106,22 +5110,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 for ac_func in lchown strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5115: checking for $ac_func" >&5
+echo "configure:5119: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5120 "configure"
+#line 5124 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $ac_func();
@@ -5134,17 +5138,17 @@ int main() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
 $ac_func();
 #endif
 
 ; return 0; }
 EOF
-if { (eval echo configure:5143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=no"
 fi
@@ -5175,17 +5179,17 @@ if test "${enable_strip+set}" = set; the
 fi
 
 
 case "${target_os}" in
 hpux*)
 if test -z "$GNU_CC"; then
 
     echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5184: checking for +Olit support" >&5
+echo "configure:5188: checking for +Olit support" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
                   ac_cv_hpux_usable_olit_option=no
         rm -f conftest*
         echo 'int main() { return 0; }' | cat > conftest.c
         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
         if test $? -eq 0; then
@@ -5214,17 +5218,17 @@ esac
 
 case "$target_os" in
 darwin*)
     _HAVE_PTHREADS=1
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5223: checking for pthread_create in -lpthreads" >&5
+echo "configure:5227: checking for pthread_create in -lpthreads" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5236,17 +5240,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5245: checking for pthread_create in -lpthread" >&5
+echo "configure:5249: checking for pthread_create in -lpthread" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5258,17 +5262,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5267: checking for pthread_create in -lc_r" >&5
+echo "configure:5271: checking for pthread_create in -lc_r" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5280,17 +5284,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5289: checking for pthread_create in -lc" >&5
+echo "configure:5293: checking for pthread_create in -lc" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5434,17 +5438,17 @@ EOF
     fi
 fi
 
 
 if test -n "$USE_PTHREADS"; then
       rm -f conftest*
    ac_cv_have_dash_pthread=no
    echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:5443: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5447: checking whether ${CC-cc} accepts -pthread" >&5
    echo 'int main() { return 0; }' | cat > conftest.c
    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
    if test $? -eq 0; then
 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 	    ac_cv_have_dash_pthread=yes
 		case "$target_os" in
 	    freebsd*)
 # Freebsd doesn't use -pthread for compiles, it uses them for linking
@@ -5457,17 +5461,17 @@ echo "configure:5443: checking whether $
 	fi
     fi
     rm -f conftest*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
 			    ac_cv_have_dash_pthreads=no
     if test "$ac_cv_have_dash_pthread" = "no"; then
 	    echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5466: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5470: checking whether ${CC-cc} accepts -pthreads" >&5
     	echo 'int main() { return 0; }' | cat > conftest.c
 	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
     	if test $? -eq 0; then
 	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 			    ac_cv_have_dash_pthreads=yes
 			    CFLAGS="$CFLAGS -pthreads"
 			    CXXFLAGS="$CXXFLAGS -pthreads"
 		    fi
@@ -5511,17 +5515,17 @@ EOF
 	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
     *-openbsd*)
         if test "$ac_cv_have_dash_pthread" = "yes"; then
             _PTHREAD_LDFLAGS=-pthread
         fi
         ;;
-    *-linux*)
+    *-linux*|*-gnu*|*-k*bsd*-gnu)
         cat >> confdefs.h <<\EOF
 #define _REENTRANT 1
 EOF
 
         ;;
     esac
 
 else 
@@ -5648,17 +5652,17 @@ EOF
 
             cat >> confdefs.h <<\EOF
 #define _PR_HAVE_GETHOST_R_POINTER 1
 EOF
 
         fi
     fi
     ;;
-*-linux*)
+*-linux*|*-gnu*|*-k*bsd*-gnu)
     if test -n "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
 EOF
 
     fi
     ;;
 *-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*)
--- a/configure.in
+++ b/configure.in
@@ -1331,28 +1331,32 @@ tools are selected during the Xcode/Deve
 	irix5*)
 	    ;;
 	*)
 	    AC_DEFINE(_PR_HAVE_SGI_PRDA_PROCMASK)
 	    ;;
 	esac
     ;;
 
-*-linux*)
+*-linux*|*-gnu*|*-k*bsd*-gnu)
     if test -z "$USE_NSPR_THREADS"; then
         USE_PTHREADS=1
         IMPL_STRATEGY=_PTH
     fi
     AC_DEFINE(XP_UNIX)
     AC_DEFINE(_POSIX_SOURCE)
     AC_DEFINE(_BSD_SOURCE)
     AC_DEFINE(_SVID_SOURCE)
     AC_DEFINE(_LARGEFILE64_SOURCE)
     AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
-    AC_DEFINE(LINUX)
+    case "${target_os}" in
+    linux*)
+        AC_DEFINE(LINUX)
+        ;;
+    esac
     CFLAGS="$CFLAGS -ansi -Wall"
     CXXFLAGS="$CXXFLAGS -ansi -Wall"
     MDCPUCFG_H=_linux.cfg
     PR_MD_CSRCS=linux.c
     MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
     DSO_CFLAGS=-fPIC
     DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)'
     _OPTIMIZE_FLAGS=-O2
@@ -2437,17 +2441,17 @@ if test -n "$USE_PTHREADS"; then
 	        _PTHREAD_LDFLAGS=
 	    fi
 	    ;;
     *-openbsd*)
         if test "$ac_cv_have_dash_pthread" = "yes"; then
             _PTHREAD_LDFLAGS=-pthread
         fi
         ;;
-    *-linux*)
+    *-linux*|*-gnu*|*-k*bsd*-gnu)
         AC_DEFINE(_REENTRANT)
         ;;
     esac
 
 else 
     if test -n "$USE_USER_PTHREADS"; then
 	    USE_PTHREADS=
 	    USE_NSPR_THREADS=
@@ -2521,17 +2525,17 @@ case "$target" in
 *-irix*)
     if test "${target_os}" = "irix6.5"; then
         if test -n "$USE_PTHREADS"; then
             AC_DEFINE(_PR_HAVE_GETHOST_R)
             AC_DEFINE(_PR_HAVE_GETHOST_R_POINTER)
         fi
     fi
     ;;
-*-linux*)
+*-linux*|*-gnu*|*-k*bsd*-gnu)
     if test -n "$USE_NSPR_THREADS"; then
         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
     fi
     ;;
 *-mingw*|*-cygwin*|*-msvc*|*-mks*|*-os2*|*-beos*)
     dnl win32, os2 & beos cannot use pthreads
     USE_PTHREADS=
     _PTHREAD_LDFLAGS=
--- a/pr/include/md/_linux.cfg
+++ b/pr/include/md/_linux.cfg
@@ -30,24 +30,29 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+/*
+ * This file is used by not only Linux but also other glibc systems
+ * such as GNU/Hurd and GNU/k*BSD.
+ */
+
 #ifndef nspr_cpucfg___
 #define nspr_cpucfg___
 
 #ifndef XP_UNIX
 #define XP_UNIX
 #endif
 
-#ifndef LINUX
+#if !defined(LINUX) && defined(__linux__)
 #define LINUX
 #endif
 
 #define PR_AF_INET6 10  /* same as AF_INET6 */
 
 #ifdef __powerpc64__
 
 #undef  IS_LITTLE_ENDIAN
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -138,20 +138,25 @@
  */
 #if defined(_PR_DCETHREADS)
 #define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) \
 	memset(&(t), 0, sizeof(pthread_t))
 #define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) \
 	(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
-	|| defined(HPUX) || defined(LINUX) || defined(FREEBSD) \
+	|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
+	|| defined(HPUX) || defined(FREEBSD) \
 	|| defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \
 	|| defined(VMS) || defined(NTO) || defined(DARWIN) \
 	|| defined(UNIXWARE) || defined(RISCOS)
+#ifdef __GNU__
+/* Hurd pthreads don't have an invalid value for pthread_t. -- rmh */
+#error Using Hurd pthreads
+#endif
 #define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t)  (t) = 0
 #define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t)  (t) == 0
 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #else 
 #error "pthreads is not supported for this architecture"
 #endif
 
 #if defined(_PR_DCETHREADS)
@@ -230,17 +235,18 @@
 #define PT_PRIO_MIN            PRI_OTHER_MIN
 #define PT_PRIO_MAX            PRI_OTHER_MAX
 #else /* defined(_PR_DCETHREADS) */
 #include <sys/sched.h>
 #define PT_PRIO_MIN            sched_get_priority_min(SCHED_OTHER)
 #define PT_PRIO_MAX            sched_get_priority_max(SCHED_OTHER)
 #endif /* defined(_PR_DCETHREADS) */
 
-#elif defined(LINUX) || defined(FREEBSD)
+#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
+	|| defined(FREEBSD)
 #define PT_PRIO_MIN            sched_get_priority_min(SCHED_OTHER)
 #define PT_PRIO_MAX            sched_get_priority_max(SCHED_OTHER)
 #elif defined(NTO)
 /*
  * Neutrino has functions that return the priority range but
  * they return invalid numbers, so I just hard coded these here
  * for now.  Jerry.Kirk@Nexarecorp.com
  */
@@ -286,17 +292,18 @@ extern int (*_PT_aix_yield_fcn)();
 #elif defined(IRIX)
 #include <time.h>
 #define _PT_PTHREAD_YIELD() \
     PR_BEGIN_MACRO               				\
 		struct timespec onemillisec = {0};		\
 		onemillisec.tv_nsec = 1000000L;			\
         nanosleep(&onemillisec,NULL);			\
     PR_END_MACRO
-#elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \
+#elif defined(HPUX) || defined(SOLARIS) \
+	|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
 	|| defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
 	|| defined(BSDI) || defined(NTO) || defined(DARWIN) \
 	|| defined(UNIXWARE) || defined(RISCOS)
 #define _PT_PTHREAD_YIELD()            	sched_yield()
 #else
 #error "Need to define _PT_PTHREAD_YIELD for this platform"
 #endif
 
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -41,17 +41,18 @@
 /*
  * If FD_SETSIZE is not defined on the command line, set the default value
  * before include select.h
  */
 /*
  * Linux: FD_SETSIZE is defined in /usr/include/sys/select.h and should
  * not be redefined.
  */
-#if !defined(LINUX) && !defined(DARWIN) && !defined(NEXTSTEP)
+#if !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__) \
+    && !defined(DARWIN) && !defined(NEXTSTEP)
 #ifndef FD_SETSIZE
 #define FD_SETSIZE  4096
 #endif
 #endif
 
 #include <unistd.h>
 #include <stddef.h>
 #include <sys/stat.h>
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -85,17 +85,17 @@ PR_BEGIN_EXTERN_C
 #include "md/_bsdi.h"
 
 #elif defined(HPUX)
 #include "md/_hpux.h"
 
 #elif defined(IRIX)
 #include "md/_irix.h"
 
-#elif defined(LINUX)
+#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)
 #include "md/_linux.h"
 
 #elif defined(OSF1)
 #include "md/_osf1.h"
 
 #elif defined(DARWIN)
 #include "md/_darwin.h"
 
--- a/pr/src/linking/Makefile.in
+++ b/pr/src/linking/Makefile.in
@@ -58,17 +58,17 @@ CSRCS =           \
 	prlink.c   \
 	$(NULL)
 
 TARGETS	= $(OBJS)
 
 INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
 
 # For Dl_info and dladdr.
-ifeq ($(OS_TARGET),Linux)
+ifeq (,$(filter-out Linux GNU GNU_kFreeBSD GNU_kNetBSD,$(OS_TARGET)))
 DEFINES    += -D_GNU_SOURCE
 endif
 
 # On Mac OS X use flat #includes.
 ifeq ($(OS_TARGET),MacOSX)
 INCLUDES    += -I$(MACOS_SDK_DIR)/Developer/Headers/FlatCarbon
 endif
 
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -1383,17 +1383,18 @@ PR_LoadStaticLibrary(const char *name, c
     PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (static lib)", lm->name));
     PR_ExitMonitor(pr_linker_lock);
     return result;
 }
 
 PR_IMPLEMENT(char *)
 PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr)
 {
-#if defined(SOLARIS) || defined(LINUX) || defined(FREEBSD)
+#if defined(SOLARIS) || defined(FREEBSD) \
+        || defined(LINUX) || defined(__GLIBC__)
     Dl_info dli;
     char *result;
 
     if (dladdr((void *)addr, &dli) == 0) {
         PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO());
         DLLErrorInternal(_MD_ERRNO());
         return NULL;
     }
--- a/pr/src/md/prosdep.c
+++ b/pr/src/md/prosdep.c
@@ -58,17 +58,18 @@ PRInt32 _pr_pageSize;
 ** Get system page size
 */
 static void GetPageSize(void)
 {
 	PRInt32 pageSize;
 
     /* Get page size */
 #ifdef XP_UNIX
-#if defined SUNOS4 || defined LINUX || defined BSDI || defined AIX \
+#if defined SUNOS4 || defined BSDI || defined AIX \
+        || defined LINUX || defined __GNU__ || defined __GLIBC__ \
         || defined FREEBSD || defined NETBSD || defined OPENBSD \
         || defined DARWIN || defined NEXTSTEP
     _pr_pageSize = getpagesize();
 #elif defined(HPUX)
     /* I have no idea. Don't get me started. --Rob */
     _pr_pageSize = sysconf(_SC_PAGE_SIZE);
 #else
     _pr_pageSize = sysconf(_SC_PAGESIZE);
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -60,17 +60,17 @@
 #include <sys/statvfs.h>
 #endif
 
 /*
  * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or
  * PRInt32* pointer to a _PRSockLen_t* pointer.
  */
 #if defined(HAVE_SOCKLEN_T) \
-    || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2)
+    || (defined(__GLIBC__) && __GLIBC__ >= 2)
 #define _PRSockLen_t socklen_t
 #elif defined(IRIX) || defined(HPUX) || defined(OSF1) || defined(SOLARIS) \
     || defined(AIX4_1) || defined(LINUX) || defined(SONY) \
     || defined(BSDI) || defined(SCO) || defined(NEC) || defined(SNI) \
     || defined(SUNOS4) || defined(NCR) || defined(DARWIN) \
     || defined(NEXTSTEP) || defined(QNX)
 #define _PRSockLen_t int
 #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -87,31 +87,33 @@ typedef struct pr_PidRecord {
     struct pr_PidRecord *next;
 } pr_PidRecord;
 
 /*
  * Irix sprocs and LinuxThreads are actually a kind of processes
  * that can share the virtual address space and file descriptors.
  */
 #if (defined(IRIX) && !defined(_PR_PTHREADS)) \
-        || (defined(LINUX) && defined(_PR_PTHREADS))
+        || ((defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)) \
+        && defined(_PR_PTHREADS))
 #define _PR_SHARE_CLONES
 #endif
 
 /*
  * The macro _PR_NATIVE_THREADS indicates that we are
  * using native threads only, so waitpid() blocks just the
  * calling thread, not the process.  In this case, the waitpid
  * daemon thread can safely block in waitpid().  So we don't
  * need to catch SIGCHLD, and the pipe to unblock PR_Poll() is
  * also not necessary.
  */
 
 #if defined(_PR_GLOBAL_THREADS_ONLY) \
-	|| (defined(_PR_PTHREADS) && !defined(LINUX))
+	|| (defined(_PR_PTHREADS) \
+	&& !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__))
 #define _PR_NATIVE_THREADS
 #endif
 
 /*
  * All the static variables used by the Unix process routines are
  * collected in this structure.
  */
 
--- a/pr/src/md/unix/uxrng.c
+++ b/pr/src/md/unix/uxrng.c
@@ -133,17 +133,18 @@ GetHighResClock(void *buf, size_t maxbyt
 #elif defined(AIX)
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     return 0;
 }
 
-#elif (defined(LINUX) || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD))
+#elif (defined(LINUX) || defined(FREEBSD) || defined(__FreeBSD_kernel__) \
+    || defined(NETBSD) || defined(__NetBSD_kernel__) || defined(OPENBSD))
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
 static int      fdDevRandom;
 static PRCallOnceType coOpenDevRandom;
 
 static PRStatus OpenDevRandom( void )
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -103,17 +103,17 @@ PRLock *_pr_dnsLock = NULL;
 #if defined(OSF1) \
         || defined(AIX4_3_PLUS) || (defined(AIX) && defined(_THREAD_SAFE)) \
 	|| (defined(HPUX10_10) && defined(_REENTRANT)) \
         || (defined(HPUX10_20) && defined(_REENTRANT))
 #define _PR_HAVE_GETPROTO_R
 #define _PR_HAVE_GETPROTO_R_INT
 #endif
 
-#if (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2)
+#if (defined(__GLIBC__) && __GLIBC__ >= 2)
 #define _PR_HAVE_GETPROTO_R
 #define _PR_HAVE_5_ARG_GETPROTO_R
 #endif
 
 #if !defined(_PR_HAVE_GETPROTO_R)
 PRLock* _getproto_lock = NULL;
 #endif
 
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -200,17 +200,18 @@ static PRBool _pr_ipv6_v6only_on_by_defa
 #endif
 
 #if (defined(HPUX) && !defined(HPUX10_30) && !defined(HPUX11))
 #define _PRSelectFdSetArg_t int *
 #elif defined(AIX4_1)
 #define _PRSelectFdSetArg_t void *
 #elif defined(IRIX) || (defined(AIX) && !defined(AIX4_1)) \
     || defined(OSF1) || defined(SOLARIS) \
-    || defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) \
+    || defined(HPUX10_30) || defined(HPUX11) \
+    || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
     || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
     || defined(BSDI) || defined(VMS) || defined(NTO) || defined(DARWIN) \
     || defined(UNIXWARE) || defined(RISCOS)
 #define _PRSelectFdSetArg_t fd_set *
 #else
 #error "Cannot determine architecture"
 #endif
 
@@ -284,17 +285,17 @@ static PRBool IsValidNetAddrLen(const PR
 /*
  * pt_SockLen is the type for the length of a socket address
  * structure, used in the address length argument to bind,
  * connect, accept, getsockname, getpeername, etc.  Posix.1g
  * defines this type as socklen_t.  It is size_t or int on
  * most current systems.
  */
 #if defined(HAVE_SOCKLEN_T) \
-    || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2)
+    || (defined(__GLIBC__) && __GLIBC__ >= 2)
 typedef socklen_t pt_SockLen;
 #elif (defined(AIX) && !defined(AIX4_1)) \
     || defined(VMS)
 typedef PRSize pt_SockLen;
 #else
 typedef PRIntn pt_SockLen;
 #endif
 
@@ -3225,17 +3226,18 @@ static PRIOMethods _pr_socketpollfd_meth
     (PRConnectcontinueFN)_PR_InvalidStatus, 
     (PRReservedFN)_PR_InvalidInt, 
     (PRReservedFN)_PR_InvalidInt, 
     (PRReservedFN)_PR_InvalidInt, 
     (PRReservedFN)_PR_InvalidInt
 };
 
 #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \
-    || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD) \
+    || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
+    || defined(AIX) || defined(FREEBSD) || defined(NETBSD) \
     || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) \
     || defined(DARWIN) || defined(UNIXWARE) || defined(RISCOS)
 #define _PR_FCNTL_FLAGS O_NONBLOCK
 #else
 #error "Can't determine architecture"
 #endif
 
 /*
@@ -4722,17 +4724,18 @@ PR_IMPLEMENT(PRInt32) PR_FD_NISSET(PRInt
        if (set->narray[index] == fd) {
            return 1;
        }
     return 0;
 }
 
 #include <sys/types.h>
 #include <sys/time.h>
-#if !defined(SUNOS4) && !defined(HPUX) && !defined(LINUX)
+#if !defined(SUNOS4) && !defined(HPUX) \
+    && !defined(LINUX) && !defined(__GNU__) && !defined(__GLIBC__)
 #include <sys/select.h>
 #endif
 
 static PRInt32
 _PR_getset(PR_fd_set *pr_set, fd_set *set)
 {
     PRUint32 index;
     PRInt32 max = 0;
--- a/pr/tests/Makefile.in
+++ b/pr/tests/Makefile.in
@@ -371,24 +371,20 @@ ifeq ($(OS_ARCH), NEWS-OS)
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
 #export LD_RUN_PATH = $(ABSOLUTE_LIB_DIR)
     LIBNSPR = $(dist_libdir)/libnspr$(MOD_MAJOR_VERSION).a
     LIBPLC = $(dist_libdir)/libplc$(MOD_MAJOR_VERSION).a
     EXTRA_LIBS = -lsocket -lnsl -lgen -lresolv
 endif
 
-ifeq ($(OS_ARCH), Linux)
-    ifeq ($(OS_RELEASE), 1.2)
-        EXTRA_LIBS = -ldl
-    else
-        LDOPTS += -Xlinker -rpath $(ABSOLUTE_LIB_DIR)
-        ifeq ($(USE_PTHREADS),1)
-            EXTRA_LIBS = -lpthread
-        endif
+ifeq (,$(filter-out Linux GNU GNU_kFreeBSD GNU_kNetBSD,$(OS_ARCH)))
+    LDOPTS += -Xlinker -rpath $(ABSOLUTE_LIB_DIR)
+    ifeq ($(USE_PTHREADS),1)
+        EXTRA_LIBS = -lpthread
     endif
 endif
 
 ifeq ($(OS_ARCH), SCOOS)
 # SCO Unix needs to link against -lsocket again even though we
 # already linked with these system libraries when we built libnspr.so.
 EXTRA_LIBS = -lsocket
 # This hardcodes in the executable programs the directory to find