From fc47bba6a3af7735cde0395e2f19b1b15e17dfb7 Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Tue, 11 Aug 1998 22:29:48 +0000 Subject: [PATCH] Checked in DG/UX port contributed by Marc Fraioli . New files: dgux.mk, _dgux.cfg, _dgux.h, and dgux.c. Files changed: lib/msgc/tests/Makefile, pr/include/md/Makefile, _unixos.h, prosdep.h, prsocket.c, pr/src/md/unix/Makefile, pr/src/md/unix/objs.mk, unix.c. --- nsprpub/config/dgux.mk | 42 +++++++++ nsprpub/lib/msgc/tests/Makefile | 4 + nsprpub/pr/include/md/Makefile | 4 + nsprpub/pr/include/md/_dgux.cfg | 121 ++++++++++++++++++++++++ nsprpub/pr/include/md/_dgux.h | 162 ++++++++++++++++++++++++++++++++ nsprpub/pr/include/md/_unixos.h | 2 +- nsprpub/pr/include/md/prosdep.h | 3 + nsprpub/pr/src/io/prsocket.c | 8 -- nsprpub/pr/src/md/unix/Makefile | 7 ++ nsprpub/pr/src/md/unix/dgux.c | 90 ++++++++++++++++++ nsprpub/pr/src/md/unix/objs.mk | 7 ++ nsprpub/pr/src/md/unix/unix.c | 2 +- 12 files changed, 442 insertions(+), 10 deletions(-) create mode 100644 nsprpub/config/dgux.mk create mode 100644 nsprpub/pr/include/md/_dgux.cfg create mode 100644 nsprpub/pr/include/md/_dgux.h create mode 100644 nsprpub/pr/src/md/unix/dgux.c diff --git a/nsprpub/config/dgux.mk b/nsprpub/config/dgux.mk new file mode 100644 index 00000000000..73a4a1a0662 --- /dev/null +++ b/nsprpub/config/dgux.mk @@ -0,0 +1,42 @@ +# +# The contents of this file are subject to the Netscape Public License +# Version 1.0 (the "NPL"); you may not use this file except in +# compliance with the NPL. You may obtain a copy of the NPL at +# http://www.mozilla.org/NPL/ +# +# Software distributed under the NPL is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL +# for the specific language governing rights and limitations under the +# NPL. +# +# The Initial Developer of this code under the NPL is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998 Netscape Communications Corporation. All Rights +# Reserved. +# + +# +# Config stuff for Data General DG/UX +# +# Initial DG/UX port by Marc Fraioli +# + +include $(MOD_DEPTH)/config/UNIX.mk + +CC = gcc +CCC = g++ + +RANLIB = true + +DEFINES += -D_PR_LOCAL_THREADS_ONLY +OS_CFLAGS = -DSVR4 -DSYSV -DDGUX -D_DGUX_SOURCE -D_POSIX4A_DRAFT6_SOURCE + +MKSHLIB = $(LD) $(DSO_LDOPTS) +DSO_LDOPTS = -G + +CPU_ARCH = x86 +ARCH = dgux + +NOSUCHFILE = /no-such-file + +OPTIMIZER = diff --git a/nsprpub/lib/msgc/tests/Makefile b/nsprpub/lib/msgc/tests/Makefile index abe5cdb74c9..fd79af359c2 100644 --- a/nsprpub/lib/msgc/tests/Makefile +++ b/nsprpub/lib/msgc/tests/Makefile @@ -212,6 +212,10 @@ ifeq ($(OS_ARCH),BSD_OS) EXTRA_LIBS = -ldl endif +ifeq ($(OS_ARCH),dgux) +EXTRA_LIBS = -lsocket -lnsl -ldl +endif + ##################################################### # # The rules diff --git a/nsprpub/pr/include/md/Makefile b/nsprpub/pr/include/md/Makefile index c16e3508c73..db9289d2993 100644 --- a/nsprpub/pr/include/md/Makefile +++ b/nsprpub/pr/include/md/Makefile @@ -107,6 +107,10 @@ ifeq ($(OS_ARCH),NCR) MDCPUCFG_H = _ncr.cfg endif +ifeq ($(OS_ARCH),dgux) +MDCPUCFG_H = _dgux.cfg +endif + export:: $(HEADERS) $(MDCPUCFG_H) $(INSTALL) -m 444 $(HEADERS) $(DIST)/include/md $(INSTALL) -m 444 $(MDCPUCFG_H) $(DIST)/include diff --git a/nsprpub/pr/include/md/_dgux.cfg b/nsprpub/pr/include/md/_dgux.cfg new file mode 100644 index 00000000000..ade4c03ea9c --- /dev/null +++ b/nsprpub/pr/include/md/_dgux.cfg @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_UNIX +#define XP_UNIX +#endif + +#ifndef DGUX +#define DGUX +#endif + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#undef HAVE_ALIGNED_DOUBLES +#undef HAVE_ALIGNED_LONGLONGS + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define _PR_USE_POLL +#define _PR_POLL_AVAILABLE + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/nsprpub/pr/include/md/_dgux.h b/nsprpub/pr/include/md/_dgux.h new file mode 100644 index 00000000000..2c3e4f49b68 --- /dev/null +++ b/nsprpub/pr/include/md/_dgux.h @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nspr_dgux_defs_h___ +#define nspr_dgux_defs_h___ + +/* + * Internal configuration macros + */ + +#define PR_LINKER_ARCH "dgux" +#define _PR_SI_SYSNAME "DGUX" +#define _PR_SI_ARCHITECTURE "x86" +#define PR_DLL_SUFFIX ".so" + +#define _PR_VMBASE 0x30000000 +#define _PR_STACK_VMBASE 0x50000000 +#define _MD_DEFAULT_STACK_SIZE 65536L +#define _MD_MMAP_FLAGS MAP_PRIVATE + +#ifndef HAVE_WEAK_IO_SYMBOLS +#define HAVE_WEAK_IO_SYMBOLS +#endif + +#undef HAVE_STACK_GROWING_UP +#define HAVE_NETCONFIG +#define HAVE_DLL +#define USE_DLFCN +#define NEED_STRFTIME_LOCK +#define NEED_TIME_R +#define _PR_NEED_STRCASECMP + +#define USE_SETJMP + +#include + +#define _SETJMP setjmp +#define _LONGJMP longjmp +#define _PR_CONTEXT_TYPE jmp_buf +#define _MD_GET_SP(_t) (_t)->md.context[4] +#define _PR_NUM_GCREGS _JBLEN + +#define CONTEXT(_th) ((_th)->md.context) + +/* +** Initialize the thread context preparing it to execute _main. +*/ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + *status = PR_TRUE; \ + if(_SETJMP(CONTEXT(_thread))) (*_main)(); \ + _MD_GET_SP(_thread) = (int) ((_sp) - 128); \ +} + +#define _MD_SWITCH_CONTEXT(_thread) \ + if (!_SETJMP(CONTEXT(_thread))) { \ + (_thread)->md.errcode = errno; \ + _PR_Schedule(); \ + } + +/* +** Restore a thread context, saved by _MD_SWITCH_CONTEXT +*/ +#define _MD_RESTORE_CONTEXT(_thread) \ +{ \ + errno = (_thread)->md.errcode; \ + _MD_SET_CURRENT_THREAD(_thread); \ + _LONGJMP(CONTEXT(_thread), 1); \ +} + +/* Machine-dependent (MD) data structures. + * Don't use SVR4 native threads (yet). + */ + +struct _MDThread { + _PR_CONTEXT_TYPE context; + int id; + int errcode; +}; + +struct _MDThreadStack { + PRInt8 notused; +}; + +struct _MDLock { + PRInt8 notused; +}; + +struct _MDSemaphore { + PRInt8 notused; +}; + +struct _MDCVar { + PRInt8 notused; +}; + +struct _MDSegment { + PRInt8 notused; +}; + +struct _MDCPU { + struct _MDCPU_Unix md_unix; +}; + +#define _MD_INIT_LOCKS() +#define _MD_NEW_LOCK(lock) PR_SUCCESS +#define _MD_FREE_LOCK(lock) +#define _MD_LOCK(lock) +#define _MD_UNLOCK(lock) +#define _MD_INIT_IO() +#define _MD_IOQ_LOCK() +#define _MD_IOQ_UNLOCK() + +/* + * The following are copied from _sunos.h, _aix.h. This means + * some of them should probably be moved into _unixos.h. But + * _irix.h seems to be quite different in regard to these macros. + */ +#define _MD_GET_INTERVAL _PR_UNIX_GetInterval +#define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond + +#define _MD_EARLY_INIT _MD_EarlyInit +#define _MD_FINAL_INIT _PR_UnixInit +#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) +#define _MD_INIT_THREAD _MD_InitializeThread +#define _MD_EXIT_THREAD(thread) +#define _MD_SUSPEND_THREAD(thread) +#define _MD_RESUME_THREAD(thread) +#define _MD_CLEAN_THREAD(_thread) + +/* + * We wrapped the select() call. _MD_SELECT refers to the built-in, + * unwrapped version. + */ +#include +#include +#include +extern int _select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *execptfds, struct timeval *timeout); +#define _MD_SELECT _select + +#define _MD_POLL _poll +#include +#include +extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout); + +#endif /* nspr_dgux_defs_h___ */ diff --git a/nsprpub/pr/include/md/_unixos.h b/nsprpub/pr/include/md/_unixos.h index 5a27cda42bc..4555a948008 100644 --- a/nsprpub/pr/include/md/_unixos.h +++ b/nsprpub/pr/include/md/_unixos.h @@ -50,7 +50,7 @@ || defined(BSDI) || defined(SONY) #include #elif defined(SUNOS4) || defined(SCO) || defined(FREEBSD) \ - || defined(NETBSD) || defined(RHAPSODY) + || defined(NETBSD) || defined(RHAPSODY) || defined(DGUX) #include #elif defined(LINUX) #include diff --git a/nsprpub/pr/include/md/prosdep.h b/nsprpub/pr/include/md/prosdep.h index f34d2451770..bd8e6a19a16 100644 --- a/nsprpub/pr/include/md/prosdep.h +++ b/nsprpub/pr/include/md/prosdep.h @@ -104,6 +104,9 @@ PR_BEGIN_EXTERN_C #elif defined(NCR) #include "md/_ncr.h" +#elif defined(DGUX) +#include "md/_dgux.h" + #else #error unknown Unix flavor diff --git a/nsprpub/pr/src/io/prsocket.c b/nsprpub/pr/src/io/prsocket.c index 9c4be75c04d..d0fbcf82343 100644 --- a/nsprpub/pr/src/io/prsocket.c +++ b/nsprpub/pr/src/io/prsocket.c @@ -18,16 +18,8 @@ #include "primpl.h" -#ifdef XP_UNIX -#include -#endif #include -#if defined(SVR4) || defined(SUNOS4) -/* To pick up FIONREAD */ -#include -#endif - /************************************************************************/ /* These two functions are only used in assertions. */ diff --git a/nsprpub/pr/src/md/unix/Makefile b/nsprpub/pr/src/md/unix/Makefile index b537f8fe40c..f5e2b1f7102 100644 --- a/nsprpub/pr/src/md/unix/Makefile +++ b/nsprpub/pr/src/md/unix/Makefile @@ -105,6 +105,10 @@ SCOOS_CSRCS = \ scoos.c \ $(NULL) +DGUX_CSRCS = \ + dgux.c \ + $(NULL) + ifeq ($(PTHREADS_USER),1) CSRCS += $(PTH_USER_CSRCS) endif @@ -163,6 +167,9 @@ endif ifeq ($(OS_ARCH),SCOOS) CSRCS += $(SCOOS_CSRCS) endif +ifeq ($(OS_ARCH),dgux) +CSRCS += $(DGUX_CSRCS) +endif # # Some Unix platforms have an assembly language file. diff --git a/nsprpub/pr/src/md/unix/dgux.c b/nsprpub/pr/src/md/unix/dgux.c new file mode 100644 index 00000000000..5750792de32 --- /dev/null +++ b/nsprpub/pr/src/md/unix/dgux.c @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "primpl.h" + +/* + * using only NSPR threads here + * + * Copied from the UnixWare implementation. Should be kept in sync + * with ../../../include/md/_dgux.h. + */ + +#include + +void _MD_EarlyInit(void) +{ +} + +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) +{ + if (isCurrent) { + (void) setjmp(CONTEXT(t)); + } + *np = sizeof(CONTEXT(t)) / sizeof(PRWord); + return (PRWord *) CONTEXT(t); +} + +void +_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) +{ + return; +} + +PRStatus +_MD_InitializeThread(PRThread *thread) +{ + return PR_SUCCESS; +} + +PRStatus +_MD_WAIT(PRThread *thread, PRIntervalTime ticks) +{ + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); + _PR_MD_SWITCH_CONTEXT(thread); + return PR_SUCCESS; +} + +PRStatus +_MD_WAKEUP_WAITER(PRThread *thread) +{ + if (thread) { + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); + } + return PR_SUCCESS; +} + +/* These functions should not be called for DG/UX */ +void +_MD_YIELD(void) +{ + PR_NOT_REACHED("_MD_YIELD should not be called for DG/UX."); +} + +PRStatus +_MD_CREATE_THREAD( + PRThread *thread, + void (*start) (void *), + PRThreadPriority priority, + PRThreadScope scope, + PRThreadState state, + PRUint32 stackSize) +{ + PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for DG/UX."); +} + diff --git a/nsprpub/pr/src/md/unix/objs.mk b/nsprpub/pr/src/md/unix/objs.mk index 93e604707c0..9fb3e7ff3a8 100644 --- a/nsprpub/pr/src/md/unix/objs.mk +++ b/nsprpub/pr/src/md/unix/objs.mk @@ -97,6 +97,10 @@ SCOOS_CSRCS = \ scoos.c \ $(NULL) +DGUX_CSRCS = \ + dgux.c \ + $(NULL) + ifeq ($(PTHREADS_USER),1) CSRCS += $(PTH_USER_CSRCS) @@ -156,6 +160,9 @@ endif ifeq ($(OS_ARCH),SCOOS) CSRCS += $(SCOOS_CSRCS) endif +ifeq ($(OS_ARCH),dgux) +CSRCS += $(DGUX_CSRCS) +endif # # Some Unix platforms have an assembly language file. diff --git a/nsprpub/pr/src/md/unix/unix.c b/nsprpub/pr/src/md/unix/unix.c index dcd31820884..c3abd13109b 100644 --- a/nsprpub/pr/src/md/unix/unix.c +++ b/nsprpub/pr/src/md/unix/unix.c @@ -48,7 +48,7 @@ || defined(SUNOS4) || defined(NCR) || defined(RHAPSODY) #define _PRSockLen_t int #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \ - || defined(NETBSD) || defined(UNIXWARE) + || defined(NETBSD) || defined(UNIXWARE) || defined(DGUX) #define _PRSockLen_t size_t #else #error "Cannot determine architecture"