NEXTSTEP port. Contributed by Balazs Pataki (balazs.pataki@sztaki.hu). NSPRPUB_RELEASE_3_0_BRANCH
authorwtc%netscape.com
Wed, 18 Nov 1998 23:59:34 +0000
branchNSPRPUB_RELEASE_3_0_BRANCH
changeset 323 9286956f3c79
parent 322 991eb7f7b094
push idunknown
push userunknown
push dateunknown
NEXTSTEP port. Contributed by Balazs Pataki (balazs.pataki@sztaki.hu).
config/Makefile
config/nsinstall.c
pr/include/gencfg.c
pr/include/md/Makefile
pr/include/md/_unixos.h
pr/include/md/prosdep.h
pr/include/private/primpl.h
pr/src/io/prfile.c
pr/src/io/prmapopt.c
pr/src/linking/prlink.c
pr/src/md/prosdep.c
pr/src/md/unix/Makefile
pr/src/md/unix/objs.mk
pr/src/md/unix/unix.c
pr/src/md/unix/uxwrap.c
pr/src/misc/pratom.c
pr/tests/Makefile
--- a/config/Makefile
+++ b/config/Makefile
@@ -29,17 +29,17 @@ ifeq ($(OS_ARCH), WINNT)
 PROG_SUFFIX = .exe
 else
 PROG_SUFFIX =
 endif
 
 # Temporary workaround to disable the generation of
 # library build time because now.c uses the 'long long'
 # data type that's not available on some platforms.
-ifeq (,$(filter-out NEC SCOOS UNIXWARE,$(OS_ARCH)))
+ifeq (,$(filter-out NEC NEXTSTEP SCOOS UNIXWARE,$(OS_ARCH)))
 DEFINES += -DOMIT_LIB_BUILD_TIME
 endif
 
 ifeq ($(OS_ARCH), IRIX)
     ifeq ($(basename $(OS_RELEASE)),6)
 	    ifeq ($(USE_N32),1)
 		    XLDOPTS += -n32 -Wl,-woff,85
 		    ifeq ($(OS_RELEASE), 6_2)
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -38,33 +38,57 @@
 #ifdef USE_REENTRANT_LIBC
 #include "libc_r.h"
 #endif /* USE_REENTRANT_LIBC */
 
 #include "pathsub.h"
 
 #define HAVE_LCHOWN
 
-#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(RHAPSODY)
+#if defined(AIX) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(UNIXWARE) || defined(RHAPSODY) || defined(NEXTSTEP)
 #undef HAVE_LCHOWN
 #endif
 
 /*
  * Does getcwd() take NULL as the first argument and malloc
  * the result buffer?
  */
-#if !defined(RHAPSODY)
+#if !defined(RHAPSODY) && !defined(NEXTSTEP)
 #define GETCWD_CAN_MALLOC
 #endif
 
+#ifdef NEXTSTEP
+#include <bsd/libc.h>
+
+/*
+** balazs.pataki@sztaki.hu: The getcwd is broken in NEXTSTEP (returns 0),
+** when called on a mounted fs. Did anyone notice this? Here's an ugly
+** workaround ...
+*/
+#define getcwd(b,s)   my_getcwd(b,s)
+
+static char *
+my_getcwd (char *buf, size_t size)
+{
+    FILE *pwd = popen("pwd", "r");
+    char *result = fgets(buf, size, pwd);
+
+    if (result) {
+        buf[strlen(buf)-1] = '\0';
+    }
+    pclose (pwd);
+    return buf;
+}
+#endif /* NEXTSTEP */
+
 #ifdef LINUX
 #include <getopt.h>
 #endif
 
-#if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC)
+#if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC) || defined(NEXTSTEP)
 #if !defined(S_ISLNK) && defined(S_IFLNK)
 #define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
 #endif
 #endif
 
 #if defined(SNI)
 extern int fchmod(int fildes, mode_t mode);
 #endif
--- a/pr/include/gencfg.c
+++ b/pr/include/gencfg.c
@@ -78,16 +78,22 @@
 #endif
 
 #if defined(__APPLE__)
 #ifndef RHAPSODY
       error - RHAPSODY is not defined
 #endif
 #endif
 
+#if defined(__NeXT__)
+#ifndef NEXTSTEP
+      error - NEXTSTEP is not defined
+#endif
+#endif
+
 /************************************************************************/
 
 /* Generate cpucfg.h */
 
 #ifdef XP_PC
 #ifdef WIN32
 #define INT64	_PRInt64
 #else
--- a/pr/include/md/Makefile
+++ b/pr/include/md/Makefile
@@ -94,16 +94,20 @@ endif
 ifeq ($(OS_ARCH),SINIX)
 MDCPUCFG_H = _reliantunix.cfg
 endif
 
 ifeq ($(OS_ARCH),Rhapsody)
 MDCPUCFG_H = _rhapsody.cfg
 endif
 
+ifeq ($(OS_ARCH),NEXTSTEP)
+MDCPUCFG_H = _nextstep.cfg
+endif
+
 ifeq ($(OS_ARCH),NEWS-OS)
 MDCPUCFG_H = _sony.cfg
 endif
 
 ifeq ($(OS_ARCH),NEC)
 MDCPUCFG_H = _nec.cfg
 endif
 
--- a/pr/include/md/_unixos.h
+++ b/pr/include/md/_unixos.h
@@ -22,17 +22,17 @@
 /*
  * 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(RHAPSODY)
+#if !defined(LINUX) && !defined(RHAPSODY) && !defined(NEXTSTEP)
 #ifndef FD_SETSIZE
 #define FD_SETSIZE  4096
 #endif
 #endif
 
 #include <unistd.h>
 #include <stddef.h>
 #include <sys/stat.h>
@@ -139,17 +139,17 @@ struct _PRCPU;
 extern void _MD_unix_init_running_cpu(struct _PRCPU *cpu);
 
 /*
 ** Make a redzone at both ends of the stack segment. Disallow access
 ** to those pages of memory. It's ok if the mprotect call's don't
 ** work - it just means that we don't really have a functional
 ** redzone.
 */
-#if defined(DEBUG) && !defined(RHAPSODY)
+#if defined(DEBUG) && !defined(RHAPSODY) && !defined(NEXTSTEP)
 #if !defined(SOLARIS)	
 #include <string.h>  /* for memset() */
 #define _MD_INIT_STACK(ts,REDZONE)					\
     PR_BEGIN_MACRO                 					\
 	(void) mprotect((void*)ts->seg->vaddr, REDZONE, PROT_NONE);	\
 	(void) mprotect((void*) ((char*)ts->seg->vaddr + REDZONE + ts->stackSize),\
 			REDZONE, PROT_NONE);				\
     /*									\
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -75,16 +75,19 @@ PR_BEGIN_EXTERN_C
 #include "md/_linux.h"
 
 #elif defined(OSF1)
 #include "md/_osf1.h"
 
 #elif defined(RHAPSODY)
 #include "md/_rhapsody.h"
 
+#elif defined(NEXTSTEP)
+#include "md/_nextstep.h"
+
 #elif defined(SOLARIS)
 #include "md/_solaris.h"
 
 #elif defined(SUNOS4)
 #include "md/_sunos4.h"
 
 #elif defined(SNI)
 #include "md/_reliantunix.h"
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1531,16 +1531,17 @@ extern PRFileDesc *_pr_stderr;
 extern PRBool _pr_ipv6_enabled;  /* defined in prnetdb.c */
 #endif
 
 /* Overriding malloc, free, etc. */
 #if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \
         && !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \
         && !defined(PURIFY) \
         && !defined(RHAPSODY) \
+        && !defined(NEXTSTEP) \
         && !(defined (UNIXWARE) && defined (USE_SVR4_THREADS))
 #define _PR_OVERRIDE_MALLOC
 #endif
 
 /*************************************************************************
 * External machine-dependent code provided by each OS.                     *                                                                     *
 *************************************************************************/
 
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -260,26 +260,26 @@ PR_IMPLEMENT(PRFileDesc*) PR_Open(const 
             (void) _PR_MD_CLOSE_FILE(osfd);
         }
     }
     return fd;
 }
 
 PRInt32 PR_GetSysfdTableMax(void)
 {
-#if defined(XP_UNIX) && !defined(AIX)
+#if defined(XP_UNIX) && !defined(AIX) && !defined(NEXTSTEP)
     struct rlimit rlim;
 
     if ( getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
        /* XXX need to call PR_SetError() */
        return -1;
     }
 
     return rlim.rlim_max;
-#elif defined(AIX)
+#elif defined(AIX) || defined(NEXTSTEP)
     return sysconf(_SC_OPEN_MAX);
 #elif defined(WIN32) || defined(OS2)
     /*
      * There is a systemwide limit of 65536 user handles.
      * Not sure on OS/2, but sounds good.
      */
     return 16384;
 #elif defined (WIN16)
@@ -289,17 +289,17 @@ PRInt32 PR_GetSysfdTableMax(void)
    return -1;
 #else
     write me;
 #endif
 }
 
 PRInt32 PR_SetSysfdTableSize(int table_size)
 {
-#if defined(XP_UNIX) && !defined(AIX)
+#if defined(XP_UNIX) && !defined(AIX) && !defined(NEXTSTEP)
     struct rlimit rlim;
     PRInt32 tableMax = PR_GetSysfdTableMax();
 
     if (tableMax < 0) 
         return -1;
 
     if (tableMax > FD_SETSIZE)
         tableMax = FD_SETSIZE;
@@ -313,17 +313,18 @@ PRInt32 PR_SetSysfdTableSize(int table_s
         rlim.rlim_cur = table_size;
 
     if ( setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
         /* XXX need to call PR_SetError() */
         return -1;
     }
 
     return rlim.rlim_cur;
-#elif defined(AIX) || defined(WIN32) || defined(WIN16) || defined(OS2)
+#elif defined(AIX) || defined(WIN32) || defined(WIN16) || defined(OS2) \
+        || defined(NEXTSTEP)
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
     return -1;
 #elif defined (XP_MAC)
 #pragma unused (table_size)
     PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
    return -1;
 #else
     write me;
--- a/pr/src/io/prmapopt.c
+++ b/pr/src/io/prmapopt.c
@@ -31,16 +31,21 @@
  */
 
 #ifdef WINNT
 #include <winsock.h>
 #endif
 
 #include "primpl.h"
 
+#if defined(NEXTSTEP)
+/* NEXTSTEP is special: this must come before netinet/tcp.h. */
+#include <netinet/in_systm.h>  /* n_short, n_long, n_time */
+#endif
+
 #if defined(XP_UNIX) || defined(OS2)
 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
 #endif
 
 #ifndef _PR_PTHREADS
 
 PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionData *data)
 {
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -27,30 +27,30 @@
 #include <Strings.h>
 #endif
 
 #ifdef XP_UNIX
 #ifdef USE_DLFCN
 #include <dlfcn.h>
 #elif defined(USE_HPSHL)
 #include <dl.h>
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
 #include <mach-o/dyld.h>
 #endif
 
 /* Define this on systems which don't have it (AIX) */
 #ifndef RTLD_LAZY
 #define RTLD_LAZY RTLD_NOW
 #endif
 #endif /* XP_UNIX */
 
 /*
  * On these platforms, symbols have a leading '_'.
  */
-#if defined(SUNOS4) || defined(RHAPSODY) || defined(WIN16)
+#if defined(SUNOS4) || defined(RHAPSODY) || defined(NEXTSTEP) || defined(WIN16)
 #define NEED_LEADING_UNDERSCORE
 #endif
 
 #ifdef XP_PC
 typedef PRStaticLinkTable *NODL_PROC(void);
 #endif
 
 /************************************************************************/
@@ -66,17 +66,17 @@ struct PRLibrary {
 #endif
 #ifdef XP_MAC
     CFragConnectionID           dlh;
 #endif
 
 #ifdef XP_UNIX
 #if defined(USE_HPSHL)
     shl_t                       dlh;
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
     NSModule                    dlh;
 #else
     void*                       dlh;
 #endif 
 #endif 
 };
 
 static PRLibrary *pr_loadmap;
@@ -165,17 +165,17 @@ void _PR_InitLinker(void)
         fprintf(stderr, "failed to initialize shared libraries [%s]\n",
             error);
         PR_DELETE(error);
         abort();/* XXX */
     }
 #elif defined(USE_HPSHL)
     h = NULL;
     /* don't abort with this NULL */
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
     h = NULL; /* XXXX  toshok */
 #else
 #error no dll strategy
 #endif /* USE_DLFCN */
 
     lm = PR_NEWZAP(PRLibrary);
     if (lm) {
         lm->name = strdup("a.out");
@@ -636,17 +636,17 @@ PR_LoadLibrary(const char *name)
 
 #ifdef XP_UNIX
 #ifdef HAVE_DLL
     {
 #if defined(USE_DLFCN)
     void *h = dlopen(name, RTLD_LAZY);
 #elif defined(USE_HPSHL)
     shl_t h = shl_load(name, BIND_DEFERRED | DYNAMIC_PATH, 0L);
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
     NSObjectFileImage ofi;
     NSModule h = NULL;
     if (NSCreateObjectFileImageFromFile(name, &ofi)
             == NSObjectFileImageSuccess) {
         h = NSLinkModule(ofi, name, TRUE);
     }
 #else
 #error Configuration error
@@ -709,17 +709,17 @@ PR_UnloadLibrary(PRLibrary *lib)
     goto done;
     }
 #ifdef XP_UNIX
 #ifdef HAVE_DLL
 #ifdef USE_DLFCN
     result = dlclose(lib->dlh);
 #elif defined(USE_HPSHL)
     result = shl_unload(lib->dlh);
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
     result = NSUnLinkModule(lib->dlh, FALSE);
 #else
 #error Configuration error
 #endif
 #endif /* HAVE_DLL */
 #endif /* XP_UNIX */
 #ifdef XP_PC
     if (lib->dlh) {
@@ -822,17 +822,17 @@ pr_FindSymbolInLib(PRLibrary *lm, const 
 #ifdef XP_UNIX
 #ifdef HAVE_DLL
 #ifdef USE_DLFCN
     f = dlsym(lm->dlh, name);
 #elif defined(USE_HPSHL)
     if (shl_findsym(&lm->dlh, name, TYPE_PROCEDURE, &f) == -1) {
         f = NULL;
     }
-#elif defined(RHAPSODY)
+#elif defined(RHAPSODY) || defined(NEXTSTEP)
     f = NSAddressOfSymbol(NSLookupAndBindSymbol(name));
 #endif
 #endif /* HAVE_DLL */
 #endif /* XP_UNIX */
     if (f == NULL) {
         PR_SetError(PR_FIND_SYMBOL_ERROR, _MD_ERRNO());
         DLLErrorInternal(_MD_ERRNO());
     }
--- a/pr/src/md/prosdep.c
+++ b/pr/src/md/prosdep.c
@@ -37,17 +37,18 @@ 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 NETBSD || defined OPENBSD || defined RHAPSODY
+        || defined FREEBSD || defined NETBSD || defined OPENBSD \
+        || defined RHAPSODY || 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);
 #endif
 #endif /* XP_UNIX */
--- a/pr/src/md/unix/Makefile
+++ b/pr/src/md/unix/Makefile
@@ -89,16 +89,20 @@ UNIXWARE_CSRCS = \
 RELIANTUNIX_CSRCS = \
       reliantunix.c \
       $(NULL)
 
 RHAPSODY_CSRCS = \
 	rhapsody.c \
 	$(NULL)
 
+NEXTSTEP_CSRCS = \
+	nextstep.c \
+	$(NULL)
+
 NEC_CSRCS = \
 	nec.c \
 	$(NULL)
 
 SONY_CSRCS = \
 	sony.c \
 	$(NULL)
 
@@ -158,16 +162,19 @@ ifeq ($(OS_ARCH),UNIXWARE)
 CSRCS += $(UNIXWARE_CSRCS)
 endif
 ifeq ($(OS_ARCH),SINIX)
 CSRCS += $(RELIANTUNIX_CSRCS)
 endif
 ifeq ($(OS_ARCH),Rhapsody)
 CSRCS += $(RHAPSODY_CSRCS)
 endif
+ifeq ($(OS_ARCH),NEXTSTEP)
+CSRCS += $(NEXTSTEP_CSRCS)
+endif
 ifeq ($(OS_ARCH),NEC)
 CSRCS += $(NEC_CSRCS)
 endif
 ifeq ($(OS_ARCH),NEWS-OS)
 CSRCS += $(SONY_CSRCS)
 endif
 ifeq ($(OS_ARCH),NCR)
 CSRCS += $(NCR_CSRCS)
--- a/pr/src/md/unix/objs.mk
+++ b/pr/src/md/unix/objs.mk
@@ -81,16 +81,20 @@ UNIXWARE_CSRCS = \
 RELIANTUNIX_CSRCS = \
 	reliantunix.c \
 	$(NULL)
 
 RHAPSODY_CSRCS = \
 	rhapsody.c \
 	$(NULL)
 
+NEXTSTEP_CSRCS = \
+	nextstep.c \
+	$(NULL)
+
 NEC_CSRCS = \
 	nec.c \
 	$(NULL)
 
 SONY_CSRCS = \
 	sony.c \
 	$(NULL)
 
@@ -151,16 +155,19 @@ ifeq ($(OS_ARCH),UNIXWARE)
 CSRCS += $(UNIXWARE_CSRCS)
 endif
 ifeq ($(OS_ARCH),SINIX)
 CSRCS += $(RELIANTUNIX_CSRCS)
 endif
 ifeq ($(OS_ARCH),Rhapsody)
 CSRCS += $(RHAPSODY_CSRCS)
 endif
+ifeq ($(OS_ARCH),NEXTSTEP)
+CSRCS += $(NEXTSTEP_CSRCS)
+endif
 ifeq ($(OS_ARCH),NEC)
 CSRCS += $(NEC_CSRCS)
 endif
 ifeq ($(OS_ARCH),NEWS-OS)
 CSRCS += $(SONY_CSRCS)
 endif
 ifeq ($(OS_ARCH),NCR)
 CSRCS += $(NCR_CSRCS)
--- a/pr/src/md/unix/unix.c
+++ b/pr/src/md/unix/unix.c
@@ -41,17 +41,18 @@
 
 /*
  * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or
  * 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)
+    || defined(SUNOS4) || defined(NCR) || defined(RHAPSODY) \
+    || defined(NEXTSTEP)
 #define _PRSockLen_t int
 #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
     || defined(NETBSD) || defined(OPENBSD) || defined(UNIXWARE) || defined(DGUX)
 #define _PRSockLen_t size_t
 #else
 #error "Cannot determine architecture"
 #endif
 
--- a/pr/src/md/unix/uxwrap.c
+++ b/pr/src/md/unix/uxwrap.c
@@ -78,16 +78,19 @@ void PR_SetXtHackOkayToReleaseXLockFn(in
  *    Wrap up the select system call so that we can deschedule
  *    a thread that tries to wait for i/o.
  *
  *-----------------------------------------------------------------------
  */
 
 #if defined(HPUX9)
 int select(size_t width, int *rl, int *wl, int *el, const struct timeval *tv)
+#elif defined(NEXTSTEP)
+int wrap_select(int width, fd_set *rd, fd_set *wr, fd_set *ex,
+        const struct timeval *tv)
 #elif defined(AIX4_1)
 int wrap_select(unsigned long width, void *rl, void *wl, void *el,
         struct timeval *tv)
 #elif (defined(BSDI) && !defined(BSDI_2))
 int select(int width, fd_set *rd, fd_set *wr, fd_set *ex,
         const struct timeval *tv)
 #else
 int select(int width, fd_set *rd, fd_set *wr, fd_set *ex, struct timeval *tv)
@@ -280,20 +283,21 @@ int select(int width, fd_set *rd, fd_set
     PR_ASSERT(tv || retVal != 0);
     PR_LOG(_pr_io_lm, PR_LOG_MIN, ("select returns %d", retVal));
     PR_DELETE(unixpds);
 
     return retVal;
 }
 
 /*
- * Linux, BSDI, FreeBSD, and Rhapsody don't have poll().
+ * Linux, BSDI, FreeBSD, Rhapsody, and NEXTSTEP don't have poll().
  */
 
-#if !defined(LINUX) && !defined(FREEBSD) && !defined(BSDI) && !defined(RHAPSODY)
+#if !defined(LINUX) && !defined(FREEBSD) && !defined(BSDI) \
+    && !defined(RHAPSODY) && !defined(NEXTSTEP)
 
 /*
  *-----------------------------------------------------------------------
  * poll() --
  *
  * RETURN VALUES: 
  *     -1:  fails, errno indicates the error.
  *      0:  timed out, the revents bitmasks are not set.
--- a/pr/src/misc/pratom.c
+++ b/pr/src/misc/pratom.c
@@ -34,78 +34,78 @@
 
 #ifndef _PR_HAVE_ATOMIC_OPS
 
 /*
  * We use a single lock for all the emulated atomic operations.
  * The lock contention should be acceptable.
  */
 
-static PRLock *monitor = NULL;
+static PRLock *lock = NULL;
 void _PR_MD_INIT_ATOMIC()
 {
-    if (monitor == NULL) {
-        monitor = PR_NewLock();
+    if (lock == NULL) {
+        lock = PR_NewLock();
     }
 }
 
 PRInt32
 _PR_MD_ATOMIC_INCREMENT(PRInt32 *val)
 {
     PRInt32 rv;
 
     if (!_pr_initialized) {
         _PR_ImplicitInitialization();
     }
-    PR_Lock(monitor);
+    PR_Lock(lock);
     rv = ++(*val);
-    PR_Unlock(monitor);
+    PR_Unlock(lock);
     return rv;
 }
 
 PRInt32
 _PR_MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val)
 {
     PRInt32 rv;
 
     if (!_pr_initialized) {
         _PR_ImplicitInitialization();
     }
-    PR_Lock(monitor);
+    PR_Lock(lock);
     rv = ((*ptr) += val);
-    PR_Unlock(monitor);
+    PR_Unlock(lock);
     return rv;
 }
 
 PRInt32
 _PR_MD_ATOMIC_DECREMENT(PRInt32 *val)
 {
     PRInt32 rv;
 
     if (!_pr_initialized) {
         _PR_ImplicitInitialization();
     }
-    PR_Lock(monitor);
+    PR_Lock(lock);
     rv = --(*val);
-    PR_Unlock(monitor);
+    PR_Unlock(lock);
     return rv;
 }
 
 PRInt32
 _PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
 {
     PRInt32 rv;
 
     if (!_pr_initialized) {
         _PR_ImplicitInitialization();
     }
-    PR_Lock(monitor);
+    PR_Lock(lock);
     rv = *val;
     *val = newval;
-    PR_Unlock(monitor);
+    PR_Unlock(lock);
     return rv;
 }
 
 #endif  /* !_PR_HAVE_ATOMIC_OPS */
 
 void _PR_InitAtomic(void)
 {
     _PR_MD_INIT_ATOMIC();
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -276,16 +276,22 @@ ifeq ($(OS_ARCH), NCR)
 # system libraries when we built libnspr.so.
     EXTRA_LIBS = -lsocket -lnsl -ldl
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
     export LD_RUN_PATH = $(PWD)/$(DIST)/lib
 endif
 
+ifeq ($(OS_ARCH), NEXTSTEP)
+# balazs.pataki@sztaki.hu: linkage is done in a different pass in the `tests'
+# modeul, so we have to pass the `-posix' flag by "hand" to `ld'
+LDOPTS += -posix
+endif
+
 ifeq ($(OS_ARCH), NEWS-OS)
 # This hardcodes in the executable programs the directory to find
 # libnspr.so etc. at program startup.  Equivalent to the -R or -rpath 
 # option for ld on other platforms.
 #export LD_RUN_PATH = $(PWD)/$(DIST)/lib
     LIBPR = $(DIST)/lib/libnspr$(MOD_VERSION).a
     LIBPLC = $(DIST)/lib/libplc$(MOD_VERSION).a
     EXTRA_LIBS = -lsocket -lnsl -lgen -lresolv