Bugzilla bug #31697: merged the Mac OS X (Darwin) port onto the NSPRPUB_CLIENT_BRANCH SeaMonkey_M15_BASE SeaMonkey_M15_RELEASE
authorwtc%netscape.com
Tue, 04 Apr 2000 00:27:26 +0000
branchNSPRPUB_CLIENT_BRANCH
changeset 1284 697114293ecd6e1760ce27f225c05960f4d025f8
parent 1283 8a9771507b81d779b8a7c80ff376a107e2b3556a
child 1285 35ba8be05c55d34dbd1cb3481acd941b0a26ba0b
child 1288 0f1540dcb2ae16a5f1d4809782aaabad3d1670f4
push idunknown
push userunknown
push dateunknown
bugs31697
Bugzilla bug #31697: merged the Mac OS X (Darwin) port onto the NSPRPUB_CLIENT_BRANCH. Modified files: Rhapsody.mk, arch.mk, _pth.h, _rhapsody.h, prlink.c, rhapsody.c, uxproces.c, uxrng.c, ptio.c, pr/tests/Makefile, pr/tests/Makefile.in
config/Rhapsody.mk
config/arch.mk
pr/include/md/_darwin.h
pr/include/md/_pth.h
pr/include/md/_rhapsody.h
pr/src/linking/prlink.c
pr/src/md/unix/darwin.c
pr/src/md/unix/rhapsody.c
pr/src/md/unix/uxproces.c
pr/src/md/unix/uxrng.c
pr/src/pthreads/ptio.c
pr/tests/Makefile
pr/tests/Makefile.in
--- a/config/Rhapsody.mk
+++ b/config/Rhapsody.mk
@@ -16,22 +16,29 @@
 #
 
 #
 # Config stuff for Rhapsody
 #
 
 include $(MOD_DEPTH)/config/UNIX.mk
 
+#
+# The default implementation strategy for Rhapsody is pthreads.
+#
+ifeq ($(CLASSIC_NSPR),1)
+IMPL_STRATEGY   = _EMU
+DEFINES         += -D_PR_LOCAL_THREADS_ONLY
+else
+USE_PTHREADS    = 1
+IMPL_STRATEGY   = _PTH
+endif
+
 CC              = cc
-ifeq ($(OS_RELEASE),5.0)
-CCC             = cc++
-else
 CCC             = c++
-endif
 RANLIB			= ranlib
 
 ifeq (86,$(findstring 86,$(OS_TEST)))
 OS_REL_CFLAGS   = -mno-486 -Di386
 CPU_ARCH        = i386
 else
 OS_REL_CFLAGS   = -Dppc
 CPU_ARCH		= ppc
@@ -44,18 +51,16 @@ endif
 # or it may be a declaration of a symbol defined in another file:
 #     extern int x;
 # Use the -fno-common option to force all commons to become true
 # definitions so that the linker can catch multiply-defined symbols.
 # Also, common symbols are not allowed with Rhapsody dynamic libraries.
 
 OS_CFLAGS		= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wmost -fno-common -pipe -DRHAPSODY -DHAVE_STRERROR -DHAVE_BSD_FLOCK
 
-DEFINES			+= -D_PR_LOCAL_THREADS_ONLY
-
 ARCH			= rhapsody
 
 # May override this with -bundle to create a loadable module.
 DSO_LDOPTS		= -dynamiclib -compatibility_version 1 -current_version 1 -all_load
 
 MKSHLIB			= $(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS)
 DLL_SUFFIX		= dylib
 
--- a/config/arch.mk
+++ b/config/arch.mk
@@ -45,16 +45,19 @@ endif
 ifeq ($(OS_ARCH),UNIX_SV)
 ifneq ($(findstring NCR,$(shell grep NCR /etc/bcheckrc | head -1 )),)
 OS_ARCH		:= NCR
 else
 OS_ARCH		:= UNIXWARE
 OS_RELEASE	:= $(shell uname -v)
 endif
 endif
+ifeq ($(OS_ARCH),Mac OS)
+OS_ARCH		:= Rhapsody
+endif
 ifeq ($(OS_ARCH),ncr)
 OS_ARCH		:= NCR
 endif
 # This is the only way to correctly determine the actual OS version on NCR boxes.
 ifeq ($(OS_ARCH),NCR)
 OS_RELEASE	:= $(shell awk '{print $$3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$$/\2.\3/')
 endif
 ifeq ($(OS_ARCH),procnto)
--- a/pr/include/md/_darwin.h
+++ b/pr/include/md/_darwin.h
@@ -37,18 +37,18 @@
 #define _MD_DEFAULT_STACK_SIZE	65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_DLL
 #define USE_MACH_DYLD
 #define _PR_HAVE_SOCKADDR_LEN  
 #define _PR_STAT_HAS_ST_ATIMESPEC
-#define _PR_TIMESPEC_HAS_TS_SEC
 #define _PR_NO_LARGE_FILES
+#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #define USE_SETJMP
 
 #if !defined(_PR_PTHREADS)
 
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	jmp_buf
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -88,17 +88,17 @@
 #if defined(_PR_DCETHREADS)
 #define _PT_PTHREAD_ZERO_THR_HANDLE(t)        memset(&(t), 0, sizeof(pthread_t))
 #define _PT_PTHREAD_THR_HANDLE_IS_ZERO(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(NETBSD) || defined(OPENBSD) || defined(BSDI) \
-	|| defined(VMS) || defined(NTO)
+	|| defined(VMS) || defined(NTO) || defined(RHAPSODY)
 #define _PT_PTHREAD_ZERO_THR_HANDLE(t)        (t) = 0
 #define _PT_PTHREAD_THR_HANDLE_IS_ZERO(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)
@@ -199,17 +199,17 @@
  * 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) || defined(NETBSD) || defined(OPENBSD) \
-	|| defined(BSDI) /* XXX */
+	|| defined(BSDI) || defined(RHAPSODY) /* XXX */
 #define PT_PRIO_MIN            0
 #define PT_PRIO_MAX            126
 #else
 #error "pthreads is not supported for this architecture"
 #endif
 
 /*
  * The _PT_PTHREAD_YIELD function is called from a signal handler.
@@ -232,15 +232,15 @@ extern int (*_PT_aix_yield_fcn)();
 #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) \
 	|| defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
-	|| defined(BSDI) || defined(NTO)
+	|| defined(BSDI) || defined(NTO) || defined(RHAPSODY)
 #define _PT_PTHREAD_YIELD()            	sched_yield()
 #else
 #error "Need to define _PT_PTHREAD_YIELD for this platform"
 #endif
 
 #endif /* nspr_pth_defs_h_ */
--- a/pr/include/md/_rhapsody.h
+++ b/pr/include/md/_rhapsody.h
@@ -37,18 +37,18 @@
 #define _MD_DEFAULT_STACK_SIZE	65536L
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_DLL
 #define USE_MACH_DYLD
 #define _PR_HAVE_SOCKADDR_LEN  
 #define _PR_STAT_HAS_ST_ATIMESPEC
-#define _PR_TIMESPEC_HAS_TS_SEC
 #define _PR_NO_LARGE_FILES
+#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #define USE_SETJMP
 
 #if !defined(_PR_PTHREADS)
 
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	jmp_buf
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -729,17 +729,17 @@ pr_LoadLibraryByPathname(const char *nam
     }
     /* No equivalent of PR_LD_GLOBAL and PR_LD_LOCAL. */
     h = shl_load(name, shl_flags, 0L);
 #elif defined(USE_MACH_DYLD)
     NSObjectFileImage ofi;
     NSModule h = NULL;
     if (NSCreateObjectFileImageFromFile(name, &ofi)
             == NSObjectFileImageSuccess) {
-        h = NSLinkModule(ofi, name, TRUE);
+        h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE);
     }
 #else
 #error Configuration error
 #endif
     if (!h) {
         PR_DELETE(lm);
         goto unlock;
     }
@@ -1078,17 +1078,24 @@ pr_FindSymbolInLib(PRLibrary *lm, const 
 #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(USE_MACH_DYLD)
-    f = NSAddressOfSymbol(NSLookupAndBindSymbol(name));
+    {
+        NSSymbol symbol;
+        symbol = NSLookupSymbolInModule(lm->dlh, name);
+        if (symbol != NULL)
+            f = NSAddressOfSymbol(symbol);
+        else
+            f = NULL;
+    }
 #endif
 #endif /* HAVE_DLL */
 #endif /* XP_UNIX */
     if (f == NULL) {
         PR_SetError(PR_FIND_SYMBOL_ERROR, _MD_ERRNO());
         DLLErrorInternal(_MD_ERRNO());
     }
     return f;
--- a/pr/src/md/unix/darwin.c
+++ b/pr/src/md/unix/darwin.c
@@ -82,18 +82,37 @@ PRStatus
     PRThreadState state,
     PRUint32 stackSize)
 {
     PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Rhapsody.");
 	return PR_FAILURE;
 }
 #endif /* ! _PR_PTHREADS */
 
+#if defined(_PR_PTHREADS)
+
 /*
-** Whoops, we don't have a syscall stub for this
+** Stubs for unimplemented functions
 */
-int mprotect (caddr_t addr, size_t size, int prot)
+
+int pthread_condattr_init(pthread_condattr_t *attr)
+{
+    return 0;
+}
+
+int pthread_kill(pthread_t thread, int sig)
 {
-   return -1;
-} 
+    return ENOSYS;
+}
+
+typedef struct siginfo_t siginfo_t;
+
+int sigtimedwait(const sigset_t *set, siginfo_t *info,
+    const struct timespec *timeout)
+{
+    errno = ENOSYS;
+    return -1;
+}
+
+#endif /* _PR_PTHREADS */
 
 /* rhapsody.c */
 
--- a/pr/src/md/unix/rhapsody.c
+++ b/pr/src/md/unix/rhapsody.c
@@ -82,18 +82,37 @@ PRStatus
     PRThreadState state,
     PRUint32 stackSize)
 {
     PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Rhapsody.");
 	return PR_FAILURE;
 }
 #endif /* ! _PR_PTHREADS */
 
+#if defined(_PR_PTHREADS)
+
 /*
-** Whoops, we don't have a syscall stub for this
+** Stubs for unimplemented functions
 */
-int mprotect (caddr_t addr, size_t size, int prot)
+
+int pthread_condattr_init(pthread_condattr_t *attr)
+{
+    return 0;
+}
+
+int pthread_kill(pthread_t thread, int sig)
 {
-   return -1;
-} 
+    return ENOSYS;
+}
+
+typedef struct siginfo_t siginfo_t;
+
+int sigtimedwait(const sigset_t *set, siginfo_t *info,
+    const struct timespec *timeout)
+{
+    errno = ENOSYS;
+    return -1;
+}
+
+#endif /* _PR_PTHREADS */
 
 /* rhapsody.c */
 
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -22,17 +22,21 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/wait.h>
 #if defined(AIX)
 #include <dlfcn.h>  /* For dlopen, dlsym, dlclose */
 #endif
 
+#if defined(RHAPSODY)
+#include <crt_externs.h>
+#else
 extern char **environ;
+#endif
 
 /*
  * HP-UX 9 doesn't have the SA_RESTART flag.
  */
 #ifndef SA_RESTART
 #define SA_RESTART 0
 #endif
 
@@ -151,17 +155,21 @@ ForkAndExec(
     if (!process) {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
         return NULL;
     }
 
     childEnvp = envp;
     if (attr && attr->fdInheritBuffer) {
         if (NULL == childEnvp) {
+#ifdef RHAPSODY
+            childEnvp = *(_NSGetEnviron());
+#else
             childEnvp = environ;
+#endif
         }
         for (nEnv = 0; childEnvp[nEnv]; nEnv++) {
         }
         newEnvp = (char **) PR_MALLOC((nEnv + 2) * sizeof(char *));
         if (NULL == newEnvp) {
             PR_DELETE(process);
             PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
             return NULL;
--- a/pr/src/md/unix/uxrng.c
+++ b/pr/src/md/unix/uxrng.c
@@ -256,17 +256,18 @@ GetHighResClock(void *buf, size_t maxbyt
 
 #elif defined(NEC)
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     return 0;
 }
-#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) || defined(QNX)
+#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) \
+    || defined(QNX) || defined(RHAPSODY)
 #include <sys/times.h>
 
 static size_t
 GetHighResClock(void *buf, size_t maxbytes)
 {
     int ticks;
     struct tms buffer;
 
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -118,31 +118,31 @@ static ssize_t (*pt_aix_sendfile_fptr)()
 #if !(defined(LINUX) && defined(__alpha))
 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
 #endif
 
 #if defined(SOLARIS)
 #define _PRSockOptVal_t char *
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(HPUX) \
     || defined(LINUX) || defined(FREEBSD) || defined(BSDI) || defined(VMS) \
-    || defined(NTO) || defined(OPENBSD)
+    || defined(NTO) || defined(OPENBSD) || defined(RHAPSODY)
 #define _PRSockOptVal_t void *
 #else
 #error "Cannot determine architecture"
 #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(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \
-    || defined(BSDI) || defined(VMS) || defined(NTO)
+    || defined(BSDI) || defined(VMS) || defined(NTO) || defined(RHAPSODY)
 #define _PRSelectFdSetArg_t fd_set *
 #else
 #error "Cannot determine architecture"
 #endif
 
 static PRFileDesc *pt_SetMethods(
     PRIntn osfd, PRDescType type, PRBool isAcceptedSocket);
 
@@ -2419,17 +2419,18 @@ static PRIOMethods _pr_socketpollfd_meth
     (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(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO)
+    || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) \
+    || defined(RHAPSODY)
 #define _PR_FCNTL_FLAGS O_NONBLOCK
 #else
 #error "Can't determine architecture"
 #endif
 
 /*
  * Put a Unix file descriptor in non-blocking mode.
  */
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -418,17 +418,17 @@ EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(USE_PTHREADS),1)
 LIBPTHREAD = -lpthread
 ifeq ($(OS_ARCH),AIX)
 LIBPTHREAD = -lpthreads
 endif
-ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO,$(OS_ARCH)))
+ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Rhapsody,$(OS_ARCH)))
 LIBPTHREAD =
 endif
 ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
 LIBPTHREAD = -ldce
 endif
 endif
 
 #####################################################
--- a/pr/tests/Makefile.in
+++ b/pr/tests/Makefile.in
@@ -420,17 +420,17 @@ EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(USE_PTHREADS),1)
 LIBPTHREAD = -lpthread
 ifeq ($(OS_ARCH),AIX)
 LIBPTHREAD = -lpthreads
 endif
-ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO,$(OS_ARCH)))
+ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Rhapsody,$(OS_ARCH)))
 LIBPTHREAD =
 endif
 ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
 LIBPTHREAD = -ldce
 endif
 endif
 
 endif # !USE_AUTOCONF