summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Hirlimann <ludovic@mozilla.com>2019-06-29 00:06:00 +0200
committerLudovic Hirlimann <ludovic@mozilla.com>2019-06-29 00:06:00 +0200
commitf3a764c57288258e4ec0f9433e5f89d742487794 (patch)
tree100899eb865a0d8cfbc62111ce926a2769da9db4
parent97aebea7a0b68f54eabd05b90649696ec64495f4 (diff)
downloadnspr-hg-f3a764c57288258e4ec0f9433e5f89d742487794.tar.gz
Bug 1535665 - Remove support for BeOS. r=kaie
-rw-r--r--config/nsinstall.c3
-rwxr-xr-xconfigure95
-rw-r--r--configure.in53
-rw-r--r--pr/include/md/_beos.cfg120
-rw-r--r--pr/include/md/_beos.h583
-rw-r--r--pr/include/md/prosdep.h7
-rw-r--r--pr/include/obsolete/protypes.h26
-rw-r--r--pr/include/prinet.h2
-rw-r--r--pr/include/prio.h8
-rw-r--r--pr/include/private/primpl.h21
-rw-r--r--pr/include/prtypes.h16
-rw-r--r--pr/src/bthreads/.cvsignore1
-rw-r--r--pr/src/bthreads/Makefile.in31
-rw-r--r--pr/src/bthreads/bsrcs.mk17
-rw-r--r--pr/src/bthreads/btcvar.c244
-rw-r--r--pr/src/bthreads/btlocks.c91
-rw-r--r--pr/src/bthreads/btmisc.c72
-rw-r--r--pr/src/bthreads/btmon.c201
-rw-r--r--pr/src/bthreads/btsem.c98
-rw-r--r--pr/src/bthreads/btthread.c662
-rw-r--r--pr/src/bthreads/objs.mk11
-rw-r--r--pr/src/io/prfile.c11
-rw-r--r--pr/src/io/prio.c2
-rw-r--r--pr/src/io/prmapopt.c10
-rw-r--r--pr/src/io/prsocket.c19
-rw-r--r--pr/src/linking/prlink.c128
-rw-r--r--pr/src/md/beos/.cvsignore1
-rw-r--r--pr/src/md/beos/Makefile.in28
-rw-r--r--pr/src/md/beos/bcpu.c23
-rw-r--r--pr/src/md/beos/beos.c232
-rw-r--r--pr/src/md/beos/beos_errors.c1494
-rw-r--r--pr/src/md/beos/bfile.c873
-rw-r--r--pr/src/md/beos/bmemory.c10
-rw-r--r--pr/src/md/beos/bmisc.c91
-rw-r--r--pr/src/md/beos/bmmap.c41
-rw-r--r--pr/src/md/beos/bnet.c911
-rw-r--r--pr/src/md/beos/bproc.c212
-rw-r--r--pr/src/md/beos/brng.c40
-rw-r--r--pr/src/md/beos/bseg.c22
-rw-r--r--pr/src/md/beos/bsrcs.mk22
-rw-r--r--pr/src/md/beos/btime.c43
-rw-r--r--pr/src/md/beos/objs.mk11
-rw-r--r--pr/src/md/prosdep.c7
-rw-r--r--pr/src/misc/prnetdb.c8
-rw-r--r--pr/src/misc/prsystem.c9
-rw-r--r--pr/src/misc/prtime.c8
-rw-r--r--pr/src/threads/prtpd.c2
-rw-r--r--pr/tests/affinity.c10
-rw-r--r--pr/tests/attach.c32
-rwxr-xr-xpr/tests/poll_er.c10
-rwxr-xr-xpr/tests/selct_er.c10
-rw-r--r--pr/tests/suspend.c10
-rw-r--r--pr/tests/testfile.c8
-rw-r--r--pr/tests/thrpool_server.c2
-rw-r--r--pr/tests/tmocon.c2
55 files changed, 31 insertions, 6673 deletions
diff --git a/config/nsinstall.c b/config/nsinstall.c
index 464f0304..478cd47b 100644
--- a/config/nsinstall.c
+++ b/config/nsinstall.c
@@ -30,9 +30,6 @@
#define HAVE_FCHMOD
-#if defined(BEOS)
-#undef HAVE_FCHMOD
-#endif
/*
* Does getcwd() take NULL as the first argument and malloc
diff --git a/configure b/configure
index 5ac489b0..618ebe5f 100755
--- a/configure
+++ b/configure
@@ -3060,9 +3060,6 @@ if test -n "$MOZ_DEBUG"; then
DEFINES="$DEFINES -UNDEBUG"
case "${target_os}" in
- beos*)
- DEFINES="$DEFINES -DDEBUG_${USER}"
- ;;
mks*|cygwin*|mingw*|msys*|os2*)
DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
;;
@@ -5980,9 +5977,6 @@ case "$host" in
CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
fi
;;
-*-beos*)
- HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
- ;;
*os2*)
;;
*)
@@ -6338,77 +6332,6 @@ fi
RESOLVE_LINK_SYMBOLS=1
;;
-*-beos*)
- $as_echo "#define XP_BEOS 1" >>confdefs.h
-
- $as_echo "#define BeOS 1" >>confdefs.h
-
- $as_echo "#define BEOS 1" >>confdefs.h
-
- $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
-
- DSO_LDOPTS=-nostart
- MDCPUCFG_H=_beos.cfg
- USE_BTHREADS=1
- PR_MD_ARCH_DIR=beos
- RESOLVE_LINK_SYMBOLS=1
- case "${target_cpu}" in
- i*86)
- _OPTIMIZE_FLAGS=-O2
- _DEBUG_FLAGS='-gdwarf-2 -O0'
- MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr in -lbind" >&5
-$as_echo_n "checking for gethostbyaddr in -lbind... " >&6; }
-if ${ac_cv_lib_bind_gethostbyaddr+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lbind $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gethostbyaddr ();
-int
-main ()
-{
-return gethostbyaddr ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_bind_gethostbyaddr=yes
-else
- ac_cv_lib_bind_gethostbyaddr=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_gethostbyaddr" >&5
-$as_echo "$ac_cv_lib_bind_gethostbyaddr" >&6; }
-if test "x$ac_cv_lib_bind_gethostbyaddr" = xyes; then :
- OS_LIBS="$OS_LIBS -lbind -lsocket"
-fi
-
- ;;
- powerpc)
- CC=mwcc
- CCC=mwcc
- LD=mwld
- DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
- _OPTIMIZE_FLAGS=-O2
- _DEBUG_FLAGS='-g -O0'
- ;;
- esac
- ;;
-
*-bsdi*)
$as_echo "#define XP_UNIX 1" >>confdefs.h
@@ -7523,7 +7446,7 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
case $target in
-*-darwin*|*-beos*|*-os2*)
+*-darwin*|*-os2*)
;;
*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
@@ -7976,20 +7899,6 @@ if test "${enable_nspr_threads+set}" = set; then :
fi
-case "$target" in
-*-beos*)
-
-# Check whether --with-bthreads was given.
-if test "${with_bthreads+set}" = set; then :
- withval=$with_bthreads; if test "$withval" = "yes"; then
- USE_BTHREADS=1
- USE_USER_PTHREADS=
- USE_PTHREADS=
- fi
-fi
-
- ;;
-esac
fi # SKIP_LIBRARY_CHECKS
@@ -8174,7 +8083,7 @@ _ACEOF
fi
;;
-*-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*|*-beos*)
+*-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
USE_PTHREADS=
_PTHREAD_LDFLAGS=
USE_USER_PTHREADS=
diff --git a/configure.in b/configure.in
index c4169843..189f58d5 100644
--- a/configure.in
+++ b/configure.in
@@ -494,9 +494,6 @@ if test -n "$MOZ_DEBUG"; then
DEFINES="$DEFINES -UNDEBUG"
case "${target_os}" in
- beos*)
- DEFINES="$DEFINES -DDEBUG_${USER}"
- ;;
mks*|cygwin*|mingw*|msys*|os2*)
DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
;;
@@ -1166,9 +1163,6 @@ case "$host" in
CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
fi
;;
-*-beos*)
- HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
- ;;
*os2*)
;;
*)
@@ -1241,34 +1235,6 @@ case "$target" in
RESOLVE_LINK_SYMBOLS=1
;;
-*-beos*)
- AC_DEFINE(XP_BEOS)
- AC_DEFINE(BeOS)
- AC_DEFINE(BEOS)
- AC_DEFINE(_POSIX_SOURCE)
- DSO_LDOPTS=-nostart
- MDCPUCFG_H=_beos.cfg
- USE_BTHREADS=1
- PR_MD_ARCH_DIR=beos
- RESOLVE_LINK_SYMBOLS=1
- case "${target_cpu}" in
- i*86)
- _OPTIMIZE_FLAGS=-O2
- _DEBUG_FLAGS='-gdwarf-2 -O0'
- MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@'
- AC_CHECK_LIB(bind, gethostbyaddr, [OS_LIBS="$OS_LIBS -lbind -lsocket"])
- ;;
- powerpc)
- CC=mwcc
- CCC=mwcc
- LD=mwld
- DSO_LDOPTS='-xms -export pragma -init _init_routine_ -term _term_routine_ -lroot -lnet /boot/develop/lib/ppc/glue-noinit.a /boot/develop/lib/ppc/init_term_dyn.o /boot/develop/lib/ppc/start_dyn.o'
- _OPTIMIZE_FLAGS=-O2
- _DEBUG_FLAGS='-g -O0'
- ;;
- esac
- ;;
-
*-bsdi*)
AC_DEFINE(XP_UNIX)
AC_DEFINE(BSDI)
@@ -2296,7 +2262,7 @@ dnl The same goes for BeOS.
dnl OS/2 has dlfcn in libc.
case $target in
-*-darwin*|*-beos*|*-os2*)
+*-darwin*|*-os2*)
;;
*)
AC_CHECK_LIB(dl, dlopen,
@@ -2462,19 +2428,6 @@ AC_ARG_ENABLE(nspr-threads,
USE_NSPR_THREADS=1
fi])
-case "$target" in
-*-beos*)
- AC_ARG_WITH(bthreads,
- [ --with-bthreads Use system bthreads library as thread subsystem
- (BeOS only)],
- [ if test "$withval" = "yes"; then
- USE_BTHREADS=1
- USE_USER_PTHREADS=
- USE_PTHREADS=
- fi])
- ;;
-esac
-
fi # SKIP_LIBRARY_CHECKS
AC_ARG_ENABLE(ipv6,
@@ -2637,8 +2590,8 @@ case "$target" in
AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
fi
;;
-*-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*|*-beos*)
- dnl win32, os2 & beos cannot use pthreads
+*-mingw*|*-msys*|*-cygwin*|*-mks*|*-os2*)
+ dnl win32, os2 cannot use pthreads
USE_PTHREADS=
_PTHREAD_LDFLAGS=
USE_USER_PTHREADS=
diff --git a/pr/include/md/_beos.cfg b/pr/include/md/_beos.cfg
deleted file mode 100644
index 5a3c5699..00000000
--- a/pr/include/md/_beos.cfg
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nspr_cpucfg___
-#define nspr_cpucfg___
-
-#ifndef XP_BEOS
-#define XP_BEOS
-#undef XP_UNIX
-#endif
-
-#ifndef BEOS
-#define BEOS
-#endif
-
-#define PR_AF_INET6 5 /* same as AF_INET6 */
-
-#ifdef __powerpc__
-#undef IS_LITTLE_ENDIAN
-#define IS_BIG_ENDIAN 1
-#else
-#define IS_LITTLE_ENDIAN 1
-#undef IS_BIG_ENDIAN
-#endif
-
-#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
-
-#ifndef HAVE_LONG_LONG
-#define HAVE_LONG_LONG
-#endif
-/*
- * XXX These two macros need to be investigated for different architectures.
- */
-#define HAVE_ALIGNED_DOUBLES
-#define HAVE_ALIGNED_LONGLONGS
-
-#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/_beos.h b/pr/include/md/_beos.h
deleted file mode 100644
index 78469dde..00000000
--- a/pr/include/md/_beos.h
+++ /dev/null
@@ -1,583 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nspr_beos_defs_h___
-#define nspr_beos_defs_h___
-
-#include "prtypes.h"
-#include "prio.h"
-#include "prthread.h"
-#include "prproces.h"
-#include "prmem.h"
-#include "obsolete/prsem.h"
-#include <errno.h>
-
-#include <support/SupportDefs.h>
-#include <kernel/OS.h>
-#include <dirent.h>
-
-/*
- * Internal configuration macros
- */
-
-#ifdef BONE_VERSION
-#define _PR_HAVE_SOCKADDR_LEN
-#define HAVE_NETINET_TCP_H
-#endif
-
-#define PR_LINKER_ARCH "beos"
-#define _PR_SI_SYSNAME "BEOS"
-#ifdef __powerpc__
-#define _PR_SI_ARCHITECTURE "ppc"
-#else
-#define _PR_SI_ARCHITECTURE "x86"
-#endif
-#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
-
-#undef HAVE_STACK_GROWING_UP
-#define HAVE_DLL
-#define _PR_NO_CLOCK_TIMER
-
-/*
- * The Atomic operations
- */
-
-#define _PR_HAVE_ATOMIC_OPS
-#define _MD_INIT_ATOMIC _MD_AtomicInit
-#define _MD_ATOMIC_INCREMENT _MD_AtomicIncrement
-#define _MD_ATOMIC_ADD _MD_AtomicAdd
-#define _MD_ATOMIC_DECREMENT _MD_AtomicDecrement
-#define _MD_ATOMIC_SET _MD_AtomicSet
-
-#define HAVE_CVAR_BUILT_ON_SEM
-#define _PR_GLOBAL_THREADS_ONLY
-#define _PR_BTHREADS
-#define _PR_NEED_FAKE_POLL
-#define _PR_HAVE_PEEK_BUFFER
-#define _PR_PEEK_BUFFER_MAX (16 * 1024)
-#define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) 1
-#define _PR_CONNECT_DOES_NOT_BIND
-#define _PR_HAVE_O_APPEND
-
-/* Define threading functions and objects as native BeOS */
-struct _MDThread {
- thread_id tid; /* BeOS thread handle */
- sem_id joinSem; /* sems used to synchronzie joining */
- PRBool is_joining; /* TRUE if someone is currently waiting to
- join this thread */
-};
-
-struct _MDThreadStack {
- PRInt8 notused;
-};
-
-/*
- * Lock and Semaphore related definitions
- */
-
-struct _MDLock {
- sem_id semaphoreID;
- int32 benaphoreCount;
-};
-
-struct _MDCVar {
- sem_id sem1;
- sem_id sem2;
- int16 count;
-};
-
-struct _MDSemaphore {
- sem_id sid;
-};
-
-/*
-** CPU-related definitions
-*/
-struct _MDCPU {
- int8 unused;
-};
-
-/*
-** Process-related definitions
-*/
-struct _MDProcess {
- pid_t pid;
-};
-
-struct _MDSegment {
- PRInt8 notused;
-};
-
-/*
-** File- and directory-related definitions
-*/
-
-#ifndef BONE_VERSION
-#define BE_SOCK_SHUTDOWN_READ 0x01
-#define BE_SOCK_SHUTDOWN_WRITE 0x02
-#endif
-
-struct _MDFileDesc {
- PRInt32 osfd;
- PRInt32 sock_state;
- PRBool accepted_socket;
- PRNetAddr peer_addr;
-#ifndef BONE_VERSION
- PRBool connectValueValid;
- int connectReturnValue;
- int connectReturnError;
-#endif
-};
-
-struct _MDDir {
- DIR *d;
-};
-
-#define PR_DIRECTORY_SEPARATOR '/'
-#define PR_DIRECTORY_SEPARATOR_STR "/"
-#define PR_PATH_SEPARATOR ':'
-#define PR_PATH_SEPARATOR_STR ":"
-
-#define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
-
-/* --- Memory-mapped files stuff --- not implemented on BeOS */
-
-struct _MDFileMap {
- PRInt8 unused;
-};
-
-/*
- * Network related definitions.
- */
-
-#ifndef BONE_VERSION
-#define IPPROTO_IP 0
-#define AF_UNIX 2
-#define TCP_NODELAY SO_NONBLOCK
-#define SO_LINGER -1
-#define SO_ERROR 4
-#endif
-
-#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
-
-#ifndef BONE_VERSION
-/* these aren't actually used. if they are, we're screwed */
-struct protoent {
- char *p_name; /* official protocol name */
- char **p_aliases; /* alias list */
- int p_proto; /* protocol # */
-};
-
-struct protoent* getprotobyname(const char* name);
-struct protoent* getprotobynumber(int number);
-#endif
-
-/*
- * malloc() related definitions.
- */
-
-#undef _PR_OVERRIDE_MALLOC
-
-/* Miscellaneous */
-
-#define _MD_ERRNO() (errno)
-
-#define _MD_CLEANUP_BEFORE_EXIT _MD_cleanup_before_exit
-#define _MD_EXIT _MD_exit
-
-#define _MD_GET_ENV getenv
-#define _MD_PUT_ENV putenv
-
-#define _MD_EARLY_INIT _MD_early_init
-#define _MD_FINAL_INIT _MD_final_init
-#define _MD_EARLY_CLEANUP()
-
-/* CPU Stuff */
-
-#define _MD_INIT_CPUS _MD_init_cpus
-#define _MD_WAKEUP_CPUS _MD_wakeup_cpus
-#define _MD_START_INTERRUPTS _MD_start_interrupts
-#define _MD_STOP_INTERRUPTS _MD_stop_interrupts
-#define _MD_DISABLE_CLOCK_INTERRUPTS _MD_disable_clock_interrupts
-#define _MD_BLOCK_CLOCK_INTERRUPTS _MD_block_clock_interrupts
-#define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_unblock_clock_interrupts
-#define _MD_CLOCK_INTERRUPT _MD_clock_interrupt
-#define _MD_INIT_STACK _MD_init_stack
-#define _MD_CLEAR_STACK _MD_clear_stack
-// #define _MD_GET_INTSOFF _MD_get_intsoff
-// #define _MD_SET_INTSOFF _MD_set_intsoff
-#define _MD_CURRENT_CPU _MD_current_cpu
-#define _MD_SET_CURRENT_CPU _MD_set_current_cpu
-#define _MD_INIT_RUNNING_CPU _MD_init_running_cpu
-#define _MD_PAUSE_CPU _MD_pause_cpu
-
-/* Thread stuff */
-
-#define _MD_CURRENT_THREAD() PR_GetCurrentThread()
-// #define _MD_GET_ATTACHED_THREAD _MD_get_attached_thread
-#define _MD_LAST_THREAD _MD_last_thread
-#define _MD_SET_CURRENT_THREAD _MD_set_current_THREAD
-#define _MD_SET_LAST_THREAD _MD_set_last_thread
-#define _MD_INIT_THREAD _MD_init_thread
-#define _MD_EXIT_THREAD _MD_exit_thread
-#define _MD_INIT_ATTACHED_THREAD _MD_init_attached_thread
-
-#define _MD_SUSPEND_THREAD _MD_suspend_thread
-#define _MD_RESUME_THREAD _MD_resume_thread
-#define _MD_SUSPEND_CPU _MD_suspend_cpu
-#define _MD_RESUME_CPU _MD_resume_cpu
-#define _MD_BEGIN_SUSPEND_ALL _MD_begin_suspend_all
-#define _MD_END_SUSPEND_ALL _MD_end_suspend_all
-#define _MD_BEGIN_RESUME_ALL _MD_begin_resume_all
-#define _MD_END_RESUME_ALL _MD_end_resume_all
-
-#define _MD_GET_SP _MD_get_sp
-
-#define _MD_CLEAN_THREAD _MD_clean_thread
-#define _MD_CREATE_PRIMORDIAL_USER_THREAD _MD_create_primordial_user_thread
-#define _MD_CREATE_USER_THREAD _MD_create_user_thread
-#define _MD_INIT_PRIMORDIAL_THREAD _MD_init_primordial_thread
-#define _MD_CREATE_THREAD _MD_create_thread
-#define _MD_YIELD _MD_yield
-#define _MD_SET_PRIORITY _MD_set_priority
-
-#define _MD_SUSPENDALL _MD_suspendall
-#define _MD_RESUMEALL _MD_resumeall
-
-#define _MD_SWITCH_CONTEXT _MD_switch_context
-#define _MD_RESTORE_CONTEXT _MD_restore_context
-
-#define _MD_WAIT _MD_wait
-#define _MD_WAKEUP_WAITER _MD_wakeup_waiter
-
-#define _MD_SETTHREADAFFINITYMASK _MD_setthreadaffinitymask
-#define _MD_GETTHREADAFFINITYMASK _MD_getthreadaffinitymask
-
-/* Thread Synchronization */
-
-#define _MD_INIT_LOCKS _MD_init_locks
-#define _MD_NEW_LOCK _MD_new_lock
-#define _MD_FREE_LOCK _MD_free_lock
-#define _MD_LOCK _MD_lock
-#define _MD_TEST_AND_LOCK _MD_test_and_lock
-#define _MD_UNLOCK _MD_unlock
-#define _MD_IOQ_LOCK _MD_ioq_lock
-#define _MD_IOQ_UNLOCK _MD_ioq_unlock
-#define _MD_NEW_SEM _MD_new_sem
-#define _MD_DESTROY_SEM _MD_destroy_sem
-#define _MD_TIMED_WAIT_SEM _MD_timed_wait_sem
-#define _MD_WAIT_SEM _MD_wait_sem
-#define _MD_POST_SEM _MD_post_sem
-// #define _MD_NEW_CV _MD_new_cv
-// #define _MD_FREE_CV _MD_free_cv
-// #define _MD_WAIT_CV _MD_wait_cv
-// #define _MD_NOTIFY_CV _MD_notify_cv
-// #define _MD_NOTIFYALL_CV _MD_notifyall_cv
-
-/* File I/O */
-
-/* don't need any I/O initializations */
-#define _MD_INIT_IO()
-#define _MD_INIT_FILEDESC(fd)
-
-#define _MD_OPEN_DIR _MD_open_dir
-#define _MD_READ_DIR _MD_read_dir
-#define _MD_CLOSE_DIR _MD_close_dir
-#define _MD_MAKE_NONBLOCK _MD_make_nonblock
-#define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
-#define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
-#define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
-#define _MD_OPEN _MD_open
-#define _MD_OPEN_FILE _MD_open
-#define _MD_CLOSE_FILE _MD_close_file
-#define _MD_READ _MD_read
-#define _MD_WRITE _MD_write
-#define _MD_WRITEV _MD_writev
-#define _MD_LSEEK _MD_lseek
-#define _MD_LSEEK64 _MD_lseek64
-#define _MD_FSYNC _MD_fsync
-#define _MD_DELETE _MD_delete
-#define _MD_GETFILEINFO _MD_getfileinfo
-#define _MD_GETFILEINFO64 _MD_getfileinfo64
-#define _MD_GETOPENFILEINFO _MD_getopenfileinfo
-#define _MD_GETOPENFILEINFO64 _MD_getopenfileinfo64
-#define _MD_RENAME _MD_rename
-#define _MD_ACCESS _MD_access
-#define _MD_STAT stat
-#define _MD_MKDIR _MD_mkdir
-#define _MD_MAKE_DIR _MD_mkdir
-#define _MD_RMDIR _MD_rmdir
-#define _MD_PR_POLL _MD_pr_poll
-
-/* Network I/O */
-
-#define _MD_CLOSE_SOCKET _MD_close_socket
-#define _MD_CONNECT _MD_connect
-#define _MD_ACCEPT _MD_accept
-#define _MD_BIND _MD_bind
-#define _MD_LISTEN _MD_listen
-#define _MD_SHUTDOWN _MD_shutdown
-#define _MD_RECV _MD_recv
-#define _MD_SEND _MD_send
-#define _MD_ACCEPT_READ _MD_accept_read
-#define _MD_GETSOCKNAME _MD_getsockname
-#define _MD_GETPEERNAME _MD_getpeername
-#define _MD_GETSOCKOPT _MD_getsockopt
-#define _MD_SETSOCKOPT _MD_setsockopt
-#define _MD_RECVFROM _MD_recvfrom
-#define _MD_SENDTO _MD_sendto
-#define _MD_SOCKETPAIR _MD_socketpair
-#define _MD_SOCKET _MD_socket
-#define _MD_SOCKETAVAILABLE _MD_socketavailable
-#define _MD_PIPEAVAILABLE _MD_socketavailable
-
-#define _MD_GET_SOCKET_ERROR() (errno)
-#define _MD_GETHOSTNAME _MD_gethostname
-
-#define _MD_SELECT select
-
-/* Process management */
-
-#define _MD_CREATE_PROCESS _MD_create_process
-#define _MD_DETACH_PROCESS _MD_detach_process
-#define _MD_WAIT_PROCESS _MD_wait_process
-#define _MD_KILL_PROCESS _MD_kill_process
-
-/* Atomic data operations */
-
-// #define _MD_INIT_ATOMIC _MD_init_atomic
-// #define _MD_ATOMIC_INCREMENT _MD_atomic_increment
-// #define _MD_ATOMIC_DECREMENT _MD_atomic_decrement
-// #define _MD_ATOMIC_SET _MD_atomic_set
-
-/* memory management */
-
-#define _MD_INIT_SEGS _MD_init_segs
-#define _MD_ALLOC_SEGMENT _MD_alloc_segment
-#define _MD_FREE_SEGMENT _MD_free_segment
-
-/* Memory mapped file I/O */
-
-#define _MD_CREATE_FILE_MAP _MD_create_file_map
-#define _MD_GET_MEM_MAP_ALIGNMENT _MD_get_mem_map_alignment
-#define _MD_MEM_MAP _MD_mem_map
-#define _MD_MEM_UNMAP _MD_mem_unmap
-#define _MD_CLOSE_FILE_MAP _MD_close_file_map
-
-/* Time related */
-
-#define _MD_NOW _MD_now
-#define _MD_INTERVAL_INIT _MD_interval_init
-#define _MD_GET_INTERVAL _MD_get_interval
-#define _MD_INTERVAL_PER_SEC _MD_interval_per_sec
-
-/* File locking */
-
-#define _MD_LOCKFILE _MD_lockfile
-#define _MD_TLOCKFILE _MD_tlockfile
-#define _MD_UNLOCKFILE _MD_unlockfile
-
-/**
- * Prototypes for machine dependent function implementations. (Too bad
- * NSPR's MD system blows so much that we have to reiterate every stinking
- * thing we implement here in our MD header file.)
- */
-
-/* Miscellaneous */
-
-NSPR_API(void) _MD_cleanup_before_exit(void);
-NSPR_API(void) _MD_exit(PRIntn status);
-
-NSPR_API(char*) _MD_get_env(const char *name);
-NSPR_API(PRIntn) _MD_put_env(const char *name);
-
-NSPR_API(void) _MD_early_init(void);
-NSPR_API(void) _MD_final_init(void);
-
-/* CPU Stuff */
-
-NSPR_API(void) _MD_init_cpus();
-NSPR_API(void) _MD_wakeup_cpus();
-NSPR_API(void) _MD_start_interrupts(void);
-NSPR_API(void) _MD_stop_interrupts(void);
-NSPR_API(void) _MD_disable_clock_interrupts(void);
-NSPR_API(void) _MD_block_clock_interrupts(void);
-NSPR_API(void) _MD_unblock_clock_interrupts(void);
-NSPR_API(void) _MD_clock_interrupt(void);
-// NSPR_API(void) _MD_init_stack(PRThreadStack *ts, PRIntn redzone);
-// NSPR_API(void) _MD_clear_stack(PRThreadStack* ts);
-// NSPR_API(PRInt32) _MD_get_intsoff(void);
-// NSPR_API(void) _MD_set_intsoff(PRInt32 _val);
-// NSPR_API(_PRCPU*) _MD_current_cpu(void);
-// NSPR_API(void) _MD_set_current_cpu(_PRCPU *cpu);
-// NSPR_API(void) _MD_init_running_cpu(_PRCPU *cpu);
-NSPR_API(PRInt32) _MD_pause_cpu(PRIntervalTime timeout);
-
-/* Thread stuff */
-
-// NSPR_API(PRThread*) _MD_current_thread(void);
-NSPR_API(PRThread*) _MD_get_attached_thread(void);
-NSPR_API(PRThread*) _MD_last_thread(void);
-NSPR_API(void) _MD_set_current_thread(PRThread *thread);
-NSPR_API(void) _MD_set_last_thread(PRThread *thread);
-NSPR_API(PRStatus) _MD_init_thread(PRThread *thread);
-NSPR_API(void) _MD_exit_thread(PRThread *thread);
-NSPR_API(PRStatus) _MD_init_attached_thread(PRThread *thread);
-
-NSPR_API(void) _MD_suspend_thread(PRThread *thread);
-NSPR_API(void) _MD_resume_thread(PRThread *thread);
-// NSPR_API(void) _MD_suspend_cpu(_PRCPU *cpu);
-// NSPR_API(void) _MD_resume_cpu(_PRCPU *cpu);
-NSPR_API(void) _MD_begin_suspend_all(void);
-NSPR_API(void) _MD_end_suspend_all(void);
-NSPR_API(void) _MD_begin_resume_all(void);
-NSPR_API(void) _MD_end_resume_all(void);
-
-NSPR_API(void *) _MD_get_sp(PRThread *thread);
-
-NSPR_API(void) _MD_clean_thread(PRThread *thread);
-NSPR_API(void) _MD_create_primordial_user_thread(PRThread *);
-NSPR_API(PRThread*) _MD_create_user_thread(PRUint32 stacksize, void (*start)(void *), void *arg);
-NSPR_API(void) _MD_init_primordial_thread(PRThread *thread);
-NSPR_API(PRStatus) _MD_create_thread(PRThread *thread, void (*start)(void *), PRThreadPriority priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize);
-NSPR_API(void) _MD_yield(void);
-NSPR_API(void) _MD_set_priority(struct _MDThread *md, PRThreadPriority newPri);
-
-NSPR_API(void) _MD_suspendall(void);
-NSPR_API(void) _MD_resumeall(void);
-
-NSPR_API(void) _MD_init_context(PRThread *thread, char *top, void (*start) (void), PRBool *status);
-NSPR_API(void) _MD_switch_context(PRThread *thread);
-NSPR_API(void) _MD_restore_context(PRThread *thread);
-
-NSPR_API(PRStatus) _MD_wait(PRThread *, PRIntervalTime timeout);
-NSPR_API(PRStatus) _MD_wakeup_waiter(PRThread *);
-
-NSPR_API(PRInt32) _MD_setthreadaffinitymask(PRThread *thread, PRUint32 mask );
-NSPR_API(PRInt32) _MD_getthreadaffinitymask(PRThread *thread, PRUint32 *mask);
-
-/* Thread Synchronization */
-
-NSPR_API(void) _MD_init_locks(void);
-NSPR_API(PRStatus) _MD_new_lock(struct _MDLock *md);
-NSPR_API(void) _MD_free_lock(struct _MDLock *md);
-NSPR_API(void) _MD_lock(struct _MDLock *md);
-NSPR_API(PRIntn) _MD_test_and_lock(struct _MDLock *md);
-NSPR_API(void) _MD_unlock(struct _MDLock *md);
-NSPR_API(void) _MD_ioq_lock(void);
-NSPR_API(void) _MD_ioq_unlock(void);
-NSPR_API(void) _MD_new_sem(struct _MDSemaphore *md, PRUintn value);
-NSPR_API(void) _MD_destroy_sem(struct _MDSemaphore *md);
-NSPR_API(PRStatus) _MD_timed_wait_sem(struct _MDSemaphore *md, PRIntervalTime timeout);
-NSPR_API(PRStatus) _MD_wait_sem(struct _MDSemaphore *md);
-NSPR_API(void) _MD_post_sem(struct _MDSemaphore *md);
-// NSPR_API(PRInt32) _MD_new_cv(struct _MDCVar *md);
-// NSPR_API(void) _MD_free_cv(struct _MDCVar *md);
-// NSPR_API(void) _MD_wait_cv(struct _MDCVar *mdCVar, struct _MDLock *mdLock, PRIntervalTime timeout);
-// NSPR_API(void) _MD_notify_cv(struct _MDCVar *md, struct _MDLock *lock);
-// NSPR_API(void) _MD_notifyall_cv(struct _MDCVar *md, struct _MDLock *lock);
-
-/* File I/O */
-
-// NSPR_API(void) _MD_init_io(void);
-NSPR_API(PRStatus) _MD_open_dir(struct _MDDir *md,const char *name);
-NSPR_API(char *) _MD_read_dir(struct _MDDir *md, PRIntn flags);
-NSPR_API(PRInt32) _MD_close_dir(struct _MDDir *md);
-NSPR_API(void) _MD_make_nonblock(PRFileDesc *fd);
-NSPR_API(void) _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);
-NSPR_API(void) _MD_query_fd_inheritable(PRFileDesc *fd);
-NSPR_API(PRInt32) _MD_open(const char *name, PRIntn osflags, PRIntn mode);
-NSPR_API(PRInt32) _MD_close_file(PRInt32 osfd);
-NSPR_API(PRInt32) _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
-NSPR_API(PRInt32) _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
-NSPR_API(PRInt32) _MD_writev(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_lseek(PRFileDesc *fd, PRInt32 offset, int whence);
-NSPR_API(PRInt64) _MD_lseek64(PRFileDesc *fd, PRInt64 offset, int whence);
-NSPR_API(PRInt32) _MD_fsync(PRFileDesc *fd);
-NSPR_API(PRInt32) _MD_delete(const char *name);
-NSPR_API(PRInt32) _MD_getfileinfo(const char *fn, PRFileInfo *info);
-NSPR_API(PRInt32) _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);
-NSPR_API(PRInt32) _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);
-NSPR_API(PRInt32) _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);
-NSPR_API(PRInt32) _MD_rename(const char *from, const char *to);
-NSPR_API(PRInt32) _MD_access(const char *name, PRIntn how);
-NSPR_API(PRInt32) _MD_stat(const char *name, struct stat *buf);
-NSPR_API(PRInt32) _MD_mkdir(const char *name, PRIntn mode);
-NSPR_API(PRInt32) _MD_rmdir(const char *name);
-NSPR_API(PRInt32) _MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout);
-
-/* Network I/O */
-NSPR_API(PRInt32) _MD_close_socket(PRInt32 osfd);
-NSPR_API(PRInt32) _MD_connect(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
-NSPR_API(PRInt32) _MD_listen(PRFileDesc *fd, PRIntn backlog);
-NSPR_API(PRInt32) _MD_shutdown(PRFileDesc *fd, PRIntn how);
-NSPR_API(PRInt32) _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);
-// NSPR_API(PRInt32) _MD_fast_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);
-// NSPR_API(PRInt32) _MD_fast_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);
-// NSPR_API(void) _MD_update_accept_context(PRInt32 s, PRInt32 ls);
-NSPR_API(PRStatus) _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
-NSPR_API(PRStatus) _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
-NSPR_API(PRStatus) _MD_getsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);
-NSPR_API(PRStatus) _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen);
-NSPR_API(PRInt32) _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
-NSPR_API(PRInt32) _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);
-NSPR_API(PRInt32) _MD_socket(int af, int type, int flags);
-NSPR_API(PRInt32) _MD_socketavailable(PRFileDesc *fd);
-
-// NSPR_API(PRInt32) _MD_get_socket_error(void);
-NSPR_API(PRStatus) _MD_gethostname(char *name, PRUint32 namelen);
-
-/* Process management */
-
-NSPR_API(PRProcess *) _MD_create_process(const char *path, char *const *argv, char *const *envp, const PRProcessAttr *attr);
-NSPR_API(PRStatus) _MD_detach_process(PRProcess *process);
-NSPR_API(PRStatus) _MD_wait_process(PRProcess *process, PRInt32 *exitCode);
-NSPR_API(PRStatus) _MD_kill_process(PRProcess *process);
-
-/* Atomic data operations */
-
-// NSPR_API(void) _MD_init_atomic(void);
-// NSPR_API(PRInt32) _MD_atomic_increment(PRInt32 *);
-// NSPR_API(PRInt32) _MD_atomic_decrement(PRInt32 *);
-// NSPR_API(PRInt32) _MD_atomic_set(PRInt32 *, PRInt32);
-
-/* Memory management */
-
-NSPR_API(void) _MD_init_segs(void);
-NSPR_API(PRStatus) _MD_alloc_segment(PRSegment *seg, PRUint32 size, void *vaddr);
-NSPR_API(void) _MD_free_segment(PRSegment *seg);
-
-/* Memory mapped file I/O */
-
-NSPR_API(PRStatus) _MD_create_file_map(PRFileMap *fmap, PRInt64 size);
-NSPR_API(PRInt32) _MD_get_mem_map_alignment(void);
-NSPR_API(void *) _MD_mem_map(PRFileMap *fmap, PRInt64 offset, PRUint32 len);
-NSPR_API(PRStatus) _MD_mem_unmap(void *addr, PRUint32 size);
-NSPR_API(PRStatus) _MD_close_file_map(PRFileMap *fmap);
-
-/* Time related */
-
-NSPR_API(PRTime) _MD_now(void);
-NSPR_API(void) _MD_interval_init(void);
-NSPR_API(PRIntervalTime) _MD_get_interval(void);
-NSPR_API(PRIntervalTime) _MD_interval_per_sec(void);
-
-/* File locking */
-
-NSPR_API(PRStatus) _MD_lockfile(PRInt32 osfd);
-NSPR_API(PRStatus) _MD_tlockfile(PRInt32 osfd);
-NSPR_API(PRStatus) _MD_unlockfile(PRInt32 osfd);
-
-#endif /* _nspr_beos_defs_h___*/
diff --git a/pr/include/md/prosdep.h b/pr/include/md/prosdep.h
index 7fdd0ff8..42eba3da 100644
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -81,14 +81,9 @@ PR_BEGIN_EXTERN_C
#include "md/_unixos.h"
#include "md/_unix_errors.h"
-#elif defined(XP_BEOS)
-
-#include "md/_beos.h"
-#include "md/_unix_errors.h"
-
#else
-#error "The platform is not BeOS, Unix, Windows, or Mac"
+#error "The platform is not Unix, Windows, or Mac"
#endif
diff --git a/pr/include/obsolete/protypes.h b/pr/include/obsolete/protypes.h
index 2275bce0..06791e13 100644
--- a/pr/include/obsolete/protypes.h
+++ b/pr/include/obsolete/protypes.h
@@ -28,14 +28,6 @@ typedef PRIntn intn;
*/
/*
- * BeOS defines all the int types below in its standard header
- * file SupportDefs.h.
- */
-#ifdef XP_BEOS
-#include <support/SupportDefs.h>
-#endif
-
-/*
* SVR4 typedef of uint is commonly found on UNIX machines.
*
* On AIX 4.3, sys/inttypes.h (which is included by sys/types.h)
@@ -56,7 +48,7 @@ typedef PRIntn intn;
* uint
*/
-#if !defined(XP_BEOS) && !defined(XP_OS2) && !defined(XP_UNIX) || defined(NTO)
+#if !defined(XP_OS2) && !defined(XP_UNIX) || defined(NTO)
typedef PRUintn uint;
#endif
@@ -64,43 +56,35 @@ typedef PRUintn uint;
* uint64
*/
-#if !defined(XP_BEOS)
typedef PRUint64 uint64;
-#endif
/*
* uint32
*/
-#if !defined(XP_BEOS)
#if !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRUint32 uint32;
#else
typedef unsigned long uint32;
#endif
-#endif
/*
* uint16
*/
-#if !defined(XP_BEOS)
typedef PRUint16 uint16;
-#endif
/*
* uint8
*/
-#if !defined(XP_BEOS)
typedef PRUint8 uint8;
-#endif
/*
* int64
*/
-#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES)
+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES)
typedef PRInt64 int64;
#endif
@@ -108,7 +92,7 @@ typedef PRInt64 int64;
* int32
*/
-#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
#if !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRInt32 int32;
@@ -121,7 +105,7 @@ typedef long int32;
* int16
*/
-#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt16 int16;
#endif
@@ -130,7 +114,7 @@ typedef PRInt16 int16;
* int8
*/
-#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
+#if !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt8 int8;
#endif
diff --git a/pr/include/prinet.h b/pr/include/prinet.h
index c082af5e..6ba5829f 100644
--- a/pr/include/prinet.h
+++ b/pr/include/prinet.h
@@ -32,7 +32,7 @@
#ifndef prinet_h__
#define prinet_h__
-#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined(XP_OS2)
#include <sys/types.h>
#include <sys/socket.h> /* AF_INET */
#include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */
diff --git a/pr/include/prio.h b/pr/include/prio.h
index 18504e5c..7c201d9d 100644
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -145,21 +145,13 @@ typedef struct PRIPv6Addr PRIPv6Addr;
union PRNetAddr {
struct {
PRUint16 family; /* address family (0x00ff maskable) */
-#ifdef XP_BEOS
- char data[10]; /* Be has a smaller structure */
-#else
char data[14]; /* raw address data */
-#endif
} raw;
struct {
PRUint16 family; /* address family (AF_INET) */
PRUint16 port; /* port number */
PRUint32 ip; /* The actual 32 bits of address */
-#ifdef XP_BEOS
- char pad[4]; /* Be has a smaller structure */
-#else
char pad[8];
-#endif
} inet;
struct {
PRUint16 family; /* address family (AF_INET6) */
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index 90acdff5..dc74a016 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -10,10 +10,6 @@
#include <pthread.h>
#endif
-#if defined(_PR_BTHREADS)
-#include <kernel/OS.h>
-#endif
-
#ifdef WIN32
/*
* Allow use of functions and symbols first defined in Win2k.
@@ -2136,23 +2132,6 @@ extern PRSize _pr_CopyLowBits( void *dest, PRSize dstlen, void *src, PRSize srcl
/* end PR_GetRandomNoise() related */
-#ifdef XP_BEOS
-
-extern PRLock *_connectLock;
-
-typedef struct _ConnectListNode {
- PRInt32 osfd;
- PRNetAddr addr;
- PRUint32 addrlen;
- PRIntervalTime timeout;
-} ConnectListNode;
-
-extern ConnectListNode connectList[64];
-
-extern PRUint32 connectCount;
-
-#endif /* XP_BEOS */
-
#if defined(_WIN64) && defined(WIN95)
typedef struct _PRFileDescList {
PRFileDesc *fd;
diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h
index dd8a2b22..5ed4409b 100644
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -64,22 +64,6 @@
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
-#elif defined(XP_BEOS)
-
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
#elif defined(XP_OS2) && defined(__declspec)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
diff --git a/pr/src/bthreads/.cvsignore b/pr/src/bthreads/.cvsignore
deleted file mode 100644
index f3c7a7c5..00000000
--- a/pr/src/bthreads/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/pr/src/bthreads/Makefile.in b/pr/src/bthreads/Makefile.in
deleted file mode 100644
index a85e6db6..00000000
--- a/pr/src/bthreads/Makefile.in
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-#! gmake
-
-MOD_DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(MOD_DEPTH)/config/autoconf.mk
-
-include $(topsrcdir)/config/config.mk
-
-include $(srcdir)/bsrcs.mk
-CSRCS += $(BTCSRCS)
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
-
-include $(topsrcdir)/config/rules.mk
-
-DEFINES += -D_NSPR_BUILD_
-
-export:: $(TARGETS)
-
-
diff --git a/pr/src/bthreads/bsrcs.mk b/pr/src/bthreads/bsrcs.mk
deleted file mode 100644
index 70832990..00000000
--- a/pr/src/bthreads/bsrcs.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# this file lists the source files to be compiled (used in Makefile) and
-# then enumerated as object files (in objs.mk) for inclusion in the NSPR
-# shared library
-
-BTCSRCS = \
- btthread.c \
- btlocks.c \
- btcvar.c \
- btmon.c \
- btsem.c \
- btmisc.c \
- $(NULL)
diff --git a/pr/src/bthreads/btcvar.c b/pr/src/bthreads/btcvar.c
deleted file mode 100644
index c7483790..00000000
--- a/pr/src/bthreads/btcvar.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <kernel/OS.h>
-
-#include "primpl.h"
-
-/*
-** Create a new condition variable.
-**
-** "lock" is the lock used to protect the condition variable.
-**
-** Condition variables are synchronization objects that threads can use
-** to wait for some condition to occur.
-**
-** This may fail if memory is tight or if some operating system resource
-** is low. In such cases, a NULL will be returned.
-*/
-PR_IMPLEMENT(PRCondVar*)
- PR_NewCondVar (PRLock *lock)
-{
- PRCondVar *cv = PR_NEW( PRCondVar );
- PR_ASSERT( NULL != lock );
- if( NULL != cv )
- {
- cv->lock = lock;
- cv->sem = create_sem(0, "CVSem");
- cv->handshakeSem = create_sem(0, "CVHandshake");
- cv->signalSem = create_sem( 0, "CVSignal");
- cv->signalBenCount = 0;
- cv->ns = cv->nw = 0;
- PR_ASSERT( cv->sem >= B_NO_ERROR );
- PR_ASSERT( cv->handshakeSem >= B_NO_ERROR );
- PR_ASSERT( cv->signalSem >= B_NO_ERROR );
- }
- return cv;
-} /* PR_NewCondVar */
-
-/*
-** Destroy a condition variable. There must be no thread
-** waiting on the condvar. The caller is responsible for guaranteeing
-** that the condvar is no longer in use.
-**
-*/
-PR_IMPLEMENT(void)
- PR_DestroyCondVar (PRCondVar *cvar)
-{
- status_t result = delete_sem( cvar->sem );
- PR_ASSERT( result == B_NO_ERROR );
-
- result = delete_sem( cvar->handshakeSem );
- PR_ASSERT( result == B_NO_ERROR );
-
- result = delete_sem( cvar->signalSem );
- PR_ASSERT( result == B_NO_ERROR );
-
- PR_DELETE( cvar );
-}
-
-/*
-** The thread that waits on a condition is blocked in a "waiting on
-** condition" state until another thread notifies the condition or a
-** caller specified amount of time expires. The lock associated with
-** the condition variable will be released, which must have be held
-** prior to the call to wait.
-**
-** Logically a notified thread is moved from the "waiting on condition"
-** state and made "ready." When scheduled, it will attempt to reacquire
-** the lock that it held when wait was called.
-**
-** The timeout has two well known values, PR_INTERVAL_NO_TIMEOUT and
-** PR_INTERVAL_NO_WAIT. The former value requires that a condition be
-** notified (or the thread interrupted) before it will resume from the
-** wait. If the timeout has a value of PR_INTERVAL_NO_WAIT, the effect
-** is to release the lock, possibly causing a rescheduling within the
-** runtime, then immediately attempting to reacquire the lock and resume.
-**
-** Any other value for timeout will cause the thread to be rescheduled
-** either due to explicit notification or an expired interval. The latter
-** must be determined by treating time as one part of the monitored data
-** being protected by the lock and tested explicitly for an expired
-** interval.
-**
-** Returns PR_FAILURE if the caller has not locked the lock associated
-** with the condition variable or the thread was interrupted (PR_Interrupt()).
-** The particular reason can be extracted with PR_GetError().
-*/
-PR_IMPLEMENT(PRStatus)
- PR_WaitCondVar (PRCondVar *cvar, PRIntervalTime timeout)
-{
- status_t err;
- if( timeout == PR_INTERVAL_NO_WAIT )
- {
- PR_Unlock( cvar->lock );
- PR_Lock( cvar->lock );
- return PR_SUCCESS;
- }
-
- if( atomic_add( &cvar->signalBenCount, 1 ) > 0 )
- {
- if (acquire_sem(cvar->signalSem) == B_INTERRUPTED)
- {
- atomic_add( &cvar->signalBenCount, -1 );
- return PR_FAILURE;
- }
- }
- cvar->nw += 1;
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
-
- PR_Unlock( cvar->lock );
- if( timeout==PR_INTERVAL_NO_TIMEOUT )
- {
- err = acquire_sem(cvar->sem);
- }
- else
- {
- err = acquire_sem_etc(cvar->sem, 1, B_RELATIVE_TIMEOUT, PR_IntervalToMicroseconds(timeout) );
- }
-
- if( atomic_add( &cvar->signalBenCount, 1 ) > 0 )
- {
- while (acquire_sem(cvar->signalSem) == B_INTERRUPTED);
- }
-
- if (cvar->ns > 0)
- {
- release_sem_etc(cvar->handshakeSem, 1, B_DO_NOT_RESCHEDULE);
- cvar->ns -= 1;
- }
- cvar->nw -= 1;
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
-
- PR_Lock( cvar->lock );
- if(err!=B_NO_ERROR)
- {
- return PR_FAILURE;
- }
- return PR_SUCCESS;
-}
-
-/*
-** Notify ONE thread that is currently waiting on 'cvar'. Which thread is
-** dependent on the implementation of the runtime. Common sense would dictate
-** that all threads waiting on a single condition have identical semantics,
-** therefore which one gets notified is not significant.
-**
-** The calling thead must hold the lock that protects the condition, as
-** well as the invariants that are tightly bound to the condition, when
-** notify is called.
-**
-** Returns PR_FAILURE if the caller has not locked the lock associated
-** with the condition variable.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_NotifyCondVar (PRCondVar *cvar)
-{
- status_t err ;
- if( atomic_add( &cvar->signalBenCount, 1 ) > 0 )
- {
- if (acquire_sem(cvar->signalSem) == B_INTERRUPTED)
- {
- atomic_add( &cvar->signalBenCount, -1 );
- return PR_FAILURE;
- }
- }
- if (cvar->nw > cvar->ns)
- {
- cvar->ns += 1;
- release_sem_etc(cvar->sem, 1, B_DO_NOT_RESCHEDULE);
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
-
- while (acquire_sem(cvar->handshakeSem) == B_INTERRUPTED)
- {
- err = B_INTERRUPTED;
- }
- }
- else
- {
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
- }
- return PR_SUCCESS;
-}
-
-/*
-** Notify all of the threads waiting on the condition variable. The order
-** that the threads are notified is indeterminant. The lock that protects
-** the condition must be held.
-**
-** Returns PR_FAILURE if the caller has not locked the lock associated
-** with the condition variable.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_NotifyAllCondVar (PRCondVar *cvar)
-{
- int32 handshakes;
- status_t err = B_OK;
-
- if( atomic_add( &cvar->signalBenCount, 1 ) > 0 )
- {
- if (acquire_sem(cvar->signalSem) == B_INTERRUPTED)
- {
- atomic_add( &cvar->signalBenCount, -1 );
- return PR_FAILURE;
- }
- }
-
- if (cvar->nw > cvar->ns)
- {
- handshakes = cvar->nw - cvar->ns;
- cvar->ns = cvar->nw;
- release_sem_etc(cvar->sem, handshakes, B_DO_NOT_RESCHEDULE);
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
-
- while (acquire_sem_etc(cvar->handshakeSem, handshakes, 0, 0) == B_INTERRUPTED)
- {
- err = B_INTERRUPTED;
- }
- }
- else
- {
- if( atomic_add( &cvar->signalBenCount, -1 ) > 1 )
- {
- release_sem_etc(cvar->signalSem, 1, B_DO_NOT_RESCHEDULE);
- }
- }
- return PR_SUCCESS;
-}
diff --git a/pr/src/bthreads/btlocks.c b/pr/src/bthreads/btlocks.c
deleted file mode 100644
index 994c09c4..00000000
--- a/pr/src/bthreads/btlocks.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
-** File: btlocks.c
-** Description: Implemenation for thread locks using bthreads
-** Exports: prlock.h
-*/
-
-#include "primpl.h"
-
-#include <string.h>
-#include <sys/time.h>
-
-void
-_PR_InitLocks (void)
-{
-}
-
-PR_IMPLEMENT(PRLock*)
- PR_NewLock (void)
-{
- PRLock *lock;
- status_t semresult;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- lock = PR_NEWZAP(PRLock);
- if (lock != NULL) {
-
- lock->benaphoreCount = 0;
- lock->semaphoreID = create_sem( 0, "nsprLockSem" );
- if( lock->semaphoreID < B_NO_ERROR ) {
-
- PR_DELETE( lock );
- lock = NULL;
- }
- }
-
- return lock;
-}
-
-PR_IMPLEMENT(void)
- PR_DestroyLock (PRLock* lock)
-{
- status_t result;
-
- PR_ASSERT(NULL != lock);
- result = delete_sem(lock->semaphoreID);
- PR_ASSERT(result == B_NO_ERROR);
- PR_DELETE(lock);
-}
-
-PR_IMPLEMENT(void)
- PR_Lock (PRLock* lock)
-{
- PR_ASSERT(lock != NULL);
-
- if( atomic_add( &lock->benaphoreCount, 1 ) > 0 ) {
-
- if( acquire_sem(lock->semaphoreID ) != B_NO_ERROR ) {
-
- atomic_add( &lock->benaphoreCount, -1 );
- return;
- }
- }
-
- lock->owner = find_thread( NULL );
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_Unlock (PRLock* lock)
-{
- PR_ASSERT(lock != NULL);
- lock->owner = NULL;
- if( atomic_add( &lock->benaphoreCount, -1 ) > 1 ) {
-
- release_sem_etc( lock->semaphoreID, 1, B_DO_NOT_RESCHEDULE );
- }
-
- return PR_SUCCESS;
-}
-
-PR_IMPLEMENT(void)
- PR_AssertCurrentThreadOwnsLock(PRLock *lock)
-{
- PR_ASSERT(lock != NULL);
- PR_ASSERT(lock->owner == find_thread( NULL ));
-}
diff --git a/pr/src/bthreads/btmisc.c b/pr/src/bthreads/btmisc.c
deleted file mode 100644
index 8d84a606..00000000
--- a/pr/src/bthreads/btmisc.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-#include <stdio.h>
-
-// void _PR_InitCPUs(void) {PT_LOG("_PR_InitCPUs")}
-// void _MD_StartInterrupts(void) {PT_LOG("_MD_StartInterrupts")}
-
-/* this is a total hack.. */
-
-struct protoent* getprotobyname(const char* name)
-{
- return 0;
-}
-
-struct protoent* getprotobynumber(int number)
-{
- return 0;
-}
-
-/* this is needed by prinit for some reason */
-void
-_PR_InitStacks (void)
-{
-}
-
-/* this is needed by prinit for some reason */
-void
-_PR_InitTPD (void)
-{
-}
-
-/*
-** Create extra virtual processor threads. Generally used with MP systems.
-*/
-PR_IMPLEMENT(void)
- PR_SetConcurrency (PRUintn numCPUs)
-{
-}
-
-/*
-** Set thread recycle mode to on (1) or off (0)
-*/
-PR_IMPLEMENT(void)
- PR_SetThreadRecycleMode (PRUint32 flag)
-{
-}
-
-/*
-** Get context registers, return with error for now.
-*/
-
-PR_IMPLEMENT(PRWord *)
-_MD_HomeGCRegisters( PRThread *t, int isCurrent, int *np )
-{
- return 0;
-}
-
-PR_IMPLEMENT(void *)
-PR_GetSP( PRThread *t )
-{
- return 0;
-}
-
-PR_IMPLEMENT(PRStatus)
-PR_EnumerateThreads( PREnumerator func, void *arg )
-{
- return PR_FAILURE;
-}
diff --git a/pr/src/bthreads/btmon.c b/pr/src/bthreads/btmon.c
deleted file mode 100644
index bd05e73d..00000000
--- a/pr/src/bthreads/btmon.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <kernel/OS.h>
-
-#include "primpl.h"
-
-/*
-** Create a new monitor. Monitors are re-entrant locks with a single built-in
-** condition variable.
-**
-** This may fail if memory is tight or if some operating system resource
-** is low.
-*/
-PR_IMPLEMENT(PRMonitor*)
- PR_NewMonitor (void)
-{
- PRMonitor *mon;
- PRCondVar *cvar;
- PRLock *lock;
-
- mon = PR_NEWZAP( PRMonitor );
- if( mon )
- {
- lock = PR_NewLock();
- if( !lock )
- {
- PR_DELETE( mon );
- return( 0 );
- }
-
- cvar = PR_NewCondVar( lock );
- if( !cvar )
- {
- PR_DestroyLock( lock );
- PR_DELETE( mon );
- return( 0 );
- }
-
- mon->cvar = cvar;
- mon->name = NULL;
- }
-
- return( mon );
-}
-
-PR_IMPLEMENT(PRMonitor*) PR_NewNamedMonitor(const char* name)
-{
- PRMonitor* mon = PR_NewMonitor();
- if( mon )
- {
- mon->name = name;
- }
- return mon;
-}
-
-/*
-** Destroy a monitor. The caller is responsible for guaranteeing that the
-** monitor is no longer in use. There must be no thread waiting on the
-** monitor's condition variable and that the lock is not held.
-**
-*/
-PR_IMPLEMENT(void)
- PR_DestroyMonitor (PRMonitor *mon)
-{
- PR_DestroyLock( mon->cvar->lock );
- PR_DestroyCondVar( mon->cvar );
- PR_DELETE( mon );
-}
-
-/*
-** Enter the lock associated with the monitor. If the calling thread currently
-** is in the monitor, the call to enter will silently succeed. In either case,
-** it will increment the entry count by one.
-*/
-PR_IMPLEMENT(void)
- PR_EnterMonitor (PRMonitor *mon)
-{
- if( mon->cvar->lock->owner == find_thread( NULL ) )
- {
- mon->entryCount++;
-
- } else
- {
- PR_Lock( mon->cvar->lock );
- mon->entryCount = 1;
- }
-}
-
-/*
-** Decrement the entry count associated with the monitor. If the decremented
-** entry count is zero, the monitor is exited. Returns PR_FAILURE if the
-** calling thread has not entered the monitor.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_ExitMonitor (PRMonitor *mon)
-{
- if( mon->cvar->lock->owner != find_thread( NULL ) )
- {
- return( PR_FAILURE );
- }
- if( --mon->entryCount == 0 )
- {
- return( PR_Unlock( mon->cvar->lock ) );
- }
- return( PR_SUCCESS );
-}
-
-/*
-** Wait for a notify on the monitor's condition variable. Sleep for "ticks"
-** amount of time (if "ticks" is PR_INTERVAL_NO_TIMEOUT then the sleep is
-** indefinite).
-**
-** While the thread is waiting it exits the monitor (as if it called
-** PR_ExitMonitor as many times as it had called PR_EnterMonitor). When
-** the wait has finished the thread regains control of the monitors lock
-** with the same entry count as before the wait began.
-**
-** The thread waiting on the monitor will be resumed when the monitor is
-** notified (assuming the thread is the next in line to receive the
-** notify) or when the "ticks" timeout elapses.
-**
-** Returns PR_FAILURE if the caller has not entered the monitor.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_Wait (PRMonitor *mon, PRIntervalTime ticks)
-{
- PRUint32 entryCount;
- PRUintn status;
- PRThread *meThread;
- thread_id me = find_thread( NULL );
- meThread = PR_GetCurrentThread();
-
- if( mon->cvar->lock->owner != me ) return( PR_FAILURE );
-
- entryCount = mon->entryCount;
- mon->entryCount = 0;
-
- status = PR_WaitCondVar( mon->cvar, ticks );
-
- mon->entryCount = entryCount;
-
- return( status );
-}
-
-/*
-** Notify a thread waiting on the monitor's condition variable. If a thread
-** is waiting on the condition variable (using PR_Wait) then it is awakened
-** and attempts to reenter the monitor.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_Notify (PRMonitor *mon)
-{
- if( mon->cvar->lock->owner != find_thread( NULL ) )
- {
- return( PR_FAILURE );
- }
-
- PR_NotifyCondVar( mon->cvar );
- return( PR_SUCCESS );
-}
-
-/*
-** Notify all of the threads waiting on the monitor's condition variable.
-** All of threads waiting on the condition are scheduled to reenter the
-** monitor.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_NotifyAll (PRMonitor *mon)
-{
- if( mon->cvar->lock->owner != find_thread( NULL ) )
- {
- return( PR_FAILURE );
- }
-
- PR_NotifyAllCondVar( mon->cvar );
- return( PR_SUCCESS );
-}
-
-/*
-** Return the number of times that the current thread has entered the
-** lock. Returns zero if the current thread has not entered the lock.
-*/
-PR_IMPLEMENT(PRIntn)
- PR_GetMonitorEntryCount(PRMonitor *mon)
-{
- return( (mon->cvar->lock->owner == find_thread( NULL )) ?
- mon->entryCount : 0 );
-}
-
-/*
-** If the current thread is in |mon|, this assertion is guaranteed to
-** succeed. Otherwise, the behavior of this function is undefined.
-*/
-PR_IMPLEMENT(void)
- PR_AssertCurrentThreadInMonitor(PRMonitor *mon)
-{
- PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(mon->cvar->lock);
-}
diff --git a/pr/src/bthreads/btsem.c b/pr/src/bthreads/btsem.c
deleted file mode 100644
index 011ee6bd..00000000
--- a/pr/src/bthreads/btsem.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <kernel/OS.h>
-
-#include "primpl.h"
-
-/*
-** Create a new semaphore object.
-*/
-PR_IMPLEMENT(PRSemaphore*)
- PR_NewSem (PRUintn value)
-{
- PRSemaphore *semaphore;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- semaphore = PR_NEWZAP(PRSemaphore);
- if (NULL != semaphore) {
- if ((semaphore->sem = create_sem(value, "nspr_sem")) < B_NO_ERROR)
- return NULL;
- else
- return semaphore;
- }
- return NULL;
-}
-
-/*
-** Destroy the given semaphore object.
-**
-*/
-PR_IMPLEMENT(void)
- PR_DestroySem (PRSemaphore *sem)
-{
- status_t result;
-
- PR_ASSERT(sem != NULL);
- result = delete_sem(sem->sem);
- PR_ASSERT(result == B_NO_ERROR);
- PR_DELETE(sem);
-}
-
-/*
-** Wait on a Semaphore.
-**
-** This routine allows a calling thread to wait or proceed depending upon
-** the state of the semahore sem. The thread can proceed only if the
-** counter value of the semaphore sem is currently greater than 0. If the
-** value of semaphore sem is positive, it is decremented by one and the
-** routine returns immediately allowing the calling thread to continue. If
-** the value of semaphore sem is 0, the calling thread blocks awaiting the
-** semaphore to be released by another thread.
-**
-** This routine can return PR_PENDING_INTERRUPT if the waiting thread
-** has been interrupted.
-*/
-PR_IMPLEMENT(PRStatus)
- PR_WaitSem (PRSemaphore *sem)
-{
- PR_ASSERT(sem != NULL);
- if (acquire_sem(sem->sem) == B_NO_ERROR)
- return PR_SUCCESS;
- else
- return PR_FAILURE;
-}
-
-/*
-** This routine increments the counter value of the semaphore. If other
-** threads are blocked for the semaphore, then the scheduler will
-** determine which ONE thread will be unblocked.
-*/
-PR_IMPLEMENT(void)
- PR_PostSem (PRSemaphore *sem)
-{
- status_t result;
-
- PR_ASSERT(sem != NULL);
- result = release_sem_etc(sem->sem, 1, B_DO_NOT_RESCHEDULE);
- PR_ASSERT(result == B_NO_ERROR);
-}
-
-/*
-** Returns the value of the semaphore referenced by sem without affecting
-** the state of the semaphore. The value represents the semaphore value
-** at the time of the call, but may not be the actual value when the
-** caller inspects it.
-*/
-PR_IMPLEMENT(PRUintn)
- PR_GetValueSem (PRSemaphore *sem)
-{
- sem_info info;
-
- PR_ASSERT(sem != NULL);
- get_sem_info(sem->sem, &info);
- return info.count;
-}
diff --git a/pr/src/bthreads/btthread.c b/pr/src/bthreads/btthread.c
deleted file mode 100644
index c2a1cd82..00000000
--- a/pr/src/bthreads/btthread.c
+++ /dev/null
@@ -1,662 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include <kernel/OS.h>
-#include <support/TLS.h>
-
-#include "prlog.h"
-#include "primpl.h"
-#include "prcvar.h"
-#include "prpdce.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-/* values for PRThread.state */
-#define BT_THREAD_PRIMORD 0x01 /* this is the primordial thread */
-#define BT_THREAD_SYSTEM 0x02 /* this is a system thread */
-#define BT_THREAD_JOINABLE 0x04 /* this is a joinable thread */
-
-struct _BT_Bookeeping
-{
- PRLock *ml; /* a lock to protect ourselves */
- sem_id cleanUpSem; /* the primoridal thread will block on this
- sem while waiting for the user threads */
- PRInt32 threadCount; /* user thred count */
-
-} bt_book = { NULL, B_ERROR, 0 };
-
-
-#define BT_TPD_LIMIT 128 /* number of TPD slots we'll provide (arbitrary) */
-
-/* these will be used to map an index returned by PR_NewThreadPrivateIndex()
- to the corresponding beos native TLS slot number, and to the destructor
- for that slot - note that, because it is allocated globally, this data
- will be automatically zeroed for us when the program begins */
-static int32 tpd_beosTLSSlots[BT_TPD_LIMIT];
-static PRThreadPrivateDTOR tpd_dtors[BT_TPD_LIMIT];
-
-static vint32 tpd_slotsUsed=0; /* number of currently-allocated TPD slots */
-static int32 tls_prThreadSlot; /* TLS slot in which PRThread will be stored */
-
-/* this mutex will be used to synchronize access to every
- PRThread.md.joinSem and PRThread.md.is_joining (we could
- actually allocate one per thread, but that seems a bit excessive,
- especially considering that there will probably be little
- contention, PR_JoinThread() is allowed to block anyway, and the code
- protected by the mutex is short/fast) */
-static PRLock *joinSemLock;
-
-static PRUint32 _bt_MapNSPRToNativePriority( PRThreadPriority priority );
-static PRThreadPriority _bt_MapNativeToNSPRPriority( PRUint32 priority );
-static void _bt_CleanupThread(void *arg);
-static PRThread *_bt_AttachThread();
-
-void
-_PR_InitThreads (PRThreadType type, PRThreadPriority priority,
- PRUintn maxPTDs)
-{
- PRThread *primordialThread;
- PRUint32 beThreadPriority;
-
- /* allocate joinSem mutex */
- joinSemLock = PR_NewLock();
- if (joinSemLock == NULL)
- {
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return;
- }
-
- /*
- ** Create and initialize NSPR structure for our primordial thread.
- */
-
- primordialThread = PR_NEWZAP(PRThread);
- if( NULL == primordialThread )
- {
- PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 );
- return;
- }
-
- primordialThread->md.joinSem = B_ERROR;
-
- /*
- ** Set the priority to the desired level.
- */
-
- beThreadPriority = _bt_MapNSPRToNativePriority( priority );
-
- set_thread_priority( find_thread( NULL ), beThreadPriority );
-
- primordialThread->priority = priority;
-
-
- /* set the thread's state - note that the thread is not joinable */
- primordialThread->state |= BT_THREAD_PRIMORD;
- if (type == PR_SYSTEM_THREAD)
- primordialThread->state |= BT_THREAD_SYSTEM;
-
- /*
- ** Allocate a TLS slot for the PRThread structure (just using
- ** native TLS, as opposed to NSPR TPD, will make PR_GetCurrentThread()
- ** somewhat faster, and will leave one more TPD slot for our client)
- */
-
- tls_prThreadSlot = tls_allocate();
-
- /*
- ** Stuff our new PRThread structure into our thread specific
- ** slot.
- */
-
- tls_set(tls_prThreadSlot, primordialThread);
-
- /* allocate lock for bt_book */
- bt_book.ml = PR_NewLock();
- if( NULL == bt_book.ml )
- {
- PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 );
- return;
- }
-}
-
-PRUint32
-_bt_MapNSPRToNativePriority( PRThreadPriority priority )
- {
- switch( priority )
- {
- case PR_PRIORITY_LOW: return( B_LOW_PRIORITY );
- case PR_PRIORITY_NORMAL: return( B_NORMAL_PRIORITY );
- case PR_PRIORITY_HIGH: return( B_DISPLAY_PRIORITY );
- case PR_PRIORITY_URGENT: return( B_URGENT_DISPLAY_PRIORITY );
- default: return( B_NORMAL_PRIORITY );
- }
-}
-
-PRThreadPriority
-_bt_MapNativeToNSPRPriority(PRUint32 priority)
- {
- if (priority < B_NORMAL_PRIORITY)
- return PR_PRIORITY_LOW;
- if (priority < B_DISPLAY_PRIORITY)
- return PR_PRIORITY_NORMAL;
- if (priority < B_URGENT_DISPLAY_PRIORITY)
- return PR_PRIORITY_HIGH;
- return PR_PRIORITY_URGENT;
-}
-
-PRUint32
-_bt_mapNativeToNSPRPriority( int32 priority )
-{
- switch( priority )
- {
- case PR_PRIORITY_LOW: return( B_LOW_PRIORITY );
- case PR_PRIORITY_NORMAL: return( B_NORMAL_PRIORITY );
- case PR_PRIORITY_HIGH: return( B_DISPLAY_PRIORITY );
- case PR_PRIORITY_URGENT: return( B_URGENT_DISPLAY_PRIORITY );
- default: return( B_NORMAL_PRIORITY );
- }
-}
-
-/* This method is called by all NSPR threads as they exit */
-void _bt_CleanupThread(void *arg)
-{
- PRThread *me = PR_GetCurrentThread();
- int32 i;
-
- /* first, clean up all thread-private data */
- for (i = 0; i < tpd_slotsUsed; i++)
- {
- void *oldValue = tls_get(tpd_beosTLSSlots[i]);
- if ( oldValue != NULL && tpd_dtors[i] != NULL )
- (*tpd_dtors[i])(oldValue);
- }
-
- /* if this thread is joinable, wait for someone to join it */
- if (me->state & BT_THREAD_JOINABLE)
- {
- /* protect access to our joinSem */
- PR_Lock(joinSemLock);
-
- if (me->md.is_joining)
- {
- /* someone is already waiting to join us (they've
- allocated a joinSem for us) - let them know we're
- ready */
- delete_sem(me->md.joinSem);
-
- PR_Unlock(joinSemLock);
-
- }
- else
- {
- /* noone is currently waiting for our demise - it
- is our responsibility to allocate the joinSem
- and block on it */
- me->md.joinSem = create_sem(0, "join sem");
-
- /* we're done accessing our joinSem */
- PR_Unlock(joinSemLock);
-
- /* wait for someone to join us */
- while (acquire_sem(me->md.joinSem) == B_INTERRUPTED);
- }
- }
-
- /* if this is a user thread, we must update our books */
- if ((me->state & BT_THREAD_SYSTEM) == 0)
- {
- /* synchronize access to bt_book */
- PR_Lock( bt_book.ml );
-
- /* decrement the number of currently-alive user threads */
- bt_book.threadCount--;
-
- if (bt_book.threadCount == 0 && bt_book.cleanUpSem != B_ERROR) {
- /* we are the last user thread, and the primordial thread is
- blocked in PR_Cleanup() waiting for us to finish - notify
- it */
- delete_sem(bt_book.cleanUpSem);
- }
-
- PR_Unlock( bt_book.ml );
- }
-
- /* finally, delete this thread's PRThread */
- PR_DELETE(me);
-}
-
-/**
- * This is a wrapper that all threads invoke that allows us to set some
- * things up prior to a thread's invocation and clean up after a thread has
- * exited.
- */
-static void*
-_bt_root (void* arg)
- {
- PRThread *thred = (PRThread*)arg;
- PRIntn rv;
- void *privData;
- status_t result;
- int i;
-
- /* save our PRThread object into our TLS */
- tls_set(tls_prThreadSlot, thred);
-
- thred->startFunc(thred->arg); /* run the dang thing */
-
- /* clean up */
- _bt_CleanupThread(NULL);
-
- return 0;
-}
-
-PR_IMPLEMENT(PRThread*)
- PR_CreateThread (PRThreadType type, void (*start)(void* arg), void* arg,
- PRThreadPriority priority, PRThreadScope scope,
- PRThreadState state, PRUint32 stackSize)
-{
- PRUint32 bePriority;
-
- PRThread* thred;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- thred = PR_NEWZAP(PRThread);
- if (thred == NULL)
- {
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return NULL;
- }
-
- thred->md.joinSem = B_ERROR;
-
- thred->arg = arg;
- thred->startFunc = start;
- thred->priority = priority;
-
- if( state == PR_JOINABLE_THREAD )
- {
- thred->state |= BT_THREAD_JOINABLE;
- }
-
- /* keep some books */
-
- PR_Lock( bt_book.ml );
-
- if (type == PR_USER_THREAD)
- {
- bt_book.threadCount++;
- }
-
- PR_Unlock( bt_book.ml );
-
- bePriority = _bt_MapNSPRToNativePriority( priority );
-
- thred->md.tid = spawn_thread((thread_func)_bt_root, "moz-thread",
- bePriority, thred);
- if (thred->md.tid < B_OK) {
- PR_SetError(PR_UNKNOWN_ERROR, thred->md.tid);
- PR_DELETE(thred);
- return NULL;
- }
-
- if (resume_thread(thred->md.tid) < B_OK) {
- PR_SetError(PR_UNKNOWN_ERROR, 0);
- PR_DELETE(thred);
- return NULL;
- }
-
- return thred;
- }
-
-PR_IMPLEMENT(PRThread*)
- PR_AttachThread(PRThreadType type, PRThreadPriority priority,
- PRThreadStack *stack)
-{
- /* PR_GetCurrentThread() will attach a thread if necessary */
- return PR_GetCurrentThread();
-}
-
-PR_IMPLEMENT(void)
- PR_DetachThread()
-{
- /* we don't support detaching */
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_JoinThread (PRThread* thred)
-{
- status_t eval, status;
-
- PR_ASSERT(thred != NULL);
-
- if ((thred->state & BT_THREAD_JOINABLE) == 0)
- {
- PR_SetError( PR_INVALID_ARGUMENT_ERROR, 0 );
- return( PR_FAILURE );
- }
-
- /* synchronize access to the thread's joinSem */
- PR_Lock(joinSemLock);
-
- if (thred->md.is_joining)
- {
- /* another thread is already waiting to join the specified
- thread - we must fail */
- PR_Unlock(joinSemLock);
- return PR_FAILURE;
- }
-
- /* let others know we are waiting to join */
- thred->md.is_joining = PR_TRUE;
-
- if (thred->md.joinSem == B_ERROR)
- {
- /* the thread hasn't finished yet - it is our responsibility to
- allocate a joinSem and wait on it */
- thred->md.joinSem = create_sem(0, "join sem");
-
- /* we're done changing the joinSem now */
- PR_Unlock(joinSemLock);
-
- /* wait for the thread to finish */
- while (acquire_sem(thred->md.joinSem) == B_INTERRUPTED);
-
- }
- else
- {
- /* the thread has already finished, and has allocated the
- joinSem itself - let it know it can finally die */
- delete_sem(thred->md.joinSem);
-
- PR_Unlock(joinSemLock);
- }
-
- /* make sure the thread is dead */
- wait_for_thread(thred->md.tid, &eval);
-
- return PR_SUCCESS;
-}
-
-PR_IMPLEMENT(PRThread*)
- PR_GetCurrentThread ()
-{
- PRThread* thred;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- thred = (PRThread *)tls_get( tls_prThreadSlot);
- if (thred == NULL)
- {
- /* this thread doesn't have a PRThread structure (it must be
- a native thread not created by the NSPR) - assimilate it */
- thred = _bt_AttachThread();
- }
- PR_ASSERT(NULL != thred);
-
- return thred;
-}
-
-PR_IMPLEMENT(PRThreadScope)
- PR_GetThreadScope (const PRThread* thred)
-{
- PR_ASSERT(thred != NULL);
- return PR_GLOBAL_THREAD;
-}
-
-PR_IMPLEMENT(PRThreadType)
- PR_GetThreadType (const PRThread* thred)
-{
- PR_ASSERT(thred != NULL);
- return (thred->state & BT_THREAD_SYSTEM) ?
- PR_SYSTEM_THREAD : PR_USER_THREAD;
-}
-
-PR_IMPLEMENT(PRThreadState)
- PR_GetThreadState (const PRThread* thred)
-{
- PR_ASSERT(thred != NULL);
- return (thred->state & BT_THREAD_JOINABLE)?
- PR_JOINABLE_THREAD: PR_UNJOINABLE_THREAD;
-}
-
-PR_IMPLEMENT(PRThreadPriority)
- PR_GetThreadPriority (const PRThread* thred)
-{
- PR_ASSERT(thred != NULL);
- return thred->priority;
-} /* PR_GetThreadPriority */
-
-PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred,
- PRThreadPriority newPri)
-{
- PRUint32 bePriority;
-
- PR_ASSERT( thred != NULL );
-
- thred->priority = newPri;
- bePriority = _bt_MapNSPRToNativePriority( newPri );
- set_thread_priority( thred->md.tid, bePriority );
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_NewThreadPrivateIndex (PRUintn* newIndex,
- PRThreadPrivateDTOR destructor)
-{
- int32 index;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- /* reserve the next available tpd slot */
- index = atomic_add( &tpd_slotsUsed, 1 );
- if (index >= BT_TPD_LIMIT)
- {
- /* no slots left - decrement value, then fail */
- atomic_add( &tpd_slotsUsed, -1 );
- PR_SetError( PR_TPD_RANGE_ERROR, 0 );
- return( PR_FAILURE );
- }
-
- /* allocate a beos-native TLS slot for this index (the new slot
- automatically contains NULL) */
- tpd_beosTLSSlots[index] = tls_allocate();
-
- /* remember the destructor */
- tpd_dtors[index] = destructor;
-
- *newIndex = (PRUintn)index;
-
- return( PR_SUCCESS );
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_SetThreadPrivate (PRUintn index, void* priv)
-{
- void *oldValue;
-
- /*
- ** Sanity checking
- */
-
- if(index < 0 || index >= tpd_slotsUsed || index >= BT_TPD_LIMIT)
- {
- PR_SetError( PR_TPD_RANGE_ERROR, 0 );
- return( PR_FAILURE );
- }
-
- /* if the old value isn't NULL, and the dtor for this slot isn't
- NULL, we must destroy the data */
- oldValue = tls_get(tpd_beosTLSSlots[index]);
- if (oldValue != NULL && tpd_dtors[index] != NULL)
- (*tpd_dtors[index])(oldValue);
-
- /* save new value */
- tls_set(tpd_beosTLSSlots[index], priv);
-
- return( PR_SUCCESS );
- }
-
-PR_IMPLEMENT(void*)
- PR_GetThreadPrivate (PRUintn index)
-{
- /* make sure the index is valid */
- if (index < 0 || index >= tpd_slotsUsed || index >= BT_TPD_LIMIT)
- {
- PR_SetError( PR_TPD_RANGE_ERROR, 0 );
- return NULL;
- }
-
- /* return the value */
- return tls_get( tpd_beosTLSSlots[index] );
- }
-
-
-PR_IMPLEMENT(PRStatus)
- PR_Interrupt (PRThread* thred)
-{
- PRIntn rv;
-
- PR_ASSERT(thred != NULL);
-
- /*
- ** there seems to be a bug in beos R5 in which calling
- ** resume_thread() on a blocked thread returns B_OK instead
- ** of B_BAD_THREAD_STATE (beos bug #20000422-19095). as such,
- ** to interrupt a thread, we will simply suspend then resume it
- ** (no longer call resume_thread(), check for B_BAD_THREAD_STATE,
- ** the suspend/resume to wake up a blocked thread). this wakes
- ** up blocked threads properly, and doesn't hurt unblocked threads
- ** (they simply get stopped then re-started immediately)
- */
-
- rv = suspend_thread( thred->md.tid );
- if( rv != B_NO_ERROR )
- {
- /* this doesn't appear to be a valid thread_id */
- PR_SetError( PR_UNKNOWN_ERROR, rv );
- return PR_FAILURE;
- }
-
- rv = resume_thread( thred->md.tid );
- if( rv != B_NO_ERROR )
- {
- PR_SetError( PR_UNKNOWN_ERROR, rv );
- return PR_FAILURE;
- }
-
- return PR_SUCCESS;
-}
-
-PR_IMPLEMENT(void)
- PR_ClearInterrupt ()
-{
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_Yield ()
-{
- /* we just sleep for long enough to cause a reschedule (100
- microseconds) */
- snooze(100);
-}
-
-#define BT_MILLION 1000000UL
-
-PR_IMPLEMENT(PRStatus)
- PR_Sleep (PRIntervalTime ticks)
-{
- bigtime_t tps;
- status_t status;
-
- if (!_pr_initialized) _PR_ImplicitInitialization();
-
- tps = PR_IntervalToMicroseconds( ticks );
-
- status = snooze(tps);
- if (status == B_NO_ERROR) return PR_SUCCESS;
-
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, status);
- return PR_FAILURE;
-}
-
-PR_IMPLEMENT(PRStatus)
- PR_Cleanup ()
-{
- PRThread *me = PR_GetCurrentThread();
-
- PR_ASSERT(me->state & BT_THREAD_PRIMORD);
- if ((me->state & BT_THREAD_PRIMORD) == 0) {
- return PR_FAILURE;
- }
-
- PR_Lock( bt_book.ml );
-
- if (bt_book.threadCount != 0)
- {
- /* we'll have to wait for some threads to finish - create a
- sem to block on */
- bt_book.cleanUpSem = create_sem(0, "cleanup sem");
- }
-
- PR_Unlock( bt_book.ml );
-
- /* note that, if all the user threads were already dead, we
- wouldn't have created a sem above, so this acquire_sem()
- will fail immediately */
- while (acquire_sem(bt_book.cleanUpSem) == B_INTERRUPTED);
-
- return PR_SUCCESS;
-}
-
-PR_IMPLEMENT(void)
- PR_ProcessExit (PRIntn status)
-{
- exit(status);
-}
-
-PRThread *_bt_AttachThread()
-{
- PRThread *thread;
- thread_info tInfo;
-
- /* make sure this thread doesn't already have a PRThread structure */
- PR_ASSERT(tls_get(tls_prThreadSlot) == NULL);
-
- /* allocate a PRThread structure for this thread */
- thread = PR_NEWZAP(PRThread);
- if (thread == NULL)
- {
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return NULL;
- }
-
- /* get the native thread's current state */
- get_thread_info(find_thread(NULL), &tInfo);
-
- /* initialize new PRThread */
- thread->md.tid = tInfo.thread;
- thread->md.joinSem = B_ERROR;
- thread->priority = _bt_MapNativeToNSPRPriority(tInfo.priority);
-
- /* attached threads are always non-joinable user threads */
- thread->state = 0;
-
- /* increment user thread count */
- PR_Lock(bt_book.ml);
- bt_book.threadCount++;
- PR_Unlock(bt_book.ml);
-
- /* store this thread's PRThread */
- tls_set(tls_prThreadSlot, thread);
-
- /* the thread must call _bt_CleanupThread() before it dies, in order
- to clean up its PRThread, synchronize with the primordial thread,
- etc. */
- on_exit_thread(_bt_CleanupThread, NULL);
-
- return thread;
-}
diff --git a/pr/src/bthreads/objs.mk b/pr/src/bthreads/objs.mk
deleted file mode 100644
index b273ba46..00000000
--- a/pr/src/bthreads/objs.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This makefile appends to the variable OBJS the bthread object modules
-# that will be part of the nspr20 library.
-
-include $(srcdir)/bthreads/bsrcs.mk
-
-OBJS += $(BTCSRCS:%.c=bthreads/$(OBJDIR)/%.$(OBJ_SUFFIX))
diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c
index e32031bb..7189fd68 100644
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -388,9 +388,6 @@ PR_IMPLEMENT(PRInt32) PR_GetSysfdTableMax(void)
ULONG ulCurMaxFH = 0;
DosSetRelMaxFH(&ulReqCount, &ulCurMaxFH);
return ulCurMaxFH;
-#elif defined(XP_BEOS)
- PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
- return -1;
#else
write me;
#endif
@@ -434,7 +431,7 @@ PR_IMPLEMENT(PRInt32) PR_SetSysfdTableSize(int table_size)
}
return tableMax;
#elif defined(AIX) || defined(QNX) \
- || defined(WIN32) || defined(WIN16) || defined(XP_BEOS)
+ || defined(WIN32) || defined(WIN16)
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return -1;
#else
@@ -692,7 +689,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
(*readPipe)->secret->inheritable = _PR_TRI_TRUE;
(*writePipe)->secret->inheritable = _PR_TRI_TRUE;
return PR_SUCCESS;
-#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
+#elif defined(XP_UNIX) || defined(XP_OS2)
#ifdef XP_OS2
HFILE pipefd[2];
#else
@@ -722,13 +719,9 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
close(pipefd[1]);
return PR_FAILURE;
}
-#ifndef XP_BEOS /* Pipes are nonblocking on BeOS */
_PR_MD_MAKE_NONBLOCK(*readPipe);
-#endif
_PR_MD_INIT_FD_INHERITABLE(*readPipe, PR_FALSE);
-#ifndef XP_BEOS /* Pipes are nonblocking on BeOS */
_PR_MD_MAKE_NONBLOCK(*writePipe);
-#endif
_PR_MD_INIT_FD_INHERITABLE(*writePipe, PR_FALSE);
return PR_SUCCESS;
#else
diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c
index 10ae5e09..b480f7f1 100644
--- a/pr/src/io/prio.c
+++ b/pr/src/io/prio.c
@@ -223,7 +223,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable(
PRFileDesc *fd,
PRBool inheritable)
{
-#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2)
/*
* Only a non-layered, NSPR file descriptor can be inherited
* by a child process.
diff --git a/pr/src/io/prmapopt.c b/pr/src/io/prmapopt.c
index f92a76b2..556001ea 100644
--- a/pr/src/io/prmapopt.c
+++ b/pr/src/io/prmapopt.c
@@ -62,7 +62,6 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat
{
case PR_SockOpt_Linger:
{
-#if !defined(XP_BEOS) || defined(BONE_VERSION)
struct linger linger;
length = sizeof(linger);
rv = _PR_MD_GETSOCKOPT(
@@ -76,10 +75,6 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat
PR_SecondsToInterval(linger.l_linger);
}
break;
-#else
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return PR_FAILURE;
-#endif
}
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
@@ -221,17 +216,12 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt
{
case PR_SockOpt_Linger:
{
-#if !defined(XP_BEOS) || defined(BONE_VERSION)
struct linger linger;
linger.l_onoff = data->value.linger.polarity;
linger.l_linger = PR_IntervalToSeconds(data->value.linger.linger);
rv = _PR_MD_SETSOCKOPT(
fd, level, name, (char*)&linger, sizeof(linger));
break;
-#else
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return PR_FAILURE;
-#endif
}
case PR_SockOpt_Reuseaddr:
case PR_SockOpt_Keepalive:
diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c
index 4063bd84..8e7ce1f9 100644
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -381,25 +381,6 @@ static PRStatus PR_CALLBACK SocketConnectContinue(
}
return PR_SUCCESS;
-#elif defined(XP_BEOS)
-
-#ifdef BONE_VERSION /* bug 122364 */
- /* temporary workaround until getsockopt(SO_ERROR) works in BONE */
- if (out_flags & PR_POLL_EXCEPT) {
- PR_SetError(PR_CONNECT_REFUSED_ERROR, 0);
- return PR_FAILURE;
- }
- PR_ASSERT(out_flags & PR_POLL_WRITE);
- return PR_SUCCESS;
-#else
- err = _MD_beos_get_nonblocking_connect_error(fd);
- if( err != 0 ) {
- _PR_MD_MAP_CONNECT_ERROR(err);
- return PR_FAILURE;
- }
- else
- return PR_SUCCESS;
-#endif /* BONE_VERSION */
#else
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index 4503d9f8..31f30b6a 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -7,10 +7,6 @@
#include <string.h>
-#ifdef XP_BEOS
-#include <image.h>
-#endif
-
#if defined(XP_MACOSX) && defined(USE_MACH_DYLD)
#include <Carbon/Carbon.h>
#include <CoreFoundation/CoreFoundation.h>
@@ -92,10 +88,6 @@ struct PRLibrary {
#endif
#endif
-#ifdef XP_BEOS
- void* dlh;
- void* stub_dlh;
-#endif
};
static PRLibrary *pr_loadmap;
@@ -272,23 +264,16 @@ PR_GetLibraryPath(void)
ev = strdup(ev);
#endif
-#if defined(XP_UNIX) || defined(XP_BEOS)
-#if defined(USE_DLFCN) || defined(USE_MACH_DYLD) || defined(XP_BEOS)
+#if defined(XP_UNIX)
+#if defined(USE_DLFCN) || defined(USE_MACH_DYLD)
{
char *p=NULL;
int len;
-#ifdef XP_BEOS
- ev = getenv("LIBRARY_PATH");
- if (!ev) {
- ev = "%A/lib:/boot/home/config/lib:/boot/beos/system/lib";
- }
-#else
ev = getenv("LD_LIBRARY_PATH");
if (!ev) {
ev = "/usr/lib:/lib";
}
-#endif
len = strlen(ev) + 1; /* +1 for the null */
p = (char*) malloc(len);
@@ -345,7 +330,7 @@ PR_GetLibraryName(const char *path, const char *lib)
}
}
#endif /* XP_PC */
-#if defined(XP_UNIX) || defined(XP_BEOS)
+#if defined(XP_UNIX)
if (strstr(lib, PR_DLL_SUFFIX) == NULL)
{
if (path) {
@@ -360,7 +345,7 @@ PR_GetLibraryName(const char *path, const char *lib)
fullname = PR_smprintf("%s", lib);
}
}
-#endif /* XP_UNIX || XP_BEOS */
+#endif /* XP_UNIX */
return fullname;
}
@@ -838,96 +823,6 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
lm->refCount = 1;
-#ifdef XP_BEOS
- {
- image_info info;
- int32 cookie = 0;
- image_id imageid = B_ERROR;
- image_id stubid = B_ERROR;
- PRLibrary *p;
-
- for (p = pr_loadmap; p != NULL; p = p->next) {
- /* hopefully, our caller will always use the same string
- to refer to the same library */
- if (strcmp(name, p->name) == 0) {
- /* we've already loaded this library */
- imageid = info.id;
- lm->refCount++;
- break;
- }
- }
-
- if(imageid == B_ERROR) {
- /* it appears the library isn't yet loaded - load it now */
- char stubName [B_PATH_NAME_LENGTH + 1];
-
- /* the following is a work-around to a "bug" in the beos -
- the beos system loader allows only 32M (system-wide)
- to be used by code loaded as "add-ons" (code loaded
- through the 'load_add_on()' system call, which includes
- mozilla components), but allows 256M to be used by
- shared libraries.
-
- unfortunately, mozilla is too large to fit into the
- "add-on" space, so we must trick the loader into
- loading some of the components as shared libraries. this
- is accomplished by creating a "stub" add-on (an empty
- shared object), and linking it with the component
- (the actual .so file generated by the build process,
- without any modifications). when this stub is loaded
- by load_add_on(), the loader will automatically load the
- component into the shared library space.
- */
-
- strcpy(stubName, name);
- strcat(stubName, ".stub");
-
- /* first, attempt to load the stub (thereby loading the
- component as a shared library */
- if ((stubid = load_add_on(stubName)) > B_ERROR) {
- /* the stub was loaded successfully. */
- imageid = B_FILE_NOT_FOUND;
-
- cookie = 0;
- while (get_next_image_info(0, &cookie, &info) == B_OK) {
- const char *endOfSystemName = strrchr(info.name, '/');
- const char *endOfPassedName = strrchr(name, '/');
- if( 0 == endOfSystemName )
- endOfSystemName = info.name;
- else
- endOfSystemName++;
- if( 0 == endOfPassedName )
- endOfPassedName = name;
- else
- endOfPassedName++;
- if (strcmp(endOfSystemName, endOfPassedName) == 0) {
- /* this is the actual component - remember it */
- imageid = info.id;
- break;
- }
- }
-
- } else {
- /* we failed to load the "stub" - try to load the
- component directly as an add-on */
- stubid = B_ERROR;
- imageid = load_add_on(name);
- }
- }
-
- if (imageid <= B_ERROR) {
- oserr = imageid;
- PR_DELETE( lm );
- goto unlock;
- }
- lm->name = strdup(name);
- lm->dlh = (void*)imageid;
- lm->stub_dlh = (void*)stubid;
- lm->next = pr_loadmap;
- pr_loadmap = lm;
- }
-#endif
-
result = lm; /* success */
PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (load lib)", lm->name));
@@ -975,13 +870,6 @@ PR_UnloadLibrary(PRLibrary *lib)
goto done;
}
-#ifdef XP_BEOS
- if(((image_id)lib->stub_dlh) == B_ERROR)
- unload_add_on( (image_id) lib->dlh );
- else
- unload_add_on( (image_id) lib->stub_dlh);
-#endif
-
#ifdef XP_UNIX
#ifdef HAVE_DLL
#ifdef USE_DLFCN
@@ -1078,7 +966,7 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name)
** If the symbol was not found in the static table then check if
** the symbol was exported in the DLL... Win16 only!!
*/
-#if !defined(WIN16) && !defined(XP_BEOS)
+#if !defined(WIN16)
PR_SetError(PR_FIND_SYMBOL_ERROR, 0);
return (void*)NULL;
#endif
@@ -1145,12 +1033,6 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name)
#undef SYM_OFFSET
#endif /* XP_MACOSX && USE_MACH_DYLD */
-#ifdef XP_BEOS
- if( B_NO_ERROR != get_image_symbol( (image_id)lm->dlh, name, B_SYMBOL_TYPE_TEXT, &f ) ) {
- f = NULL;
- }
-#endif
-
#ifdef XP_UNIX
#ifdef HAVE_DLL
#ifdef USE_DLFCN
diff --git a/pr/src/md/beos/.cvsignore b/pr/src/md/beos/.cvsignore
deleted file mode 100644
index f3c7a7c5..00000000
--- a/pr/src/md/beos/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/pr/src/md/beos/Makefile.in b/pr/src/md/beos/Makefile.in
deleted file mode 100644
index 340f144a..00000000
--- a/pr/src/md/beos/Makefile.in
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-MOD_DEPTH = ../../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(MOD_DEPTH)/config/autoconf.mk
-
-include $(topsrcdir)/config/config.mk
-
-include $(srcdir)/bsrcs.mk
-CSRCS += $(MDCSRCS)
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(topsrcdir)/config/rules.mk
-
-export:: $(TARGETS)
-
diff --git a/pr/src/md/beos/bcpu.c b/pr/src/md/beos/bcpu.c
deleted file mode 100644
index 6c253865..00000000
--- a/pr/src/md/beos/bcpu.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-PR_EXTERN(void) _PR_MD_INIT_CPUS();
-PR_EXTERN(void) _PR_MD_WAKEUP_CPUS();
-PR_EXTERN(void) _PR_MD_START_INTERRUPTS(void);
-PR_EXTERN(void) _PR_MD_STOP_INTERRUPTS(void);
-PR_EXTERN(void) _PR_MD_DISABLE_CLOCK_INTERRUPTS(void);
-PR_EXTERN(void) _PR_MD_BLOCK_CLOCK_INTERRUPTS(void);
-PR_EXTERN(void) _PR_MD_UNBLOCK_CLOCK_INTERRUPTS(void);
-PR_EXTERN(void) _PR_MD_CLOCK_INTERRUPT(void);
-PR_EXTERN(void) _PR_MD_INIT_STACK(PRThreadStack *ts, PRIntn redzone);
-PR_EXTERN(void) _PR_MD_CLEAR_STACK(PRThreadStack* ts);
-PR_EXTERN(PRInt32) _PR_MD_GET_INTSOFF(void);
-PR_EXTERN(void) _PR_MD_SET_INTSOFF(PRInt32 _val);
-PR_EXTERN(_PRCPU*) _PR_MD_CURRENT_CPU(void);
-PR_EXTERN(void) _PR_MD_SET_CURRENT_CPU(_PRCPU *cpu);
-PR_EXTERN(void) _PR_MD_INIT_RUNNING_CPU(_PRCPU *cpu);
-PR_EXTERN(PRInt32) _PR_MD_PAUSE_CPU(PRIntervalTime timeout);
diff --git a/pr/src/md/beos/beos.c b/pr/src/md/beos/beos.c
deleted file mode 100644
index a1df7d2f..00000000
--- a/pr/src/md/beos/beos.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-#include <signal.h>
-#include <unistd.h>
-#include <memory.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-/*
- * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or
- * PRInt32* pointer to a _PRSockLen_t* pointer.
- */
-#define _PRSockLen_t int
-
-/*
-** Global lock variable used to bracket calls into rusty libraries that
-** aren't thread safe (like libc, libX, etc).
-*/
-static PRLock *_pr_rename_lock = NULL;
-static PRMonitor *_pr_Xfe_mon = NULL;
-
-/*
- * Variables used by the GC code, initialized in _MD_InitSegs().
- * _pr_zero_fd should be a static variable. Unfortunately, there is
- * still some Unix-specific code left in function PR_GrowSegment()
- * in file memory/prseg.c that references it, so it needs
- * to be a global variable for now.
- */
-PRInt32 _pr_zero_fd = -1;
-static PRLock *_pr_md_lock = NULL;
-
-sigset_t timer_set;
-
-void _PR_UnixInit()
-{
- struct sigaction sigact;
- int rv;
-
- sigemptyset(&timer_set);
-
- sigact.sa_handler = SIG_IGN;
- sigemptyset(&sigact.sa_mask);
- sigact.sa_flags = 0;
- rv = sigaction(SIGPIPE, &sigact, 0);
- PR_ASSERT(0 == rv);
-
- _pr_rename_lock = PR_NewLock();
- PR_ASSERT(NULL != _pr_rename_lock);
- _pr_Xfe_mon = PR_NewMonitor();
- PR_ASSERT(NULL != _pr_Xfe_mon);
-}
-
-/*
- *-----------------------------------------------------------------------
- *
- * PR_Now --
- *
- * Returns the current time in microseconds since the epoch.
- * The epoch is midnight January 1, 1970 GMT.
- * The implementation is machine dependent. This is the Unix
- * implementation.
- * Cf. time_t time(time_t *tp)
- *
- *-----------------------------------------------------------------------
- */
-
-PR_IMPLEMENT(PRTime)
-PR_Now(void)
-{
- struct timeval tv;
- PRInt64 s, us, s2us;
-
- GETTIMEOFDAY(&tv);
- LL_I2L(s2us, PR_USEC_PER_SEC);
- LL_I2L(s, tv.tv_sec);
- LL_I2L(us, tv.tv_usec);
- LL_MUL(s, s, s2us);
- LL_ADD(s, s, us);
- return s;
-}
-
-PRIntervalTime
-_PR_UNIX_GetInterval()
-{
- struct timeval time;
- PRIntervalTime ticks;
-
- (void)GETTIMEOFDAY(&time); /* fallicy of course */
- ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC; /* that's in milliseconds */
- ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC; /* so's that */
- return ticks;
-} /* _PR_SUNOS_GetInterval */
-
-PRIntervalTime _PR_UNIX_TicksPerSecond()
-{
- return 1000; /* this needs some work :) */
-}
-
-/************************************************************************/
-
-/*
-** Special hacks for xlib. Xlib/Xt/Xm is not re-entrant nor is it thread
-** safe. Unfortunately, neither is mozilla. To make these programs work
-** in a pre-emptive threaded environment, we need to use a lock.
-*/
-
-void PR_XLock()
-{
- PR_EnterMonitor(_pr_Xfe_mon);
-}
-
-void PR_XUnlock()
-{
- PR_ExitMonitor(_pr_Xfe_mon);
-}
-
-PRBool PR_XIsLocked()
-{
- return (PR_InMonitor(_pr_Xfe_mon)) ? PR_TRUE : PR_FALSE;
-}
-
-void PR_XWait(int ms)
-{
- PR_Wait(_pr_Xfe_mon, PR_MillisecondsToInterval(ms));
-}
-
-void PR_XNotify(void)
-{
- PR_Notify(_pr_Xfe_mon);
-}
-
-void PR_XNotifyAll(void)
-{
- PR_NotifyAll(_pr_Xfe_mon);
-}
-
-#if !defined(BEOS)
-#ifdef HAVE_BSD_FLOCK
-
-#include <sys/file.h>
-
-PR_IMPLEMENT(PRStatus)
-_MD_LOCKFILE (PRInt32 f)
-{
- PRInt32 rv;
- rv = flock(f, LOCK_EX);
- 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;
- rv = flock(f, LOCK_EX|LOCK_NB);
- 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;
- rv = flock(f, LOCK_UN);
- if (rv == 0)
- return PR_SUCCESS;
- _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-#else
-
-PR_IMPLEMENT(PRStatus)
-_MD_LOCKFILE (PRInt32 f)
-{
- PRInt32 rv;
- rv = lockf(f, F_LOCK, 0);
- if (rv == 0)
- return PR_SUCCESS;
- _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
-PR_IMPLEMENT(PRStatus)
-_MD_TLOCKFILE (PRInt32 f)
-{
- PRInt32 rv;
- rv = lockf(f, F_TLOCK, 0);
- if (rv == 0)
- return PR_SUCCESS;
- _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
-PR_IMPLEMENT(PRStatus)
-_MD_UNLOCKFILE (PRInt32 f)
-{
- PRInt32 rv;
- rv = lockf(f, F_ULOCK, 0);
- if (rv == 0)
- return PR_SUCCESS;
- _PR_MD_MAP_LOCKF_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-#endif
-
-PR_IMPLEMENT(PRStatus)
- _MD_GETHOSTNAME (char *name, PRUint32 namelen)
-{
- PRIntn rv;
-
- rv = gethostname(name, namelen);
- if (0 == rv) {
- return PR_SUCCESS;
- }
- _PR_MD_MAP_GETHOSTNAME_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
-#endif
diff --git a/pr/src/md/beos/beos_errors.c b/pr/src/md/beos/beos_errors.c
deleted file mode 100644
index 687a5351..00000000
--- a/pr/src/md/beos/beos_errors.c
+++ /dev/null
@@ -1,1494 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "prtypes.h"
-#include "md/_unix_errors.h"
-#include "prerror.h"
-#include <errno.h>
-
-void _MD_unix_map_opendir_error(int err)
-{
- switch (err) {
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EMFILE:
- PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
- break;
- case ENFILE:
- PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_closedir_error(int err)
-{
- switch (err) {
- case EINVAL:
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_readdir_error(int err)
-{
-
- switch (err) {
- case 0:
- case ENOENT:
- PR_SetError(PR_NO_MORE_FILES_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#ifdef IRIX
-#ifdef IRIX5_3
-#else
- case EDIRCORRUPTED:
- PR_SetError(PR_DIRECTORY_CORRUPTED_ERROR, err);
- break;
-#endif
-#endif
-#ifdef EOVERFLOW
- case EOVERFLOW:
- PR_SetError(PR_IO_ERROR, err);
- break;
-#endif
- case EINVAL:
- PR_SetError(PR_IO_ERROR, err);
- break;
-#ifdef EBADMSG
- case EBADMSG:
- PR_SetError(PR_IO_ERROR, err);
- break;
-#endif
- case EDEADLK:
- PR_SetError(PR_DEADLOCK_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case ENOLCK:
- PR_SetError(PR_FILE_IS_LOCKED_ERROR, err);
- break;
-#ifdef ENOLINK
- case ENOLINK:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
-#endif
- case ENXIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_unlink_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EBUSY:
- PR_SetError(PR_FILESYSTEM_MOUNTED_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EPERM:
- PR_SetError(PR_IS_DIRECTORY_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_stat_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
-#ifdef EOVERFLOW
- case EOVERFLOW:
- PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_fstat_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ETIMEDOUT:
-#ifdef ENOLINK
- case ENOLINK:
-#endif
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
-#ifdef EOVERFLOW
- case EOVERFLOW:
- PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_rename_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EBUSY:
- PR_SetError(PR_FILESYSTEM_MOUNTED_ERROR, err);
- break;
-#ifdef EDQUOT
- case EDQUOT:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
-#endif
- case EEXIST:
- PR_SetError(PR_DIRECTORY_NOT_EMPTY_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case EISDIR:
- PR_SetError(PR_IS_DIRECTORY_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOSPC:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- case EXDEV:
- PR_SetError(PR_NOT_SAME_DEVICE_ERROR, err);
- break;
- case EMLINK:
- PR_SetError(PR_MAX_DIRECTORY_ENTRIES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_access_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_mkdir_error(int err)
-{
- switch (err) {
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EEXIST:
- PR_SetError(PR_FILE_EXISTS_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case EMLINK:
- PR_SetError(PR_MAX_DIRECTORY_ENTRIES_ERROR, err);
- break;
- case ENOSPC:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
-#ifdef EDQUOT
- case EDQUOT:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
-#endif
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_rmdir_error(int err)
-{
-
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EBUSY:
- PR_SetError(PR_FILESYSTEM_MOUNTED_ERROR, err);
- break;
- case EEXIST:
- PR_SetError(PR_DIRECTORY_NOT_EMPTY_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_DIRECTORY_NOT_EMPTY_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_read_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#ifdef EBADMSG
- case EBADMSG:
- PR_SetError(PR_IO_ERROR, err);
- break;
-#endif
- case EDEADLK:
- PR_SetError(PR_DEADLOCK_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case ENOLCK:
- PR_SetError(PR_FILE_IS_LOCKED_ERROR, err);
- break;
- case ENXIO:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EISDIR:
- PR_SetError(PR_IS_DIRECTORY_ERROR, err);
- break;
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
-#ifdef ENOLINK
- case ENOLINK:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_write_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EDEADLK:
- PR_SetError(PR_DEADLOCK_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EFBIG:
- PR_SetError(PR_FILE_TOO_BIG_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case ENOLCK:
- PR_SetError(PR_FILE_IS_LOCKED_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case ENOSPC:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
- case ENXIO:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- case ERANGE:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
-#ifdef EDQUOT
- case EDQUOT:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
-#endif
-#ifdef ENOLINK
- case ENOLINK:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_lseek_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case ESPIPE:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_fsync_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#ifdef ENOLINK
- case ENOLINK:
-#endif
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_METHOD_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_close_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
-#ifdef ENOLINK
- case ENOLINK:
-#endif
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_socket_error(int err)
-{
- switch (err) {
- case EPROTONOSUPPORT:
- PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err);
- break;
- case EMFILE:
- PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
- break;
- case ENFILE:
- PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
-#if !defined(SCO)
- case ENOBUFS:
-#endif /* !defined(SCO) */
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_socketavailable_error(int err)
-{
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
-}
-
-void _MD_unix_map_recv_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_recvfrom_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case ECONNRESET:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_send_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
-#if !defined(BEOS)
- case EMSGSIZE:
-#endif
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
-#if !defined(SCO)
- case ENOBUFS:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif /* !defined(SCO) */
- case ECONNREFUSED:
- PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
- break;
- case EISCONN:
- PR_SetError(PR_IS_CONNECTED_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_sendto_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
-#if !defined(BEOS)
- case EMSGSIZE:
-#endif
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
-#if !defined(SCO)
- case ENOBUFS:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif /* !defined(SCO) */
- case ECONNREFUSED:
- PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
- break;
- case EISCONN:
- PR_SetError(PR_IS_CONNECTED_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_writev_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case ECONNRESET:
- case EPIPE:
- PR_SetError(PR_CONNECT_RESET_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_accept_error(int err)
-{
- switch (err) {
- case EAGAIN:
-#if EWOULDBLOCK != EAGAIN
- case EWOULDBLOCK:
-#endif
- PR_SetError(PR_WOULD_BLOCK_ERROR, err);
- break;
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
-#if !defined(BEOS)
- case EOPNOTSUPP:
-#endif
- case ENODEV:
- PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EMFILE:
- PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
- break;
- case ENFILE:
- PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
-#ifdef EPROTO
- case EPROTO:
- PR_SetError(PR_IO_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_connect_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EADDRNOTAVAIL:
- PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err);
- break;
- case EINPROGRESS:
- PR_SetError(PR_IN_PROGRESS_ERROR, err);
- break;
- case EALREADY:
- PR_SetError(PR_ALREADY_INITIATED_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case EAFNOSUPPORT:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
- case EISCONN:
- PR_SetError(PR_IS_CONNECTED_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_IO_TIMEOUT_ERROR, err);
- break;
- case ECONNREFUSED:
- PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
- break;
- case ENETUNREACH:
- PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, err);
- break;
- case EADDRINUSE:
- PR_SetError(PR_ADDRESS_IN_USE_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- /*
- * UNIX domain sockets are not supported in NSPR
- */
- case EACCES:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EIO:
-#if defined(UNIXWARE)
- /*
- * On some platforms, if we connect to a port on
- * the local host (the loopback address) that no
- * process is listening on, we get EIO instead
- * of ECONNREFUSED.
- */
- PR_SetError(PR_CONNECT_REFUSED_ERROR, err);
-#else
- PR_SetError(PR_IO_ERROR, err);
-#endif
- break;
- case ELOOP:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
- case ENOENT:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- case ENXIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case EPROTOTYPE:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_bind_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EADDRNOTAVAIL:
- PR_SetError(PR_ADDRESS_NOT_AVAILABLE_ERROR, err);
- break;
- case EADDRINUSE:
- PR_SetError(PR_ADDRESS_IN_USE_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_SOCKET_ADDRESS_IS_BOUND_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- /*
- * UNIX domain sockets are not supported in NSPR
- */
- case EIO:
- case EISDIR:
- case ELOOP:
- case ENOENT:
- case ENOTDIR:
- case EROFS:
- PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_listen_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
-#if !defined(BEOS)
- case EOPNOTSUPP:
- PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_shutdown_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case ENOTCONN:
- PR_SetError(PR_NOT_CONNECTED_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_socketpair_error(int err)
-{
- switch (err) {
- case EMFILE:
- PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- case EAFNOSUPPORT:
- case EPROTONOSUPPORT:
-#if !defined(BEOS)
- case EOPNOTSUPP:
-#endif
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_getsockname_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
-#if !defined(SCO)
- case ENOBUFS:
-#endif /* !defined(SCO) */
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_getpeername_error(int err)
-{
-
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case ENOTCONN:
- PR_SetError(PR_NOT_CONNECTED_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
-#if !defined(SCO)
- case ENOBUFS:
-#endif /* !defined(SCO) */
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_getsockopt_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case ENOPROTOOPT:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
- break;
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_setsockopt_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
-#if !defined(BEOS)
- case ENOTSOCK:
- PR_SetError(PR_NOT_SOCKET_ERROR, err);
- break;
-#endif
- case ENOPROTOOPT:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_BUFFER_OVERFLOW_ERROR, err);
- break;
- case ENOMEM:
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_open_error(int err)
-{
- switch (err) {
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case EAGAIN:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- case EBUSY:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case EEXIST:
- PR_SetError(PR_FILE_EXISTS_ERROR, err);
- break;
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- case EIO:
- PR_SetError(PR_IO_ERROR, err);
- break;
- case EISDIR:
- PR_SetError(PR_IS_DIRECTORY_ERROR, err);
- break;
- case ELOOP:
- PR_SetError(PR_LOOP_ERROR, err);
- break;
- case EMFILE:
- PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err);
- break;
- case ENAMETOOLONG:
- PR_SetError(PR_NAME_TOO_LONG_ERROR, err);
- break;
- case ENFILE:
- PR_SetError(PR_SYS_DESC_TABLE_FULL_ERROR, err);
- break;
- case ENODEV:
- case ENOENT:
- case ENXIO:
- PR_SetError(PR_FILE_NOT_FOUND_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- case ENOSPC:
- PR_SetError(PR_NO_DEVICE_SPACE_ERROR, err);
- break;
-#ifdef ENOSR
- case ENOSR:
-#endif
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- case ENOTDIR:
- PR_SetError(PR_NOT_DIRECTORY_ERROR, err);
- break;
- case EPERM:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case ETIMEDOUT:
- PR_SetError(PR_REMOTE_FILE_ERROR, err);
- break;
- case EROFS:
- PR_SetError(PR_READ_ONLY_FILESYSTEM_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_mmap_error(int err)
-{
-
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EAGAIN:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, err);
- break;
- case ENOMEM:
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_gethostname_error(int err)
-{
- switch (err) {
- case EFAULT:
- PR_SetError(PR_ACCESS_FAULT_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_select_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EINTR:
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, err);
- break;
- case EINVAL:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_poll_error(int err)
-{
- PRErrorCode prerror;
- switch (err) {
- case EAGAIN:
- prerror = PR_INSUFFICIENT_RESOURCES_ERROR;
- break;
- case EINVAL:
- prerror = PR_INVALID_ARGUMENT_ERROR;
- break;
- case EFAULT:
- prerror = PR_ACCESS_FAULT_ERROR;
- break;
- default:
- prerror = PR_UNKNOWN_ERROR;
- break;
- }
- PR_SetError(prerror, err);
-}
-
-void _MD_unix_map_flock_error(int err)
-{
- switch (err) {
- case EBADF:
- case EINVAL:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EWOULDBLOCK:
- PR_SetError(PR_FILE_IS_LOCKED_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-void _MD_unix_map_lockf_error(int err)
-{
- switch (err) {
- case EBADF:
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err);
- break;
- case EACCES:
- PR_SetError(PR_FILE_IS_LOCKED_ERROR, err);
- break;
- case EDEADLK:
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err);
- break;
- default:
- PR_SetError(PR_UNKNOWN_ERROR, err);
- break;
- }
-}
-
-#ifdef HPUX11
-void _MD_hpux_map_sendfile_error(int oserror)
-{
- PRErrorCode prerror;
-
- switch (oserror) {
- case ENOTSOCK:
- prerror = PR_NOT_SOCKET_ERROR;
- break;
- case EFAULT:
- prerror = PR_ACCESS_FAULT_ERROR;
- break;
- case ENOBUFS:
- prerror = PR_INSUFFICIENT_RESOURCES_ERROR;
- break;
- case EINVAL:
- prerror = PR_INVALID_ARGUMENT_ERROR;
- break;
- case ENOTCONN:
- prerror = PR_NOT_CONNECTED_ERROR;
- break;
- case EPIPE:
- prerror = PR_CONNECT_RESET_ERROR;
- break;
- case ENOMEM:
- prerror = PR_OUT_OF_MEMORY_ERROR;
- break;
- case EOPNOTSUPP:
- prerror = PR_NOT_TCP_SOCKET_ERROR;
- break;
- default:
- prerror = PR_UNKNOWN_ERROR;
- }
- PR_SetError(prerror, oserror);
-}
-#endif /* HPUX11 */
diff --git a/pr/src/md/beos/bfile.c b/pr/src/md/beos/bfile.c
deleted file mode 100644
index 89fea29a..00000000
--- a/pr/src/md/beos/bfile.c
+++ /dev/null
@@ -1,873 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; c-basic-offset: 8 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-/*
-** Global lock variable used to bracket calls into rusty libraries that
-** aren't thread safe (like libc, libX, etc).
-*/
-static PRLock *_pr_rename_lock = NULL;
-
-void
-_MD_InitIO (void)
-{
-}
-
-PRStatus
-_MD_open_dir (_MDDir *md,const char *name)
-{
-int err;
-
- md->d = opendir(name);
- if (!md->d) {
- err = _MD_ERRNO();
- _PR_MD_MAP_OPENDIR_ERROR(err);
- return PR_FAILURE;
- }
- return PR_SUCCESS;
-}
-
-char*
-_MD_read_dir (_MDDir *md, PRIntn flags)
-{
-struct dirent *de;
-int err;
-
- for (;;) {
- /*
- * XXX: readdir() is not MT-safe
- */
- _MD_ERRNO() = 0;
- de = readdir(md->d);
-
- if (!de) {
- err = _MD_ERRNO();
- _PR_MD_MAP_READDIR_ERROR(err);
- return 0;
- }
-
- if ((flags & PR_SKIP_DOT) &&
- (de->d_name[0] == '.') && (de->d_name[1] == 0))
- continue;
-
- if ((flags & PR_SKIP_DOT_DOT) &&
- (de->d_name[0] == '.') && (de->d_name[1] == '.') &&
- (de->d_name[2] == 0))
- continue;
-
- if ((flags & PR_SKIP_HIDDEN) && (de->d_name[1] == '.'))
- continue;
-
- break;
- }
- return de->d_name;
-}
-
-
-PRInt32
-_MD_close_dir (_MDDir *md)
-{
-int rv = 0, err;
-
- if (md->d) {
- rv = closedir(md->d);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_CLOSEDIR_ERROR(err);
- }
- }
- return(rv);
-}
-
-void
-_MD_make_nonblock (PRFileDesc *fd)
-{
- int blocking = 1;
- setsockopt(fd->secret->md.osfd, SOL_SOCKET, SO_NONBLOCK, &blocking, sizeof(blocking));
-
-}
-
-PRStatus
-_MD_set_fd_inheritable (PRFileDesc *fd, PRBool inheritable)
-{
- int rv;
-
- rv = fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC);
- if (-1 == rv) {
- PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
- return PR_FAILURE;
- }
- return PR_SUCCESS;
-}
-
-void
-_MD_init_fd_inheritable (PRFileDesc *fd, PRBool imported)
-{
- if (imported) {
- fd->secret->inheritable = _PR_TRI_UNKNOWN;
- } else {
- int flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);
- if (flags == -1) {
- PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
- return;
- }
- fd->secret->inheritable = (flags & FD_CLOEXEC) ?
- _PR_TRI_TRUE : _PR_TRI_FALSE;
- }
-}
-
-void
-_MD_query_fd_inheritable (PRFileDesc *fd)
-{
- int flags;
-
- PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);
- flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);
- PR_ASSERT(-1 != flags);
- fd->secret->inheritable = (flags & FD_CLOEXEC) ?
- _PR_TRI_FALSE : _PR_TRI_TRUE;
-}
-
-PRInt32
-_MD_open (const char *name, PRIntn flags, PRIntn mode)
-{
- PRInt32 osflags;
- PRInt32 rv, err;
-
- if (flags & PR_RDWR) {
- osflags = O_RDWR;
- } else if (flags & PR_WRONLY) {
- osflags = O_WRONLY;
- } else {
- osflags = O_RDONLY;
- }
-
- if (flags & PR_EXCL)
- osflags |= O_EXCL;
- if (flags & PR_APPEND)
- osflags |= O_APPEND;
- if (flags & PR_TRUNCATE)
- osflags |= O_TRUNC;
- if (flags & PR_SYNC) {
-/* Ummmm. BeOS doesn't appear to
- support sync in any way shape or
- form. */
- return PR_NOT_IMPLEMENTED_ERROR;
- }
-
- /*
- ** On creations we hold the 'create' lock in order to enforce
- ** the semantics of PR_Rename. (see the latter for more details)
- */
- if (flags & PR_CREATE_FILE)
- {
- osflags |= O_CREAT ;
- if (NULL !=_pr_rename_lock)
- PR_Lock(_pr_rename_lock);
- }
-
- rv = open(name, osflags, mode);
-
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_OPEN_ERROR(err);
- }
-
- if ((flags & PR_CREATE_FILE) && (NULL !=_pr_rename_lock))
- PR_Unlock(_pr_rename_lock);
- return rv;
-}
-
-PRInt32
-_MD_close_file (PRInt32 osfd)
-{
-PRInt32 rv, err;
-
- rv = close(osfd);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_CLOSE_ERROR(err);
- }
- return(rv);
-}
-
-PRInt32
-_MD_read (PRFileDesc *fd, void *buf, PRInt32 amount)
-{
- PRInt32 rv, err;
- PRInt32 osfd = fd->secret->md.osfd;
-
- rv = read( osfd, buf, amount );
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_READ_ERROR(err);
- }
- return(rv);
-}
-
-PRInt32
-_MD_write (PRFileDesc *fd, const void *buf, PRInt32 amount)
-{
- PRInt32 rv, err;
- PRInt32 osfd = fd->secret->md.osfd;
-
- rv = write( osfd, buf, amount );
-
- if( rv < 0 ) {
-
- err = _MD_ERRNO();
- _PR_MD_MAP_WRITE_ERROR(err);
- }
- return( rv );
-}
-
-#ifndef BONE_VERSION /* Writev moves to bnet.c with BONE */
-PRInt32
-_MD_writev (PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
- PRIntervalTime timeout)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-#endif
-
-PRInt32
-_MD_lseek (PRFileDesc *fd, PRInt32 offset, int whence)
-{
-PRInt32 rv, err;
-
- rv = lseek (fd->secret->md.osfd, offset, whence);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_LSEEK_ERROR(err);
- }
- return( rv );
-}
-
-PRInt64
-_MD_lseek64 (PRFileDesc *fd, PRInt64 offset, int whence)
-{
-PRInt32 rv, err;
-
-/* According to the BeOS headers, lseek accepts a
- * variable of type off_t for the offset, and off_t
- * is defined to be a 64-bit value. So no special
- * cracking needs to be done on "offset".
- */
-
- rv = lseek (fd->secret->md.osfd, offset, whence);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_LSEEK_ERROR(err);
- }
- return( rv );
-}
-
-PRInt32
-_MD_fsync (PRFileDesc *fd)
-{
-PRInt32 rv, err;
-
- rv = fsync(fd->secret->md.osfd);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_FSYNC_ERROR(err);
- }
- return(rv);
-}
-
-PRInt32
-_MD_delete (const char *name)
-{
-PRInt32 rv, err;
-
- rv = unlink(name);
- if (rv == -1)
- {
- err = _MD_ERRNO();
- _PR_MD_MAP_UNLINK_ERROR(err);
- }
- return (rv);
-}
-
-PRInt32
-_MD_getfileinfo (const char *fn, PRFileInfo *info)
-{
-struct stat sb;
-PRInt32 rv, err;
-PRInt64 s, s2us;
-
- rv = stat(fn, &sb);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_STAT_ERROR(err);
- } else if (info) {
- if (S_IFREG & sb.st_mode)
- info->type = PR_FILE_FILE;
- else if (S_IFDIR & sb.st_mode)
- info->type = PR_FILE_DIRECTORY;
- else
- info->type = PR_FILE_OTHER;
-
- /* Must truncate file size for the 32 bit
- version */
- info->size = (sb.st_size & 0xffffffff);
- LL_I2L(s, sb.st_mtime);
- LL_I2L(s2us, PR_USEC_PER_SEC);
- LL_MUL(s, s, s2us);
- info->modifyTime = s;
- LL_I2L(s, sb.st_ctime);
- LL_MUL(s, s, s2us);
- info->creationTime = s;
- }
- return rv;
-}
-
-PRInt32
-_MD_getfileinfo64 (const char *fn, PRFileInfo64 *info)
-{
-struct stat sb;
-PRInt32 rv, err;
-PRInt64 s, s2us;
-
- rv = stat(fn, &sb);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_STAT_ERROR(err);
- } else if (info) {
- if (S_IFREG & sb.st_mode)
- info->type = PR_FILE_FILE;
- else if (S_IFDIR & sb.st_mode)
- info->type = PR_FILE_DIRECTORY;
- else
- info->type = PR_FILE_OTHER;
-
- /* For the 64 bit version we can use
- * the native st_size without modification
- */
- info->size = sb.st_size;
- LL_I2L(s, sb.st_mtime);
- LL_I2L(s2us, PR_USEC_PER_SEC);
- LL_MUL(s, s, s2us);
- info->modifyTime = s;
- LL_I2L(s, sb.st_ctime);
- LL_MUL(s, s, s2us);
- info->creationTime = s;
- }
- return rv;
-}
-
-PRInt32
-_MD_getopenfileinfo (const PRFileDesc *fd, PRFileInfo *info)
-{
- struct stat sb;
- PRInt64 s, s2us;
- PRInt32 rv, err;
-
- rv = fstat(fd->secret->md.osfd, &sb);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_FSTAT_ERROR(err);
- } else if (info) {
- if (info) {
- if (S_IFREG & sb.st_mode)
- info->type = PR_FILE_FILE ;
- else if (S_IFDIR & sb.st_mode)
- info->type = PR_FILE_DIRECTORY;
- else
- info->type = PR_FILE_OTHER;
- /* Use lower 32 bits of file size */
- info->size = ( sb.st_size & 0xffffffff);
- LL_I2L(s, sb.st_mtime);
- LL_I2L(s2us, PR_USEC_PER_SEC);
- LL_MUL(s, s, s2us);
- info->modifyTime = s;
- LL_I2L(s, sb.st_ctime);
- LL_MUL(s, s, s2us);
- info->creationTime = s;
- }
- }
- return rv;
-}
-
-PRInt32
-_MD_getopenfileinfo64 (const PRFileDesc *fd, PRFileInfo64 *info)
-{
- struct stat sb;
- PRInt64 s, s2us;
- PRInt32 rv, err;
-
- rv = fstat(fd->secret->md.osfd, &sb);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_FSTAT_ERROR(err);
- } else if (info) {
- if (info) {
- if (S_IFREG & sb.st_mode)
- info->type = PR_FILE_FILE ;
- else if (S_IFDIR & sb.st_mode)
- info->type = PR_FILE_DIRECTORY;
- else
- info->type = PR_FILE_OTHER;
- info->size = sb.st_size;
- LL_I2L(s, sb.st_mtime);
- LL_I2L(s2us, PR_USEC_PER_SEC);
- LL_MUL(s, s, s2us);
- info->modifyTime = s;
- LL_I2L(s, sb.st_ctime);
- LL_MUL(s, s, s2us);
- info->creationTime = s;
- }
- }
- return rv;
-}
-
-PRInt32
-_MD_rename (const char *from, const char *to)
-{
- PRInt32 rv = -1, err;
-
- /*
- ** This is trying to enforce the semantics of WINDOZE' rename
- ** operation. That means one is not allowed to rename over top
- ** of an existing file. Holding a lock across these two function
- ** and the open function is known to be a bad idea, but ....
- */
- if (NULL != _pr_rename_lock)
- PR_Lock(_pr_rename_lock);
- if (0 == access(to, F_OK))
- PR_SetError(PR_FILE_EXISTS_ERROR, 0);
- else
- {
- rv = rename(from, to);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_RENAME_ERROR(err);
- }
- }
- if (NULL != _pr_rename_lock)
- PR_Unlock(_pr_rename_lock);
- return rv;
-}
-
-PRInt32
-_MD_access (const char *name, PRIntn how)
-{
-PRInt32 rv, err;
-int checkFlags;
-struct stat buf;
-
- switch (how) {
- case PR_ACCESS_WRITE_OK:
- checkFlags = S_IWUSR | S_IWGRP | S_IWOTH;
- break;
-
- case PR_ACCESS_READ_OK:
- checkFlags = S_IRUSR | S_IRGRP | S_IROTH;
- break;
-
- case PR_ACCESS_EXISTS:
- /* we don't need to examine st_mode. */
- break;
-
- default:
- PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
- return -1;
- }
-
- rv = stat(name, &buf);
- if (rv == 0 && how != PR_ACCESS_EXISTS && (!(buf.st_mode & checkFlags))) {
- PR_SetError(PR_NO_ACCESS_RIGHTS_ERROR, 0);
- return -1;
- }
-
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_STAT_ERROR(err);
- }
-
- return(rv);
-}
-
-PRInt32
-_MD_stat (const char *name, struct stat *buf)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-
-PRInt32
-_MD_mkdir (const char *name, PRIntn mode)
-{
- status_t rv;
- int err;
-
- /*
- ** This lock is used to enforce rename semantics as described
- ** in PR_Rename. Look there for more fun details.
- */
- if (NULL !=_pr_rename_lock)
- PR_Lock(_pr_rename_lock);
-
- rv = mkdir(name, mode);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_MKDIR_ERROR(err);
- }
- if (NULL !=_pr_rename_lock)
- PR_Unlock(_pr_rename_lock);
- return rv;
-}
-
-PRInt32
-_MD_rmdir (const char *name)
-{
-int rv, err;
-
- rv = rmdir(name);
- if (rv == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_RMDIR_ERROR(err);
- }
- return rv;
-}
-
-PRInt32
-_MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
-{
- PRInt32 rv = 0;
- PRThread *me = _PR_MD_CURRENT_THREAD();
- /*
- * This code is almost a duplicate of w32poll.c's _PR_MD_PR_POLL().
- */
- fd_set rd, wt, ex;
- PRFileDesc *bottom;
- PRPollDesc *pd, *epd;
- PRInt32 maxfd = -1, ready, err;
- PRIntervalTime remaining, elapsed, start;
-
- struct timeval tv, *tvp = NULL;
-
- if (_PR_PENDING_INTERRUPT(me))
- {
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
- return -1;
- }
-
- if (0 == npds) {
- PR_Sleep(timeout);
- return rv;
- }
-
- FD_ZERO(&rd);
- FD_ZERO(&wt);
- FD_ZERO(&ex);
-
- ready = 0;
- for (pd = pds, epd = pd + npds; pd < epd; pd++)
- {
- PRInt16 in_flags_read = 0, in_flags_write = 0;
- PRInt16 out_flags_read = 0, out_flags_write = 0;
-
- if ((NULL != pd->fd) && (0 != pd->in_flags))
- {
- if (pd->in_flags & PR_POLL_READ)
- {
- in_flags_read = (pd->fd->methods->poll)(pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read);
- }
- if (pd->in_flags & PR_POLL_WRITE)
- {
- in_flags_write = (pd->fd->methods->poll)(pd->fd, pd->in_flags & ~PR_POLL_READ, &out_flags_write);
- }
- if ((0 != (in_flags_read & out_flags_read))
- || (0 != (in_flags_write & out_flags_write)))
- {
- /* this one's ready right now */
- if (0 == ready)
- {
- /*
- * We will have to return without calling the
- * system poll/select function. So zero the
- * out_flags fields of all the poll descriptors
- * before this one.
- */
- PRPollDesc *prev;
- for (prev = pds; prev < pd; prev++)
- {
- prev->out_flags = 0;
- }
- }
- ready += 1;
- pd->out_flags = out_flags_read | out_flags_write;
- }
- else
- {
- pd->out_flags = 0; /* pre-condition */
-
- /* make sure this is an NSPR supported stack */
- bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
- PR_ASSERT(NULL != bottom); /* what to do about that? */
- if ((NULL != bottom)
- && (_PR_FILEDESC_OPEN == bottom->secret->state))
- {
- if (0 == ready)
- {
- PRInt32 osfd = bottom->secret->md.osfd;
- if (osfd > maxfd) maxfd = osfd;
- if (in_flags_read & PR_POLL_READ)
- {
- pd->out_flags |= _PR_POLL_READ_SYS_READ;
- FD_SET(osfd, &rd);
- }
- if (in_flags_read & PR_POLL_WRITE)
- {
- pd->out_flags |= _PR_POLL_READ_SYS_WRITE;
- FD_SET(osfd, &wt);
- }
- if (in_flags_write & PR_POLL_READ)
- {
- pd->out_flags |= _PR_POLL_WRITE_SYS_READ;
- FD_SET(osfd, &rd);
- }
- if (in_flags_write & PR_POLL_WRITE)
- {
- pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE;
- FD_SET(osfd, &wt);
- }
- if (pd->in_flags & PR_POLL_EXCEPT) FD_SET(osfd, &ex);
- }
- }
- else
- {
- if (0 == ready)
- {
- PRPollDesc *prev;
- for (prev = pds; prev < pd; prev++)
- {
- prev->out_flags = 0;
- }
- }
- ready += 1; /* this will cause an abrupt return */
- pd->out_flags = PR_POLL_NVAL; /* bogii */
- }
- }
- }
- else
- {
- pd->out_flags = 0;
- }
- }
-
- if (0 != ready) return ready; /* no need to block */
-
- remaining = timeout;
- start = PR_IntervalNow();
-
- retry:
- if (timeout != PR_INTERVAL_NO_TIMEOUT)
- {
- PRInt32 ticksPerSecond = PR_TicksPerSecond();
- tv.tv_sec = remaining / ticksPerSecond;
- tv.tv_usec = PR_IntervalToMicroseconds( remaining % ticksPerSecond );
- tvp = &tv;
- }
-
- ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp);
-
- if (ready == -1 && errno == EINTR)
- {
- if (timeout == PR_INTERVAL_NO_TIMEOUT) goto retry;
- else
- {
- elapsed = (PRIntervalTime) (PR_IntervalNow() - start);
- if (elapsed > timeout) ready = 0; /* timed out */
- else
- {
- remaining = timeout - elapsed;
- goto retry;
- }
- }
- }
-
- /*
- ** Now to unravel the select sets back into the client's poll
- ** descriptor list. Is this possibly an area for pissing away
- ** a few cycles or what?
- */
- if (ready > 0)
- {
- ready = 0;
- for (pd = pds, epd = pd + npds; pd < epd; pd++)
- {
- PRInt16 out_flags = 0;
- if ((NULL != pd->fd) && (0 != pd->in_flags))
- {
- PRInt32 osfd;
- bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
- PR_ASSERT(NULL != bottom);
-
- osfd = bottom->secret->md.osfd;
-
- if (FD_ISSET(osfd, &rd))
- {
- if (pd->out_flags & _PR_POLL_READ_SYS_READ)
- out_flags |= PR_POLL_READ;
- if (pd->out_flags & _PR_POLL_WRITE_SYS_READ)
- out_flags |= PR_POLL_WRITE;
- }
- if (FD_ISSET(osfd, &wt))
- {
- if (pd->out_flags & _PR_POLL_READ_SYS_WRITE)
- out_flags |= PR_POLL_READ;
- if (pd->out_flags & _PR_POLL_WRITE_SYS_WRITE)
- out_flags |= PR_POLL_WRITE;
- }
- if (FD_ISSET(osfd, &ex)) out_flags |= PR_POLL_EXCEPT;
-
-/* Workaround for nonblocking connects under net_server */
-#ifndef BONE_VERSION
- if (out_flags)
- {
- /* check if it is a pending connect */
- int i = 0, j = 0;
- PR_Lock( _connectLock );
- for( i = 0; i < connectCount; i++ )
- {
- if(connectList[i].osfd == osfd)
- {
- int connectError;
- int connectResult;
-
- connectResult = connect(connectList[i].osfd,
- &connectList[i].addr,
- connectList[i].addrlen);
- connectError = errno;
-
- if(connectResult < 0 )
- {
- if(connectError == EINTR || connectError == EWOULDBLOCK ||
- connectError == EINPROGRESS || connectError == EALREADY)
- {
- break;
- }
- }
-
- if(i == (connectCount - 1))
- {
- connectList[i].osfd = -1;
- } else {
- for(j = i; j < connectCount; j++ )
- {
- memcpy( &connectList[j], &connectList[j+1],
- sizeof(connectList[j]));
- }
- }
- connectCount--;
-
- bottom->secret->md.connectReturnValue = connectResult;
- bottom->secret->md.connectReturnError = connectError;
- bottom->secret->md.connectValueValid = PR_TRUE;
- break;
- }
- }
- PR_Unlock( _connectLock );
- }
-#endif
- }
- pd->out_flags = out_flags;
- if (out_flags) ready++;
- }
- PR_ASSERT(ready > 0);
- }
- else if (ready < 0)
- {
- err = _MD_ERRNO();
- if (err == EBADF)
- {
- /* Find the bad fds */
- ready = 0;
- for (pd = pds, epd = pd + npds; pd < epd; pd++)
- {
- pd->out_flags = 0;
- if ((NULL != pd->fd) && (0 != pd->in_flags))
- {
- bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
- if (fcntl(bottom->secret->md.osfd, F_GETFL, 0) == -1)
- {
- pd->out_flags = PR_POLL_NVAL;
- ready++;
- }
- }
- }
- PR_ASSERT(ready > 0);
- }
- else _PR_MD_MAP_SELECT_ERROR(err);
- }
-
- return ready;
-} /* _MD_pr_poll */
-
-/*
- * File locking.
- */
-
-PRStatus
-_MD_lockfile (PRInt32 osfd)
-{
- PRInt32 rv;
- struct flock linfo;
-
- linfo.l_type =
- linfo.l_whence = SEEK_SET;
- linfo.l_start = 0;
- linfo.l_len = 0;
-
- rv = fcntl(osfd, F_SETLKW, &linfo);
- if (rv == 0)
- return PR_SUCCESS;
-
- _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
-PRStatus
-_MD_tlockfile (PRInt32 osfd)
-{
- PRInt32 rv;
- struct flock linfo;
-
- linfo.l_type =
- linfo.l_whence = SEEK_SET;
- linfo.l_start = 0;
- linfo.l_len = 0;
-
- rv = fcntl(osfd, F_SETLK, &linfo);
- if (rv == 0)
- return PR_SUCCESS;
-
- _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
-PRStatus
-_MD_unlockfile (PRInt32 osfd)
-{
- PRInt32 rv;
- struct flock linfo;
-
- linfo.l_type =
- linfo.l_whence = SEEK_SET;
- linfo.l_start = 0;
- linfo.l_len = 0;
-
- rv = fcntl(osfd, F_UNLCK, &linfo);
-
- if (rv == 0)
- return PR_SUCCESS;
-
- _PR_MD_MAP_FLOCK_ERROR(_MD_ERRNO());
- return PR_FAILURE;
-}
-
diff --git a/pr/src/md/beos/bmemory.c b/pr/src/md/beos/bmemory.c
deleted file mode 100644
index fb906f0f..00000000
--- a/pr/src/md/beos/bmemory.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-PR_EXTERN(void) _PR_MD_INIT_SEGS(void);
-PR_EXTERN(PRStatus) _PR_MD_ALLOC_SEGMENT(PRSegment *seg, PRUint32 size, void *vaddr);
-PR_EXTERN(void) _PR_MD_FREE_SEGMENT(PRSegment *seg);
diff --git a/pr/src/md/beos/bmisc.c b/pr/src/md/beos/bmisc.c
deleted file mode 100644
index 4bdad411..00000000
--- a/pr/src/md/beos/bmisc.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-#include <stdlib.h>
-
-PRLock *_connectLock = NULL;
-
-#ifndef BONE_VERSION
-/* Workaround for nonblocking connects under net_server */
-PRUint32 connectCount = 0;
-ConnectListNode connectList[64];
-#endif
-
-void
-_MD_cleanup_before_exit (void)
-{
-}
-
-void
-_MD_exit (PRIntn status)
-{
- exit(status);
-}
-
-void
-_MD_early_init (void)
-{
-}
-
-static PRLock *monitor = NULL;
-
-void
-_MD_final_init (void)
-{
- _connectLock = PR_NewLock();
- PR_ASSERT(NULL != _connectLock);
-#ifndef BONE_VERSION
- /* Workaround for nonblocking connects under net_server */
- connectCount = 0;
-#endif
-}
-
-void
-_MD_AtomicInit (void)
-{
- if (monitor == NULL) {
- monitor = PR_NewLock();
- }
-}
-
-/*
-** This is exceedingly messy. atomic_add returns the last value, NSPR expects the new value.
-** We just add or subtract 1 from the result. The actual memory update is atomic.
-*/
-
-PRInt32
-_MD_AtomicAdd( PRInt32 *ptr, PRInt32 val )
-{
- return( ( atomic_add( (long *)ptr, val ) ) + val );
-}
-
-PRInt32
-_MD_AtomicIncrement( PRInt32 *val )
-{
- return( ( atomic_add( (long *)val, 1 ) ) + 1 );
-}
-
-PRInt32
-_MD_AtomicDecrement( PRInt32 *val )
-{
- return( ( atomic_add( (long *)val, -1 ) ) - 1 );
-}
-
-PRInt32
-_MD_AtomicSet( PRInt32 *val, PRInt32 newval )
-{
- PRInt32 rv;
-
- if (!_pr_initialized) {
- _PR_ImplicitInitialization();
- }
- PR_Lock(monitor);
- rv = *val;
- *val = newval;
- PR_Unlock(monitor);
- return rv;
-}
diff --git a/pr/src/md/beos/bmmap.c b/pr/src/md/beos/bmmap.c
deleted file mode 100644
index a9b3ac58..00000000
--- a/pr/src/md/beos/bmmap.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-PR_EXTERN(PRStatus)
-_PR_MD_CREATE_FILE_MAP(PRFileMap *fmap, PRInt64 size)
-{
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return PR_FAILURE;
-}
-
-PR_EXTERN(PRInt32)
-_PR_MD_GET_MEM_MAP_ALIGNMENT(void)
-{
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return -1;
-}
-
-PR_EXTERN(void *)
-_PR_MD_MEM_MAP(PRFileMap *fmap, PRInt64 offset, PRUint32 len)
-{
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return 0;
-}
-
-PR_EXTERN(PRStatus)
-_PR_MD_MEM_UNMAP(void *addr, PRUint32 size)
-{
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return PR_FAILURE;
-}
-
-PR_EXTERN(PRStatus)
-_PR_MD_CLOSE_FILE_MAP(PRFileMap *fmap)
-{
- PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
- return PR_FAILURE;
-}
diff --git a/pr/src/md/beos/bnet.c b/pr/src/md/beos/bnet.c
deleted file mode 100644
index 8bfd4aea..00000000
--- a/pr/src/md/beos/bnet.c
+++ /dev/null
@@ -1,911 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-#include <signal.h>
-#include <unistd.h>
-#include <memory.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-
-/*
- * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or
- * PRInt32* pointer to a _PRSockLen_t* pointer.
- */
-#define _PRSockLen_t int
-
-
-/*
-** Global lock variable used to bracket calls into rusty libraries that
-** aren't thread safe (like libc, libX, etc).
-*/
-static PRLock *_pr_rename_lock = NULL;
-static PRMonitor *_pr_Xfe_mon = NULL;
-
-#define READ_FD 1
-#define WRITE_FD 2
-
-/*
-** This is a support routine to handle "deferred" i/o on sockets.
-** It uses "select", so it is subject to all of the BeOS limitations
-** (only READ notification, only sockets)
-*/
-
-/*
- * socket_io_wait --
- *
- * wait for socket i/o, periodically checking for interrupt
- *
- */
-
-static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type,
- PRIntervalTime timeout)
-{
- PRInt32 rv = -1;
- struct timeval tv;
- PRThread *me = _PR_MD_CURRENT_THREAD();
- PRIntervalTime epoch, now, elapsed, remaining;
- PRBool wait_for_remaining;
- PRInt32 syserror;
- fd_set rd_wr;
-
- switch (timeout) {
- case PR_INTERVAL_NO_WAIT:
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- break;
- case PR_INTERVAL_NO_TIMEOUT:
- /*
- * This is a special case of the 'default' case below.
- * Please see the comments there.
- */
- tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;
- tv.tv_usec = 0;
- FD_ZERO(&rd_wr);
- do {
- FD_SET(osfd, &rd_wr);
- if (fd_type == READ_FD)
- rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);
- else
- rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);
- if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-#ifdef BONE_VERSION
- _PR_MD_MAP_SELECT_ERROR(syserror);
-#else
- if (syserror == EBADF) {
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);
- } else {
- PR_SetError(PR_UNKNOWN_ERROR, syserror);
- }
-#endif
- break;
- }
- if (_PR_PENDING_INTERRUPT(me)) {
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
- rv = -1;
- break;
- }
- } while (rv == 0 || (rv == -1 && syserror == EINTR));
- break;
- default:
- now = epoch = PR_IntervalNow();
- remaining = timeout;
- FD_ZERO(&rd_wr);
- do {
- /*
- * We block in _MD_SELECT for at most
- * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds,
- * so that there is an upper limit on the delay
- * before the interrupt bit is checked.
- */
- wait_for_remaining = PR_TRUE;
- tv.tv_sec = PR_IntervalToSeconds(remaining);
- if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) {
- wait_for_remaining = PR_FALSE;
- tv.tv_sec = _PR_INTERRUPT_CHECK_INTERVAL_SECS;
- tv.tv_usec = 0;
- } else {
- tv.tv_usec = PR_IntervalToMicroseconds(
- remaining -
- PR_SecondsToInterval(tv.tv_sec));
- }
- FD_SET(osfd, &rd_wr);
- if (fd_type == READ_FD)
- rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv);
- else
- rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv);
- /*
- * we don't consider EINTR a real error
- */
- if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) {
-#ifdef BONE_VERSION
- _PR_MD_MAP_SELECT_ERROR(syserror);
-#else
- if (syserror == EBADF) {
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF);
- } else {
- PR_SetError(PR_UNKNOWN_ERROR, syserror);
- }
-#endif
- break;
- }
- if (_PR_PENDING_INTERRUPT(me)) {
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
- rv = -1;
- break;
- }
- /*
- * We loop again if _MD_SELECT timed out or got interrupted
- * by a signal, and the timeout deadline has not passed yet.
- */
- if (rv == 0 || (rv == -1 && syserror == EINTR)) {
- /*
- * If _MD_SELECT timed out, we know how much time
- * we spent in blocking, so we can avoid a
- * PR_IntervalNow() call.
- */
- if (rv == 0) {
- if (wait_for_remaining) {
- now += remaining;
- } else {
- now += PR_SecondsToInterval(tv.tv_sec)
- + PR_MicrosecondsToInterval(tv.tv_usec);
- }
- } else {
- now = PR_IntervalNow();
- }
- elapsed = (PRIntervalTime) (now - epoch);
- if (elapsed >= timeout) {
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- rv = -1;
- break;
- } else {
- remaining = timeout - elapsed;
- }
- }
- } while (rv == 0 || (rv == -1 && syserror == EINTR));
- break;
- }
- return(rv);
-}
-
-PRInt32
-_MD_recv (PRFileDesc *fd, void *buf, PRInt32 amount, PRInt32 flags,
- PRIntervalTime timeout)
-{
- PRInt32 osfd = fd->secret->md.osfd;
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
-
-#ifndef BONE_VERSION
- if (fd->secret->md.sock_state & BE_SOCK_SHUTDOWN_READ) {
- _PR_MD_MAP_RECV_ERROR(EPIPE);
- return -1;
- }
-#endif
-
-#ifdef BONE_VERSION
- /*
- ** Gah, stupid hack. If reading a zero amount, instantly return success.
- ** BONE beta 6 returns EINVAL for reads of zero bytes, which parts of
- ** mozilla use to check for socket availability.
- */
-
- if( 0 == amount ) return(0);
-#endif
-
- while ((rv = recv(osfd, buf, amount, flags)) == -1) {
- err = _MD_ERRNO();
-
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
- /* If socket was supposed to be blocking,
- wait a while for the condition to be
- satisfied. */
- if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
- goto done;
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
- continue;
-
- } else
- break;
- }
-
- if (rv < 0) {
- _PR_MD_MAP_RECV_ERROR(err);
- }
-
-done:
- return(rv);
-}
-
-PRInt32
-_MD_recvfrom (PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
- PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout)
-{
- PRInt32 osfd = fd->secret->md.osfd;
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
-
- while ((*addrlen = PR_NETADDR_SIZE(addr)),
- ((rv = recvfrom(osfd, buf, amount, flags,
- (struct sockaddr *) addr,
- (_PRSockLen_t *)addrlen)) == -1)) {
- err = _MD_ERRNO();
-
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
- if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
- goto done;
-
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {
- continue;
- } else {
- break;
- }
- }
-
- if (rv < 0) {
- _PR_MD_MAP_RECVFROM_ERROR(err);
- }
-
-done:
-#ifdef _PR_HAVE_SOCKADDR_LEN
- if (rv != -1) {
- /* ignore the sa_len field of struct sockaddr */
- if (addr) {
- addr->raw.family = ((struct sockaddr *) addr)->sa_family;
- }
- }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
- return(rv);
-}
-
-PRInt32
-_MD_send (PRFileDesc *fd, const void *buf, PRInt32 amount, PRInt32 flags,
- PRIntervalTime timeout)
-{
- PRInt32 osfd = fd->secret->md.osfd;
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
-
-#ifndef BONE_VERSION
- if (fd->secret->md.sock_state & BE_SOCK_SHUTDOWN_WRITE)
- {
- _PR_MD_MAP_SEND_ERROR(EPIPE);
- return -1;
- }
-#endif
-
- while ((rv = send(osfd, buf, amount, flags)) == -1) {
- err = _MD_ERRNO();
-
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
-
-#ifndef BONE_VERSION
- if( _PR_PENDING_INTERRUPT(me)) {
-
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
- return -1;
- }
-
- /* in UNIX implementations, you could do a socket_io_wait here.
- * but since BeOS doesn't yet support WRITE notification in select,
- * you're spanked.
- */
- snooze( 10000L );
- continue;
-#else /* BONE_VERSION */
- if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))< 0)
- goto done;
-#endif
-
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {
- continue;
-
- } else {
- break;
- }
- }
-
-#ifdef BONE_VERSION
- /*
- * optimization; if bytes sent is less than "amount" call
- * select before returning. This is because it is likely that
- * the next writev() call will return EWOULDBLOCK.
- */
- if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount)
- && (timeout != PR_INTERVAL_NO_WAIT)) {
- if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {
- rv = -1;
- goto done;
- }
- }
-#endif /* BONE_VERSION */
-
- if (rv < 0) {
- _PR_MD_MAP_SEND_ERROR(err);
- }
-
-#ifdef BONE_VERSION
-done:
-#endif
- return(rv);
-}
-
-PRInt32
-_MD_sendto (PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
- const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
-{
- PRInt32 osfd = fd->secret->md.osfd;
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
-#ifdef _PR_HAVE_SOCKADDR_LEN
- PRNetAddr addrCopy;
-
- addrCopy = *addr;
- ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
- ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
-
- while ((rv = sendto(osfd, buf, amount, flags,
- (struct sockaddr *) &addrCopy, addrlen)) == -1) {
-#else
- while ((rv = sendto(osfd, buf, amount, flags,
- (struct sockaddr *) addr, addrlen)) == -1) {
-#endif
- err = _MD_ERRNO();
-
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
-
-#ifdef BONE_VERSION
- if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))< 0)
- goto done;
-#endif
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {
- continue;
-
- } else {
- break;
- }
- }
-
- if (rv < 0) {
- _PR_MD_MAP_SENDTO_ERROR(err);
- }
-
-#ifdef BONE_VERSION
-done:
-#endif
- return(rv);
-}
-
-#ifdef BONE_VERSION
-
-PRInt32 _MD_writev(
- PRFileDesc *fd, const PRIOVec *iov,
- PRInt32 iov_size, PRIntervalTime timeout)
-{
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
- PRInt32 index, amount = 0;
- PRInt32 osfd = fd->secret->md.osfd;
- struct iovec osiov[PR_MAX_IOVECTOR_SIZE];
-
- /* Ensured by PR_Writev */
- PR_ASSERT(iov_size <= PR_MAX_IOVECTOR_SIZE);
-
- /*
- * We can't pass iov to writev because PRIOVec and struct iovec
- * may not be binary compatible. Make osiov a copy of iov and
- * pass osiov to writev.
- */
- for (index = 0; index < iov_size; index++) {
- osiov[index].iov_base = iov[index].iov_base;
- osiov[index].iov_len = iov[index].iov_len;
- }
-
- /*
- * Calculate the total number of bytes to be sent; needed for
- * optimization later.
- * We could avoid this if this number was passed in; but it is
- * probably not a big deal because iov_size is usually small (less than
- * 3)
- */
- if (!fd->secret->nonblocking) {
- for (index=0; index<iov_size; index++) {
- amount += iov[index].iov_len;
- }
- }
-
- while ((rv = writev(osfd, osiov, iov_size)) == -1) {
- err = _MD_ERRNO();
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
- if ((rv = socket_io_wait(osfd, WRITE_FD, timeout))<0)
- goto done;
-
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){
- continue;
- } else {
- break;
- }
- }
-
- /*
- * optimization; if bytes sent is less than "amount" call
- * select before returning. This is because it is likely that
- * the next writev() call will return EWOULDBLOCK.
- */
- if ((!fd->secret->nonblocking) && (rv > 0) && (rv < amount)
- && (timeout != PR_INTERVAL_NO_WAIT)) {
- if (socket_io_wait(osfd, WRITE_FD, timeout) < 0) {
- rv = -1;
- goto done;
- }
- }
-
-
- if (rv < 0) {
- _PR_MD_MAP_WRITEV_ERROR(err);
- }
-done:
- return(rv);
-}
-
-#endif /* BONE_VERSION */
-
-PRInt32
-_MD_accept (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen,
- PRIntervalTime timeout)
-{
- PRInt32 osfd = fd->secret->md.osfd;
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
-
- while ((rv = accept(osfd, (struct sockaddr *) addr,
- (_PRSockLen_t *)addrlen)) == -1) {
- err = _MD_ERRNO();
-
- if ((err == EAGAIN) || (err == EWOULDBLOCK)) {
- if (fd->secret->nonblocking) {
- break;
- }
- /* If it's SUPPOSED to be a blocking thread, wait
- * a while to see if the triggering condition gets
- * satisfied.
- */
- /* Assume that we're always using a native thread */
- if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0)
- goto done;
- } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) {
- continue;
- } else {
- break;
- }
- }
- if (rv < 0) {
- _PR_MD_MAP_ACCEPT_ERROR(err);
- } else if (addr != NULL) {
- /* bug 134099 */
- err = getpeername(rv, (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
- }
-done:
-#ifdef _PR_HAVE_SOCKADDR_LEN
- if (rv != -1) {
- /* Mask off the first byte of struct sockaddr (the length field) */
- if (addr) {
- addr->raw.family = ((struct sockaddr *) addr)->sa_family;
- }
- }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
- return(rv);
-}
-
-PRInt32
-_MD_connect (PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
- PRIntervalTime timeout)
-{
- PRInt32 rv, err;
- PRThread *me = _PR_MD_CURRENT_THREAD();
- PRInt32 osfd = fd->secret->md.osfd;
-
-#ifndef BONE_VERSION
- fd->secret->md.connectValueValid = PR_FALSE;
-#endif
-#ifdef _PR_HAVE_SOCKADDR_LEN
- PRNetAddr addrCopy;
-
- addrCopy = *addr;
- ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
- ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
-#endif
-
- /* (Copied from unix.c)
- * We initiate the connection setup by making a nonblocking connect()
- * call. If the connect() call fails, there are two cases we handle
- * specially:
- * 1. The connect() call was interrupted by a signal. In this case
- * we simply retry connect().
- * 2. The NSPR socket is nonblocking and connect() fails with
- * EINPROGRESS. We first wait until the socket becomes writable.
- * Then we try to find out whether the connection setup succeeded
- * or failed.
- */
-
-retry:
-#ifdef _PR_HAVE_SOCKADDR_LEN
- if ((rv = connect(osfd, (struct sockaddr *)&addrCopy, addrlen)) == -1) {
-#else
- if ((rv = connect(osfd, (struct sockaddr *)addr, addrlen)) == -1) {
-#endif
- err = _MD_ERRNO();
-#ifndef BONE_VERSION
- fd->secret->md.connectReturnValue = rv;
- fd->secret->md.connectReturnError = err;
- fd->secret->md.connectValueValid = PR_TRUE;
-#endif
- if( err == EINTR ) {
-
- if( _PR_PENDING_INTERRUPT(me)) {
-
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
- return -1;
- }
-#ifndef BONE_VERSION
- snooze( 100000L );
-#endif
- goto retry;
- }
-
-#ifndef BONE_VERSION
- if(!fd->secret->nonblocking && ((err == EINPROGRESS) || (err==EAGAIN) || (err==EALREADY))) {
-
- /*
- ** There's no timeout on this connect, but that's not
- ** a big deal, since the connect times out anyways
- ** after 30 seconds. Just sleep for 1/10th of a second
- ** and retry until we go through or die.
- */
-
- if( _PR_PENDING_INTERRUPT(me)) {
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
- return -1;
- }
-
- goto retry;
- }
-
- if( fd->secret->nonblocking && ((err == EAGAIN) || (err == EINPROGRESS))) {
- PR_Lock(_connectLock);
- if (connectCount < sizeof(connectList)/sizeof(connectList[0])) {
- connectList[connectCount].osfd = osfd;
- memcpy(&connectList[connectCount].addr, addr, addrlen);
- connectList[connectCount].addrlen = addrlen;
- connectList[connectCount].timeout = timeout;
- connectCount++;
- PR_Unlock(_connectLock);
- _PR_MD_MAP_CONNECT_ERROR(err);
- } else {
- PR_Unlock(_connectLock);
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
- }
- return rv;
- }
-#else /* BONE_VERSION */
- if(!fd->secret->nonblocking && (err == EINTR)) {
-
- rv = socket_io_wait(osfd, WRITE_FD, timeout);
- if (rv == -1) {
- return -1;
- }
-
- PR_ASSERT(rv == 1);
- if (_PR_PENDING_INTERRUPT(me)) {
- me->flags &= ~_PR_INTERRUPT;
- PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0);
- return -1;
- }
- err = _MD_beos_get_nonblocking_connect_error(osfd);
- if (err != 0) {
- _PR_MD_MAP_CONNECT_ERROR(err);
- return -1;
- }
- return 0;
- }
-#endif
-
- _PR_MD_MAP_CONNECT_ERROR(err);
- }
-
- return rv;
-}
-
-PRInt32
-_MD_bind (PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen)
-{
- PRInt32 rv, err;
-#ifdef _PR_HAVE_SOCKADDR_LEN
- PRNetAddr addrCopy;
-
- addrCopy = *addr;
- ((struct sockaddr *) &addrCopy)->sa_len = addrlen;
- ((struct sockaddr *) &addrCopy)->sa_family = addr->raw.family;
- rv = bind(fd->secret->md.osfd, (struct sockaddr *) &addrCopy, (int )addrlen);
-#else
- rv = bind(fd->secret->md.osfd, (struct sockaddr *) addr, (int )addrlen);
-#endif
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_BIND_ERROR(err);
- }
-
- return(rv);
-}
-
-PRInt32
-_MD_listen (PRFileDesc *fd, PRIntn backlog)
-{
- PRInt32 rv, err;
-
-#ifndef BONE_VERSION
- /* Bug workaround! Setting listen to 0 on Be accepts no connections.
- ** On most UN*Xes this sets the default.
- */
-
- if( backlog == 0 ) backlog = 5;
-#endif
-
- rv = listen(fd->secret->md.osfd, backlog);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_LISTEN_ERROR(err);
- }
-
- return(rv);
-}
-
-PRInt32
-_MD_shutdown (PRFileDesc *fd, PRIntn how)
-{
- PRInt32 rv, err;
-
-#ifndef BONE_VERSION
- if (how == PR_SHUTDOWN_SEND)
- fd->secret->md.sock_state = BE_SOCK_SHUTDOWN_WRITE;
- else if (how == PR_SHUTDOWN_RCV)
- fd->secret->md.sock_state = BE_SOCK_SHUTDOWN_READ;
- else if (how == PR_SHUTDOWN_BOTH) {
- fd->secret->md.sock_state = (BE_SOCK_SHUTDOWN_WRITE | BE_SOCK_SHUTDOWN_READ);
- }
-
- return 0;
-#else /* BONE_VERSION */
- rv = shutdown(fd->secret->md.osfd, how);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_SHUTDOWN_ERROR(err);
- }
- return(rv);
-#endif
-}
-
-PRInt32
-_MD_socketpair (int af, int type, int flags, PRInt32 *osfd)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-
-PRInt32
-_MD_close_socket (PRInt32 osfd)
-{
-#ifdef BONE_VERSION
- close( osfd );
-#else
- closesocket( osfd );
-#endif
-}
-
-PRStatus
-_MD_getsockname (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
-{
- PRInt32 rv, err;
-
- rv = getsockname(fd->secret->md.osfd,
- (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
-#ifdef _PR_HAVE_SOCKADDR_LEN
- if (rv == 0) {
- /* ignore the sa_len field of struct sockaddr */
- if (addr) {
- addr->raw.family = ((struct sockaddr *) addr)->sa_family;
- }
- }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_GETSOCKNAME_ERROR(err);
- }
-
- return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus
-_MD_getpeername (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
-{
- PRInt32 rv, err;
-
- rv = getpeername(fd->secret->md.osfd,
- (struct sockaddr *) addr, (_PRSockLen_t *)addrlen);
-
-#ifdef _PR_HAVE_SOCKADDR_LEN
- if (rv == 0) {
- /* ignore the sa_len field of struct sockaddr */
- if (addr) {
- addr->raw.family = ((struct sockaddr *) addr)->sa_family;
- }
- }
-#endif /* _PR_HAVE_SOCKADDR_LEN */
-
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_GETPEERNAME_ERROR(err);
- }
- return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus
-_MD_getsockopt (PRFileDesc *fd, PRInt32 level,
- PRInt32 optname, char* optval, PRInt32* optlen)
-{
- PRInt32 rv, err;
-
- rv = getsockopt(fd->secret->md.osfd, level, optname,
- optval, (_PRSockLen_t *)optlen);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_GETSOCKOPT_ERROR(err);
- }
-
- return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRStatus
-_MD_setsockopt (PRFileDesc *fd, PRInt32 level,
- PRInt32 optname, const char* optval, PRInt32 optlen)
-{
- PRInt32 rv, err;
-
- rv = setsockopt(fd->secret->md.osfd, level, optname, optval, optlen);
- if (rv < 0) {
- err = _MD_ERRNO();
- _PR_MD_MAP_SETSOCKOPT_ERROR(err);
- }
- return rv==0?PR_SUCCESS:PR_FAILURE;
-}
-
-PRInt32
-_MD_accept_read (PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr,
- void *buf, PRInt32 amount, PRIntervalTime timeout)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-
-#ifndef BONE_VERSION
-PRInt32
-_MD_socket (int af, int type, int flags)
-{
- PRInt32 osfd, err;
-
- osfd = socket( af, type, 0 );
-
- if( -1 == osfd ) {
-
- err = _MD_ERRNO();
- _PR_MD_MAP_SOCKET_ERROR( err );
- }
-
- return( osfd );
-}
-#else
-PRInt32
-_MD_socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
-{
- PRInt32 osfd, err;
-
- osfd = socket(domain, type, proto);
-
- if (osfd == -1) {
- err = _MD_ERRNO();
- _PR_MD_MAP_SOCKET_ERROR(err);
- }
-
- return(osfd);
-}
-#endif
-
-PRInt32
-_MD_socketavailable (PRFileDesc *fd)
-{
-#ifdef BONE_VERSION
- PRInt32 result;
-
- if (ioctl(fd->secret->md.osfd, FIONREAD, &result) < 0) {
- _PR_MD_MAP_SOCKETAVAILABLE_ERROR(_MD_ERRNO());
- return -1;
- }
- return result;
-#else
- return PR_NOT_IMPLEMENTED_ERROR;
-#endif
-}
-
-PRInt32
-_MD_get_socket_error (void)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-
-PRStatus
-_MD_gethostname (char *name, PRUint32 namelen)
-{
- PRInt32 rv, err;
-
- rv = gethostname(name, namelen);
- if (rv == 0)
- {
- err = _MD_ERRNO();
- _PR_MD_MAP_GETHOSTNAME_ERROR(err);
- return PR_FAILURE;
- }
- return PR_SUCCESS;
-}
-
-#ifndef BONE_VERSION
-PRInt32
-_MD_beos_get_nonblocking_connect_error(PRFileDesc *fd)
-{
- int rv;
- int flags = 0;
-
- rv = recv(fd->secret->md.osfd, NULL, 0, flags);
- PR_ASSERT(-1 == rv || 0 == rv);
- if (-1 == rv && errno != EAGAIN && errno != EWOULDBLOCK) {
- return errno;
- }
- return 0; /* no error */
-}
-#else
-PRInt32
-_MD_beos_get_nonblocking_connect_error(int osfd)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
- // int err;
- // _PRSockLen_t optlen = sizeof(err);
- // if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &optlen) == -1) {
- // return errno;
- // } else {
- // return err;
- // }
-}
-#endif /* BONE_VERSION */
diff --git a/pr/src/md/beos/bproc.c b/pr/src/md/beos/bproc.c
deleted file mode 100644
index 30ac5699..00000000
--- a/pr/src/md/beos/bproc.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; c-basic-offset: 8 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-#include <stdio.h>
-#include <signal.h>
-
-#define _PR_SIGNALED_EXITSTATUS 256
-
-PRProcess*
-_MD_create_process (const char *path, char *const *argv,
- char *const *envp, const PRProcessAttr *attr)
-{
- PRProcess *process;
- int nEnv, idx;
- char *const *childEnvp;
- char **newEnvp = NULL;
- int flags;
- PRBool found = PR_FALSE;
-
- process = PR_NEW(PRProcess);
- if (!process) {
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return NULL;
- }
-
- childEnvp = envp;
- if (attr && attr->fdInheritBuffer) {
- if (NULL == childEnvp) {
- childEnvp = environ;
- }
- for (nEnv = 0; childEnvp[nEnv]; nEnv++) {
- }
- newEnvp = (char **) PR_MALLOC((nEnv + 2) * sizeof(char *));
- if (NULL == newEnvp) {
- PR_DELETE(process);
- PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
- return NULL;
- }
- for (idx = 0; idx < nEnv; idx++) {
- newEnvp[idx] = childEnvp[idx];
- if (!found && !strncmp(newEnvp[idx], "NSPR_INHERIT_FDS=", 17)) {
- newEnvp[idx] = attr->fdInheritBuffer;
- found = PR_TRUE;
- }
- }
- if (!found) {
- newEnvp[idx++] = attr->fdInheritBuffer;
- }
- newEnvp[idx] = NULL;
- childEnvp = newEnvp;
- }
-
- process->md.pid = fork();
-
- if ((pid_t) -1 == process->md.pid) {
- PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, errno);
- PR_DELETE(process);
- if (newEnvp) {
- PR_DELETE(newEnvp);
- }
- return NULL;
- } else if (0 == process->md.pid) { /* the child process */
- /*
- * If the child process needs to exit, it must call _exit().
- * Do not call exit(), because exit() will flush and close
- * the standard I/O file descriptors, and hence corrupt
- * the parent process's standard I/O data structures.
- */
-
- if (attr) {
- /* the osfd's to redirect stdin, stdout, and stderr to */
- int in_osfd = -1, out_osfd = -1, err_osfd = -1;
-
- if (attr->stdinFd
- && attr->stdinFd->secret->md.osfd != 0) {
- in_osfd = attr->stdinFd->secret->md.osfd;
- if (dup2(in_osfd, 0) != 0) {
- _exit(1); /* failed */
- }
- flags = fcntl(0, F_GETFL, 0);
- if (flags & O_NONBLOCK) {
- fcntl(0, F_SETFL, flags & ~O_NONBLOCK);
- }
- }
- if (attr->stdoutFd
- && attr->stdoutFd->secret->md.osfd != 1) {
- out_osfd = attr->stdoutFd->secret->md.osfd;
- if (dup2(out_osfd, 1) != 1) {
- _exit(1); /* failed */
- }
- flags = fcntl(1, F_GETFL, 0);
- if (flags & O_NONBLOCK) {
- fcntl(1, F_SETFL, flags & ~O_NONBLOCK);
- }
- }
- if (attr->stderrFd
- && attr->stderrFd->secret->md.osfd != 2) {
- err_osfd = attr->stderrFd->secret->md.osfd;
- if (dup2(err_osfd, 2) != 2) {
- _exit(1); /* failed */
- }
- flags = fcntl(2, F_GETFL, 0);
- if (flags & O_NONBLOCK) {
- fcntl(2, F_SETFL, flags & ~O_NONBLOCK);
- }
- }
- if (in_osfd != -1) {
- close(in_osfd);
- }
- if (out_osfd != -1 && out_osfd != in_osfd) {
- close(out_osfd);
- }
- if (err_osfd != -1 && err_osfd != in_osfd
- && err_osfd != out_osfd) {
- close(err_osfd);
- }
- if (attr->currentDirectory) {
- if (chdir(attr->currentDirectory) < 0) {
- _exit(1); /* failed */
- }
- }
- }
-
- if (childEnvp) {
- (void)execve(path, argv, childEnvp);
- } else {
- /* Inherit the environment of the parent. */
- (void)execv(path, argv);
- }
- /* Whoops! It returned. That's a bad sign. */
- _exit(1);
- }
-
- if (newEnvp) {
- PR_DELETE(newEnvp);
- }
-
- return process;
-}
-
-PRStatus
-_MD_detach_process (PRProcess *process)
-{
- /* If we kept a process table like unix does,
- * we'd remove the entry here.
- * Since we dont', just delete the process variable
- */
- PR_DELETE(process);
- return PR_SUCCESS;
-}
-
-PRStatus
-_MD_wait_process (PRProcess *process, PRInt32 *exitCode)
-{
- PRStatus retVal = PR_SUCCESS;
- int ret, status;
-
- /* Ignore interruptions */
- do {
- ret = waitpid(process->md.pid, &status, 0);
- } while (ret == -1 && errno == EINTR);
-
- /*
- * waitpid() cannot return 0 because we did not invoke it
- * with the WNOHANG option.
- */
- PR_ASSERT(0 != ret);
-
- if (ret < 0) {
- PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
- return PR_FAILURE;
- }
-
- /* If child process exited normally, return child exit code */
- if (WIFEXITED(status)) {
- *exitCode = WEXITSTATUS(status);
- } else {
- PR_ASSERT(WIFSIGNALED(status));
- *exitCode = _PR_SIGNALED_EXITSTATUS;
- }
-
- PR_DELETE(process);
- return PR_SUCCESS;
-}
-
-PRStatus
-_MD_kill_process (PRProcess *process)
-{
- PRErrorCode prerror;
- PRInt32 oserror;
-
- if (kill(process->md.pid, SIGKILL) == 0) {
- return PR_SUCCESS;
- }
- oserror = errno;
- switch (oserror) {
- case EPERM:
- prerror = PR_NO_ACCESS_RIGHTS_ERROR;
- break;
- case ESRCH:
- prerror = PR_INVALID_ARGUMENT_ERROR;
- break;
- default:
- prerror = PR_UNKNOWN_ERROR;
- break;
- }
- PR_SetError(prerror, oserror);
- return PR_FAILURE;
-}
diff --git a/pr/src/md/beos/brng.c b/pr/src/md/beos/brng.c
deleted file mode 100644
index 18a3bbf1..00000000
--- a/pr/src/md/beos/brng.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <signal.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <assert.h>
-#include <time.h>
-#include "primpl.h"
-
-extern PRSize _PR_MD_GetRandomNoise( void *buf, PRSize size )
-{
- struct timeval tv;
- int n = 0;
- int s;
-
- GETTIMEOFDAY(&tv);
-
- if ( size > 0 ) {
- s = _pr_CopyLowBits((char*)buf+n, size, &tv.tv_usec, sizeof(tv.tv_usec));
- size -= s;
- n += s;
- }
- if ( size > 0 ) {
- s = _pr_CopyLowBits((char*)buf+n, size, &tv.tv_sec, sizeof(tv.tv_usec));
- size -= s;
- n += s;
- }
-
- return n;
-} /* end _PR_MD_GetRandomNoise() */
diff --git a/pr/src/md/beos/bseg.c b/pr/src/md/beos/bseg.c
deleted file mode 100644
index e7bb9b3d..00000000
--- a/pr/src/md/beos/bseg.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-
-PR_IMPLEMENT(void)
- _MD_init_segs (void)
-{
-}
-
-PR_IMPLEMENT(PRStatus)
- _MD_alloc_segment (PRSegment *seg, PRUint32 size, void *vaddr)
-{
- return PR_NOT_IMPLEMENTED_ERROR;
-}
-
-PR_IMPLEMENT(void)
- _MD_free_segment (PRSegment *seg)
-{
-}
diff --git a/pr/src/md/beos/bsrcs.mk b/pr/src/md/beos/bsrcs.mk
deleted file mode 100644
index 94424537..00000000
--- a/pr/src/md/beos/bsrcs.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-
-# this file lists the source files to be compiled (used in Makefile) and
-# then enumerated as object files (in objs.mk) for inclusion in the NSPR
-# shared library
-
-MDCSRCS = \
- beos.c \
- beos_errors.c \
- bfile.c \
- bmisc.c \
- bnet.c \
- bproc.c \
- brng.c \
- bseg.c \
- btime.c \
- bmmap.c \
- $(NULL)
diff --git a/pr/src/md/beos/btime.c b/pr/src/md/beos/btime.c
deleted file mode 100644
index b6e02fc7..00000000
--- a/pr/src/md/beos/btime.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C++; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "primpl.h"
-#include <kernel/OS.h>
-
-static bigtime_t start;
-
-PRTime
-_MD_now (void)
-{
- return (PRTime)real_time_clock_usecs();
-}
-
-void
-_MD_interval_init (void)
-{
- /* grab the base interval time */
- start = real_time_clock_usecs();
-}
-
-PRIntervalTime
-_MD_get_interval (void)
-{
- return( (PRIntervalTime) real_time_clock_usecs() / 10 );
-
-#if 0
- /* return the number of tens of microseconds that have elapsed since
- we were initialized */
- bigtime_t now = real_time_clock_usecs();
- now -= start;
- now /= 10;
- return (PRIntervalTime)now;
-#endif
-}
-
-PRIntervalTime
-_MD_interval_per_sec (void)
-{
- return 100000L;
-}
diff --git a/pr/src/md/beos/objs.mk b/pr/src/md/beos/objs.mk
deleted file mode 100644
index 8727ee0e..00000000
--- a/pr/src/md/beos/objs.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# This makefile appends to the variable OBJS the platform-dependent
-# object modules that will be part of the nspr20 library.
-
-include $(srcdir)/md/beos/bsrcs.mk
-
-OBJS += $(MDCSRCS:%.c=md/beos/$(OBJDIR)/%.$(OBJ_SUFFIX))
diff --git a/pr/src/md/prosdep.c b/pr/src/md/prosdep.c
index aa4bdb0d..20b0a46e 100644
--- a/pr/src/md/prosdep.c
+++ b/pr/src/md/prosdep.c
@@ -12,9 +12,6 @@
#ifdef _WIN32
#include <windows.h>
#endif
-#ifdef XP_BEOS
-#include <OS.h>
-#endif
PRInt32 _pr_pageShift;
PRInt32 _pr_pageSize;
@@ -41,10 +38,6 @@ static void GetPageSize(void)
#endif
#endif /* XP_UNIX */
-#ifdef XP_BEOS
- _pr_pageSize = B_PAGE_SIZE;
-#endif
-
#ifdef XP_PC
#ifdef _WIN32
SYSTEM_INFO info;
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index fd575c8e..76a1f1e3 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -57,12 +57,6 @@ PRLock *_pr_dnsLock = NULL;
* Some return a pointer to struct protoent, others return
* an int, and glibc's flavor takes five arguments.
*/
-#if defined(XP_BEOS) && defined(BONE_VERSION)
-#include <arpa/inet.h> /* pick up define for inet_addr */
-#include <sys/socket.h>
-#define _PR_HAVE_GETPROTO_R
-#define _PR_HAVE_GETPROTO_R_POINTER
-#endif
#if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \
|| (defined(LINUX) && defined(_REENTRANT) \
@@ -85,7 +79,7 @@ PRLock *_pr_dnsLock = NULL;
#endif
/* BeOS has glibc but not the glibc-style getprotobyxxx_r functions. */
-#if (defined(__GLIBC__) && __GLIBC__ >= 2 && !defined(XP_BEOS))
+#if (defined(__GLIBC__) && __GLIBC__ >= 2)
#define _PR_HAVE_GETPROTO_R
#define _PR_HAVE_5_ARG_GETPROTO_R
#endif
diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c
index 8b7c25fa..cdbbe2a5 100644
--- a/pr/src/misc/prsystem.c
+++ b/pr/src/misc/prsystem.c
@@ -8,10 +8,6 @@
#include "prprf.h"
#include "prlong.h"
-#if defined(BEOS)
-#include <kernel/OS.h>
-#endif
-
#if defined(OS2)
#define INCL_DOS
#define INCL_DOSMISC
@@ -183,11 +179,6 @@ PR_IMPLEMENT(PRInt32) PR_GetNumberOfProcessors( void )
GetSystemInfo( &info );
numCpus = info.dwNumberOfProcessors;
-#elif defined(BEOS)
- system_info sysInfo;
-
- get_system_info(&sysInfo);
- numCpus = sysInfo.cpu_count;
#elif defined(OS2)
DosQuerySysInfo( QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &numCpus, sizeof(numCpus));
#elif defined(_PR_HAVE_SYSCTL)
diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c
index 1487ec4d..92079597 100644
--- a/pr/src/misc/prtime.c
+++ b/pr/src/misc/prtime.c
@@ -585,7 +585,7 @@ void _PR_CleanupTime(void)
#endif
}
-#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined(XP_PC)
PR_IMPLEMENT(PRTimeParameters)
PR_LocalTimeParameters(const PRExplodedTime *gmt)
@@ -736,7 +736,7 @@ PR_LocalTimeParameters(const PRExplodedTime *gmt)
return retVal;
}
-#endif /* defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS) */
+#endif /* defined(XP_UNIX) || defined(XP_PC) */
/*
*------------------------------------------------------------------------
@@ -1720,8 +1720,8 @@ PR_FormatTime(char *buf, int buflen, const char *fmt,
* additional fields: tm_zone and tm_gmtoff.
*/
-#if (__GLIBC__ >= 2) || defined(XP_BEOS) \
- || defined(NETBSD) || defined(OPENBSD) || defined(FREEBSD) \
+#if (__GLIBC__ >= 2) || defined(NETBSD) \
+ || defined(OPENBSD) || defined(FREEBSD) \
|| defined(DARWIN) || defined(ANDROID)
a.tm_zone = NULL;
a.tm_gmtoff = time->tm_params.tp_gmt_offset +
diff --git a/pr/src/threads/prtpd.c b/pr/src/threads/prtpd.c
index 0eb2a011..96ed0403 100644
--- a/pr/src/threads/prtpd.c
+++ b/pr/src/threads/prtpd.c
@@ -32,7 +32,6 @@
** the routines in pr/src/btthreads/
*/
-#ifndef XP_BEOS
#include "primpl.h"
@@ -249,4 +248,3 @@ void _PR_DestroyThreadPrivate(PRThread* self)
}
} /* _PR_DestroyThreadPrivate */
-#endif /* !XP_BEOS */
diff --git a/pr/tests/affinity.c b/pr/tests/affinity.c
index 4bdbaf72..cfc20e63 100644
--- a/pr/tests/affinity.c
+++ b/pr/tests/affinity.c
@@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
-#ifndef XP_BEOS
/*
* Test PR_GetThreadAffinityMask
@@ -81,12 +80,3 @@ int main(int argc, char **argv)
return 0;
}
-
-#else /* !XP_BEOS */
-
-int main()
-{
- printf( "This test is not supported on the BeOS\n" );
- return 0;
-}
-#endif /* !XP_BEOS */
diff --git a/pr/tests/attach.c b/pr/tests/attach.c
index d466644e..5b914487 100644
--- a/pr/tests/attach.c
+++ b/pr/tests/attach.c
@@ -47,8 +47,6 @@
#define INCL_ERRORS
#include <os2.h>
#include <process.h>
-#elif defined(XP_BEOS)
-#include <kernel/OS.h>
#endif
#define DEFAULT_COUNT 1000
@@ -98,8 +96,6 @@ static void Measure(void (*func)(void), const char *msg)
#ifdef WIN32
static unsigned __stdcall threadStartFunc(void *arg)
-#elif defined(XP_BEOS)
-static int32 threadStartFunc(void *arg)
#else
static void * threadStartFunc(void *arg)
#endif
@@ -125,10 +121,6 @@ int main(int argc, char **argv)
#elif defined(OS2)
int rv;
TID threadID;
-#elif defined(XP_BEOS)
- thread_id threadID;
- int32 threadRV;
- status_t waitRV;
#endif
/* The command line argument: -d is used to determine if the test is being run
@@ -267,29 +259,6 @@ int main(int argc, char **argv)
goto exit_now;
}
-#elif defined(XP_BEOS)
-
- threadID = spawn_thread(threadStartFunc, NULL, B_NORMAL_PRIORITY, NULL);
- if (threadID <= B_ERROR) {
- fprintf(stderr, "thread creation failed: error code %08lx\n", threadID);
- failed_already = 1;
- goto exit_now;
- }
- if (resume_thread(threadID) != B_OK) {
- fprintf(stderr, "failed starting thread: error code %08lx\n", threadID);
- failed_already = 1;
- goto exit_now;
- }
-
- waitRV = wait_for_thread(threadID, &threadRV);
- if (debug_mode)
- PR_ASSERT(waitRV == B_OK);
- else if (waitRV != B_OK) {
- failed_already = 1;
- goto exit_now;
- }
-
-#else
if (!debug_mode)
failed_already=1;
else
@@ -297,7 +266,6 @@ int main(int argc, char **argv)
"either this platform does not have native threads or the\n"
"test needs to be written for this platform.\n");
goto exit_now;
-#endif
exit_now:
if(failed_already)
diff --git a/pr/tests/poll_er.c b/pr/tests/poll_er.c
index a50a75fb..5f7ec2e5 100755
--- a/pr/tests/poll_er.c
+++ b/pr/tests/poll_er.c
@@ -20,15 +20,6 @@
** recognize the return code from tha main program.
***********************************************************************/
-#ifdef XP_BEOS
-#include <stdio.h>
-int main()
-{
- printf( "This test is not ported to the BeOS\n" );
- return 0;
-}
-#else
-
/***********************************************************************
** Includes
***********************************************************************/
@@ -207,4 +198,3 @@ exit_now:
return 0;
}
-#endif /* XP_BEOS */
diff --git a/pr/tests/selct_er.c b/pr/tests/selct_er.c
index 85edb989..8df259fd 100755
--- a/pr/tests/selct_er.c
+++ b/pr/tests/selct_er.c
@@ -20,15 +20,6 @@
** recognize the return code from tha main program.
***********************************************************************/
-#ifdef XP_BEOS
-#include <stdio.h>
-int main()
-{
- printf( "This test is not ported to the BeOS\n" );
- return 0;
-}
-#else
-
/***********************************************************************
** Includes
***********************************************************************/
@@ -197,4 +188,3 @@ exit_now:
}
-#endif /* XP_BEOS */
diff --git a/pr/tests/suspend.c b/pr/tests/suspend.c
index 7dfe28c6..7a4f83fd 100644
--- a/pr/tests/suspend.c
+++ b/pr/tests/suspend.c
@@ -3,15 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifdef XP_BEOS
-#include <stdio.h>
-int main()
-{
- printf( "This test is not ported to the BeOS\n" );
- return 0;
-}
-#else
-
#include "nspr.h"
#include "prpriv.h"
#include "prinrval.h"
@@ -184,4 +175,3 @@ int main(int argc, char **argv)
return 0;
}
-#endif /* XP_BEOS */
diff --git a/pr/tests/testfile.c b/pr/tests/testfile.c
index 0bd28cf9..5bc8e2f9 100644
--- a/pr/tests/testfile.c
+++ b/pr/tests/testfile.c
@@ -641,14 +641,14 @@ HANDLE hfile;
}
PR_Close(fd_file);
}
-#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2)
/*
* Create a hidden file - a platform-dependent operation
*/
strcpy(pathname, TEST_DIR);
strcat(pathname, "/");
strcat(pathname, HIDDEN_FILE_NAME);
-#if defined(XP_UNIX) || defined(XP_BEOS)
+#if defined(XP_UNIX)
DPRINTF(("Creating hidden test file %s\n",pathname));
fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);
@@ -726,7 +726,7 @@ HANDLE hfile;
* List all files, including hidden files
*/
DPRINTF(("Listing all files in directory %s\n",TEST_DIR));
-#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2)
num_files = FILES_IN_DIR + 1;
#else
num_files = FILES_IN_DIR;
@@ -762,7 +762,7 @@ HANDLE hfile;
PR_CloseDir(fd_dir);
-#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2)
/*
* List all files, except hidden files
diff --git a/pr/tests/thrpool_server.c b/pr/tests/thrpool_server.c
index ef09f23b..0b77004b 100644
--- a/pr/tests/thrpool_server.c
+++ b/pr/tests/thrpool_server.c
@@ -26,7 +26,7 @@
#endif
/* for getcwd */
-#if defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined (XP_OS2)
#include <unistd.h>
#elif defined(XP_PC)
#include <direct.h>
diff --git a/pr/tests/tmocon.c b/pr/tests/tmocon.c
index 48a72f67..24cb05f3 100644
--- a/pr/tests/tmocon.c
+++ b/pr/tests/tmocon.c
@@ -34,7 +34,7 @@
#include <string.h>
/* for getcwd */
-#if defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS)
+#if defined(XP_UNIX) || defined (XP_OS2)
#include <unistd.h>
#elif defined(XP_PC)
#include <direct.h>