diff options
author | wtc%netscape.com <devnull@localhost> | 1999-01-19 23:38:54 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1999-01-19 23:38:54 +0000 |
commit | ba3bdd645a7a660ef4f4bff554940b3ca45df334 (patch) | |
tree | 9939cc7db5977ec27cc1dbe0eb819b719402da29 | |
parent | 5d0037f16ed3af1fa2a8b7e11e3f632ea8b9adb3 (diff) | |
download | nspr-hg-ba3bdd645a7a660ef4f4bff554940b3ca45df334.tar.gz |
Merged the pthreads patches for BSD/OS 4.0 contributed by
Bert Driehuis <bert_driehuis@nl.compuware.com>.
Modified files: BSD_OS.mk, _pth.h, bsdi.c, ptio.c, and pr/tests/Makefile.
-rw-r--r-- | config/BSD_OS.mk | 7 | ||||
-rw-r--r-- | pr/include/md/_pth.h | 24 | ||||
-rw-r--r-- | pr/src/md/unix/bsdi.c | 7 | ||||
-rw-r--r-- | pr/src/pthreads/ptio.c | 17 | ||||
-rw-r--r-- | pr/tests/Makefile | 12 |
5 files changed, 48 insertions, 19 deletions
diff --git a/config/BSD_OS.mk b/config/BSD_OS.mk index cc385b1e..bc011bfe 100644 --- a/config/BSD_OS.mk +++ b/config/BSD_OS.mk @@ -30,7 +30,14 @@ CCC = shlicc2 endif RANLIB = ranlib +ifeq ($(USE_PTHREADS),1) +IMPL_STRATEGY = _PTH +DEFINES += -D_THREAD_SAFE +else +IMPL_STRATEGY = _EMU DEFINES += -D_PR_LOCAL_THREADS_ONLY +endif + OS_CFLAGS = -DBSDI -DHAVE_STRERROR -D__386BSD__ -DNEED_BSDREGEX -Di386 ifeq ($(OS_RELEASE),2.1) diff --git a/pr/include/md/_pth.h b/pr/include/md/_pth.h index 9ca91a74..621eaf90 100644 --- a/pr/include/md/_pth.h +++ b/pr/include/md/_pth.h @@ -49,6 +49,19 @@ * * */ +#elif defined(BSDI) +/* + * Mutex and condition attributes are not supported. The attr + * argument to pthread_mutex_init() and pthread_cond_init() must + * be passed as NULL. + */ +#define PTHREAD_MUTEXATTR_INIT(x) 0 +#define PTHREAD_MUTEXATTR_DESTROY(x) /* */ +#define PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), NULL) +#define PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m))) +#define PTHREAD_CONDATTR_INIT(x) 0 +#define PTHREAD_CONDATTR_DESTROY(x) /* */ +#define PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), NULL) #else #define PTHREAD_MUTEXATTR_INIT pthread_mutexattr_init #define PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_destroy @@ -71,7 +84,7 @@ #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(NETBSD) || defined(OPENBSD) + || defined(NETBSD) || defined(OPENBSD) || defined(BSDI) #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) @@ -130,7 +143,8 @@ * These platforms don't have sigtimedwait() */ #if (defined(AIX) && !defined(AIX4_3)) || defined(LINUX) \ - || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) + || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ + || defined(BSDI) #define PT_NO_SIGTIMEDWAIT #endif @@ -172,7 +186,8 @@ */ #define PT_PRIO_MIN 1 #define PT_PRIO_MAX 127 -#elif defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) /* XXX */ +#elif defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ + || defined(BSDI) /* XXX */ #define PT_PRIO_MIN 0 #define PT_PRIO_MAX 126 #else @@ -204,7 +219,8 @@ extern int (*_PT_aix_yield_fcn)(); nanosleep(&onemillisec,NULL); \ PR_END_MACRO #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \ - || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) + || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ + || defined(BSDI) #define PTHREAD_YIELD() sched_yield() #else #error "Need to define PTHREAD_YIELD for this platform" diff --git a/pr/src/md/unix/bsdi.c b/pr/src/md/unix/bsdi.c index dae92a47..de5ef1d2 100644 --- a/pr/src/md/unix/bsdi.c +++ b/pr/src/md/unix/bsdi.c @@ -36,13 +36,19 @@ void _MD_EarlyInit(void) PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) { +#ifndef _PR_PTHREADS if (isCurrent) { (void) setjmp(CONTEXT(t)); } *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) { @@ -91,3 +97,4 @@ _MD_CREATE_THREAD( PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for BSDI."); return PR_FAILURE; } +#endif /* ! _PR_PTHREADS */ diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index c6bd63be..5893c0d1 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -38,10 +38,8 @@ #ifdef SOLARIS #include <sys/filio.h> /* to pick up FIONREAD */ #endif -/* Linux (except glibc) and FreeBSD don't have poll */ -#if !(defined(LINUX) && !(defined(__GLIBC__) && __GLIBC__ >= 2)) \ - && !defined(FREEBSD) -#include <sys/poll.h> +#ifdef _PR_POLL_AVAILABLE +#include <poll.h> #endif #ifdef AIX /* To pick up sysconf() */ @@ -62,7 +60,7 @@ #if defined(SOLARIS) #define _PRSockOptVal_t char * #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(HPUX) \ - || defined(LINUX) || defined(FREEBSD) + || defined(LINUX) || defined(FREEBSD) || defined(BSDI) #define _PRSockOptVal_t void * #else #error "Cannot determine architecture" @@ -75,7 +73,8 @@ #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(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ + || defined(BSDI) #define _PRSelectFdSetArg_t fd_set * #else #error "Cannot determine architecture" @@ -83,7 +82,6 @@ static PRFileDesc *pt_SetMethods(PRIntn osfd, PRDescType type); -static pthread_condattr_t _pt_cvar_attr; static PRLock *_pr_flock_lock; /* For PR_LockFile() etc. */ static PRLock *_pr_rename_lock; /* For PR_Rename() */ @@ -1095,9 +1093,6 @@ void _PR_InitIO() pt_debug.timeStarted = PR_Now(); #endif - rv = PTHREAD_CONDATTR_INIT(&_pt_cvar_attr); - PR_ASSERT(0 == rv); - pt_tq.thread = NULL; _pr_flock_lock = PR_NewLock(); @@ -2529,7 +2524,7 @@ static PRIOMethods _pr_udp_methods = { #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \ || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD) \ - || defined(OPENBSD) + || defined(OPENBSD) || defined(BSDI) #define _PR_FCNTL_FLAGS O_NONBLOCK #else #error "Can't determine architecture" diff --git a/pr/tests/Makefile b/pr/tests/Makefile index c66c5216..7631ae2b 100644 --- a/pr/tests/Makefile +++ b/pr/tests/Makefile @@ -362,7 +362,11 @@ else ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10) LIBPTHREAD = -ldce else - LIBPTHREAD = -lpthread + ifeq ($(OS_ARCH),BSD_OS) + LIBPTHREAD = + else + LIBPTHREAD = -lpthread + endif endif endif endif @@ -410,7 +414,7 @@ else ifeq ($(USE_PTHREADS), 1) $(OBJDIR)/attach: $(OBJDIR)/attach.$(OBJ_SUFFIX) @$(MAKE_OBJDIR) - $(CC) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(LIBPTHREAD) -o $@ + $(CC) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@ endif @@ -452,9 +456,9 @@ clean:: ifeq ($(USE_PTHREADS), 1) $(OBJDIR)/foreign: $(OBJDIR)/foreign.o - $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(EXTRA_LIBS) $(LIBPTHREAD) -o $@ + $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@ $(OBJDIR)/provider: $(OBJDIR)/provider.o - $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(EXTRA_LIBS) $(LIBPTHREAD) -o $@ + $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(LIBPTHREAD) $(EXTRA_LIBS) -o $@ endif # |