Bugzilla bug #263: Merged the NetBSD port of NSPR contributed by
authorwtc%netscape.com
Fri, 17 Jul 1998 23:33:36 +0000
changeset 185 9fd53e31756d66541f3d2cf1793c821bd7f20f25
parent 180 f9daa5fe4a6810b676be3d36d818bd907a5e5b2f
child 186 d087a5886398f2a798b16b825d428d494f19c39e
push idunknown
push userunknown
push dateunknown
bugs263
Bugzilla bug #263: Merged the NetBSD port of NSPR contributed by Frank van der Linden <frank@wins.uva.nl>.
config/NetBSD.mk
pr/include/md/Makefile
pr/include/md/_netbsd.cfg
pr/include/md/_netbsd.h
pr/include/md/_pth.h
pr/include/md/_unixos.h
pr/include/md/prosdep.h
pr/src/md/prosdep.c
pr/src/md/unix/Makefile
pr/src/md/unix/netbsd.c
pr/src/md/unix/objs.mk
pr/src/md/unix/unix.c
pr/src/md/unix/unix_errors.c
pr/src/md/unix/uxwrap.c
pr/src/pthreads/ptio.c
pr/src/pthreads/ptthread.c
new file mode 100644
--- /dev/null
+++ b/config/NetBSD.mk
@@ -0,0 +1,62 @@
+#
+# The contents of this file are subject to the Netscape Public License
+# Version 1.0 (the "NPL"); you may not use this file except in
+# compliance with the NPL.  You may obtain a copy of the NPL at
+# http://www.mozilla.org/NPL/
+# 
+# Software distributed under the NPL is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+# for the specific language governing rights and limitations under the
+# NPL.
+# 
+# The Initial Developer of this code under the NPL is Netscape
+# Communications Corporation.  Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+# Reserved.
+#
+
+#
+# Config stuff for NetBSD
+#
+
+include $(MOD_DEPTH)/config/UNIX.mk
+
+CC			= gcc
+CCC			= g++
+RANLIB			= ranlib
+
+OS_REL_CFLAGS		=
+ifeq (86,$(findstring 86,$(OS_TEST)))
+CPU_ARCH		= x86
+else
+CPU_ARCH		= $(OS_TEST)
+endif
+
+OS_CFLAGS		= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe -DNETBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK
+
+ifeq ($(USE_PTHREADS),1)
+OS_LIBS			= -lc_r
+# XXX probably should define _THREAD_SAFE too.
+else
+OS_LIBS			= -lc
+DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
+endif
+
+ARCH			= netbsd
+
+DSO_CFLAGS		= -fPIC
+DSO_LDFLAGS		=
+DSO_LDOPTS		= -Bshareable
+ifeq ($(OS_TEST),alpha)
+DSO_LDOPTS		= -shared
+endif
+ifeq ($(OS_TEST),mips)
+DSO_LDOPTS		= -shared
+endif
+ifeq ($(OS_TEST),pmax)  
+DSO_LDOPTS		= -shared
+endif
+
+MKSHLIB			= $(LD) $(DSO_LDOPTS)
+
+G++INCLUDES		= -I/usr/include/g++
--- a/pr/include/md/Makefile
+++ b/pr/include/md/Makefile
@@ -50,16 +50,20 @@ endif
 ifeq ($(OS_ARCH),BSD_OS)
 MDCPUCFG_H = _bsdi.cfg
 endif
 
 ifeq ($(OS_ARCH),FreeBSD)
 MDCPUCFG_H = _freebsd.cfg
 endif
 
+ifeq ($(OS_ARCH),NetBSD)
+MDCPUCFG_H = _netbsd.cfg
+endif
+
 ifeq ($(OS_ARCH),HP-UX)
 MDCPUCFG_H = _hpux.cfg
 endif
 
 ifeq ($(OS_ARCH),Linux)
 MDCPUCFG_H = _linux.cfg
 endif
 
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_netbsd.cfg
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ * 
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ * 
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+#ifndef nspr_cpucfg___
+#define nspr_cpucfg___
+
+#ifndef XP_UNIX
+#define XP_UNIX
+#endif
+
+#ifndef NETBSD
+#define NETBSD
+#endif
+
+#if defined(__i386__) || defined(__arm32__)
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define	HAVE_LONG_LONG
+#undef	HAVE_ALIGNED_DOUBLES
+#undef	HAVE_ALIGNED_LONGLONGS
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   4
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_POINTER 4
+
+#elif defined(__sparc__)
+
+#undef IS_LITTLE_ENDIAN 1
+#define  IS_BIG_ENDIAN 1
+#define HAVE_LONG_LONG
+#define  HAVE_ALIGNED_DOUBLES
+#define  HAVE_ALIGNED_LONGLONGS
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 4
+
+#elif defined(__alpha__)
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+
+#define PR_BYTES_PER_WORD_LOG2  3
+#define PR_BYTES_PER_DWORD_LOG2 3
+
+#elif defined(__powerpc__) || defined(__m68k__)
+
+#undef  IS_LITTLE_ENDIAN
+#define IS_BIG_ENDIAN    1
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   4
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   4
+#define PR_BYTES_PER_DWORD  8
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    32
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    32
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   5
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   5
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    4
+#define PR_ALIGN_OF_INT64   4
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  4
+#define PR_ALIGN_OF_POINTER 4
+
+#define PR_BYTES_PER_WORD_LOG2   2
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#else
+
+#error Must define constants for type sizes here.
+
+#endif
+
+
+#ifndef NO_NSPR_10_SUPPORT
+
+#define BYTES_PER_BYTE		PR_BYTES_PER_BYTE
+#define BYTES_PER_SHORT 	PR_BYTES_PER_SHORT
+#define BYTES_PER_INT 		PR_BYTES_PER_INT
+#define BYTES_PER_INT64		PR_BYTES_PER_INT64
+#define BYTES_PER_LONG		PR_BYTES_PER_LONG
+#define BYTES_PER_FLOAT		PR_BYTES_PER_FLOAT
+#define BYTES_PER_DOUBLE	PR_BYTES_PER_DOUBLE
+#define BYTES_PER_WORD		PR_BYTES_PER_WORD
+#define BYTES_PER_DWORD		PR_BYTES_PER_DWORD
+
+#define BITS_PER_BYTE		PR_BITS_PER_BYTE
+#define BITS_PER_SHORT		PR_BITS_PER_SHORT
+#define BITS_PER_INT		PR_BITS_PER_INT
+#define BITS_PER_INT64		PR_BITS_PER_INT64
+#define BITS_PER_LONG		PR_BITS_PER_LONG
+#define BITS_PER_FLOAT		PR_BITS_PER_FLOAT
+#define BITS_PER_DOUBLE		PR_BITS_PER_DOUBLE
+#define BITS_PER_WORD		PR_BITS_PER_WORD
+
+#define BITS_PER_BYTE_LOG2	PR_BITS_PER_BYTE_LOG2
+#define BITS_PER_SHORT_LOG2	PR_BITS_PER_SHORT_LOG2
+#define BITS_PER_INT_LOG2	PR_BITS_PER_INT_LOG2
+#define BITS_PER_INT64_LOG2	PR_BITS_PER_INT64_LOG2
+#define BITS_PER_LONG_LOG2	PR_BITS_PER_LONG_LOG2
+#define BITS_PER_FLOAT_LOG2	PR_BITS_PER_FLOAT_LOG2
+#define BITS_PER_DOUBLE_LOG2 	PR_BITS_PER_DOUBLE_LOG2
+#define BITS_PER_WORD_LOG2	PR_BITS_PER_WORD_LOG2
+
+#define ALIGN_OF_SHORT		PR_ALIGN_OF_SHORT
+#define ALIGN_OF_INT		PR_ALIGN_OF_INT
+#define ALIGN_OF_LONG		PR_ALIGN_OF_LONG
+#define ALIGN_OF_INT64		PR_ALIGN_OF_INT64
+#define ALIGN_OF_FLOAT		PR_ALIGN_OF_FLOAT
+#define ALIGN_OF_DOUBLE		PR_ALIGN_OF_DOUBLE
+#define ALIGN_OF_POINTER	PR_ALIGN_OF_POINTER
+#define ALIGN_OF_WORD		PR_ALIGN_OF_WORD
+
+#define BYTES_PER_WORD_LOG2	PR_BYTES_PER_WORD_LOG2
+#define BYTES_PER_DWORD_LOG2	PR_BYTES_PER_DWORD_LOG2
+#define WORDS_PER_DWORD_LOG2	PR_WORDS_PER_DWORD_LOG2
+
+#endif /* NO_NSPR_10_SUPPORT */
+
+#endif /* nspr_cpucfg___ */
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_netbsd.h
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ * 
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ * 
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+#ifndef nspr_netbsd_defs_h___
+#define nspr_netbsd_defs_h___
+
+#include <sys/syscall.h>
+
+#define PR_LINKER_ARCH	"netbsd"
+#define _PR_SI_SYSNAME  "NetBSD"
+#if defined(__i386__)
+#define _PR_SI_ARCHITECTURE "x86"
+#elif defined(__alpha__)
+#define _PR_SI_ARCHITECTURE "alpha"
+#elif defined(__m68k__)
+#define _PR_SI_ARCHITECTURE "m68k"
+#elif defined(__powerpc__)
+#define _PR_SI_ARCHITECTURE "powerpc"
+#elif defined(__sparc__)
+#define _PR_SI_ARCHITECTURE "sparc"
+#elif defined(__arm32__)
+#define _PR_SI_ARCHITECTURE "arm32"
+#endif
+
+#define PR_DLL_SUFFIX		".so.1.0"
+
+#define _PR_VMBASE              0x30000000
+#define _PR_STACK_VMBASE	0x50000000
+#define _MD_DEFAULT_STACK_SIZE	65536L
+#define _MD_MMAP_FLAGS          MAP_PRIVATE
+
+#undef  HAVE_STACK_GROWING_UP
+#define HAVE_DLL
+#define USE_DLFCN
+#define _PR_HAVE_SOCKADDR_LEN
+
+#define USE_SETJMP
+
+#ifndef _PR_PTHREADS
+#include <setjmp.h>
+
+#define PR_CONTEXT_TYPE	sigjmp_buf
+
+#define CONTEXT(_th) ((_th)->md.context)
+
+#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__)
+#define JB_SP_INDEX 2
+#elif defined(__alpha__)
+#define JB_SP_INDEX 34
+#elif defined(__arm32__)
+#define JB_SP_INDEX JMPBUF_REG_R13
+#else
+#error "Need to define SP index in jmp_buf here"
+#endif
+#define _MD_GET_SP(_th)    (_th)->md.context[JB_SP_INDEX]
+
+#define PR_NUM_GCREGS	_JBLEN
+
+/*
+** Initialize a thread context to run "_main()" when started
+*/
+#define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
+{  \
+    *status = PR_TRUE;  \
+    if (sigsetjmp(CONTEXT(_thread), 1)) {  \
+        _main();  \
+    }  \
+    _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
+}
+
+#define _MD_SWITCH_CONTEXT(_thread)  \
+    if (!sigsetjmp(CONTEXT(_thread), 1)) {  \
+        (_thread)->md.errcode = errno;  \
+        _PR_Schedule();  \
+    }
+
+/*
+** Restore a thread context, saved by _MD_SWITCH_CONTEXT
+*/
+#define _MD_RESTORE_CONTEXT(_thread) \
+{   \
+    errno = (_thread)->md.errcode;  \
+    _MD_SET_CURRENT_THREAD(_thread);  \
+    siglongjmp(CONTEXT(_thread), 1);  \
+}
+
+/* Machine-dependent (MD) data structures */
+
+struct _MDThread {
+    PR_CONTEXT_TYPE context;
+    int id;
+    int errcode;
+};
+
+struct _MDThreadStack {
+    PRInt8 notused;
+};
+
+struct _MDLock {
+    PRInt8 notused;
+};
+
+struct _MDSemaphore {
+    PRInt8 notused;
+};
+
+struct _MDCVar {
+    PRInt8 notused;
+};
+
+struct _MDSegment {
+    PRInt8 notused;
+};
+
+struct _MDCPU {
+    struct _MDCPU_Unix md_unix;
+};
+
+#define _MD_INIT_LOCKS()
+#define _MD_NEW_LOCK(lock) PR_SUCCESS
+#define _MD_FREE_LOCK(lock)
+#define _MD_LOCK(lock)
+#define _MD_UNLOCK(lock)
+#define _MD_INIT_IO()
+#define _MD_IOQ_LOCK()
+#define _MD_IOQ_UNLOCK()
+
+#define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
+#define _MD_INIT_THREAD                 _MD_InitializeThread
+#define _MD_EXIT_THREAD(thread)
+#define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
+#define _MD_RESUME_THREAD(thread)       _MD_resume_thread
+#define _MD_CLEAN_THREAD(_thread)
+
+#endif /* ! _PR_PTHREADS */
+
+#define _MD_EARLY_INIT                  _MD_EarlyInit
+#define _MD_FINAL_INIT			_PR_UnixInit
+#define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
+#define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
+
+/*
+ * We wrapped the select() call.  _MD_SELECT refers to the built-in,
+ * unwrapped version.
+ */
+#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
+#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
+
+#if NetBSD1_3 == 1L
+typedef unsigned int nfds_t;
+#endif
+
+#endif /* nspr_netbsd_defs_h___ */
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -64,17 +64,18 @@
  * more of a problem as we adapt to more pthreads implementations.
  */
 #if defined(_PR_DCETHREADS)
 #define PTHREAD_ZERO_THR_HANDLE(t)        memset(&(t), 0, sizeof(pthread_t))
 #define PTHREAD_THR_HANDLE_IS_ZERO(t) \
 	(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
 #define PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
-	|| defined(HPUX) || defined(LINUX) || defined(FREEBSD)
+	|| defined(HPUX) || defined(LINUX) || defined(FREEBSD) \
+	|| defined(NETBSD)
 #define PTHREAD_ZERO_THR_HANDLE(t)        (t) = 0
 #define PTHREAD_THR_HANDLE_IS_ZERO(t)     (t) == 0
 #define PTHREAD_COPY_THR_HANDLE(st, dt)   (dt) = (st)
 #else 
 #error "pthreads is not supported for this architecture"
 #endif
 
 #if defined(_PR_DCETHREADS)
@@ -129,25 +130,26 @@ PR_EXTERN(PRIntn) pt_hpux_privcheck(void
 #define PT_TRYLOCK_SUCCESS 0
 #define PT_TRYLOCK_BUSY    EBUSY
 #endif
 
 /*
  * These platforms don't have pthread_atfork()
  */
 #if defined(_PR_DCETHREADS) || defined(FREEBSD) \
-	|| (defined(LINUX) && defined(__alpha))
+	|| (defined(LINUX) && defined(__alpha)) \
+	|| defined(NETBSD)
 #define PT_NO_ATFORK
 #endif
 
 /*
  * These platforms don't have sigtimedwait()
  */
 #if (defined(AIX) && !defined(AIX4_3)) || defined(LINUX) \
-	|| defined(FREEBSD)
+	|| defined(FREEBSD) || defined(NETBSD)
 #define PT_NO_SIGTIMEDWAIT
 #endif
 
 #if defined(OSF1)
 #define PT_PRIO_MIN            PRI_OTHER_MIN
 #define PT_PRIO_MAX            PRI_OTHER_MAX
 #elif defined(IRIX)
 #include <sys/sched.h>
@@ -179,17 +181,17 @@ PR_EXTERN(PRIntn) pt_hpux_privcheck(void
 /*
  * Solaris doesn't seem to have macros for the min/max priorities.
  * The range of 0-127 is mentioned in the pthread_setschedparam(3T)
  * man pages, and pthread_setschedparam indeed allows 0-127.  However,
  * pthread_attr_setschedparam does not allow 0; it allows 1-127.
  */
 #define PT_PRIO_MIN            1
 #define PT_PRIO_MAX            127
-#elif defined(FREEBSD) /* XXX */
+#elif defined(FREEBSD) || defined(NETBSD) /* XXX */
 #define PT_PRIO_MIN            0
 #define PT_PRIO_MAX            126
 #else
 #error "pthreads is not supported for this architecture"
 #endif
 
 /* Needed for garbage collection -- Look at PR_Suspend/PR_Resume implementation */
 #if defined(OSF1)
@@ -208,17 +210,17 @@ extern int (*_PT_aix_yield_fcn)();
 		struct timespec onemillisec = {0};		\
 		onemillisec.tv_nsec = 1000000L;			\
         nanosleep(&onemillisec,NULL);			\
     PR_END_MACRO
 #elif defined(SOLARIS)
 #define PTHREAD_YIELD()             sched_yield()
 #elif defined(LINUX)
 #define PTHREAD_YIELD()            	sched_yield()
-#elif defined(FREEBSD)
+#elif defined(FREEBSD) || defined(NETBSD)
 #define PTHREAD_YIELD()                 pthread_yield()
 #else
 #error "Need to define PTHREAD_YIELD for this platform"
 #endif
 
 /*
 ** And when you really wanted hardcore locking w/o any fluff ...
 **
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -44,17 +44,18 @@
 
 /* To pick up fd_set */
 #if defined(HPUX)
 #include <sys/time.h>
 #elif defined(OSF1) || defined(AIX) || defined(SOLARIS) || defined(IRIX) \
         || defined(UNIXWARE) || defined(NCR) || defined(SNI) || defined(NEC) \
         || defined(BSDI) || defined(SONY)
 #include <sys/select.h>
-#elif defined(SUNOS4) || defined(SCO) || defined(FREEBSD) || defined(RHAPSODY)
+#elif defined(SUNOS4) || defined(SCO) || defined(FREEBSD) \
+        || defined(NETBSD) || defined(RHAPSODY)
 #include <sys/types.h>
 #elif defined(LINUX)
 #include <sys/time.h>
 #include <sys/types.h>
 #else
 #error Find out what include file defines fd_set on this platform
 #endif
 
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -54,16 +54,19 @@ PR_BEGIN_EXTERN_C
 #include "md/_unix_errors.h"
 
 #if defined(AIX)
 #include "md/_aix.h"
 
 #elif defined(FREEBSD)
 #include "md/_freebsd.h"
 
+#elif defined(NETBSD)
+#include "md/_netbsd.h"
+
 #elif defined(BSDI)
 #include "md/_bsdi.h"
 
 #elif defined(HPUX)
 #include "md/_hpux.h"
 
 #elif defined(IRIX)
 #include "md/_irix.h"
--- a/pr/src/md/prosdep.c
+++ b/pr/src/md/prosdep.c
@@ -37,17 +37,17 @@ PRInt32 _pr_pageSize;
 */
 static void GetPageSize(void)
 {
 	PRInt32 pageSize;
 
     /* Get page size */
 #ifdef XP_UNIX
 #if defined SUNOS4 || defined LINUX || defined BSDI || defined AIX \
-	|| defined FREEBSD || defined RHAPSODY
+	|| defined FREEBSD || defined NETBSD || defined RHAPSODY
     _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);
 #endif
 #endif /* XP_UNIX */
--- a/pr/src/md/unix/Makefile
+++ b/pr/src/md/unix/Makefile
@@ -52,16 +52,20 @@ SOLARIS_CSRCS = \
 AIX_CSRCS =	\
 	aix.c	\
 	$(NULL)
 
 FREEBSD_CSRCS = \
 	freebsd.c \
 	$(NULL)
 
+NETBSD_CSRCS = \
+	netbsd.c \
+	$(NULL)
+
 BSDI_CSRCS = \
 	bsdi.c \
 	$(NULL)
 
 HPUX_CSRCS = \
 	hpux.c \
 	$(NULL)
 
@@ -118,16 +122,19 @@ endif
 endif
 
 ifeq ($(OS_ARCH),AIX)
 CSRCS += $(AIX_CSRCS)
 endif
 ifeq ($(OS_ARCH),FreeBSD)
 CSRCS += $(FREEBSD_CSRCS)
 endif
+ifeq ($(OS_ARCH),NetBSD)
+CSRCS += $(NETBSD_CSRCS)
+endif
 ifeq ($(OS_ARCH),BSD_OS)
 CSRCS += $(BSDI_CSRCS)
 endif
 ifeq ($(OS_ARCH),HP-UX)
 CSRCS += $(HPUX_CSRCS)
 endif
 ifeq ($(OS_ARCH),OSF1)
 CSRCS += $(OSF1_CSRCS)
new file mode 100644
--- /dev/null
+++ b/pr/src/md/unix/netbsd.c
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ * 
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ * 
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+#include "primpl.h"
+
+#include <signal.h>
+#include <poll.h>
+#include <sys/syscall.h>
+
+void _MD_EarlyInit(void)
+{
+    /*
+     * Ignore FPE because coercion of a NaN to an int causes SIGFPE
+     * to be raised.
+     */
+    struct sigaction act;
+
+    act.sa_handler = SIG_IGN;
+    sigemptyset(&act.sa_mask);
+    act.sa_flags = SA_RESTART;
+    sigaction(SIGFPE, &act, 0);
+}
+
+PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
+{
+#ifndef _PR_PTHREADS
+    if (isCurrent) {
+        (void) sigsetjmp(CONTEXT(t), 1);
+    }
+    *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
+    return (PRWord *) CONTEXT(t);
+#else
+    *np = 0;
+    return NULL;
+#endif
+}
+
+#ifndef _PR_PTHREADS
+void
+_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
+{
+    return;
+}
+
+PRStatus
+_MD_InitializeThread(PRThread *thread)
+{
+    return PR_SUCCESS;
+}
+
+PRStatus
+_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
+{
+    PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
+    _PR_MD_SWITCH_CONTEXT(thread);
+    return PR_SUCCESS;
+}
+
+PRStatus
+_MD_WAKEUP_WAITER(PRThread *thread)
+{
+    if (thread) {
+        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
+    }
+    return PR_SUCCESS;
+}
+
+/* These functions should not be called for NetBSD */
+void
+_MD_YIELD(void)
+{
+    PR_NOT_REACHED("_MD_YIELD should not be called for NetBSD.");
+}
+
+PRStatus
+_MD_CREATE_THREAD(
+    PRThread *thread,
+    void (*start) (void *),
+    PRThreadPriority priority,
+    PRThreadScope scope,
+    PRThreadState state,
+    PRUint32 stackSize)
+{
+    PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for NetBSD.");
+    return PR_FAILURE;
+}
+#endif /* ! _PR_PTHREADS */
--- a/pr/src/md/unix/objs.mk
+++ b/pr/src/md/unix/objs.mk
@@ -44,16 +44,20 @@ SOLARIS_CSRCS = \
 AIX_CSRCS =	\
 	aix.c	\
 	$(NULL)
 
 FREEBSD_CSRCS = \
 	freebsd.c \
 	$(NULL)
 
+NETBSD_CSRCS = \
+	netbsd.c \
+	$(NULL)
+
 BSDI_CSRCS = \
 	bsdi.c \
 	$(NULL)
 
 HPUX_CSRCS = \
 	hpux.c \
 	$(NULL)
 
@@ -111,16 +115,19 @@ endif
 endif
 
 ifeq ($(OS_ARCH),AIX)
 CSRCS += $(AIX_CSRCS)
 endif
 ifeq ($(OS_ARCH),FreeBSD)
 CSRCS += $(FREEBSD_CSRCS)
 endif
+ifeq ($(OS_ARCH),NetBSD)
+CSRCS += $(NETBSD_CSRCS)
+endif
 ifeq ($(OS_ARCH),BSD_OS)
 CSRCS += $(BSDI_CSRCS)
 endif
 ifeq ($(OS_ARCH),HP-UX)
 CSRCS += $(HPUX_CSRCS)
 endif
 ifeq ($(OS_ARCH),OSF1)
 CSRCS += $(OSF1_CSRCS)
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -43,17 +43,17 @@
  * PRInt32* pointer to a _PRSockLen_t* pointer.
  */
 #if 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(RHAPSODY)
 #define _PRSockLen_t int
 #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
-    || defined(UNIXWARE)
+    || defined(NETBSD) || defined(UNIXWARE)
 #define _PRSockLen_t size_t
 #else
 #error "Cannot determine architecture"
 #endif
 
 /*
 ** Global lock variable used to bracket calls into rusty libraries that
 ** aren't thread safe (like libc, libX, etc).
--- a/pr/src/md/unix/unix_errors.c
+++ b/pr/src/md/unix/unix_errors.c
@@ -155,18 +155,22 @@ void _MD_unix_map_unlink_error(int err)
 			PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
 			break;
 		case EPERM:
 			PR_SetError(PR_IS_DIRECTORY_ERROR, err);
 			break;
 		case EROFS:
 			PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+			PR_SetError(PR_REMOTE_FILE_ERROR, err);
+			break;
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 #endif
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
 	}
@@ -179,21 +183,23 @@ void _MD_unix_map_stat_error(int err)
 			PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
 			break;
 		case EFAULT:
 			PR_SetError(PR_ACCESS_FAULT_ERROR, err);
 			break;
 		case EINTR:
 			PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
 			break;
-		case ETIMEDOUT:
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 #endif
+		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
@@ -273,18 +279,22 @@ void _MD_unix_map_rename_error(int err)
 			PR_SetError(PR_IO_ERROR, err);
 			break;
 		case EISDIR:
 			PR_SetError(PR_IS_DIRECTORY_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+			PR_SetError(PR_REMOTE_FILE_ERROR, err);
+			break;
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 #endif
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
 		case ENOENT:
@@ -324,18 +334,20 @@ void _MD_unix_map_access_error(int err)
 			PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
 			break;
 		case EINVAL:
 			PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 #endif
 		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
@@ -390,18 +402,22 @@ void _MD_unix_map_mkdir_error(int err)
 #ifdef EDQUOT
 		case EDQUOT:
 			PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
 			break;
 #endif
 		case EIO:
 			PR_SetError(PR_IO_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+			PR_SetError(PR_REMOTE_FILE_ERROR, err);
+			break;
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 #endif
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
 	}
@@ -427,18 +443,20 @@ void _MD_unix_map_rmdir_error(int err)
 			PR_SetError(PR_DIRECTORY_NOT_EMPTY_ERROR, err);
 			break;
 		case EIO:
 			PR_SetError(PR_IO_ERROR, err);
 			break;
 		case ELOOP:
 			PR_SetError(PR_LOOP_ERROR, err);
 			break;
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 #endif
 		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case ENAMETOOLONG:
 			PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
 			break;
@@ -1339,21 +1357,23 @@ void _MD_unix_map_open_error(int err)
 			PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
 			break;
 		case ENOTDIR:
 			PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
 			break;
 		case EPERM:
 			PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
 			break;
-		case ETIMEDOUT:
-#if !defined(OSF1) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#ifdef EMULTIHOP
 		case EMULTIHOP:
+#endif
+#ifdef ENOLINK
 		case ENOLINK:
 #endif
+		case ETIMEDOUT:
 			PR_SetError(PR_REMOTE_FILE_ERROR, err);
 			break;
 		case EROFS:
 			PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
 			break;
 		default:
 			PR_SetError(PR_UNKNOWN_ERROR, err);
 			break;
--- a/pr/src/md/unix/uxwrap.c
+++ b/pr/src/md/unix/uxwrap.c
@@ -319,16 +319,18 @@ int select(int width, fd_set *rd, fd_set
 #if defined(AIX4_1)
 int wrap_poll(void *listptr, unsigned long nfds, long timeout)
 #elif (defined(AIX) && !defined(AIX4_1))
 int poll(void *listptr, unsigned long nfds, long timeout)
 #elif defined(OSF1) || (defined(HPUX) && !defined(HPUX9))
 int poll(struct pollfd filedes[], unsigned int nfds, int timeout)
 #elif defined(HPUX9)
 int poll(struct pollfd filedes[], int nfds, int timeout)
+#elif defined(NETBSD)
+int poll(struct pollfd *filedes, nfds_t nfds, int timeout)
 #else
 int poll(struct pollfd *filedes, unsigned long nfds, int timeout)
 #endif
 {
 #ifdef AIX
     struct pollfd *filedes = (struct pollfd *) listptr;
 #endif
     void *pollset;
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -70,17 +70,17 @@
 
 #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(FREEBSD)
+    || defined(FREEBSD) || defined(NETBSD)
 #define _PRSelectFdSetArg_t fd_set *
 #else
 #error "Cannot determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type);
 
 static pthread_condattr_t _pt_cvar_attr;
@@ -2501,17 +2501,17 @@ static PRIOMethods _pr_udp_methods = {
     pt_SetSocketOption
 };
 
 #if defined(_PR_FCNTL_FLAGS)
 #undef _PR_FCNTL_FLAGS
 #endif
 
 #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \
-    || defined(AIX) || defined(LINUX) || defined(FREEBSD)
+    || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD)
 #define _PR_FCNTL_FLAGS O_NONBLOCK
 #else
 #error "Can't determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type)
 {
     PRInt32 flags, one = 1;
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -189,31 +189,31 @@ static PRThread* _PR_CreateThread(
     else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)priority)
         priority = PR_PRIORITY_LAST;
 
     rv = PTHREAD_ATTR_INIT(&tattr);
     PR_ASSERT(0 == rv);
 
     if (EPERM != pt_schedpriv)
     {
-#if !defined(_PR_DCETHREADS) && !defined(FREEBSD)
+#if !defined(_PR_DCETHREADS) && !defined(FREEBSD) && !defined(NETBSD)
         struct sched_param schedule;
 #endif
 
-#if !defined(FREEBSD)
+#if !defined(FREEBSD) && !defined(NETBSD)
         rv = pthread_attr_setinheritsched(&tattr, PTHREAD_EXPLICIT_SCHED);
         PR_ASSERT(0 == rv);
 #endif
 
         /* Use the default scheduling policy */
 
 #if defined(_PR_DCETHREADS)
         rv = pthread_attr_setprio(&tattr, pt_PriorityMap(priority));
         PR_ASSERT(0 == rv);
-#elif !defined(FREEBSD)
+#elif !defined(FREEBSD) && !defined(NETBSD)
         rv = pthread_attr_getschedparam(&tattr, &schedule);
         PR_ASSERT(0 == rv);
         schedule.sched_priority = pt_PriorityMap(priority);
         rv = pthread_attr_setschedparam(&tattr, &schedule);
         PR_ASSERT(0 == rv);
 #endif /* !defined(_PR_DCETHREADS) */
     }
 
@@ -545,17 +545,17 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(
         newPri = PR_PRIORITY_FIRST;
     else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri)
         newPri = PR_PRIORITY_LAST;
 
 #if defined(_PR_DCETHREADS)
     rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
     /* pthread_setprio returns the old priority */
     PR_ASSERT(-1 != rv);
-#elif !defined(FREEBSD)
+#elif !defined(FREEBSD) && !defined(NETBSD)
     if (EPERM != pt_schedpriv)
     {
         int policy;
         struct sched_param schedule;
 
         rv = pthread_getschedparam(thred->id, &policy, &schedule);
         PR_ASSERT(0 == rv);
         schedule.sched_priority = pt_PriorityMap(newPri);
@@ -746,17 +746,17 @@ void _PR_InitThreads(
     pt_schedpriv = PT_PRIVCHECK();
     PR_SetThreadPriority(thred, priority);
 
     /*
      * Linux pthreads use SIGUSR1 and SIGUSR2 internally, which
      * conflict with the use of these two signals in our GC support.
      * So we don't know how to support GC on Linux pthreads.
      */
-#if !defined(LINUX) && !defined(FREEBSD)
+#if !defined(LINUX) && !defined(FREEBSD) && !defined(NETBSD)
 	init_pthread_gc_support();
 #endif
 
 }  /* _PR_InitThreads */
 
 PR_IMPLEMENT(PRStatus) PR_Cleanup()
 {
     PRThread *me = PR_CurrentThread();
@@ -1031,17 +1031,17 @@ static void suspend_signal_handler(PRInt
 
 	/*
 	 * now, block current thread
 	 */
 #if defined(PT_NO_SIGTIMEDWAIT)
 	pthread_cond_signal(&me->suspendResumeCV);
 	while (me->suspend & PT_THREAD_SUSPENDED)
 	{
-#if !defined(FREEBSD)  /*XXX*/
+#if !defined(FREEBSD) && !defined(NETBSD)  /*XXX*/
         PRIntn rv;
 	    sigwait(&sigwait_set, &rv);
 #endif
 	}
 	me->suspend |= PT_THREAD_RESUMED;
 	pthread_cond_signal(&me->suspendResumeCV);
 #else /* defined(PT_NO_SIGTIMEDWAIT) */
 	while (me->suspend & PT_THREAD_SUSPENDED)