From ce35f2bc2089628f974c361001d0880963964238 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Wed, 22 Dec 1999 23:39:09 +0000 Subject: [PATCH] Fixed pthreads build problems on OpenBSD (Bugzilla bug #20529) and FreeBSD. Modified files: _freebsd.h, _openbsd.h, ptio.c, ptsynch.c, pr/tests/Makefile --- nsprpub/pr/include/md/_freebsd.h | 2 ++ nsprpub/pr/include/md/_openbsd.h | 5 +++++ nsprpub/pr/src/pthreads/ptio.c | 2 +- nsprpub/pr/src/pthreads/ptsynch.c | 3 ++- nsprpub/pr/tests/Makefile | 31 +++++++++++++------------------ 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/nsprpub/pr/include/md/_freebsd.h b/nsprpub/pr/include/md/_freebsd.h index 6a199aca5c8..22dfa668838 100644 --- a/nsprpub/pr/include/md/_freebsd.h +++ b/nsprpub/pr/include/md/_freebsd.h @@ -59,6 +59,8 @@ #define _PR_USE_POLL #endif #endif +#define _PR_HAVE_SYSV_SEMAPHORES +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY #define USE_SETJMP diff --git a/nsprpub/pr/include/md/_openbsd.h b/nsprpub/pr/include/md/_openbsd.h index ef61583668a..5d8d3e20c37 100644 --- a/nsprpub/pr/include/md/_openbsd.h +++ b/nsprpub/pr/include/md/_openbsd.h @@ -50,6 +50,10 @@ #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 @@ -204,6 +208,7 @@ struct _MDCPU { * unwrapped version. */ #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv) +#include #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout) #if OpenBSD1_3 == 1L diff --git a/nsprpub/pr/src/pthreads/ptio.c b/nsprpub/pr/src/pthreads/ptio.c index a1f4695e30b..c33fa5a50ec 100644 --- a/nsprpub/pr/src/pthreads/ptio.c +++ b/nsprpub/pr/src/pthreads/ptio.c @@ -123,7 +123,7 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; #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" diff --git a/nsprpub/pr/src/pthreads/ptsynch.c b/nsprpub/pr/src/pthreads/ptsynch.c index 119e9e47d22..0731786e64a 100644 --- a/nsprpub/pr/src/pthreads/ptsynch.c +++ b/nsprpub/pr/src/pthreads/ptsynch.c @@ -760,7 +760,8 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) /* * 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 */ #else /* according to X/OPEN we have to define it ourselves */ diff --git a/nsprpub/pr/tests/Makefile b/nsprpub/pr/tests/Makefile index 347dd5ba5ec..b3138a061af 100644 --- a/nsprpub/pr/tests/Makefile +++ b/nsprpub/pr/tests/Makefile @@ -397,6 +397,12 @@ 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 @@ -404,26 +410,15 @@ 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