Fixed pthreads build problems on OpenBSD (Bugzilla bug #20529) and FreeBSD.
authorwtc%netscape.com
Wed, 22 Dec 1999 23:39:09 +0000
changeset 1012 72502b3c5d144d6fd0ac8a33665159b5f86e35b9
parent 1011 89a62ea84dd982b37cd0a51b23fd74405e72bcea
child 1013 601aeea6f902c1a77c4e522659eb4308ff33947b
push idunknown
push userunknown
push dateunknown
bugs20529
Fixed pthreads build problems on OpenBSD (Bugzilla bug #20529) and FreeBSD. Modified files: _freebsd.h, _openbsd.h, ptio.c, ptsynch.c, pr/tests/Makefile
pr/include/md/_freebsd.h
pr/include/md/_openbsd.h
pr/src/pthreads/ptio.c
pr/src/pthreads/ptsynch.c
pr/tests/Makefile
--- a/pr/include/md/_freebsd.h
+++ b/pr/include/md/_freebsd.h
@@ -54,16 +54,18 @@
 /*
  * libc_r doesn't have poll().  Although libc has poll(), it is not
  * thread-safe so we can't use it in the pthreads version.
  */
 #define _PR_POLL_AVAILABLE
 #define _PR_USE_POLL
 #endif
 #endif
+#define _PR_HAVE_SYSV_SEMAPHORES
+#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #define USE_SETJMP
 
 #ifndef _PR_PTHREADS
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	sigjmp_buf
 
--- a/pr/include/md/_openbsd.h
+++ b/pr/include/md/_openbsd.h
@@ -45,16 +45,20 @@
 #define _MD_MMAP_FLAGS          MAP_PRIVATE
 
 #undef  HAVE_STACK_GROWING_UP
 #define HAVE_DLL
 #define USE_DLFCN
 #define _PR_HAVE_SOCKADDR_LEN
 #define _PR_NO_LARGE_FILES
 #define _PR_STAT_HAS_ST_ATIMESPEC
+#define _PR_POLL_AVAILABLE
+#define _PR_USE_POLL
+#define _PR_HAVE_SYSV_SEMAPHORES
+#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #define USE_SETJMP
 
 #ifndef _PR_PTHREADS
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	sigjmp_buf
 
@@ -199,15 +203,16 @@ struct _MDCPU {
 #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)
+#include <poll.h>
 #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
 
 #if OpenBSD1_3 == 1L
 typedef unsigned int nfds_t;
 #endif
 
 #endif /* nspr_openbsd_defs_h___ */
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -118,17 +118,17 @@ 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(NTO) || defined(OPENBSD)
 #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)
--- a/pr/src/pthreads/ptsynch.c
+++ b/pr/src/pthreads/ptsynch.c
@@ -755,17 +755,18 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphor
 #ifdef _PR_HAVE_SYSV_SEMAPHORES
 
 #include <fcntl.h>
 #include <sys/sem.h>
 
 /*
  * From the semctl(2) man page in glibc 2.0
  */
-#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
+#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
+    || defined(FREEBSD) || defined(OPENBSD)
 /* union semun is defined by including <sys/sem.h> */
 #else
 /* according to X/OPEN we have to define it ourselves */
 union semun {
     int val;
     struct semid_ds *buf;
     unsigned short  *array;
 };
--- a/pr/tests/Makefile
+++ b/pr/tests/Makefile
@@ -392,43 +392,38 @@ endif
 
 ifeq ($(OS_ARCH),FreeBSD)
 ifeq ($(USE_PTHREADS),1)
 LDOPTS += -pthread
 endif
 LDOPTS += -Xlinker -R $(ABSOLUTE_LIB_DIR)
 endif
 
+ifeq ($(OS_ARCH),OpenBSD)
+ifeq ($(USE_PTHREADS),1)
+LDOPTS += -pthread
+endif
+endif
+
 ifeq ($(OS_ARCH),BSD_OS)
 ifneq ($(OS_RELEASE),1.1)
 EXTRA_LIBS = -ldl
 endif
 endif
 
 ifeq ($(USE_PTHREADS),1)
+LIBPTHREAD = -lpthread
 ifeq ($(OS_ARCH),AIX)
 LIBPTHREAD = -lpthreads
-else
-  ifeq ($(OS_ARCH),FreeBSD)
-  LIBPTHREAD =
-  else
-    ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
-    LIBPTHREAD = -ldce
-    else
-      ifeq ($(OS_ARCH),BSD_OS)
-      LIBPTHREAD =
-      else
-        ifeq ($(OS_ARCH),NTO)
-         LIBPTHREAD =
-        else
-         LIBPTHREAD = -lpthread
-        endif
-      endif
-    endif
-  endif
+endif
+ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO,$(OS_ARCH)))
+LIBPTHREAD =
+endif
+ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
+LIBPTHREAD = -ldce
 endif
 endif
 
 #####################################################
 #
 # The rules
 #
 #####################################################