diff options
author | wtc%netscape.com <devnull@localhost> | 1999-06-28 23:13:18 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1999-06-28 23:13:18 +0000 |
commit | edaf51d05ffe0ba805d8772a118e32c3186307ea (patch) | |
tree | f331f15e571e3325cef3fa1ebf544fe4fd7e4524 | |
parent | 09a282d9c2c6d114098e25e44213720ca7c3744d (diff) | |
download | nspr-hg-edaf51d05ffe0ba805d8772a118e32c3186307ea.tar.gz |
Merged Neutrino (NTO) changes contributed by Jerry L. Kirk
<Jerry.Kirk@Nexwarecorp.com>.
Modified files: pr/include/md/Makefile, _pth.h, prosdep.h,
pr/src/md/unix/Makefile, objs.mk, unix.c, unix_errors.c,
ptio.c, ptthread.c.
Added files: NTO.mk, _nto.cfg, _nto.h, nto.c.
-rw-r--r-- | config/NTO.mk | 51 | ||||
-rw-r--r-- | pr/include/md/Makefile | 4 | ||||
-rw-r--r-- | pr/include/md/_nto.cfg | 129 | ||||
-rw-r--r-- | pr/include/md/_nto.h | 196 | ||||
-rw-r--r-- | pr/include/md/_pth.h | 12 | ||||
-rw-r--r-- | pr/include/md/prosdep.h | 3 | ||||
-rw-r--r-- | pr/src/md/unix/Makefile | 8 | ||||
-rw-r--r-- | pr/src/md/unix/nto.c | 47 | ||||
-rw-r--r-- | pr/src/md/unix/objs.mk | 7 | ||||
-rw-r--r-- | pr/src/md/unix/unix.c | 48 | ||||
-rw-r--r-- | pr/src/md/unix/unix_errors.c | 5 | ||||
-rw-r--r-- | pr/src/pthreads/ptio.c | 7 | ||||
-rw-r--r-- | pr/src/pthreads/ptthread.c | 13 |
13 files changed, 522 insertions, 8 deletions
diff --git a/config/NTO.mk b/config/NTO.mk new file mode 100644 index 00000000..7cdd9665 --- /dev/null +++ b/config/NTO.mk @@ -0,0 +1,51 @@ +# +# The contents of this file are subject to the Netscape Public License +# Version 1.1 (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 Neutrino +###################################################################### + +include $(MOD_DEPTH)/config/UNIX.mk + +CPU_ARCH = x86 +AR = qcc -Vgcc_ntox86 -M -a $@ +CC = qcc -Vgcc_ntox86 -shared +LD = $(CC) +CCC = $(CC) +OS_CFLAGS = -Wc,-Wall -Wc,-Wno-parentheses -DNTO -DNTO2 -Di386 \ + -D_QNX_SOURCE -DNO_REGEX \ + -DSTRINGS_ALIGNED -D__i386__ -D__QNXNTO__ -DPIC \ + -DHAVE_POINTER_LOCALTIME_R +COMPILER_TAG = _qcc +MKSHLIB = qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -g2 -M + +RANLIB = ranlib +G++INCLUDES = +OS_LIBS = +XLDOPTS = + +ifdef USE_PTHREADS + IMPL_STRATEGY = _PTH +else + IMPL_STRATEGY = _EMU +endif + +NOSUCHFILE = /no-such-file + +GARBAGE = $(wildcard *.err) + +
\ No newline at end of file diff --git a/pr/include/md/Makefile b/pr/include/md/Makefile index b976d2d1..f6b1ca37 100644 --- a/pr/include/md/Makefile +++ b/pr/include/md/Makefile @@ -139,6 +139,10 @@ ifeq ($(OS_ARCH),QNX) MDCPUCFG_H = _qnx.cfg endif +ifeq ($(OS_ARCH),NTO) +MDCPUCFG_H = _nto.cfg +endif + ifeq ($(OS_ARCH),BeOS) MDCPUCFG_H = _beos.cfg endif diff --git a/pr/include/md/_nto.cfg b/pr/include/md/_nto.cfg new file mode 100644 index 00000000..584aa10b --- /dev/null +++ b/pr/include/md/_nto.cfg @@ -0,0 +1,129 @@ +/* -*- 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.1 (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 NTO +#define NTO +#endif + +#ifdef __i386__ + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1L +#define PR_BYTES_PER_SHORT 2L +#define PR_BYTES_PER_INT 4L +#define PR_BYTES_PER_INT64 8L +#define PR_BYTES_PER_LONG 4L +#define PR_BYTES_PER_FLOAT 4L +#define PR_BYTES_PER_DOUBLE 8L +#define PR_BYTES_PER_WORD 4L +#define PR_BYTES_PER_DWORD 8L + +#define PR_BITS_PER_BYTE 8L +#define PR_BITS_PER_SHORT 16L +#define PR_BITS_PER_INT 32L +#define PR_BITS_PER_INT64 64L +#define PR_BITS_PER_LONG 32L +#define PR_BITS_PER_FLOAT 32L +#define PR_BITS_PER_DOUBLE 64L +#define PR_BITS_PER_WORD 32L + +#define PR_BITS_PER_BYTE_LOG2 3L +#define PR_BITS_PER_SHORT_LOG2 4L +#define PR_BITS_PER_INT_LOG2 5L +#define PR_BITS_PER_INT64_LOG2 6L +#define PR_BITS_PER_LONG_LOG2 5L +#define PR_BITS_PER_FLOAT_LOG2 5L +#define PR_BITS_PER_DOUBLE_LOG2 6L +#define PR_BITS_PER_WORD_LOG2 5L + +#define PR_ALIGN_OF_SHORT 2L +#define PR_ALIGN_OF_INT 4L +#define PR_ALIGN_OF_LONG 4L +#define PR_ALIGN_OF_INT64 4L +#define PR_ALIGN_OF_FLOAT 4L +#define PR_ALIGN_OF_DOUBLE 4L +#define PR_ALIGN_OF_POINTER 4L +#define PR_ALIGN_OF_WORD 4L + +#define PR_BYTES_PER_WORD_LOG2 2L +#define PR_BYTES_PER_DWORD_LOG2 3L +#define PR_WORDS_PER_DWORD_LOG2 1L + +#else + +#error Undefined CPU Architecture + +#endif + +#define HAVE_LONG_LONG + +#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/pr/include/md/_nto.h b/pr/include/md/_nto.h new file mode 100644 index 00000000..d157aead --- /dev/null +++ b/pr/include/md/_nto.h @@ -0,0 +1,196 @@ +/* -*- 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.1 (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_nto_defs_h___ +#define nspr_nto_defs_h___ + +/* +** Internal configuration macros +*/ +#define PR_LINKER_ARCH "nto" +#define _PR_SI_SYSNAME "NTO" +#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 _PR_POLL_AVAILABLE +#undef _PR_USE_POLL +#define _PR_HAVE_SOCKADDR_LEN +#undef HAVE_BSD_FLOCK +#define HAVE_FCNTL_FILE_LOCKING +#define _PR_NO_LARGE_FILES +#define _PR_STAT_HAS_ONLY_ST_ATIME + +#include <sys/select.h> + +#undef HAVE_STACK_GROWING_UP +#define HAVE_DLL +#define USE_DLFCN +#define NEED_STRFTIME_LOCK +#define NEED_TIME_R +#define _PR_NEED_STRCASECMP + +#ifndef HAVE_STRERROR +#define HAVE_STRERROR +#endif + +#define USE_SETJMP + +#include <setjmp.h> + +#define _SETJMP setjmp +#define _LONGJMP longjmp +#define _PR_CONTEXT_TYPE jmp_buf +#define _PR_NUM_GCREGS _JBLEN +#define _MD_GET_SP(_t) (_t)->md.context[7] + +#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. +*/ +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; +}; + +/* +** md-specific cpu structure field +*/ +#define _PR_MD_MAX_OSFD FD_SETSIZE + +struct _MDCPU_Unix { + PRCList ioQ; + PRUint32 ioq_timeout; + PRInt32 ioq_max_osfd; + PRInt32 ioq_osfd_cnt; +#ifndef _PR_USE_POLL + fd_set fd_read_set, fd_write_set, fd_exception_set; + PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD]; +#else + struct pollfd *ioq_pollfds; + int ioq_pollfds_size; +#endif +}; + +#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) +#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) +#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) +#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) +#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) +#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) +#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) +#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) +#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) +#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) +#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) +#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) +#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) + +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 + +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() + +#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 <sys/time.h> +#include <sys/types.h> +#include <sys/select.h> +#define _MD_SELECT select + +#endif /* nspr_nto_defs_h___ */ diff --git a/pr/include/md/_pth.h b/pr/include/md/_pth.h index 280542cb..5edae533 100644 --- a/pr/include/md/_pth.h +++ b/pr/include/md/_pth.h @@ -93,7 +93,7 @@ #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \ || defined(HPUX) || defined(LINUX) || defined(FREEBSD) \ || defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \ - || defined(VMS) + || defined(VMS) || defined(NTO) #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) @@ -186,6 +186,14 @@ #elif defined(LINUX) #define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER) #define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER) +#elif defined(NTO) +/* + * Neutrino has functions that return the priority range but + * they return invalid numbers, so I just hard coded these here + * for now. Jerry.Kirk@Nexarecorp.com + */ +#define PT_PRIO_MIN 0 +#define PT_PRIO_MAX 30 #elif defined(SOLARIS) /* * Solaris doesn't seem to have macros for the min/max priorities. @@ -229,7 +237,7 @@ extern int (*_PT_aix_yield_fcn)(); PR_END_MACRO #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \ || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) + || defined(BSDI) || defined(NTO) #define PTHREAD_YIELD() sched_yield() #else #error "Need to define PTHREAD_YIELD for this platform" diff --git a/pr/include/md/prosdep.h b/pr/include/md/prosdep.h index 39f8abee..f09cf792 100644 --- a/pr/include/md/prosdep.h +++ b/pr/include/md/prosdep.h @@ -116,6 +116,9 @@ PR_BEGIN_EXTERN_C #elif defined(VMS) #include "md/_openvms.h" +#elif defined(NTO) +#include "md/_nto.h" + #else #error unknown Unix flavor diff --git a/pr/src/md/unix/Makefile b/pr/src/md/unix/Makefile index aed65a70..b38c9e6a 100644 --- a/pr/src/md/unix/Makefile +++ b/pr/src/md/unix/Makefile @@ -126,6 +126,10 @@ QNX_CSRCS = \ qnx.c \ $(NULL) +NTO_CSRCS = \ + nto.c \ + $(NULL) + ifeq ($(PTHREADS_USER),1) CSRCS += $(PTH_USER_CSRCS) endif @@ -197,8 +201,12 @@ ifeq ($(OS_ARCH),DGUX) CSRCS += $(DGUX_CSRCS) endif ifeq ($(OS_ARCH),QNX) +ifeq ($(OS_TARGET),NTO) +CSRCS += $(NTO_CSRCS) +else CSRCS += $(QNX_CSRCS) endif +endif # # Some Unix platforms have an assembly language file. diff --git a/pr/src/md/unix/nto.c b/pr/src/md/unix/nto.c new file mode 100644 index 00000000..68e362a5 --- /dev/null +++ b/pr/src/md/unix/nto.c @@ -0,0 +1,47 @@ +/* -*- 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.1 (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" + +#include <setjmp.h> + +/* Fake this out */ +int socketpair (int foo, int foo2, int foo3, int sv[2]) +{ + printf("error in socketpair\n"); + exit (-1); +} + +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 +} diff --git a/pr/src/md/unix/objs.mk b/pr/src/md/unix/objs.mk index a6e50900..6ca4ca52 100644 --- a/pr/src/md/unix/objs.mk +++ b/pr/src/md/unix/objs.mk @@ -118,6 +118,9 @@ QNX_CSRCS = \ qnx.c \ $(NULL) +NTO_CSRCS = \ + nto.c \ + $(NULL) ifeq ($(PTHREADS_USER),1) CSRCS += $(PTH_USER_CSRCS) @@ -190,8 +193,12 @@ ifeq ($(OS_ARCH),DGUX) CSRCS += $(DGUX_CSRCS) endif ifeq ($(OS_ARCH),QNX) +ifeq ($(OS_TARGET),NTO) +CSRCS += $(NTO_CSRCS) +else CSRCS += $(QNX_CSRCS) endif +endif # # Some Unix platforms have an assembly language file. diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c index c4731823..a4d17425 100644 --- a/pr/src/md/unix/unix.c +++ b/pr/src/md/unix/unix.c @@ -52,7 +52,7 @@ #define _PRSockLen_t int #elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \ || defined(NETBSD) || defined(OPENBSD) || defined(UNIXWARE) \ - || defined(DGUX) || defined(VMS) + || defined(DGUX) || defined(VMS) || defined(NTO) #define _PRSockLen_t size_t #else #error "Cannot determine architecture" @@ -3420,7 +3420,51 @@ void PR_XNotifyAll(void) PR_NotifyAll(_pr_Xfe_mon); } -#ifdef HAVE_BSD_FLOCK +#if defined(HAVE_FCNTL_FILE_LOCKING) + +PR_IMPLEMENT(PRStatus) +_MD_LockFile(PRInt32 f) +{ + PRInt32 rv; + struct flock arg; + + arg.l_type = F_WRLCK; + rv = fcntl(f, F_SETLKW, &arg); + if (rv == 0) + return PR_SUCCESS; + _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO()); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) +_MD_TLockFile(PRInt32 f) +{ + PRInt32 rv; + struct flock arg; + + arg.l_type = F_WRLCK; + rv = fcntl(f, F_SETLK, &arg); + if (rv == 0) + return PR_SUCCESS; + _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO()); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) +_MD_UnlockFile(PRInt32 f) +{ + PRInt32 rv; + struct flock arg; + + arg.l_type = F_UNLCK; + rv = fcntl(f, F_SETLK, &arg); + if (rv == 0) + return PR_SUCCESS; + _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO()); + return PR_FAILURE; +} + +#elif defined(HAVE_BSD_FLOCK) #include <sys/file.h> diff --git a/pr/src/md/unix/unix_errors.c b/pr/src/md/unix/unix_errors.c index e33dbe8b..c3321cf3 100644 --- a/pr/src/md/unix/unix_errors.c +++ b/pr/src/md/unix/unix_errors.c @@ -42,7 +42,10 @@ static void _MD_unix_map_default_error(int err) case EAGAIN: prError = PR_WOULD_BLOCK_ERROR; break; -#ifndef QNX + /* + * On QNX and Neutrino, EALREADY is defined as EBUSY. + */ +#if EALREADY != EBUSY case EALREADY: prError = PR_ALREADY_INITIATED_ERROR; break; diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index b44c45fd..c67f6aa1 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -123,7 +123,8 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; #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(LINUX) || defined(FREEBSD) || defined(BSDI) || defined(VMS) \ + || defined(NTO) #define _PRSockOptVal_t void * #else #error "Cannot determine architecture" @@ -137,7 +138,7 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; || defined(OSF1) || defined(SOLARIS) \ || defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) \ || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) || defined(VMS) + || defined(BSDI) || defined(VMS) || defined(NTO) #define _PRSelectFdSetArg_t fd_set * #else #error "Cannot determine architecture" @@ -2814,7 +2815,7 @@ static PRIOMethods _pr_socketpollfd_methods = { #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \ || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD) \ - || defined(OPENBSD) || defined(BSDI) || defined(VMS) + || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) #define _PR_FCNTL_FLAGS O_NONBLOCK #else #error "Can't determine architecture" diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index 6e06e652..54bfa29e 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -62,8 +62,17 @@ static void init_pthread_gc_support(void); #if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING) static PRIntn pt_PriorityMap(PRThreadPriority pri) { +#ifdef NTO + /* This priority algorithm causes lots of problems on Neutrino + * for now I have just hard coded everything to run at priority 10 + * until I can come up with a new algorithm. + * Jerry.Kirk@Nexwarecorp.com + */ + return 10; +#else return pt_book.minPrio + pri * (pt_book.maxPrio - pt_book.minPrio) / PR_PRIORITY_LAST; +#endif } #endif @@ -271,6 +280,10 @@ static PRThread* _PR_CreateThread( schedule.sched_priority = pt_PriorityMap(priority); rv = pthread_attr_setschedparam(&tattr, &schedule); PR_ASSERT(0 == rv); +#ifdef NTO + rv = pthread_attr_setschedpolicy(&tattr, SCHED_RR); /* Round Robin */ + PR_ASSERT(0 == rv); +#endif #endif /* !defined(_PR_DCETHREADS) */ } |