From fe1583ce0b08d601ddfef9d5bbd0af422f890fab Mon Sep 17 00:00:00 2001 From: cvs2hg Date: Thu, 17 Jul 2003 23:13:48 +0000 Subject: fixup commit for branch 'THUNDERBIRD_0_2_BRANCH' --- Makefile.in | 29 +- admin/repackage.sh | 20 +- build/autoconf/config.guess | 416 ++++++++------ build/autoconf/config.sub | 287 ++++++---- build/cygwin-wrapper | 23 + config/AIX.mk | 171 ------ config/BSD_OS.mk | 91 --- config/BeOS.mk | 139 ----- config/DGUX.mk | 63 --- config/FreeBSD.mk | 82 --- config/HP-UX.mk | 203 ------- config/IRIX.mk | 158 ------ config/Linux.mk | 131 ----- config/Makefile.in | 6 +- config/NCR.mk | 97 ---- config/NEC.mk | 61 -- config/NEWS-OS.mk | 74 --- config/NEXTSTEP.mk | 68 --- config/NTO.mk | 90 --- config/NetBSD.mk | 89 --- config/OS2.mk | 171 ------ config/OSF1.mk | 122 ---- config/OpenBSD.mk | 78 --- config/OpenVMS.mk | 67 --- config/QNX.mk | 57 -- config/Rhapsody.mk | 83 --- config/SCOOS.mk | 63 --- config/SINIX.mk | 108 ---- config/SunOS.mk | 42 -- config/SunOS4.mk | 68 --- config/SunOS5.mk | 196 ------- config/UNIX.mk | 92 ---- config/UNIXWARE.mk | 71 --- config/WIN32.mk | 176 ------ config/WIN95.mk | 38 -- config/WINNT.mk | 38 -- config/arch.mk | 286 ---------- config/autoconf.mk.in | 8 +- config/config.mk | 12 + config/module.df | 40 -- config/now.c | 22 +- config/nsinstall.c | 16 + config/nspr-config.in | 4 +- config/rules.mk | 125 +++-- config/win16.mk | 116 ---- configure | 913 ++++++++++++++++++------------ configure.in | 432 ++++++++++----- lib/ds/Makefile.in | 30 +- lib/ds/plarena.c | 8 +- lib/ds/plds.def | 78 +++ lib/ds/plds_symvec.opt | 37 ++ lib/ds/plhash.c | 2 +- lib/libc/src/Makefile.in | 29 +- lib/libc/src/base64.c | 2 +- lib/libc/src/plc.def | 94 ++++ lib/libc/src/plc_symvec.opt | 53 ++ lib/libc/src/strstr.c | 6 +- lib/msgc/src/Makefile.in | 4 + macbuild/NSPR.Debug.Prefix | 1 - macbuild/NSPR.Prefix | 1 - macbuild/NSPR20.toc | 69 --- macbuild/NSPR20PPC.mcp | Bin 163973 -> 0 bytes macbuild/NSPRCarbon.Prefix | 11 - macbuild/NSPRCarbonDebug.Prefix | 12 - macbuild/NSPRConfig.h | 42 -- macbuild/NSPRDebug.Prefix | 11 - pkg/Makefile.in | 54 ++ pkg/linux/Makefile.in | 44 ++ pkg/linux/sun-nspr.spec | 122 ++++ pkg/solaris/Makefile.com | 32 ++ pkg/solaris/Makefile.in | 60 ++ pkg/solaris/Makefile.targ | 40 ++ pkg/solaris/SUNWpr/Makefile.in | 22 + pkg/solaris/SUNWpr/depend | 27 + pkg/solaris/SUNWpr/pkginfo.tmpl | 34 ++ pkg/solaris/SUNWpr/prototype_com | 31 ++ pkg/solaris/SUNWpr/prototype_i386 | 30 + pkg/solaris/SUNWpr/prototype_sparc | 33 ++ pkg/solaris/SUNWprx/Makefile.in | 22 + pkg/solaris/SUNWprx/depend | 30 + pkg/solaris/SUNWprx/pkginfo.tmpl | 35 ++ pkg/solaris/SUNWprx/prototype_com | 28 + pkg/solaris/SUNWprx/prototype_sparc | 35 ++ pkg/solaris/bld_awk_pkginfo.ksh | 105 ++++ pkg/solaris/common_files/copyright | 28 + pr/include/md/Makefile.in | 17 +- pr/include/md/_aix.h | 6 +- pr/include/md/_aix32.cfg | 3 + pr/include/md/_aix32in6.cfg | 142 ----- pr/include/md/_beos.h | 16 +- pr/include/md/_bsdi.h | 11 + pr/include/md/_darwin.cfg | 4 - pr/include/md/_darwin.h | 34 ++ pr/include/md/_freebsd.cfg | 9 +- pr/include/md/_freebsd.h | 25 +- pr/include/md/_hpux.h | 27 +- pr/include/md/_hpux64.cfg | 4 +- pr/include/md/_irix.h | 6 + pr/include/md/_linux.cfg | 91 +++ pr/include/md/_linux.h | 7 + pr/include/md/_macos.h | 76 ++- pr/include/md/_netbsd.h | 1 + pr/include/md/_nto.h | 2 + pr/include/md/_openvms.h | 5 +- pr/include/md/_os2.h | 76 ++- pr/include/md/_os2_errors.h | 10 +- pr/include/md/_osf1.h | 11 +- pr/include/md/_pth.h | 27 +- pr/include/md/_solaris.h | 12 +- pr/include/md/_solaris32.cfg | 4 +- pr/include/md/_solaris64.cfg | 4 +- pr/include/md/_unixos.h | 3 + pr/include/md/_win16.h | 7 - pr/include/md/_win95.h | 24 +- pr/include/md/_winnt.h | 8 + pr/include/obsolete/Makefile.in | 2 +- pr/include/prcountr.h | 78 ++- pr/include/prerr.h | 5 +- pr/include/prinet.h | 2 +- pr/include/prinit.h | 12 +- pr/include/prio.h | 56 +- pr/include/private/Makefile.in | 2 +- pr/include/private/primpl.h | 68 ++- pr/include/prlink.h | 8 + pr/include/prlong.h | 5 + pr/include/prolock.h | 59 +- pr/include/prsystem.h | 7 + pr/include/prthread.h | 2 + pr/include/prtrace.h | 72 ++- pr/include/prtypes.h | 75 ++- pr/include/prwin16.h | 2 +- pr/src/Makefile.in | 49 +- pr/src/io/Makefile.in | 8 + pr/src/io/prdir.c | 50 ++ pr/src/io/prfdcach.c | 4 +- pr/src/io/prfile.c | 88 ++- pr/src/io/prio.c | 11 +- pr/src/io/priometh.c | 12 +- pr/src/io/prlayer.c | 4 +- pr/src/io/prlog.c | 27 +- pr/src/io/prmapopt.c | 13 +- pr/src/io/prmwait.c | 39 +- pr/src/io/prprf.c | 109 ++-- pr/src/io/prsocket.c | 106 ++-- pr/src/io/prstdio.c | 38 ++ pr/src/linking/Makefile.in | 10 + pr/src/linking/prlink.c | 1041 ++++++++++++++++++++++++++++------- pr/src/malloc/prmem.c | 76 ++- pr/src/md/beos/bfile.c | 423 +++++++++----- pr/src/md/beos/bmisc.c | 7 + pr/src/md/beos/bmmap.c | 3 + pr/src/md/beos/bnet.c | 773 +++++++++++++++++--------- pr/src/md/beos/bproc.c | 184 ++++++- pr/src/md/mac/macdll.c | 106 ++-- pr/src/md/mac/macio.c | 22 +- pr/src/md/mac/macsocket.h | 1 + pr/src/md/mac/macsockotpt.c | 346 ++++++++---- pr/src/md/mac/macthr.c | 170 +++++- pr/src/md/mac/mdcriticalregion.c | 1 + pr/src/md/mac/mdmac.c | 5 + pr/src/md/os2/Makefile.in | 4 + pr/src/md/os2/objs.mk | 6 +- pr/src/md/os2/os2_errors.c | 125 ++--- pr/src/md/os2/os2cv.c | 112 ++-- pr/src/md/os2/os2emx.s | 111 ++++ pr/src/md/os2/os2inrval.c | 73 +-- pr/src/md/os2/os2io.c | 6 + pr/src/md/os2/os2misc.c | 391 +++++-------- pr/src/md/os2/os2poll.c | 268 ++++++--- pr/src/md/os2/os2sock.c | 1020 ++++++++++++++-------------------- pr/src/md/os2/os2thred.c | 34 +- pr/src/md/os2/os2vacpp.asm | 199 ++++++- pr/src/md/unix/Makefile.in | 22 +- pr/src/md/unix/darwin.c | 33 +- pr/src/md/unix/irix.c | 8 +- pr/src/md/unix/openvms.c | 76 +++ pr/src/md/unix/os_Darwin_ppc.s | 92 ++++ pr/src/md/unix/unix.c | 53 +- pr/src/md/unix/unix_errors.c | 10 + pr/src/md/unix/uxpoll.c | 6 + pr/src/md/unix/uxproces.c | 2 +- pr/src/md/unix/uxrng.c | 19 +- pr/src/md/unix/uxshm.c | 7 +- pr/src/md/windows/Makefile.in | 10 + pr/src/md/windows/ntinrval.c | 47 +- pr/src/md/windows/ntio.c | 18 +- pr/src/md/windows/ntmisc.c | 24 +- pr/src/md/windows/ntthread.c | 22 + pr/src/md/windows/w32poll.c | 37 +- pr/src/md/windows/w95io.c | 420 +++++++++++++- pr/src/md/windows/w95sock.c | 26 +- pr/src/md/windows/w95thred.c | 8 +- pr/src/misc/Makefile.in | 12 +- pr/src/misc/compile-et.pl | 2 +- pr/src/misc/pralarm.c | 4 +- pr/src/misc/prcountr.c | 12 - pr/src/misc/prdtoa.c | 209 ++++--- pr/src/misc/prenv.c | 2 +- pr/src/misc/prerr.c | 5 +- pr/src/misc/prerr.et | 1 + pr/src/misc/prerr.properties | 2 +- pr/src/misc/prerror.c | 4 +- pr/src/misc/prinit.c | 56 +- pr/src/misc/prinrval.c | 4 +- pr/src/misc/prlong.c | 4 + pr/src/misc/prnetdb.c | 358 +++++++++++- pr/src/misc/prolock.c | 11 - pr/src/misc/prrng.c | 10 + pr/src/misc/prsystem.c | 19 +- pr/src/misc/prtime.c | 58 +- pr/src/misc/prtpool.c | 6 +- pr/src/misc/prtrace.c | 11 - pr/src/nspr.def | 449 +++++++++++++++ pr/src/nspr_symvec.opt | 491 +++++++++++++++++ pr/src/pthreads/Makefile.in | 5 + pr/src/pthreads/ptio.c | 462 +++++++++++++--- pr/src/pthreads/ptsynch.c | 9 +- pr/src/pthreads/ptthread.c | 73 ++- pr/src/threads/combined/prucpu.c | 204 ++++--- pr/src/threads/combined/pruthr.c | 13 +- pr/src/threads/prcthr.c | 2 - pr/src/threads/prtpd.c | 2 +- pr/tests/Makefile.in | 29 +- pr/tests/affinity.c | 10 + pr/tests/attach.c | 20 +- pr/tests/dll/Makefile.in | 4 + pr/tests/libfilename.c | 126 +++++ pr/tests/macbuild/NSPR20TestApp.mcp | Bin 97544 -> 0 bytes pr/tests/runtests.ksh | 7 +- pr/tests/runtests.sh | 287 ++++++++++ pr/tests/sigpipe.c | 26 +- pr/tests/thrpool_server.c | 7 + pr/tests/vercheck.c | 11 +- 233 files changed, 10828 insertions(+), 7385 deletions(-) create mode 100755 build/cygwin-wrapper delete mode 100644 config/AIX.mk delete mode 100644 config/BSD_OS.mk delete mode 100644 config/BeOS.mk delete mode 100644 config/DGUX.mk delete mode 100644 config/FreeBSD.mk delete mode 100644 config/HP-UX.mk delete mode 100644 config/IRIX.mk delete mode 100644 config/Linux.mk delete mode 100644 config/NCR.mk delete mode 100644 config/NEC.mk delete mode 100644 config/NEWS-OS.mk delete mode 100644 config/NEXTSTEP.mk delete mode 100644 config/NTO.mk delete mode 100644 config/NetBSD.mk delete mode 100644 config/OS2.mk delete mode 100644 config/OSF1.mk delete mode 100644 config/OpenBSD.mk delete mode 100644 config/OpenVMS.mk delete mode 100644 config/QNX.mk delete mode 100644 config/Rhapsody.mk delete mode 100644 config/SCOOS.mk delete mode 100644 config/SINIX.mk delete mode 100644 config/SunOS.mk delete mode 100644 config/SunOS4.mk delete mode 100644 config/SunOS5.mk delete mode 100644 config/UNIX.mk delete mode 100644 config/UNIXWARE.mk delete mode 100644 config/WIN32.mk delete mode 100644 config/WIN95.mk delete mode 100644 config/WINNT.mk delete mode 100644 config/arch.mk delete mode 100644 config/module.df delete mode 100644 config/win16.mk create mode 100644 lib/ds/plds.def create mode 100644 lib/ds/plds_symvec.opt create mode 100644 lib/libc/src/plc.def create mode 100644 lib/libc/src/plc_symvec.opt delete mode 100644 macbuild/NSPR.Debug.Prefix delete mode 100644 macbuild/NSPR.Prefix delete mode 100644 macbuild/NSPR20.toc delete mode 100644 macbuild/NSPR20PPC.mcp delete mode 100644 macbuild/NSPRCarbon.Prefix delete mode 100644 macbuild/NSPRCarbonDebug.Prefix delete mode 100644 macbuild/NSPRConfig.h delete mode 100644 macbuild/NSPRDebug.Prefix create mode 100644 pkg/Makefile.in create mode 100644 pkg/linux/Makefile.in create mode 100644 pkg/linux/sun-nspr.spec create mode 100644 pkg/solaris/Makefile.com create mode 100644 pkg/solaris/Makefile.in create mode 100644 pkg/solaris/Makefile.targ create mode 100644 pkg/solaris/SUNWpr/Makefile.in create mode 100644 pkg/solaris/SUNWpr/depend create mode 100644 pkg/solaris/SUNWpr/pkginfo.tmpl create mode 100644 pkg/solaris/SUNWpr/prototype_com create mode 100644 pkg/solaris/SUNWpr/prototype_i386 create mode 100644 pkg/solaris/SUNWpr/prototype_sparc create mode 100644 pkg/solaris/SUNWprx/Makefile.in create mode 100644 pkg/solaris/SUNWprx/depend create mode 100644 pkg/solaris/SUNWprx/pkginfo.tmpl create mode 100644 pkg/solaris/SUNWprx/prototype_com create mode 100644 pkg/solaris/SUNWprx/prototype_sparc create mode 100644 pkg/solaris/bld_awk_pkginfo.ksh create mode 100644 pkg/solaris/common_files/copyright delete mode 100644 pr/include/md/_aix32in6.cfg create mode 100644 pr/src/md/os2/os2emx.s create mode 100644 pr/src/md/unix/os_Darwin_ppc.s create mode 100644 pr/src/nspr.def create mode 100644 pr/src/nspr_symvec.opt create mode 100644 pr/tests/libfilename.c delete mode 100644 pr/tests/macbuild/NSPR20TestApp.mcp create mode 100755 pr/tests/runtests.sh diff --git a/Makefile.in b/Makefile.in index ac081b6b..b0a1cae1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -41,11 +41,19 @@ VPATH = @srcdir@ include $(MOD_DEPTH)/config/autoconf.mk +MAKE := $(patsubst -j%,,$(MAKE)) -j1 + DIRS = config pr lib ifdef MOZILLA_CLIENT -PR_CLIENT_BUILD = 1 -PR_CLIENT_BUILD_UNIX = 1 +# Make nsinstall use absolute symlinks by default for Mozilla OSX builds +# http://bugzilla.mozilla.org/show_bug.cgi?id=193164 +ifeq ($(OS_ARCH),Darwin) +ifndef NSDISTMODE +NSDISTMODE=absolute_symlink +export NSDISTMODE +endif +endif endif DIST_GARBAGE = config.cache config.log config.status @@ -68,15 +76,6 @@ ifeq ($(OS_ARCH),WINNT) ZIP_ASCII_OPT = -ll endif -ifdef PR_CLIENT_BUILD -export:: - rm -r -f $(DIST)/../public/nspr -ifdef PR_CLIENT_BUILD_UNIX - rm -f $(dist_libdir)/libnspr.a - rm -f $(dist_bindir)/libnspr.$(DLL_SUFFIX) -endif -endif - # Delete config/autoconf.mk last because it is included by every makefile. distclean:: @echo "cd pr/tests; $(MAKE) $@" @@ -108,12 +107,12 @@ ifeq ($(OS_ARCH),WINNT) @if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \ rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \ echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)"; \ - config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER); \ + $(topsrcdir)/config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER); \ fi @if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); then \ rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \ echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)"; \ - config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER)\\$(RELEASE_OBJDIR_NAME); \ + $(topsrcdir)/config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER)\\$(RELEASE_OBJDIR_NAME); \ fi else @if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \ @@ -140,5 +139,9 @@ endif cp -f mdheader.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \ chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)/mdheader.jar +package: + @echo "cd pkg; $(MAKE) publish" + $(MAKE) -C pkg publish + depend: @echo "NSPR20 has no dependencies. Skipped." diff --git a/admin/repackage.sh b/admin/repackage.sh index 2a705c49..999aa0e0 100755 --- a/admin/repackage.sh +++ b/admin/repackage.sh @@ -60,10 +60,10 @@ # # These variables should be modified for each NSPR release. # -FROMTOP=/share/builds/components/nspr20/v4.1.1 -TOTOP=./v4.1.1 -NSPRDIR=nspr-4.1.1 -SOURCETAG=NSPRPUB_RELEASE_4_1_1 +FROMTOP=/share/builds/components/nspr20/v4.3 +TOTOP=./v4.3 +NSPRDIR=nspr-4.3 +SOURCETAG=NSPR_4_3_RTM # # enumerate Unix object directories on /s/b/c @@ -80,12 +80,16 @@ IRIX6.5_n32_PTH_DBG.OBJ IRIX6.5_n32_PTH_OPT.OBJ Linux2.2_x86_glibc_PTH_DBG.OBJ Linux2.2_x86_glibc_PTH_OPT.OBJ -OSF1V4.0D_DBG.OBJ -OSF1V4.0D_OPT.OBJ +Linux2.4_x86_glibc_PTH_DBG.OBJ +Linux2.4_x86_glibc_PTH_OPT.OBJ +OSF1V5.0_DBG.OBJ +OSF1V5.0_OPT.OBJ SunOS5.6_DBG.OBJ SunOS5.6_OPT.OBJ -SunOS5.7_64_DBG.OBJ -SunOS5.7_64_OPT.OBJ +SunOS5.8_64_DBG.OBJ +SunOS5.8_64_OPT.OBJ +SunOS5.8_DBG.OBJ +SunOS5.8_OPT.OBJ " # # enumerate Windows object directories on /s/b/c diff --git a/build/autoconf/config.guess b/build/autoconf/config.guess index 627c6158..2f81c082 100755 --- a/build/autoconf/config.guess +++ b/build/autoconf/config.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-10-05' +timestamp='2003-02-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ timestamp='2001-10-05' # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Originally written by Per Bothner . +# Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # @@ -88,30 +88,41 @@ if test $# != 0; then exit 1 fi +trap 'exit 1' 1 2 15 -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. -# CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; - rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' +esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -135,23 +146,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - sparc*) machine=`uname -p`-unknown ;; - *) machine=${UNAME_MACHINE}-unknown ;; + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null @@ -168,7 +179,18 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. @@ -217,63 +239,47 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) @@ -291,6 +297,9 @@ EOF *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; @@ -311,6 +320,10 @@ EOF NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; @@ -339,7 +352,7 @@ EOF echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) @@ -417,15 +430,20 @@ EOF exit (-1); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; @@ -498,8 +516,7 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 @@ -508,7 +525,7 @@ EOF fi exit 0 ;; *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else @@ -597,11 +614,21 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) @@ -635,8 +662,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) @@ -682,9 +708,6 @@ EOF C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; @@ -697,18 +720,15 @@ EOF CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` @@ -725,7 +745,18 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -738,19 +769,21 @@ EOF xx:WINNT:* | xx:WIN95:*) echo i586-pc-msvc exit 0 ;; -# MKS Toolkit - [34567]86:Windows_NT:*) - echo i386-pc-mksnt - exit 0 ;; ### End MozillaHack i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; + x86:Interix*:3*) + echo i586-pc-interix3 + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix + echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin @@ -771,16 +804,48 @@ EOF echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux + echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) - case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in - big) echo mips-unknown-linux-gnu && exit 0 ;; - little) echo mipsel-unknown-linux-gnu && exit 0 ;; - esac + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu @@ -829,7 +894,8 @@ EOF # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. - ld_supported_targets=`cd /; ld --help 2>&1 \ + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// @@ -841,7 +907,7 @@ EOF ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; + exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; @@ -853,32 +919,28 @@ EOF esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build - cat >$dummy.c < -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-pc-linux-gnu\n", argv[1]); -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -# else - printf ("%s-pc-linux-gnulibc1\n", argv[1]); -# endif -#else - printf ("%s-pc-linux-gnuaout\n", argv[1]); -#endif - return 0; -} + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif EOF - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) @@ -895,6 +957,23 @@ EOF # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -916,22 +995,19 @@ EOF UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -955,9 +1031,15 @@ EOF # "miniframe" echo m68010-convergent-sysv exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -974,9 +1056,6 @@ EOF mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; @@ -1058,6 +1137,9 @@ EOF SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; @@ -1065,18 +1147,24 @@ EOF echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) + NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) @@ -1099,9 +1187,6 @@ EOF fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; - i*86:OS/2:*:*) - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; @@ -1120,12 +1205,6 @@ EOF *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1246,8 +1325,7 @@ main () } EOF -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. diff --git a/build/autoconf/config.sub b/build/autoconf/config.sub index 0cee56fb..cccb756d 100755 --- a/build/autoconf/config.sub +++ b/build/autoconf/config.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-10-05' +timestamp='2003-02-22' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -118,7 +118,7 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -224,35 +224,50 @@ esac case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. +#### MozillaHack +# mips*el +#### End MozillaHack 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ + | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ + | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ - | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipseb | mips*el | mipsle | mipstx39 | mipstx39el \ - | mipsisa32 \ + | mips | mipsbe | mipseb | mips*el | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | msp430 \ | ns16k | ns32k \ - | openrisc \ + | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | s390 | s390x \ - | sh | sh[34] | sh[34]eb | shbe | shle \ - | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ - | stormy16 | strongarm \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ | tahoe | thumb | tic80 | tron \ - | v850 \ + | v850 | v850e \ | we32k \ - | x86 | xscale \ + | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; @@ -276,42 +291,61 @@ case $basic_machine in exit 1 ;; # Recognize the basic CPU types with company name. +#### MozillaHack +# mips*el +#### End MozillaHack 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alphapca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cray2-* | cydra-* \ - | d10v-* | d30v-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* \ | m32r-* \ - | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ - | mipsle-* | mips*el-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ + | mips-* | mipsbe-* | mipseb-* | mips*el-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | s390-* | s390x-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ - | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | vax-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ | ymp-* \ | z8k-*) ;; @@ -376,6 +410,10 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -396,16 +434,8 @@ case $basic_machine in basic_machine=c38-convex os=-bsd ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray + cray | j90) + basic_machine=j90-cray os=-unicos ;; crds | unos) @@ -420,6 +450,14 @@ case $basic_machine in decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola @@ -598,10 +636,6 @@ case $basic_machine in basic_machine=i386-pc os=-msvc ;; - i386-mksnt) - basic_machine=i386-pc - os=-mksnt - ;; #### End MozillaHack miniframe) basic_machine=m68000-convergent @@ -610,14 +644,6 @@ case $basic_machine in basic_machine=m68k-atari os=-mint ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; @@ -632,6 +658,10 @@ case $basic_machine in basic_machine=m68k-rom68k os=-coff ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; msdos) basic_machine=i386-pc os=-msdos @@ -704,6 +734,10 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -711,6 +745,10 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose @@ -733,13 +771,13 @@ case $basic_machine in pbb) basic_machine=m68k-tti ;; - pc532 | pc532-*) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; - pentiumpro | p6 | 6x86 | athlon) + pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2) @@ -760,22 +798,22 @@ case $basic_machine in power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown - ;; + ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown - ;; + ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown - ;; + ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown - ;; + ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; @@ -796,10 +834,22 @@ case $basic_machine in rtpc | rtpc-*) basic_machine=romp-ibm ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; sa29200) basic_machine=a29k-amd os=-udi ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; sequent) basic_machine=i386-sequent ;; @@ -874,19 +924,39 @@ case $basic_machine in os=-dynix ;; t3e) - basic_machine=t3e-cray + basic_machine=alphaev5-cray os=-unicos ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic4x | c4x*) + basic_machine=tic4x-unknown + os=-coff + ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; tower | tower-32) basic_machine=m68k-ncr ;; @@ -911,8 +981,8 @@ case $basic_machine in os=-vms ;; vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -933,17 +1003,13 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt + xps | xps100) + basic_machine=xps100-honeywell ;; - xmp) - basic_machine=xmp-cray + ymp) + basic_machine=ymp-cray os=-unicos ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim @@ -964,13 +1030,6 @@ case $basic_machine in op60c) basic_machine=hppa1.1-oki ;; - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; romp) basic_machine=romp-ibm ;; @@ -990,13 +1049,16 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh3eb | sh4eb) + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; + sh64) + basic_machine=sh64-unknown + ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; - cydra) + cydra) basic_machine=cydra-cydrome ;; orion) @@ -1011,10 +1073,6 @@ case $basic_machine in pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; @@ -1063,6 +1121,9 @@ case $os in # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. +#### MozillaHack +# msvc +#### End MozillaHack -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ @@ -1077,11 +1138,13 @@ case $os in | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ - | -msvc* | -mksnt* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -msvc* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos*) + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1093,8 +1156,10 @@ case $os in ;; esac ;; + -nto-qnx*) + ;; -nto*) - os=-nto-qnx + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ @@ -1133,14 +1198,20 @@ case $os in -acis*) os=-aos ;; + -atheos*) + os=-atheos + ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; + -nova*) + os=-rtmk-nova + ;; -ns2 ) - os=-nextstep2 + os=-nextstep2 ;; -nsk*) os=-nsk @@ -1179,8 +1250,14 @@ case $os in -xenix) os=-xenix ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos ;; -none) ;; @@ -1213,10 +1290,11 @@ case $basic_machine in arm*-semi) os=-aout ;; + # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; - pdp11-*) + pdp11-*) os=-none ;; *-dec | vax-*) @@ -1243,6 +1321,9 @@ case $basic_machine in mips*-*) os=-elf ;; + or32-*) + os=-coff + ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; @@ -1306,19 +1387,19 @@ case $basic_machine in *-next) os=-nextstep3 ;; - *-gould) + *-gould) os=-sysv ;; - *-highlevel) + *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; - *-sgi) + *-sgi) os=-irix ;; - *-siemens) + *-siemens) os=-sysv4 ;; *-masscomp) @@ -1390,7 +1471,7 @@ case $basic_machine in -ptx*) vendor=sequent ;; - -vxsim* | -vxworks*) + -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) diff --git a/build/cygwin-wrapper b/build/cygwin-wrapper new file mode 100755 index 00000000..3da3c508 --- /dev/null +++ b/build/cygwin-wrapper @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Stupid wrapper to avoid win32 dospath/cygdrive issues +# +prog=$1 +shift +if test -z "$prog"; then + exit 0 +fi +mountpoint=`mount -p | awk '{ if (/^\//) { print $1; exit } }'` +if test -z "$mountpoint"; then + print "Cannot determine cygwin mount points. Exiting" + exit 1 +fi +mountpoint=`echo $mountpoint | sed 's|/$||'` +if test "$prog" = "-up"; then + prog=$1 + shift + args=`echo $* | sed -e "s|-I\([a-zA-Z]\):/|-I${mountpoint}/\1/|g;"` +else + args=`echo $* | sed -e "s|${mountpoint}/\([a-zA-Z]\)/|\1:/|g;"` +fi +exec $prog $args diff --git a/config/AIX.mk b/config/AIX.mk deleted file mode 100644 index 0df9d2db..00000000 --- a/config/AIX.mk +++ /dev/null @@ -1,171 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for AIX. -# - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -CLASSIC_NSPR = 1 -endif -endif - -# -# There are three implementation strategies available on AIX: -# pthreads, classic, and pthreads-user. -# -# On AIX 3.2, classic nspr is the default (and only) implementation -# strategy. On AIX 4.1 and later, the default is pthreads. -# -ifeq ($(OS_RELEASE),3.2) -CLASSIC_NSPR = 1 -endif - -ifeq ($(CLASSIC_NSPR),1) - PTHREADS_USER = - USE_PTHREADS = - IMPL_STRATEGY = _EMU - DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -ifeq ($(PTHREADS_USER),1) - USE_PTHREADS = - IMPL_STRATEGY = _PTH_USER -else - USE_PTHREADS = 1 - IMPL_STRATEGY = _PTH -endif -endif - -# IPv6 support part of the standard AIX 4.3 release. -ifneq (,$(filter-out 3.2 4.1 4.2,$(OS_RELEASE))) -USE_IPV6 = 1 -endif - -ifeq ($(CLASSIC_NSPR),1) -CC = xlC -CCC = xlC -else -CC = xlC_r -CCC = xlC_r -endif -OS_CFLAGS = -qro -qroconst -ifeq ($(USE_64),1) -OBJECT_MODE = 64 -export OBJECT_MODE -COMPILER_TAG = _64 -else -COMPILER_TAG = _32 -endif - -CPU_ARCH = rs6000 - -RANLIB = ranlib - -OS_CFLAGS += -DAIX -DSYSV -ifeq ($(CC),xlC_r) -OS_CFLAGS += -qarch=com -endif - -ifneq ($(OS_RELEASE),3.2) -OS_CFLAGS += -DAIX_HAVE_ATOMIC_OP_H -DAIX_TIMERS -endif - -ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE))) -ifndef USE_PTHREADS -OS_CFLAGS += -DAIX_RENAME_SELECT -endif -endif - -ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE))) -OS_CFLAGS += -D_PR_NO_LARGE_FILES -else -OS_CFLAGS += -D_PR_HAVE_OFF64_T -endif - -ifeq ($(OS_RELEASE),4.1) -OS_CFLAGS += -DAIX4_1 -else -DSO_LDOPTS = -brtl -bM:SRE -bnoentry -bexpall -MKSHLIB = $(LD) $(DSO_LDOPTS) -ifeq ($(OS_RELEASE),4.3) -OS_CFLAGS += -DAIX4_3 -endif -endif - -# Have the socklen_t data type -ifeq ($(OS_RELEASE),4.3) -OS_CFLAGS += -DHAVE_SOCKLEN_T -endif - -ifneq (,$(filter-out 3.2 4.1 4.2,$(OS_RELEASE))) -OS_CFLAGS += -DHAVE_FCNTL_FILE_LOCKING -endif - -ifeq (,$(filter-out 4.2 4.3,$(OS_RELEASE))) -# On these OS revisions, localtime_r() is declared if _THREAD_SAFE -# is defined. -ifneq ($(CLASSIC_NSPR),1) -OS_CFLAGS += -DHAVE_POINTER_LOCALTIME_R -endif -endif - -ifeq (,$(filter-out 4.3,$(OS_RELEASE))) -# On these OS revisions, gethostbyXXX() returns result in thread -# specific storage. -ifeq ($(USE_PTHREADS),1) -OS_CFLAGS += -D_PR_HAVE_THREADSAFE_GETHOST -endif -endif - -# -# Special link info for constructing AIX programs. On AIX we have to -# statically link programs that use NSPR into a single .o, rewriting the -# calls to select to call "aix". Once that is done we then can -# link that .o with a .o built in nspr which implements the system call. -# -ifneq (,$(filter-out 3.2 4.1,$(OS_RELEASE))) -AIX_LINK_OPTS = -brtl -bnso -berok -else -AIX_LINK_OPTS = -bnso -berok -#AIX_LINK_OPTS = -bnso -berok -brename:.select,.wrap_select -brename:.poll,.wrap_poll -bI:/usr/lib/syscalls.exp -endif - -AIX_WRAP = $(DIST)/lib/aixwrap.o -AIX_TMP = $(OBJDIR)/_aix_tmp.o diff --git a/config/BSD_OS.mk b/config/BSD_OS.mk deleted file mode 100644 index 17b6ee54..00000000 --- a/config/BSD_OS.mk +++ /dev/null @@ -1,91 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for BSD/OS Unix. -# - -include $(MOD_DEPTH)/config/UNIX.mk - -ifeq (,$(filter-out 1.1 4.%,$(OS_RELEASE))) -CC = gcc -Wall -Wno-format -CCC = g++ -else -CC = shlicc2 -CCC = shlicc2 -endif -RANLIB = ranlib - -ifeq ($(USE_PTHREADS),1) -IMPL_STRATEGY = _PTH -DEFINES += -D_PR_NEED_PTHREAD_INIT -else -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -endif - -OS_CFLAGS = $(DSO_CFLAGS) -DBSDI -DHAVE_STRERROR -DNEED_BSDREGEX - -ifeq (86,$(findstring 86,$(OS_TEST))) -CPU_ARCH = x86 -endif -ifeq (sparc,$(findstring sparc,$(OS_TEST))) -CPU_ARCH = sparc -endif - -ifeq ($(OS_RELEASE),2.1) -OS_CFLAGS += -D_PR_TIMESPEC_HAS_TS_SEC -endif - -ifeq (,$(filter-out 1.1 2.1,$(OS_RELEASE))) -OS_CFLAGS += -D_PR_BSDI_JMPBUF_IS_ARRAY -else -OS_CFLAGS += -D_PR_SELECT_CONST_TIMEVAL -D_PR_BSDI_JMPBUF_IS_STRUCT -endif - -NOSUCHFILE = /no-such-file - -ifeq ($(OS_RELEASE),1.1) -OS_CFLAGS += -D_PR_STAT_HAS_ONLY_ST_ATIME -D_PR_NEED_H_ERRNO -else -OS_CFLAGS += -DHAVE_DLL -DUSE_DLFCN -D_PR_STAT_HAS_ST_ATIMESPEC -OS_LIBS = -ldl -ifeq (,$(filter-out 4.%,$(OS_RELEASE))) -MKSHLIB = $(CC) $(DSO_LDOPTS) -DSO_CFLAGS = -fPIC -DSO_LDOPTS = -shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so) -else -MKSHLIB = $(LD) $(DSO_LDOPTS) -DSO_LDOPTS = -r -endif -endif diff --git a/config/BeOS.mk b/config/BeOS.mk deleted file mode 100644 index 9c4efa94..00000000 --- a/config/BeOS.mk +++ /dev/null @@ -1,139 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - - -###################################################################### -# Config stuff for BeOS (all architectures) -###################################################################### - -###################################################################### -# Version-independent -###################################################################### - -DEFINES += -XP_DEFINE = -DXP_BEOS - -OBJ_SUFFIX = o -LIB_SUFFIX = a -DLL_SUFFIX = so -AR = ar cr $@ -STRIP = strip - -ifdef BUILD_OPT -DEFINES = -UDEBUG -DNDEBUG -OBJDIR_TAG = _OPT -else -DEFINES = -DDEBUG -UNDEBUG -OBJDIR_TAG = _DBG -endif - -ifeq (PC,$(findstring PC,$(OS_TEST))) -CPU_ARCH = x86 -CC = gcc -CCC = g++ -LD = gcc -RANLIB = ranlib -DSO_LDOPTS = -nostart -PORT_FLAGS = -DHAVE_STRERROR -ifdef BUILD_OPT -OPTIMIZER = -O2 -LDFLAGS += -s -else -OPTIMIZER = -gdwarf-2 -O0 -endif -else -CPU_ARCH = ppc -CC = mwcc -CCC = mwcc -LD = mwld -RANLIB = ranlib -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 - -PORT_FLAGS = -DHAVE_STRERROR -D_POSIX_SOURCE -ifdef BUILD_OPT -OPTIMIZER = -O2 -else -OPTIMIZER = -g -O0 -endif -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -OS_INCLUDES = -I- -I. -#G++INCLUDES = -I/usr/include/g++ - -PLATFORM_FLAGS = -DBeOS -DBEOS $(OS_INCLUDES) - -OS_CFLAGS = $(DSO_CFLAGS) $(PLATFORM_FLAGS) $(PORT_FLAGS) - -USE_BTHREADS = 1 - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -OBJDIR_NAME = $(OS_CONFIG)_$(CPU_ARCH)$(OBJDIR_TAG).OBJ - -#################################################################### -# -# One can define the makefile variable NSDISTMODE to control -# how files are published to the 'dist' directory. If not -# defined, the default is "install using relative symbolic -# links". The two possible values are "copy", which copies files -# but preserves source mtime, and "absolute_symlink", which -# installs using absolute symbolic links. The "absolute_symlink" -# option requires NFSPWD. -# -#################################################################### - -NSINSTALL = $(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall - -ifeq ($(NSDISTMODE),copy) -# copy files, but preserve source mtime -INSTALL = $(NSINSTALL) -t -else -ifeq ($(NSDISTMODE),absolute_symlink) -# install using absolute symbolic links -INSTALL = $(NSINSTALL) -L `$(NFSPWD)` -else -# install using relative symbolic links -INSTALL = $(NSINSTALL) -R -endif -endif - -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi -endef diff --git a/config/DGUX.mk b/config/DGUX.mk deleted file mode 100644 index 3928aa4f..00000000 --- a/config/DGUX.mk +++ /dev/null @@ -1,63 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for Data General DG/UX -# -# Initial DG/UX port by Marc Fraioli -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = gcc -CCC = g++ - -RANLIB = true - -DEFINES += -D_PR_LOCAL_THREADS_ONLY -OS_CFLAGS = -DSVR4 -DSYSV -DDGUX -D_DGUX_SOURCE -D_POSIX4A_DRAFT6_SOURCE - -MKSHLIB = $(LD) $(DSO_LDOPTS) -DSO_LDOPTS = -G - -CPU_ARCH = x86 -ARCH = dgux - -NOSUCHFILE = /no-such-file - -ifdef BUILD_OPT -OPTIMIZER = -O2 -else -# -g would produce a huge executable. -OPTIMIZER = -endif diff --git a/config/FreeBSD.mk b/config/FreeBSD.mk deleted file mode 100644 index 41ee17c5..00000000 --- a/config/FreeBSD.mk +++ /dev/null @@ -1,82 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for FreeBSD -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = gcc -CCC = g++ -RANLIB = ranlib - -ifeq ($(OS_TEST),alpha) -CPU_ARCH = alpha -else -OS_REL_CFLAGS = -Di386 -CPU_ARCH = x86 -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DFREEBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK - -# -# The default implementation strategy for FreeBSD is pthreads. -# -ifeq ($(CLASSIC_NSPR),1) -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -DEFINES += -D_THREAD_SAFE -THREAD_FLAG += -pthread -endif - -ARCH = freebsd - -MOZ_OBJFORMAT := $(shell test -x /usr/bin/objformat && /usr/bin/objformat || echo aout) - -ifeq ($(MOZ_OBJFORMAT),elf) -DLL_SUFFIX = so -else -DLL_SUFFIX = so.1.0 -endif - -DSO_CFLAGS = -fPIC -DSO_LDOPTS = -Bshareable - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -G++INCLUDES = -I/usr/include/g++ diff --git a/config/HP-UX.mk b/config/HP-UX.mk deleted file mode 100644 index 63208618..00000000 --- a/config/HP-UX.mk +++ /dev/null @@ -1,203 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for HP-UX -# - -include $(MOD_DEPTH)/config/UNIX.mk - -DLL_SUFFIX = sl - -ifdef NS_USE_GCC - CC = gcc - CCC = g++ - OS_CFLAGS = - COMPILER_TAG = _gcc -else - CC = cc -Ae - CCC = CC -ext - OS_CFLAGS = +ESlit -endif - -RANLIB = echo - -CPU_ARCH = hppa - -OS_CFLAGS += $(DSO_CFLAGS) -DHPUX -D$(CPU_ARCH) -D_HPUX_SOURCE - -# -# The header netdb.h on HP-UX 9 does not declare h_errno. -# On 10.10 and 10.20, netdb.h declares h_errno only if -# _XOPEN_SOURCE_EXTENDED is defined. So we need to declare -# h_errno ourselves. -# -ifeq ($(basename $(OS_RELEASE)),A.09) -OS_CFLAGS += -D_PR_NEED_H_ERRNO -endif -ifeq (,$(filter-out B.10.10 B.10.20,$(OS_RELEASE))) -OS_CFLAGS += -D_PR_NEED_H_ERRNO -endif - -# Do we have localtime_r()? Does it return 'int' or 'struct tm *'? -ifeq (,$(filter-out B.10.10 B.10.20,$(OS_RELEASE))) -OS_CFLAGS += -DHAVE_INT_LOCALTIME_R -endif -ifeq (,$(filter-out B.10.30 B.11.00,$(OS_RELEASE))) -OS_CFLAGS += -DHAVE_POINTER_LOCALTIME_R -endif - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -CLASSIC_NSPR = 1 -endif - -# -# On HP-UX 9, the default (and only) implementation strategy is -# classic nspr. -# -# On HP-UX 10.10 and 10.20, the default implementation strategy is -# pthreads (actually DCE threads). Classic nspr is also available. -# -# On HP-UX 10.30 and 11.00, the default implementation strategy is -# pthreads. Classic nspr and pthreads-user are also available. -# -ifeq ($(basename $(OS_RELEASE)),A.09) -OS_CFLAGS += -DHPUX9 -DEFAULT_IMPL_STRATEGY = _EMU -endif - -ifeq ($(OS_RELEASE),B.10.01) -OS_CFLAGS += -DHPUX10 -DEFAULT_IMPL_STRATEGY = _EMU -endif - -ifeq ($(OS_RELEASE),B.10.10) -OS_CFLAGS += -DHPUX10 -DHPUX10_10 -DEFAULT_IMPL_STRATEGY = _PTH -endif - -ifeq ($(OS_RELEASE),B.10.20) -OS_CFLAGS += -DHPUX10 -DHPUX10_20 -ifndef NS_USE_GCC -OS_CFLAGS += +DAportable +DS1.1 -endif -DEFAULT_IMPL_STRATEGY = _PTH -endif - -# -# On 10.30 and 11.00, we use the new ANSI C++ compiler aCC. -# - -ifeq ($(OS_RELEASE),B.10.30) -ifndef NS_USE_GCC -CCC = /opt/aCC/bin/aCC -ext -OS_CFLAGS += +DAportable +DS1.1 -endif -OS_CFLAGS += -DHPUX10 -DHPUX10_30 -DEFAULT_IMPL_STRATEGY = _PTH -endif - -# 11.00 is similar to 10.30. -ifeq ($(OS_RELEASE),B.11.00) - ifndef NS_USE_GCC - CCC = /opt/aCC/bin/aCC -ext - ifeq ($(USE_64), 1) - OS_CFLAGS += +DA2.0W +DS2.0 - COMPILER_TAG = _64 - else - OS_CFLAGS += +DAportable +DS2.0 - COMPILER_TAG = _32 - endif - endif -OS_CFLAGS += -DHPUX10 -DHPUX11 -D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T -DHAVE_FCNTL_FILE_LOCKING -DEFAULT_IMPL_STRATEGY = _PTH -endif - -ifeq ($(DEFAULT_IMPL_STRATEGY),_EMU) -CLASSIC_NSPR = 1 -endif - -ifeq ($(DEFAULT_IMPL_STRATEGY),_PTH) -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -ifeq ($(CLASSIC_NSPR),1) -USE_PTHREADS = -IMPL_STRATEGY = _EMU -endif -ifeq ($(PTHREADS_USER),1) -USE_PTHREADS = -IMPL_STRATEGY = _PTH_USER -endif -endif - -ifeq ($(CLASSIC_NSPR),1) -DEFINES += -D_PR_LOCAL_THREADS_ONLY -endif - -ifeq (,$(filter-out A.09 B.10,$(basename $(OS_RELEASE)))) -DEFINES += -D_PR_NO_LARGE_FILES -endif - -# -# To use the true pthread (kernel thread) library on 10.30 and -# 11.00, we should define _POSIX_C_SOURCE to be 199506L. -# The _REENTRANT macro is deprecated. -# - -ifdef USE_PTHREADS -ifeq (,$(filter-out B.10.10 B.10.20,$(OS_RELEASE))) -OS_CFLAGS += -D_REENTRANT -D_PR_DCETHREADS -else -OS_CFLAGS += -D_POSIX_C_SOURCE=199506L -D_PR_HAVE_THREADSAFE_GETHOST -endif -endif - -ifdef PTHREADS_USER -OS_CFLAGS += -D_POSIX_C_SOURCE=199506L -endif - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -DSO_LDOPTS = -b +h $(notdir $@) - -# -fPIC or +Z generates position independent code for use in shared -# libraries. -ifdef NS_USE_GCC -DSO_CFLAGS = -fPIC -else -DSO_CFLAGS = +Z -endif diff --git a/config/IRIX.mk b/config/IRIX.mk deleted file mode 100644 index 8620ea65..00000000 --- a/config/IRIX.mk +++ /dev/null @@ -1,158 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for IRIX -# - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -CLASSIC_NSPR = 1 -endif -endif - -# -# On IRIX 5.x, classic nspr (user-level threads on top of sprocs) -# is the default (and only) implementation strategy. -# -# On IRIX 6.x and later, the default implementation strategy is -# pthreads. Classic nspr is also available. -# -ifeq ($(basename $(OS_RELEASE)),5) -CLASSIC_NSPR = 1 -endif - -ifeq ($(CLASSIC_NSPR),1) - IMPL_STRATEGY = _MxN -else - USE_PTHREADS = 1 - USE_N32 = 1 - IMPL_STRATEGY = _PTH -endif - -ifdef NS_USE_GCC - CC = gcc - COMPILER_TAG = _gcc - AS = $(CC) -x assembler-with-cpp -D_ASM -mips2 - ODD_CFLAGS = -Wall -Wno-format - ifdef BUILD_OPT - OPTIMIZER = -O6 - endif -else - CC = cc - CCC = CC - ODD_CFLAGS = -fullwarn -xansi - ifdef BUILD_OPT - ifneq ($(USE_N32),1) - OPTIMIZER = -O -Olimit 4000 - else - OPTIMIZER = -O -OPT:Olimit=4000 - endif - endif - -# -# The default behavior is still -o32 generation, hence the explicit tests -# for -n32 and -64 and implicitly assuming -o32. If that changes, ... -# - ifeq ($(basename $(OS_RELEASE)),6) - ODD_CFLAGS += -multigot - SHLIB_LD_OPTS = -no_unresolved - ifeq ($(USE_N32),1) - ODD_CFLAGS += -n32 -woff 1209 - COMPILER_TAG = _n32 - LDOPTS += -n32 - SHLIB_LD_OPTS += -n32 - ifeq ($(OS_RELEASE), 6_2) - LDOPTS += -Wl,-woff,85 - SHLIB_LD_OPTS += -woff 85 - endif - else - ifeq ($(USE_64),1) - ODD_CFLAGS += -64 - COMPILER_TAG = _64 - else - ODD_CFLAGS += -32 - COMPILER_TAG = _o32 - endif - endif - else - ODD_CFLAGS += -xgot - endif -endif - -ODD_CFLAGS += -DSVR4 -DIRIX -DHAVE_FCNTL_FILE_LOCKING - -CPU_ARCH = mips - -RANLIB = /bin/true - -# For purify -# XXX: should always define _SGI_MP_SOURCE -NOMD_OS_CFLAGS = $(ODD_CFLAGS) -D_SGI_MP_SOURCE - -ifeq ($(OS_RELEASE),5.3) -OS_CFLAGS += -DIRIX5_3 -endif - -ifneq ($(basename $(OS_RELEASE)),5) -OS_CFLAGS += -D_PR_HAVE_SGI_PRDA_PROCMASK -endif - -ifeq (,$(filter-out 6.5,$(OS_RELEASE))) -ifndef NS_USE_GCC -OS_CFLAGS += -mips3 -endif -OS_CFLAGS += -D_PR_HAVE_GETPROTO_R -D_PR_HAVE_GETPROTO_R_POINTER -ifeq ($(USE_PTHREADS),1) -OS_CFLAGS += -D_PR_HAVE_GETHOST_R -D_PR_HAVE_GETHOST_R_POINTER -endif -endif - -ifndef NO_MDUPDATE -OS_CFLAGS += $(NOMD_OS_CFLAGS) -MDupdate $(DEPENDENCIES) -else -OS_CFLAGS += $(NOMD_OS_CFLAGS) -endif - -# -rdata_shared is an ld option that puts string constants and -# const data into the text segment, where they will be shared -# across processes and be read-only. -MKSHLIB = $(LD) $(SHLIB_LD_OPTS) -rdata_shared -shared -soname $(notdir $@) - -DSO_LDOPTS = -elf -shared -all diff --git a/config/Linux.mk b/config/Linux.mk deleted file mode 100644 index eabdb5b1..00000000 --- a/config/Linux.mk +++ /dev/null @@ -1,131 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -###################################################################### -# Config stuff for Linux (all architectures) -###################################################################### - -###################################################################### -# Version-independent -###################################################################### - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -CLASSIC_NSPR = 1 -endif -endif - -# -# The default implementation strategy for Linux is pthreads. -# -ifeq ($(CLASSIC_NSPR),1) -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -DEFINES += -D_REENTRANT -endif - -ifeq (86,$(findstring 86,$(OS_TEST))) -CPU_ARCH := x86 -else -ifeq (,$(filter-out arm% sa110,$(OS_TEST))) -CPU_ARCH := arm -else -CPU_ARCH := $(OS_TEST) -endif -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -CC = gcc -CCC = g++ -RANLIB = ranlib - -OS_INCLUDES = -G++INCLUDES = -I/usr/include/g++ - -PLATFORM_FLAGS = -ansi -Wall -pipe -DLINUX -Dlinux -PORT_FLAGS = -D_POSIX_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -DHAVE_STRERROR -DHAVE_FCNTL_FILE_LOCKING - -OS_CFLAGS = $(DSO_CFLAGS) $(PLATFORM_FLAGS) $(PORT_FLAGS) - -###################################################################### -# Version-specific stuff -###################################################################### - -ifeq ($(CPU_ARCH),alpha) -PLATFORM_FLAGS += -D_ALPHA_ -D__alpha -mieee -endif -ifeq ($(CPU_ARCH),x86) -PLATFORM_FLAGS += -Di386 -endif -ifeq ($(CPU_ARCH),m68k) -# -# gcc on Linux/m68k either has a bug or triggers a code-sequence -# bug in the 68060 which causes gcc to crash. The simplest way to -# avoid this is to enable a minimum level of optimization. -# -ifndef BUILD_OPT -OPTIMIZER += -O -endif -PLATFORM_FLAGS += -m68020-40 -endif - -# -# Linux 2.x has shared libraries. -# - -MKSHLIB = $(LD) $(DSO_LDOPTS) -soname $(notdir $@) -ifdef BUILD_OPT -OPTIMIZER = -O2 -# invoke 'strip' on *.so files in optimized builds -STRIP = strip -endif - -###################################################################### -# Overrides for defaults in config.mk (or wherever) -###################################################################### - -###################################################################### -# Other -###################################################################### - -DSO_CFLAGS = -fPIC -DSO_LDOPTS = -shared diff --git a/config/Makefile.in b/config/Makefile.in index 0360255b..2e07307a 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -90,7 +90,7 @@ endif ifeq ($(OS_ARCH), HP-UX) ifeq ($(USE_64),1) - XLDOPTS += +DA2.0W + XLDOPTS += +DD64 endif endif @@ -119,8 +119,10 @@ endif OUTOPTION = -o # end of the line ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET))) +ifndef NS_USE_GCC OUTOPTION = /Fe endif +endif # Redefine MAKE_OBJDIR for just this directory define MAKE_OBJDIR @@ -135,7 +137,7 @@ $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) ifeq ($(MOZ_OS2_TOOLS),VACPP) $(LD) $(EXEFLAGS) $< else - $(CC) $(XCFLAGS) $< $(XLDOPTS) $(OUTOPTION)$@ + $(CC) $(XCFLAGS) $< $(LDFLAGS) $(XLDOPTS) $(OUTOPTION)$@ endif real_install:: nspr.m4 diff --git a/config/NCR.mk b/config/NCR.mk deleted file mode 100644 index 18e175f9..00000000 --- a/config/NCR.mk +++ /dev/null @@ -1,97 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for NCR SVR4 MP-RAS -# - -include $(MOD_DEPTH)/config/UNIX.mk -### -NS_USE_NATIVE = 1 - -# NS_USE_GCC = 1 - -export PATH:=$(PATH):/opt/ncc/bin -### - -RANLIB = true -GCC_FLAGS_EXTRA = -pipe - -DEFINES += -DSVR4 -DSYSV -DHAVE_STRERROR -DNCR -D_PR_LOCAL_THREADS_ONLY - -ifeq (,$(filter-out 2.03,$(OS_RELEASE))) -DEFINES += -D_PR_STAT_HAS_ST_ATIM -else -DEFINES += -D_PR_STAT_HAS_ST_ATIM_UNION -endif - -ifdef NS_USE_NATIVE -CC = cc -CCC = ncc -OS_CFLAGS = -Hnocopyr -#OS_LIBS = -L/opt/ncc/lib -else -#OS_LIBS = -endif - -CCC = g++ - -#OS_LIBS += -lsocket -lnsl -ldl -lc - -MKSHLIB = $(LD) $(DSO_LDOPTS) -#DSO_LDOPTS = -G -z defs -DSO_LDOPTS = -G - -CPU_ARCH = x86 -ARCH = ncr - -NOSUCHFILE = /no-such-file - -# now take care of default GCC (rus@5/5/97) - -ifdef NS_USE_GCC -# if gcc-settings are redefined already - don't touch it -# -ifeq (,$(findstring gcc, $(CC))) -CC = gcc -CCC = g++ -CXX = g++ -COMPILER_TAG = _gcc -# always use -fPIC - some makefiles are still broken and don't distinguish -# situation when they build shared and static libraries -CFLAGS += -fPIC -Wall $(GCC_FLAGS_EXTRA) -#OS_LIBS += -L/usr/local/lib -lstdc++ -lg++ -lgcc -endif -endif -### - diff --git a/config/NEC.mk b/config/NEC.mk deleted file mode 100644 index d9f65a65..00000000 --- a/config/NEC.mk +++ /dev/null @@ -1,61 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for NEC Mips SYSV -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CPU_ARCH = mips - -ifdef NS_USE_GCC -CC = gcc -CCC = g++ -else -CC = $(NSDEPTH)/build/hcc cc -Xa -KGnum=0 -KOlimit=4000 -CCC = g++ -endif - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -RANLIB = /bin/true - -DEFINES += -D_PR_LOCAL_THREADS_ONLY -OS_CFLAGS = $(ODD_CFLAGS) -DSVR4 -D__SVR4 -DNEC -Dnec_ews -DHAVE_STRERROR -OS_LIBS = -lsocket -lnsl -ldl $(LDOPTIONS) -LDOPTIONS = -lc -L/usr/ucblib -lucb - -NOSUCHFILE = /no-such-file - -DSO_LDOPTS = -G diff --git a/config/NEWS-OS.mk b/config/NEWS-OS.mk deleted file mode 100644 index cf3b6a82..00000000 --- a/config/NEWS-OS.mk +++ /dev/null @@ -1,74 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -###################################################################### -# Config stuff for Sony NEWS-OS -###################################################################### - -###################################################################### -# Version-independent -###################################################################### - -include $(MOD_DEPTH)/config/UNIX.mk - -ARCH := sony -CPU_ARCH := mips - -CC = cc -CCC = CC -RANLIB = /bin/true - -OS_INCLUDES = -I/usr/include -G++INCLUDES = -#OS_LIBS = -lsocket -lnsl -lgen -lresolv - -PLATFORM_FLAGS = -Xa -fullwarn -DSONY -PORT_FLAGS = -DSYSV -DSVR4 -D__svr4 -D__svr4__ -D_PR_LOCAL_THREADS_ONLY -DHAVE_SVID_GETTOD - -OS_CFLAGS = $(PLATFORM_FLAGS) $(PORT_FLAGS) - -###################################################################### -# Version-specific stuff -###################################################################### - -###################################################################### -# Overrides for defaults in config.mk (or wherever) -###################################################################### - -###################################################################### -# Other -###################################################################### - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -DSO_LDOPTS = -G diff --git a/config/NEXTSTEP.mk b/config/NEXTSTEP.mk deleted file mode 100644 index 01b07825..00000000 --- a/config/NEXTSTEP.mk +++ /dev/null @@ -1,68 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for NEXTSTEP -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = cc -CCC = cc++ - -RANLIB = ranlib - -OS_REL_CFLAGS = -D$(shell uname -p) -CPU_ARCH := $(shell uname -p) - -# "Commons" are tentative definitions in a global scope, like this: -# int x; -# The meaning of a common is ambiguous. It may be a true definition: -# int x = 0; -# or it may be a declaration of a symbol defined in another file: -# extern int x; -# Use the -fno-common option to force all commons to become true -# definitions so that the linker can catch multiply-defined symbols. -# Also, common symbols are not allowed with Rhapsody dynamic libraries. - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wall -fno-common -pipe -DNEXTSTEP -DHAVE_STRERROR -DHAVE_BSD_FLOCK -D_POSIX_SOURCE -traditional-cpp -posix - -DEFINES += -D_PR_LOCAL_THREADS_ONLY - -ARCH = $(CPU_ARCH) - -# May override this with -bundle to create a loadable module. -#DSO_LDOPTS = -dynamiclib - -#MKSHLIB = $(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -DLL_SUFFIX = dylib diff --git a/config/NTO.mk b/config/NTO.mk deleted file mode 100644 index 7ccaad46..00000000 --- a/config/NTO.mk +++ /dev/null @@ -1,90 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1999-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -###################################################################### -# Config stuff for Neutrino -###################################################################### - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -CLASSIC_NSPR = 1 -endif -endif - -# -# The default implementation strategy for Linux is pthreads. -# -ifeq ($(CLASSIC_NSPR),1) -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -DEFINES += -D_REENTRANT -endif - - -AR = qcc -Vgcc_ntox86 -M -a $@ -CC = qcc -Vgcc_ntox86 -LD = $(CC) -CCC = $(CC) - -# Old Flags -DNO_REGEX -DSTRINGS_ALIGNED - -OS_CFLAGS = -Wc,-Wall -Wc,-Wno-parentheses -DNTO \ - -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared - -COMPILER_TAG = _qcc -MKSHLIB = qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M - -RANLIB = ranlib -G++INCLUDES = -OS_LIBS = -EXTRA_LIBS = -lsocket - -ifdef BUILD_OPT -OPTIMIZER = -O1 -else -OPTIMIZER = -O1 -gstabs -endif - -NOSUCHFILE = /no-such-file - -GARBAGE += *.map - diff --git a/config/NetBSD.mk b/config/NetBSD.mk deleted file mode 100644 index 5b95655d..00000000 --- a/config/NetBSD.mk +++ /dev/null @@ -1,89 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for NetBSD -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = gcc -CCC = g++ -RANLIB = ranlib - -ifndef OBJECT_FMT -OBJECT_FMT := $(shell if echo __ELF__ | $${CC:-cc} -E - | grep -q __ELF__ ; then echo a.out ; else echo ELF ; fi) -endif - -OS_REL_CFLAGS = -ifeq (86,$(findstring 86,$(OS_TEST))) -CPU_ARCH = x86 -else -CPU_ARCH = $(OS_TEST) -endif - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe -DNETBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK - -ifeq ($(USE_PTHREADS),1) -OS_LIBS = -lc_r -# XXX probably should define _THREAD_SAFE too. -else -OS_LIBS = -lc -DEFINES += -D_PR_LOCAL_THREADS_ONLY -endif - -ARCH = netbsd - -ifeq ($(OBJECT_FMT),ELF) -DLL_SUFFIX = so -else -DLL_SUFFIX = so.1.0 -# XXX work around a bug in the a.out ld(1). -OS_LIBS = -endif - -DSO_CFLAGS = -fPIC -DPIC -DSO_LDOPTS = -shared -ifeq ($(OBJECT_FMT),ELF) -DSO_LDOPTS +=-Wl,-soname,lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX) -endif - -ifdef LIBRUNPATH -#DSO_LDOPTS += -R$(LIBRUNPATH) -DSO_LDOPTS += -Wl,-R$(LIBRUNPATH) -endif - -#MKSHLIB = $(LD) $(DSO_LDOPTS) -MKSHLIB = $(CC) $(DSO_LDOPTS) - -G++INCLUDES = -I/usr/include/g++ diff --git a/config/OS2.mk b/config/OS2.mk deleted file mode 100644 index 43be1fee..00000000 --- a/config/OS2.mk +++ /dev/null @@ -1,171 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Configuration common to all (supported) versions of OS/2 -# -# OS_CFLAGS is the command line options for the compiler when -# building the .DLL object files. -# OS_EXE_CFLAGS is the command line options for the compiler -# when building the .EXE object files; this is for the test -# programs. -# the macro OS_CFLAGS is set to OS_EXE_CFLAGS inside of the -# makefile for the pr/tests directory. ... Hack. - -# Specify toolset. Default to EMX. -ifeq ($(MOZ_OS2_TOOLS),VACPP) -XP_OS2_VACPP = 1 -else -ifeq ($(MOZ_OS2_TOOLS),PGCC) -XP_OS2_EMX = 1 -else -MOZ_OS2_TOOLS = EMX -XP_OS2_EMX = 1 -endif -endif - -ifeq ($(XP_OS2_EMX),1) -MOZ_EMXTAG = $(subst .,,$(MOZ_OS2_EMX_OBJECTFORMAT)) -endif - -# -# On OS/2 we proudly support gbash... -# -SHELL := GBASH.EXE - -CC = icc -q -DXP_OS2 -N10 -CCC = icc -q -DXP_OS2 -DOS2=4 -N10 -LINK = -ilink -AR = -ilib /noignorecase /nologo /Out:$(subst /,\\,$@) -RANLIB = @echo RANLIB -BSDECHO = @echo BSDECHO -STRIP = @echo STRIP -NSINSTALL = nsinstall -INSTALL = $(NSINSTALL) -MAKE_OBJDIR = if test ! -d $(OBJDIR); then mkdir $(OBJDIR); fi -IMPLIB = implib -nologo -noignorecase -FILTER = cppfilt -b -p -q -RC = rc.exe - -GARBAGE = - -XP_DEFINE = -DXP_PC -LIB_SUFFIX = lib -DLL_SUFFIX = dll -OBJ_SUFFIX = obj - -OS_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge- -Mp -OS_EXE_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -Mp -AR_EXTRA_ARGS = - -ifdef BUILD_OPT -OPTIMIZER = -O+ -Oi -DEFINES = -UDEBUG -U_DEBUG -DNDEBUG -DLLFLAGS = -DLL -OUT:$@ -MAP:$(@:.dll=.map) -EXEFLAGS = -PMTYPE:VIO -OUT:$@ -MAP:$(@:.exe=.map) -nologo -NOE -OBJDIR_TAG = _OPT -else -OPTIMIZER = -Ti+ -DE -DEFINES = -DDEBUG -D_DEBUG -DDEBUGPRINTS -DLLFLAGS = -DEBUG -DLL -OUT:$@ -MAP:$(@:.dll=.map) -EXEFLAGS = -DEBUG -PMTYPE:VIO -OUT:$@ -MAP:$(@:.exe=.map) -nologo -NOE -OBJDIR_TAG = _DBG -LDFLAGS = -DEBUG -endif - -DEFINES += -DOS2=4 -DEFINES += -D_X86_ -DEFINES += -D_PR_GLOBAL_THREADS_ONLY -DBSD_SELECT - -# Name of the binary code directories -ifdef MOZ_LITE -OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ -else -OBJDIR_NAME = $(OS_CONFIG)_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ -endif - -OS_DLLFLAGS = -nologo -DLL -FREE -NOE - -ifdef XP_OS2_VACPP - -OS_LIBS = so32dll.lib tcp32dll.lib - -DEFINES += -DXP_OS2_VACPP -DTCPV40HDRS - -else -CC = gcc -CCC = gcc -LINK = gcc -RC = rc.exe -FILTER = emxexp -IMPLIB = emximp -o - -# Determine which object format to use. Two choices: -# a.out and omf. We default to omf. -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT), A.OUT) -AR = ar -q $@ -LIB_SUFFIX = a -else -OMF_FLAG = -Zomf -AR = emxomfar r $@ -LIB_SUFFIX = lib -endif - -OS_LIBS = -lsocket -lemxio - -DEFINES += -DXP_OS2 -DXP_OS2_EMX -DOS2EMX_PLAIN_CHAR - -OS_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd -OS_EXE_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd -OS_DLLFLAGS = $(OMF_FLAG) -Zmt -Zdll -Zcrtdll -o $@ -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) -EXEFLAGS += -Zlinker /DE -endif - -ifdef BUILD_OPT -OPTIMIZER = -O3 -DLLFLAGS = -EXEFLAGS = -Zmtd -o $@ -else -OPTIMIZER = -g #-s -DLLFLAGS = -g #-s -EXEFLAGS = -g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@ # -s -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) -EXEFLAGS += -Zlinker /DE -endif -endif - -AR_EXTRA_ARGS = -endif - - diff --git a/config/OSF1.mk b/config/OSF1.mk deleted file mode 100644 index 1c05ba18..00000000 --- a/config/OSF1.mk +++ /dev/null @@ -1,122 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for DEC OSF/1 -# - -# -# The Bourne shell (sh) on OSF1 doesn't handle "set -e" correctly, -# which we use to stop LOOP_OVER_DIRS submakes as soon as any -# submake fails. So we use the Korn shell instead. -# -SHELL := /usr/bin/ksh - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -CLASSIC_NSPR = 1 -endif -endif - -# -# Prior to OSF1 V4.0, classic nspr is the default (and only) implementation -# strategy. -# -# On OSF1 V4.0, pthreads is the default implementation strategy. -# Classic nspr is also available. -# -ifeq (,$(filter-out V2.0 V3.2,$(OS_RELEASE))) -CLASSIC_NSPR = 1 -endif - -ifeq ($(CLASSIC_NSPR), 1) - IMPL_STRATEGY = _EMU - DEFINES += -D_PR_LOCAL_THREADS_ONLY -else - USE_PTHREADS = 1 - IMPL_STRATEGY = _PTH -endif - -CC = cc $(NON_LD_FLAGS) -std1 -ifneq ($(OS_RELEASE),V2.0) -CC += -readonly_strings -endif -# The C++ compiler cxx has -readonly_strings on by default. -CCC = cxx - -RANLIB = /bin/true - -CPU_ARCH = alpha - -ifdef BUILD_OPT -OPTIMIZER += -Olimit 4000 -endif - -NON_LD_FLAGS = -ieee_with_inexact - -OS_CFLAGS = -DOSF1 -D_REENTRANT - -ifneq (,$(filter-out V2.0 V3.2,$(OS_RELEASE))) -OS_CFLAGS += -DOSF1_HAVE_MACHINE_BUILTINS_H -endif - -ifneq (,$(filter-out V2.0 V3.2,$(OS_RELEASE))) -OS_CFLAGS += -DHAVE_FCNTL_FILE_LOCKING -endif - -ifeq (,$(filter-out V2.0 V3.2,$(OS_RELEASE))) -OS_CFLAGS += -DHAVE_INT_LOCALTIME_R -else -OS_CFLAGS += -DHAVE_POINTER_LOCALTIME_R -endif - -ifeq (,$(filter-out V4.0%,$(OS_RELEASE))) -OS_CFLAGS += -DOSF1V4_MAP_PRIVATE_BUG -endif - -ifeq ($(USE_PTHREADS),1) -OS_CFLAGS += -pthread -ifneq (,$(filter-out V2.0 V3.2,$(OS_RELEASE))) -OS_CFLAGS += -D_PR_HAVE_THREADSAFE_GETHOST -endif -endif - -# The command to build a shared library on OSF1. -MKSHLIB = ld -shared -all -expect_unresolved "*" -soname $(notdir $@) -DSO_LDOPTS = -shared diff --git a/config/OpenBSD.mk b/config/OpenBSD.mk deleted file mode 100644 index e303b908..00000000 --- a/config/OpenBSD.mk +++ /dev/null @@ -1,78 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for OpenBSD -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = gcc -CCC = g++ -RANLIB = ranlib - -OS_REL_CFLAGS = -ifeq (86,$(findstring 86,$(OS_TEST))) -CPU_ARCH = x86 -else -CPU_ARCH = $(OS_TEST) -endif - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DOPENBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK - -ifeq ($(USE_PTHREADS),1) -THREAD_FLAG += -pthread -# XXX probably should define _THREAD_SAFE too. -else -DEFINES += -D_PR_LOCAL_THREADS_ONLY -endif - -ARCH = openbsd - -DLL_SUFFIX = so.1.0 - -DSO_CFLAGS = -fPIC -DSO_LDOPTS = -Bshareable -ifeq ($(OS_TEST),alpha) -DSO_LDOPTS = -shared -endif -ifeq ($(OS_TEST),mips) -DSO_LDOPTS = -shared -endif -ifeq ($(OS_TEST),pmax) -DSO_LDOPTS = -shared -endif - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -G++INCLUDES = -I/usr/include/g++ diff --git a/config/OpenVMS.mk b/config/OpenVMS.mk deleted file mode 100644 index 98a0aaa4..00000000 --- a/config/OpenVMS.mk +++ /dev/null @@ -1,67 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for Compaq OpenVMS -# - -include $(MOD_DEPTH)/config/UNIX.mk - -ifdef INTERNAL_TOOLS -CC = c89 -CCC = cxx -OPTIMIZER = -O -else -CC = ccc -CCC = ccc -endif - -RANLIB = /bin/true - -CPU_ARCH_TAG = _$(CPU_ARCH) - -OS_CFLAGS = -DVMS -DVMS_AS_IS -Wc,names=\(short,as\) \ - -DGENERIC_PTHREAD_REDEFINES -D_SOCKADDR_LEN -OS_CXXFLAGS = -DVMS -DVMS_AS_IS -Wc,names=\(short,as\) \ - -DGENERIC_PTHREAD_REDEFINES -D_SOCKADDR_LEN - -# -# XCFLAGS are the only CFLAGS that are used during a link operation. Defining -# OPTIMIZER in XCFLAGS means that each compilation line gets OPTIMIZER -# included twice, but at least we get OPTIMIZER included in the link -# operations; and OpenVMS needs it! -# -XCFLAGS += $(OPTIMIZER) - -# The command to build a shared library in POSIX on OpenVMS. -MKSHLIB = vmsld $(OPTIMIZER) diff --git a/config/QNX.mk b/config/QNX.mk deleted file mode 100644 index a5e9e6bd..00000000 --- a/config/QNX.mk +++ /dev/null @@ -1,57 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -###################################################################### -# Config stuff for QNX. -###################################################################### - -include $(MOD_DEPTH)/config/UNIX.mk - -CPU_ARCH = x86 - -ifndef NS_USE_GCC -CC = cc -CCC = cc -endif -RANLIB = true - -G++INCLUDES = -OS_LIBS = -XLDOPTS = -lunix - -OS_CFLAGS = -DQNX -Di386 -D_PR_LOCAL_THREADS_ONLY -D_PR_NEED_H_ERRNO -#IMPL_STRATEGY = _EMU - -NOSUCHFILE = /no-such-file - -GARBAGE = $(wildcard *.err) diff --git a/config/Rhapsody.mk b/config/Rhapsody.mk deleted file mode 100644 index db27247f..00000000 --- a/config/Rhapsody.mk +++ /dev/null @@ -1,83 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for Rhapsody -# - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# The default implementation strategy for Rhapsody is pthreads. -# -ifeq ($(CLASSIC_NSPR),1) -IMPL_STRATEGY = _EMU -DEFINES += -D_PR_LOCAL_THREADS_ONLY -else -USE_PTHREADS = 1 -IMPL_STRATEGY = _PTH -endif - -CC = cc -CCC = c++ -RANLIB = ranlib - -ifeq (86,$(findstring 86,$(OS_TEST))) -OS_REL_CFLAGS = -mno-486 -Di386 -CPU_ARCH = i386 -else -OS_REL_CFLAGS = -Dppc -CPU_ARCH = ppc -endif - -# "Commons" are tentative definitions in a global scope, like this: -# int x; -# The meaning of a common is ambiguous. It may be a true definition: -# int x = 0; -# or it may be a declaration of a symbol defined in another file: -# extern int x; -# Use the -fno-common option to force all commons to become true -# definitions so that the linker can catch multiply-defined symbols. -# Also, common symbols are not allowed with Rhapsody dynamic libraries. - -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wmost -fno-common -pipe -DRHAPSODY -DHAVE_STRERROR -DHAVE_BSD_FLOCK - -ARCH = rhapsody - -# May override this with -bundle to create a loadable module. -DSO_LDOPTS = -dynamiclib -compatibility_version 1 -current_version 1 -all_load - -MKSHLIB = $(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS) -DLL_SUFFIX = dylib - -G++INCLUDES = -I/usr/include/g++ diff --git a/config/SCOOS.mk b/config/SCOOS.mk deleted file mode 100644 index 6e19d07a..00000000 --- a/config/SCOOS.mk +++ /dev/null @@ -1,63 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SCO OpenServer for x86. -# SCO OpenServer 5, based on SVR3.2, is intended for small to -# medium customers. -# - -include $(MOD_DEPTH)/config/UNIX.mk - -CC = cc -b elf -KPIC -CCC = $(NSDEPTH)/build/hcpp CC +.cpp +w -RANLIB = /bin/true - -DEFINES += -D_PR_LOCAL_THREADS_ONLY -# -# -DSCO - Changes to Netscape source (consistent with AIX, LINUX, etc..) -# -Dsco - Needed for /usr/include/X11/* -# -OS_CFLAGS = -DSYSV -D_SVID3 -DHAVE_STRERROR -D_PR_NEED_H_ERRNO -DSCO -Dsco -#OS_LIBS = -lpmapi -lsocket -lc - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -CPU_ARCH = x86 -ARCH = sco - -NOSUCHFILE = /no-such-file - -BSDECHO = /bin/echo - -DSO_LDOPTS = -b elf -G diff --git a/config/SINIX.mk b/config/SINIX.mk deleted file mode 100644 index e4ce6e41..00000000 --- a/config/SINIX.mk +++ /dev/null @@ -1,108 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SNI SINIX (aka ReliantUNIX) -# - -include $(MOD_DEPTH)/config/UNIX.mk - -ifeq (86,$(findstring 86,$(OS_TEST))) -CPU_ARCH = x86 -else -CPU_ARCH = mips -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -# use gcc -tf- -NS_USE_GCC = 1 - -ifeq ($(NS_USE_GCC),1) -## gcc-2.7.2 homebrewn -CC = gcc -COMPILER_TAG = _gcc -CCC = g++ -AS = $(CC) -x assembler-with-cpp -ifeq ($(CPU_ARCH),mips) -LD = gld -endif -ODD_CFLAGS = -Wall -Wno-format -ifeq ($(CPU_ARCH),mips) -# The -pipe flag only seems to work on the mips version of SINIX. -ODD_CFLAGS += -pipe -endif -ifdef BUILD_OPT -OPTIMIZER = -O -#OPTIMIZER = -O6 -endif -MKSHLIB = $(LD) -G -z defs -h $(@:$(OBJDIR)/%.so=%.so) -#DSO_LDOPTS = -G -Xlinker -Blargedynsym -else -## native compiler (CDS++ 1.0) -CC = /usr/bin/cc -CCC = /usr/bin/CC -AS = /usr/bin/cc -#ODD_CFLAGS = -fullwarn -xansi -ODD_CFLAGS = -ifdef BUILD_OPT -#OPTIMIZER = -Olimit 4000 -OPTIMIZER = -O -F Olimit,4000 -endif -MKSHLIB = $(LD) -G -z defs -h $(@:$(OBJDIR)/%.so=%.so) -#DSO_LDOPTS = -G -W l,-Blargedynsym -endif - -ifeq ($(CPU_ARCH),x86) -DEFINES += -Di386 -endif - -ODD_CFLAGS += -DSVR4 -DSNI -DRELIANTUNIX -Dsinix -DHAVE_SVID_GETTOD - -# On SINIX 5.43, need to define IP_MULTICAST in order to get the -# IP multicast macro and struct definitions in netinet/in.h. -# (SINIX 5.42 does not have IP multicast at all.) -ifeq ($(OS_RELEASE),5.43) -ODD_CFLAGS += -DIP_MULTICAST -endif - -RANLIB = /bin/true - -# For purify -NOMD_OS_CFLAGS = $(ODD_CFLAGS) - -# we do not have -MDupdate ... -OS_CFLAGS = $(NOMD_OS_CFLAGS) -OS_LIBS = -lsocket -lnsl -lresolv -ldl -lc -NOSUCHFILE = /no-such-file - -DEFINES += -D_PR_LOCAL_THREADS_ONLY diff --git a/config/SunOS.mk b/config/SunOS.mk deleted file mode 100644 index 1a945d2e..00000000 --- a/config/SunOS.mk +++ /dev/null @@ -1,42 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SunOS. -# 4 and 5 are vastly different, so we use 2 different files. -# -ifeq ($(basename $(OS_RELEASE)),4.1) -include $(MOD_DEPTH)/config/SunOS4.mk -else -include $(MOD_DEPTH)/config/SunOS5.mk -endif diff --git a/config/SunOS4.mk b/config/SunOS4.mk deleted file mode 100644 index 41d9dbc5..00000000 --- a/config/SunOS4.mk +++ /dev/null @@ -1,68 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SunOS4.1 -# - -include $(MOD_DEPTH)/config/UNIX.mk - -# SunOS 4 _requires_ that shared libs have a version number. -# XXX FIXME: Version number should use NSPR_VERSION_NUMBER? -DLL_SUFFIX = so.1.0 - -CC = gcc -CCC = g++ -COMPILER_TAG = _gcc - -RANLIB = ranlib - -CPU_ARCH = sparc - -DEFINES += -D_PR_LOCAL_THREADS_ONLY -# Purify doesn't like -MDupdate -NOMD_OS_CFLAGS = -Wall -Wno-format -DSUNOS4 - -ifdef NO_MDUPDATE -OS_CFLAGS = $(DSO_CFLAGS) $(NOMD_OS_CFLAGS) -else -OS_CFLAGS = $(DSO_CFLAGS) $(NOMD_OS_CFLAGS) -MDupdate $(DEPENDENCIES) -endif - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -NOSUCHFILE = /no-such-file - -DSO_LDOPTS = -# -fPIC generates position-independent code for use in a shared library. -DSO_CFLAGS = -fPIC diff --git a/config/SunOS5.mk b/config/SunOS5.mk deleted file mode 100644 index 17602834..00000000 --- a/config/SunOS5.mk +++ /dev/null @@ -1,196 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SunOS 5.x on sparc and x86 -# - -include $(MOD_DEPTH)/config/UNIX.mk - -# -# XXX -# Temporary define for the Client; to be removed when binary release is used -# -ifdef MOZILLA_CLIENT -ifneq ($(USE_PTHREADS),1) -LOCAL_THREADS_ONLY = 1 -endif -ifndef NS_USE_NATIVE -NS_USE_GCC = 1 -endif -endif - -# -# The default implementation strategy on Solaris is pthreads. -# Global threads only and local threads only are also available. -# -ifeq ($(GLOBAL_THREADS_ONLY),1) - IMPL_STRATEGY = _NATIVE - DEFINES += -D_PR_GLOBAL_THREADS_ONLY -else - ifeq ($(LOCAL_THREADS_ONLY),1) - IMPL_STRATEGY = _EMU - DEFINES += -D_PR_LOCAL_THREADS_ONLY - else - USE_PTHREADS = 1 - IMPL_STRATEGY = _PTH - endif -endif - -ifdef NS_USE_GCC -CC = gcc -Wall -CCC = g++ -Wall -ASFLAGS += -Wa,-P -COMPILER_TAG = _gcc -ifdef NO_MDUPDATE -OS_CFLAGS = $(NOMD_OS_CFLAGS) -else -OS_CFLAGS = $(NOMD_OS_CFLAGS) -MDupdate $(DEPENDENCIES) -endif -else -CC = cc -xstrconst -CCC = CC -Qoption cg -xstrconst -ASFLAGS += -Wa,-P -OS_CFLAGS = $(NOMD_OS_CFLAGS) -# -# If we are building for a release, we want to put all symbol -# tables in the debug executable or share library instead of -# the .o files, so that our clients can run dbx on the debug -# library without having the .o files around. -# -ifdef BUILD_NUMBER -ifndef BUILD_OPT -OS_CFLAGS += -xs -endif -endif -endif - -ifeq ($(USE_64),1) -ifndef INTERNAL_TOOLS -ifndef NS_USE_GCC -CC += -xarch=v9 -CCC += -xarch=v9 -endif -endif -COMPILER_TAG = _64 -else -COMPILER_TAG = _32 -endif - -RANLIB = echo - -OS_DEFINES = -DSVR4 -DSYSV -D__svr4 -D__svr4__ -DSOLARIS -DHAVE_FCNTL_FILE_LOCKING - -ifeq ($(OS_TEST),i86pc) -CPU_ARCH = x86 -OS_DEFINES += -Di386 -# The default debug format, DWARF (-g), is not supported by gcc -# on i386-ANY-sysv4/solaris, but the stabs format is. It is -# assumed that the Solaris assembler /usr/ccs/bin/as is used. -# If your gcc uses GNU as, you do not need the -Wa,-s option. -ifndef BUILD_OPT -ifdef NS_USE_GCC -OPTIMIZER = -Wa,-s -gstabs -endif -endif -else -CPU_ARCH = sparc -endif -CPU_ARCH_TAG = _$(CPU_ARCH) - -ifeq (5.5,$(findstring 5.5,$(OS_RELEASE))) -OS_DEFINES += -DSOLARIS2_5 -else -ifeq (,$(filter-out 5.3 5.4,$(OS_RELEASE))) -OS_DEFINES += -D_PR_NO_LARGE_FILES -else -OS_DEFINES += -D_PR_HAVE_OFF64_T -# The lfcompile64(5) man page on Solaris 2.6 says: -# For applications that do not wish to conform to the POSIX or -# X/Open specifications, the 64-bit transitional interfaces -# are available by default. No compile-time flags need to be -# set. -# But gcc 2.7.2.x fails to define _LARGEFILE64_SOURCE by default. -# The native compiler, gcc 2.8.x, and egcs don't have this problem. -ifdef NS_USE_GCC -OS_DEFINES += -D_LARGEFILE64_SOURCE -endif -endif -endif - -ifneq ($(LOCAL_THREADS_ONLY),1) -OS_DEFINES += -D_REENTRANT -DHAVE_POINTER_LOCALTIME_R -endif - -# Purify doesn't like -MDupdate -NOMD_OS_CFLAGS = $(DSO_CFLAGS) $(OS_DEFINES) $(SOL_CFLAGS) - -MKSHLIB = $(LD) $(DSO_LDOPTS) - -# ld options: -# -G: produce a shared object -# -z defs: no unresolved symbols allowed -DSO_LDOPTS = -G -h $(notdir $@) - -# -KPIC generates position independent code for use in shared libraries. -# (Similarly for -fPIC in case of gcc.) -ifdef NS_USE_GCC -DSO_CFLAGS = -fPIC -else -DSO_CFLAGS = -KPIC -endif - -NOSUCHFILE = /no-such-file - -# -# Library of atomic functions for UltraSparc systems -# -# The nspr makefiles build ULTRASPARC_LIBRARY (which contains assembly language -# implementation of the nspr atomic functions for UltraSparc systems) in addition -# to libnspr.so. (The actual name of the library is -# lib$(ULTRASPARC_LIBRARY)$(MOD_VERSION).so -# -# The actual name of the filter-library, recorded in libnspr.so, is set to the -# value of $(ULTRASPARC_FILTER_LIBRARY). -# For an application to use the assembly-language implementation, a link should be -# made so that opening ULTRASPARC_FILTER_LIBRARY results in opening -# ULTRASPARC_LIBRARY. This indirection requires the user to explicitly set up -# library for use on UltraSparc systems, thereby helping to avoid using it by -# accident on non-UltraSparc systems. -# The directory containing the ultrasparc libraries should be in LD_LIBRARY_PATH. -# -ifeq ($(OS_TEST),sun4u) -ULTRASPARC_LIBRARY = ultrasparc -ULTRASPARC_FILTER_LIBRARY = libatomic.so -DSO_LDOPTS += -f $(ULTRASPARC_FILTER_LIBRARY) -endif diff --git a/config/UNIX.mk b/config/UNIX.mk deleted file mode 100644 index bdb72b5b..00000000 --- a/config/UNIX.mk +++ /dev/null @@ -1,92 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -PR_UNIXOS = 1 -XP_DEFINE = -DXP_UNIX -OBJ_SUFFIX = o -LIB_SUFFIX = a -DLL_SUFFIX = so -AR = ar cr $@ -STRIP = true - -ifdef BUILD_OPT -OPTIMIZER = -O -DEFINES = -UDEBUG -DNDEBUG -OBJDIR_TAG = _OPT -else -OPTIMIZER = -g -DEFINES = -DDEBUG -UNDEBUG -DDEBUG_$(shell whoami) -OBJDIR_TAG = _DBG -endif - -# Name of the binary code directories -ifdef MOZILLA_CLIENT -OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(OBJDIR_TAG).OBJ -else -OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(COMPILER_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ -endif - -MKDEPEND_DIR = $(DEPTH)/config/mkdepend -MKDEPEND = $(MKDEPEND_DIR)/$(OBJDIR_NAME)/mkdepend -MKDEPENDENCIES = $(OBJDIR)/depend.mk - -#################################################################### -# -# One can define the makefile variable NSDISTMODE to control -# how files are published to the 'dist' directory. If not -# defined, the default is "install using relative symbolic -# links". The two possible values are "copy", which copies files -# but preserves source mtime, and "absolute_symlink", which -# installs using absolute symbolic links. The "absolute_symlink" -# option requires NFSPWD. -# -#################################################################### - -NSINSTALL = $(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall - -ifeq ($(NSDISTMODE),copy) -# copy files, but preserve source mtime -INSTALL = $(NSINSTALL) -t -else -ifeq ($(NSDISTMODE),absolute_symlink) -# install using absolute symbolic links -INSTALL = $(NSINSTALL) -L `$(NFSPWD)` -else -# install using relative symbolic links -INSTALL = $(NSINSTALL) -R -endif -endif - -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); else true; fi -endef diff --git a/config/UNIXWARE.mk b/config/UNIXWARE.mk deleted file mode 100644 index 0419b1b8..00000000 --- a/config/UNIXWARE.mk +++ /dev/null @@ -1,71 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for SCO UnixWare -# UnixWare is intended for high-end enterprise customers. -# UnixWare 2.1 and 2.1.1 are based on SVR4. (2.1.2 is a maintenance -# release.) -# UnixWare 7 (codename Gemini) is based on what SCO calls SVR5. -# The somewhat odd version number 7 was chosen to suggest that -# UnixWare 2 + OpenServer 5 = UnixWare 7 -# - -include $(MOD_DEPTH)/config/UNIX.mk - -ifeq (,$(filter-out 2.1,$(OS_RELEASE))) -CC = $(NSDEPTH)/build/hcc cc -CCC = $(NSDEPTH)/build/hcpp CC -else -CC = cc -CCC = CC -endif - -RANLIB = true - -DEFINES += -D_PR_LOCAL_THREADS_ONLY -OS_CFLAGS = -DSVR4 -DSYSV -DUNIXWARE - -ifeq (,$(filter-out 2.1,$(OS_RELEASE))) -OS_CFLAGS += -D_PR_NO_LARGE_FILES -else -OS_CFLAGS += -D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T -D_PR_HAVE_SOCKADDR_LEN -endif - -MKSHLIB = $(LD) $(DSO_LDOPTS) -DSO_LDOPTS = -G - -CPU_ARCH = x86 -ARCH = sco - -NOSUCHFILE = /no-such-file diff --git a/config/WIN32.mk b/config/WIN32.mk deleted file mode 100644 index f002c074..00000000 --- a/config/WIN32.mk +++ /dev/null @@ -1,176 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Configuration common to all versions of Windows NT -# and Windows 95. -# - -# -# Client build: make sure we use the shmsdos.exe under $(MOZ_TOOLS). -# $(MOZ_TOOLS_FLIPPED) is $(MOZ_TOOLS) with all the backslashes -# flipped, so that gmake won't interpret them as escape characters. -# -ifdef PR_CLIENT_BUILD_WINDOWS -SHELL := $(MOZ_TOOLS_FLIPPED)/bin/shmsdos.exe -endif - -CC = cl -CCC = cl -LINK = link -AR = lib -NOLOGO -OUT:"$@" -RANLIB = echo -BSDECHO = echo -STRIP = echo -NSINSTALL = nsinstall -INSTALL = $(NSINSTALL) -define MAKE_OBJDIR -if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi -endef -RC = rc.exe - -GARBAGE = $(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb - -XP_DEFINE = -DXP_PC -OBJ_SUFFIX = obj -LIB_SUFFIX = lib -DLL_SUFFIX = dll - -OS_CFLAGS = -W3 -nologo -GF -Gy - -ifdef BUILD_OPT -OS_CFLAGS += -MD -OPTIMIZER = -O2 -DEFINES = -UDEBUG -U_DEBUG -DNDEBUG -DLLFLAGS = -OUT:"$@" -OBJDIR_TAG = _OPT - -# Add symbolic information for use by a profiler -ifdef MOZ_PROFILE -OPTIMIZER += -Z7 -DLLFLAGS += -DEBUG -DEBUGTYPE:CV -LDFLAGS += -DEBUG -DEBUGTYPE:CV -endif - -else -# -# Define USE_DEBUG_RTL if you want to use the debug runtime library -# (RTL) in the debug build -# -ifdef USE_DEBUG_RTL -OS_CFLAGS += -MDd -else -OS_CFLAGS += -MD -endif -OPTIMIZER = -Od -Z7 -#OPTIMIZER = -Zi -Fd$(OBJDIR)/ -Od -DEFINES = -DDEBUG -D_DEBUG -UNDEBUG - -DLLFLAGS = -DEBUG -DEBUGTYPE:CV -OUT:"$@" -ifdef GLOWCODE -DLLFLAGS = -DEBUG -DEBUGTYPE:both -INCLUDE:_GlowCode -OUT:"$@" -endif - -OBJDIR_TAG = _DBG -LDFLAGS = -DEBUG -DEBUGTYPE:CV -# -# When PROFILE=1 is defined, set the compile and link options -# to build targets for use by the ms-win32 profiler -# -ifdef PROFILE -LDFLAGS += -PROFILE -MAP -DLLFLAGS += -PROFILE -MAP -endif -endif - -DEFINES += -DWIN32 - -# -# On Win95, we use the TlsXXX() interface by default because that -# allows us to load the NSPR DLL dynamically at run time. -# If you want to use static thread-local storage (TLS) for better -# performance, build the NSPR library with USE_STATIC_TLS=1. -# -ifeq ($(USE_STATIC_TLS),1) -DEFINES += -D_PR_USE_STATIC_TLS -endif - -# -# NSPR uses both fibers and static thread-local storage -# (i.e., __declspec(thread) variables) on NT. We need the -GT -# flag to turn off certain compiler optimizations so that fibers -# can use static TLS safely. -# -# Also, we optimize for Pentium (-G5) on NT. -# -ifeq ($(OS_TARGET),WINNT) -OS_CFLAGS += -GT -ifeq ($(CPU_ARCH),x86) -OS_CFLAGS += -G5 -endif -DEFINES += -DWINNT -else -DEFINES += -DWIN95 -D_PR_GLOBAL_THREADS_ONLY -endif - -ifeq ($(CPU_ARCH),x86) -DEFINES += -D_X86_ -else -ifeq ($(CPU_ARCH),MIPS) -DEFINES += -D_MIPS_ -else -ifeq ($(CPU_ARCH),ALPHA) -DEFINES += -D_ALPHA_=1 -else -CPU_ARCH = processor_is_undefined -endif -endif -endif - -# Name of the binary code directories - -ifeq ($(CPU_ARCH),x86) -CPU_ARCH_TAG = -else -CPU_ARCH_TAG = $(CPU_ARCH) -endif - -ifdef USE_DEBUG_RTL -OBJDIR_SUFFIX = OBJD -else -OBJDIR_SUFFIX = OBJ -endif - -OBJDIR_NAME = $(OS_CONFIG)$(CPU_ARCH_TAG)$(OBJDIR_TAG).$(OBJDIR_SUFFIX) - -OS_DLLFLAGS = -nologo -DLL -SUBSYSTEM:WINDOWS -PDB:NONE diff --git a/config/WIN95.mk b/config/WIN95.mk deleted file mode 100644 index c30d48d6..00000000 --- a/config/WIN95.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for WIN95 -# - -include $(MOD_DEPTH)/config/WIN32.mk diff --git a/config/WINNT.mk b/config/WINNT.mk deleted file mode 100644 index 781c2b5d..00000000 --- a/config/WINNT.mk +++ /dev/null @@ -1,38 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Config stuff for WINNT -# - -include $(MOD_DEPTH)/config/WIN32.mk diff --git a/config/arch.mk b/config/arch.mk deleted file mode 100644 index 7c0c07df..00000000 --- a/config/arch.mk +++ /dev/null @@ -1,286 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -####################################################################### -# Master "Core Components" macros for getting the OS architecture # -####################################################################### - -# -# Important internal static macros -# - -OS_ARCH := $(subst /,_,$(shell uname -s)) -OS_RELEASE := $(shell uname -r) -OS_TEST := $(shell uname -m) - -# -# Tweak the default OS_ARCH and OS_RELEASE macros as needed. -# -ifeq ($(OS_ARCH),AIX) -OS_RELEASE := $(shell uname -v).$(shell uname -r) -endif -ifeq ($(OS_ARCH),BSD_386) -OS_ARCH := BSD_OS -endif -ifeq ($(OS_ARCH),dgux) -OS_ARCH := DGUX -endif -ifeq ($(OS_ARCH),IRIX64) -OS_ARCH := IRIX -endif -ifeq ($(OS_ARCH),UNIX_SV) -ifneq ($(findstring NCR,$(shell grep NCR /etc/bcheckrc | head -1 )),) -OS_ARCH := NCR -else -OS_ARCH := UNIXWARE -OS_RELEASE := $(shell uname -v) -endif -endif -ifeq ($(OS_ARCH),Mac OS) -OS_ARCH := Rhapsody -endif -ifeq ($(OS_ARCH),Darwin) -OS_ARCH := Rhapsody -endif -ifeq ($(OS_ARCH),ncr) -OS_ARCH := NCR -endif -# This is the only way to correctly determine the actual OS version on NCR boxes. -ifeq ($(OS_ARCH),NCR) -OS_RELEASE := $(shell awk '{print $$3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$$/\2.\3/') -endif -ifeq ($(OS_ARCH),UNIX_System_V) -OS_ARCH := NEC -endif -ifneq (,$(findstring POSIX_for_OpenVMS,$(OS_ARCH))) -OS_ARCH := OpenVMS -CPU_ARCH := $(shell uname -Wh) -OS_RELEASE := $(shell uname -v) -endif -ifeq ($(OS_ARCH),QNX) - ifeq ($(OS_RELEASE),6.00) - OS_ARCH := NTO - OS_RELEASE := _$(OS_TEST)$(OS_RELEASE) - else - OS_RELEASE := $(shell uname -v | sed 's/^\([0-9]\)\([0-9]*\)$$/\1.\2/') - endif -endif -ifeq ($(OS_ARCH),SCO_SV) -OS_ARCH := SCOOS -OS_RELEASE := 5.0 -endif -ifeq ($(OS_ARCH),SINIX-N) -OS_ARCH := SINIX -endif -ifeq ($(OS_ARCH),SINIX-Y) -OS_ARCH := SINIX -endif -ifeq ($(OS_ARCH),SINIX-Z) -OS_ARCH := SINIX -endif -# SINIX changes name to ReliantUNIX with 5.43 -ifeq ($(OS_ARCH),ReliantUNIX-N) -OS_ARCH := SINIX -endif -ifeq ($(OS_ARCH),UnixWare) -OS_ARCH := UNIXWARE -OS_RELEASE := $(shell uname -v) -endif - -# -# Handle FreeBSD 2.2-STABLE and Linux 2.0.30-osfmach3 -# - -ifeq (,$(filter-out Linux FreeBSD,$(OS_ARCH))) -OS_RELEASE := $(shell echo "$(OS_RELEASE)" | sed 's/-.*//') -endif - -# -# Distinguish between OSF1 V4.0B and V4.0D -# - -ifeq ($(OS_ARCH)$(OS_RELEASE),OSF1V4.0) - OS_VERSION := $(shell uname -v) - ifeq ($(OS_VERSION),564) - OS_RELEASE := V4.0B - endif - ifeq ($(OS_VERSION),878) - OS_RELEASE := V4.0D - endif -endif - -# -# Handle uname variants for OS/2. -# - -ifeq ($(OS_ARCH),OS_2) - OS_ARCH := OS2 - OS_RELEASE := 4.0 -endif - -####################################################################### -# Master "Core Components" macros for getting the OS target # -####################################################################### - -# -# Note: OS_TARGET should be specified on the command line for gmake. -# When OS_TARGET=WIN95 is specified, then a Windows 95 target is built. -# The difference between the Win95 target and the WinNT target is that -# the WinNT target uses Windows NT specific features not available -# in Windows 95. The Win95 target will run on Windows NT, but (supposedly) -# at lesser performance (the Win95 target uses threads; the WinNT target -# uses fibers). -# -# When OS_TARGET=WIN16 is specified, then a Windows 3.11 (16bit) target -# is built. See: win16_3.11.mk for lots more about the Win16 target. -# -# If OS_TARGET is not specified, it defaults to $(OS_ARCH), i.e., no -# cross-compilation. -# - -# -# The following hack allows one to build on a WIN95 machine (as if -# s/he were cross-compiling on a WINNT host for a WIN95 target). -# It also accomodates for MKS's uname.exe. If you never intend -# to do development on a WIN95 machine, you don't need this hack. -# -ifeq ($(OS_ARCH),WIN95) - OS_ARCH := WINNT - OS_TARGET := WIN95 -endif -ifeq ($(OS_ARCH),Windows_95) - OS_ARCH := Windows_NT - OS_TARGET := WIN95 -endif -ifeq ($(OS_ARCH),Windows_98) - OS_ARCH := Windows_NT - OS_TARGET := WIN95 -endif -ifeq ($(OS_ARCH),CYGWIN_95-4.0) - OS_ARCH := CYGWIN_NT-4.0 - OS_TARGET := WIN95 -endif -ifeq ($(OS_ARCH),CYGWIN_98-4.10) - OS_ARCH := CYGWIN_NT-4.0 - OS_TARGET := WIN95 -endif -ifeq ($(OS_ARCH),OS2) - OS_ARCH := OS2 - OS_TARGET := OS2 -endif - -# -# On WIN32, we also define the variable CPU_ARCH. -# - -ifeq ($(OS_ARCH), WINNT) - ifneq ($(subst /,_,$(shell uname -s)),OS_2) - CPU_ARCH := $(shell uname -p) - else - CPU_ARCH := $(shell uname -m) - endif - ifeq ($(CPU_ARCH),I386) - CPU_ARCH = x86 - endif -else -# -# If uname -s returns "Windows_NT", we assume that we are using -# the uname.exe in MKS toolkit. -# -# The -r option of MKS uname only returns the major version number. -# So we need to use its -v option to get the minor version number. -# Moreover, it doesn't have the -p option, so we need to use uname -m. -# -ifeq ($(OS_ARCH), Windows_NT) - OS_ARCH = WINNT - OS_MINOR_RELEASE := $(shell uname -v) - ifeq ($(OS_MINOR_RELEASE),00) - OS_MINOR_RELEASE = 0 - endif - OS_RELEASE := $(OS_RELEASE).$(OS_MINOR_RELEASE) - CPU_ARCH := $(shell uname -m) - # - # MKS's uname -m returns "586" on a Pentium machine. - # - ifneq (,$(findstring 86,$(CPU_ARCH))) - CPU_ARCH = x86 - endif -else -# -# If uname -s returns "CYGWIN_NT-4.0", we assume that we are using -# the uname.exe in the Cygwin tools. -# -ifeq (CYGWIN_NT,$(findstring CYGWIN_NT,$(OS_ARCH))) - OS_RELEASE := $(patsubst CYGWIN_NT-%,%,$(OS_ARCH)) - OS_ARCH = WINNT - CPU_ARCH := $(shell uname -m) - # - # Cygwin's uname -m returns "i686" on a Pentium Pro machine. - # - ifneq (,$(findstring 86,$(CPU_ARCH))) - CPU_ARCH = x86 - endif -else -# -# Prior to the Beta 20 release, Cygwin was called GNU-Win32. -# If uname -s returns "CYGWIN32/NT", we assume that we are using -# the uname.exe in the GNU-Win32 tools. -# -ifeq ($(OS_ARCH), CYGWIN32_NT) - OS_ARCH = WINNT - CPU_ARCH := $(shell uname -m) - # - # GNU-Win32's uname -m returns "i686" on a Pentium Pro machine. - # - ifneq (,$(findstring 86,$(CPU_ARCH))) - CPU_ARCH = x86 - endif -endif -endif -endif -endif - -ifndef OS_TARGET - OS_TARGET := $(OS_ARCH) -endif - -ifeq ($(OS_TARGET), WIN95) - OS_RELEASE := 4.0 -endif - -ifeq ($(OS_TARGET), WIN16) - OS_RELEASE := -# OS_RELEASE := _3.11 -endif - -OS_CONFIG := $(OS_TARGET)$(OS_RELEASE) diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 3a049f60..a83ac501 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -30,7 +30,7 @@ MOD_NAME = @NSPR_MODNAME@ MOD_MAJOR_VERSION = @MOD_MAJOR_VERSION@ MOD_MINOR_VERSION = @MOD_MINOR_VERSION@ -MOD_REVISION_VERSION = @MOD_REVISION_VERSION@ +MOD_PATCH_VERSION = @MOD_PATCH_VERSION@ LIBNSPR = @LIBNSPR@ LIBPLC = @LIBPLC@ @@ -55,18 +55,19 @@ ASFLAGS = @ASFLAGS@ CC = @CC@ CCC = @CXX@ NS_USE_GCC = @GNU_CC@ +GCC_USE_GNU_LD = @GCC_USE_GNU_LD@ AR = @AR@ AR_FLAGS = @AR_FLAGS@ LD = @LD@ RANLIB = @RANLIB@ PERL = @PERL@ -DLLTOOL = @DLLTOOL@ -WINDRES = @WINDRES@ RC = @RC@ +RCFLAGS = @RCFLAGS@ STRIP = @STRIP@ NSINSTALL = @NSINSTALL@ FILTER = @FILTER@ IMPLIB = @IMPLIB@ +CYGWIN_WRAPPER = @CYGWIN_WRAPPER@ OS_CPPFLAGS = @CPPFLAGS@ OS_CFLAGS = $(OS_CPPFLAGS) @CFLAGS@ $(DSO_CFLAGS) @@ -104,7 +105,6 @@ NOSUCHFILE = @NOSUCHFILE@ AIX_LINK_OPTS = @AIX_LINK_OPTS@ MOZ_OBJFORMAT = @MOZ_OBJFORMAT@ ULTRASPARC_LIBRARY = @ULTRASPARC_LIBRARY@ -ULTRASPARC_FILTER_LIBRARY = @ULTRASPARC_FILTER_LIBRARY@ OBJECT_MODE = @OBJECT_MODE@ ifdef OBJECT_MODE diff --git a/config/config.mk b/config/config.mk index 623a0aae..815291a1 100644 --- a/config/config.mk +++ b/config/config.mk @@ -76,6 +76,10 @@ endef LINK_DLL = $(LD) $(OS_DLLFLAGS) $(DLLFLAGS) +ifeq ($(OS_ARCH),Darwin) +PWD := $(shell pwd) +endif + ifneq (,$(filter WINNT OS2, $(OS_ARCH))) INSTALL = $(NSINSTALL) else @@ -85,7 +89,11 @@ INSTALL = $(NSINSTALL) -t else ifeq ($(NSDISTMODE),absolute_symlink) # install using absolute symbolic links +ifeq ($(OS_ARCH),Darwin) +INSTALL = $(NSINSTALL) -L $(PWD) +else INSTALL = $(NSINSTALL) -L `$(NFSPWD)` +endif else # install using relative symbolic links INSTALL = $(NSINSTALL) -R @@ -127,6 +135,10 @@ ifeq ($(USE_IPV6),1) DEFINES += -D_PR_INET6 endif +ifeq ($(MOZ_UNICODE),1) +DEFINES += -DMOZ_UNICODE +endif + #################################################################### # # Configuration for the release process diff --git a/config/module.df b/config/module.df deleted file mode 100644 index e8b78485..00000000 --- a/config/module.df +++ /dev/null @@ -1,40 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# Module description file -# -# A module is also called a component or a subsystem. - -MOD_NAME = nspr20 -MOD_VERSION = 4 diff --git a/config/now.c b/config/now.c index 784b5cea..28beb7be 100644 --- a/config/now.c +++ b/config/now.c @@ -39,7 +39,9 @@ #include #elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) #include -#elif defined(WIN32) || defined(XP_OS2_VACPP) +#elif defined(WIN32) +#include +#elif defined(XP_OS2_VACPP) #include #else #error "Architecture not supported" @@ -86,12 +88,20 @@ int main(int argc, char **argv) #elif defined(WIN32) __int64 now; - struct timeb b; - ftime(&b); - now = b.time; - now *= 1000000; - now += (1000 * b.millitm); + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + CopyMemory(&now, &ft, sizeof(now)); + /* + * 116444736000000000 is the number of 100-nanosecond intervals + * between Jan. 1, 1601 and Jan. 1, 1970. + */ +#ifdef __GNUC__ + now = (now - 116444736000000000LL) / 10LL; + fprintf(stdout, "%lld", now); +#else + now = (now - 116444736000000000i64) / 10i64; fprintf(stdout, "%I64d", now); +#endif #elif defined(XP_OS2_VACPP) /* no long long or i64 so we use a string */ diff --git a/config/nsinstall.c b/config/nsinstall.c index 0f3cd3e2..a5ef8dca 100644 --- a/config/nsinstall.c +++ b/config/nsinstall.c @@ -365,6 +365,11 @@ main(int argc, char **argv) if (ftruncate(tofd, sb.st_size) < 0) fail("cannot truncate %s", toname); + /* + ** On OpenVMS we can't chmod() until the file is closed, and we + ** have to utime() last since fchown/chmod alter the timestamps. + */ +#ifndef VMS if (dotimes) { utb.actime = sb.st_atime; utb.modtime = sb.st_mtime; @@ -377,6 +382,7 @@ main(int argc, char **argv) if (chmod(toname, mode) < 0) #endif fail("cannot change mode of %s", toname); +#endif if ((owner || group) && fchown(tofd, uid, gid) < 0) fail("cannot change owner of %s", toname); @@ -384,6 +390,16 @@ main(int argc, char **argv) if (close(tofd) < 0) fail("cannot write to %s", toname); close(fromfd); +#ifdef VMS + if (chmod(toname, mode) < 0) + fail("cannot change mode of %s", toname); + if (dotimes) { + utb.actime = sb.st_atime; + utb.modtime = sb.st_mtime; + if (utime(toname, &utb) < 0) + fail("cannot set times of %s", toname); + } +#endif } free(toname); diff --git a/config/nspr-config.in b/config/nspr-config.in index daae782d..e9e18679 100755 --- a/config/nspr-config.in +++ b/config/nspr-config.in @@ -6,7 +6,7 @@ exec_prefix_set=no major_version=@MOD_MAJOR_VERSION@ minor_version=@MOD_MINOR_VERSION@ -revision_version=@MOD_REVISION_VERSION@ +patch_version=@MOD_PATCH_VERSION@ usage() { @@ -58,7 +58,7 @@ while test $# -gt 0; do echo_exec_prefix=yes ;; --version) - echo ${major_version}.${minor_version}.${revision_version} + echo ${major_version}.${minor_version}.${patch_version} ;; --cflags) echo_cflags=yes diff --git a/config/rules.mk b/config/rules.mk index ffd63dfc..6aad726e 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -160,6 +160,19 @@ ALL_TRASH = $(TARGETS) $(OBJS) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAG $(NOSUCHFILE) \ so_locations +ifeq ($(OS_ARCH),OpenVMS) +ALL_TRASH += $(wildcard *.c*_defines) +ifdef SHARED_LIBRARY +VMS_SYMVEC_FILE = $(SHARED_LIBRARY:.$(DLL_SUFFIX)=_symvec.opt) +VMS_SYMVEC_FILE_MODULE = $(srcdir)/$(LIBRARY_NAME)_symvec.opt +ALL_TRASH += $(VMS_SYMVEC_FILE) +endif +endif + +ifndef RELEASE_LIBS_DEST +RELEASE_LIBS_DEST = $(RELEASE_LIB_DIR) +endif + ifdef DIRS LOOP_OVER_DIRS = \ @for d in $(DIRS); do \ @@ -206,10 +219,10 @@ ifdef RELEASE_BINS $(NSINSTALL) -t -m 0755 $(RELEASE_BINS) $(DESTDIR)$(bindir) endif ifdef RELEASE_HEADERS - $(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir) + $(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir)/$(include_subdir) endif ifdef RELEASE_LIBS - $(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir) + $(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir)/$(lib_subdir) endif +$(LOOP_OVER_DIRS) @@ -238,13 +251,13 @@ ifdef RELEASE_LIBS else \ true; \ fi - @if test ! -d $(RELEASE_LIB_DIR); then \ - rm -rf $(RELEASE_LIB_DIR); \ - $(NSINSTALL) -D $(RELEASE_LIB_DIR);\ + @if test ! -d $(RELEASE_LIBS_DEST); then \ + rm -rf $(RELEASE_LIBS_DEST); \ + $(NSINSTALL) -D $(RELEASE_LIBS_DEST);\ else \ true; \ fi - cp $(RELEASE_LIBS) $(RELEASE_LIB_DIR) + cp $(RELEASE_LIBS) $(RELEASE_LIBS_DEST) endif ifdef RELEASE_HEADERS @echo "Copying header files to release directory" @@ -274,7 +287,7 @@ $(NFSPWD): $(PROGRAM): $(OBJS) @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH),WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) else ifeq ($(MOZ_OS2_TOOLS),VACPP) @@ -298,11 +311,12 @@ endif $(RANLIB) $@ ifeq ($(OS_TARGET), OS2) -$(IMPORT_LIBRARY): $(SHARED_LIBRARY) - $(IMPLIB) $@ $(SHARED_LIBRARY).def +$(IMPORT_LIBRARY): $(MAPFILE) + rm -f $@ + $(IMPLIB) $@ $(MAPFILE) endif - -$(SHARED_LIBRARY): $(OBJS) + +$(SHARED_LIBRARY): $(OBJS) $(MAPFILE) @$(MAKE_OBJDIR) rm -f $@ ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) @@ -314,29 +328,22 @@ ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1) $(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \ -bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS) else # AIX 4.1 -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(LINK_DLL) -MAP $(DLLBASE) $(DLL_LIBS) $(EXTRA_LIBS) $(OBJS) else -ifeq ($(OS_ARCH),OS2) -# append ( >> ) doesn't seem to be working under OS/2 gmake. Run through OS/2 shell instead. - @cmd /C "echo LIBRARY $(notdir $(basename $(SHARED_LIBRARY))) INITINSTANCE TERMINSTANCE >$@.def" - @cmd /C "echo PROTMODE >>$@.def" - @cmd /C "echo CODE LOADONCALL MOVEABLE DISCARDABLE >>$@.def" - @cmd /C "echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >>$@.def" - @cmd /C "echo EXPORTS >>$@.def" - @cmd /C "$(FILTER) $(LIBRARY) | grep -v _DLL_InitTerm >>$@.def" - $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $@.def -else # OS2 +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $(MAPFILE) +else # !os2 vacpp ifeq ($(OS_TARGET), OpenVMS) - @if test ! -f $(OBJDIR)/VMSuni.opt; then \ - echo "Creating universal symbol option file $(OBJDIR)/VMSuni.opt";\ - create_opt_uni $(OBJS); \ + @if test ! -f $(VMS_SYMVEC_FILE); then \ + if test -f $(VMS_SYMVEC_FILE_MODULE); then \ + echo Creating component options file $(VMS_SYMVEC_FILE); \ + cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \ + fi; \ fi - $(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OBJDIR)/VMSuni.opt -else # OpenVMS - $(MKSHLIB) $(OBJS) $(EXTRA_LIBS) endif # OpenVMS -endif # OS2 + $(MKSHLIB) $(OBJS) $(EXTRA_LIBS) +endif # OS2 vacpp endif # WINNT endif # AIX 4.1 ifdef ENABLE_STRIP @@ -350,37 +357,83 @@ ifeq ($(OS_TARGET),OS2) $(RC) -DOS2 -r $< $@ else # The resource compiler does not understand the -U option. - $(RC) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $< +ifdef NS_USE_GCC + $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $< +else + $(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $< +endif # GCC endif @echo $(RES) finished endif +$(MAPFILE): $(LIBRARY_NAME).def + @$(MAKE_OBJDIR) +ifeq ($(OS_ARCH),SunOS) + grep -v ';-' $< | \ + sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ +endif +ifeq ($(OS_ARCH),OS2) + echo LIBRARY $(LIBRARY_NAME)$(LIBRARY_VERSION) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + grep -v ';+' $< | grep -v ';-' | \ + sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' >> $@ +endif + +# +# Translate source filenames to absolute paths. This is required for +# debuggers under Windows and OS/2 to find source files automatically. +# + +ifeq ($(OS_ARCH),OS2) +NEED_ABSOLUTE_PATH = 1 +endif + +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) +NEED_ABSOLUTE_PATH = 1 +endif + +ifdef NEED_ABSOLUTE_PATH +PWD := $(shell pwd) +abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1))) +endif + $(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH), WINNT) - $(CCC) -Fo$@ -c $(CCCFLAGS) $< +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) + $(CCC) -Fo$@ -c $(CCCFLAGS) $(call abspath,$<) else ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(CCC) -Fo$@ -c $(CCCFLAGS) $< + $(CCC) -Fo$@ -c $(CCCFLAGS) $(call abspath,$<) +else +ifdef NEED_ABSOLUTE_PATH + $(CCC) -o $@ -c $(CCCFLAGS) $(call abspath,$<) else $(CCC) -o $@ -c $(CCCFLAGS) $< endif endif +endif WCCFLAGS1 = $(subst /,\\,$(CFLAGS)) WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1)) WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2)) $(OBJDIR)/%.$(OBJ_SUFFIX): %.c @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH), WINNT) - $(CC) -Fo$@ -c $(CFLAGS) $< +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) + $(CC) -Fo$@ -c $(CFLAGS) $(call abspath,$<) else ifeq ($(MOZ_OS2_TOOLS),VACPP) - $(CC) -Fo$@ -c $(CFLAGS) $< + $(CC) -Fo$@ -c $(CFLAGS) $(call abspath,$<) +else +ifdef NEED_ABSOLUTE_PATH + $(CC) -o $@ -c $(CFLAGS) $(call abspath,$<) else $(CC) -o $@ -c $(CFLAGS) $< endif endif +endif $(OBJDIR)/%.$(OBJ_SUFFIX): %.s diff --git a/config/win16.mk b/config/win16.mk deleted file mode 100644 index 39a46df2..00000000 --- a/config/win16.mk +++ /dev/null @@ -1,116 +0,0 @@ -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Netscape Portable Runtime (NSPR). -# -# The Initial Developer of the Original Code is Netscape -# Communications Corporation. Portions created by Netscape are -# Copyright (C) 1998-2000 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): -# -# Alternatively, the contents of this file may be used under the -# terms of the GNU General Public License Version 2 or later (the -# "GPL"), in which case the provisions of the GPL are applicable -# instead of those above. If you wish to allow use of your -# version of this file only under the terms of the GPL and not to -# allow others to use your version of this file under the MPL, -# indicate your decision by deleting the provisions above and -# replace them with the notice and other provisions required by -# the GPL. If you do not delete the provisions above, a recipient -# may use your version of this file under either the MPL or the -# GPL. -# - -# -# win16_3.11.mk -- Make configuration for Win16 -# -# This file configures gmake to build the Win16 variant of -# NSPR 2.0. This file has the function of two files commonly -# used on other platforms, for example: winnt.mk and -# winnt4.0.mk. ... The packaging is easier and there is only -# one variant of the Win16 target. -# -# Win16 is built using the Watcom C/C++ version 11.0 -# compiler. You gotta set up the compiler first. Follow the -# directions in the manual (Ha! ... really, its not a -# problem). The Watcom compiler depends on a few environment -# variables; these environment variables define where the -# compiler components are installed; they must be set before -# running the make. -# -# Notes: -# OS_CFLAGS is the command line options for the compiler when -# building the .DLL object files. -# OS_EXE_CFLAGS is the command line options for the compiler -# when building the .EXE object files; this is for the test -# programs. -# the macro OS_CFLAGS is set to OS_EXE_CFLAGS inside of the -# makefile for the pr/tests directory. ... Hack. -# -# USE_WATCOM_DEBUG_DATA environment variable causes the -# watcom compiler flag to be set to -hw (otherwise -# it is set to -hc (codeview debug data)) for debug builds. -# - -# -- configuration ----------------------------------------- - -CC = wcc -CCC = wcl -LINK = wlink -AR = wlib -q $@ -RC = wrc.exe /r /dWIN16=1 /bt=windows -RANLIB = echo -BSDECHO = echo -STRIP = echo -NSINSTALL = nsinstall -INSTALL = $(NSINSTALL) -MAKE_OBJDIR = mkdir $(OBJDIR) - -XP_DEFINE = -DXP_PC -OBJ_SUFFIX = obj -LIB_SUFFIX = lib -DLL_SUFFIX = dll - -ifdef BUILD_OPT -OBJDIR_TAG = _O -OPTIMIZER = -oneatx -oh -oi -ei -3 -fpi87 -fp3 -s -else -ifdef USE_WATCOM_DEBUG_DATA -OPTIMIZER = -d2 -hw -s -DDEBUG -DEBUGTYPE = watcom -else -OPTIMIZER = -d2 -hc -s -DDEBUG -DEBUGTYPE = codeview -endif -OBJDIR_TAG = _D -endif - -# XXX FIXME: I doubt we use this. It is redundant with -# SHARED_LIBRARY. -ifdef DLL -DLL := $(addprefix $(OBJDIR)/, $(DLL)) -endif - - -CPU_ARCH = x86 -OS_CFLAGS = -ml -3 -bd -zc -zu -bt=windows -d_X86_ -dWIN16 -d_WINDLL -OS_EXE_CFLAGS = -ml -3 -bt=windows -d_X86_ -dWIN16 -OS_LIB_FLAGS = -c -iro -n - -# Name of the binary code directories -OBJDIR_NAME = $(OS_CONFIG)$(OBJDIR_TAG).OBJ - -OS_DLL_OPTION = CASEEXACT -OS_DLLFLAGS = -OS_LIBS = -W16_EXPORTS = # diff --git a/configure b/configure index e5d01dbe..b32d6a17 100755 --- a/configure +++ b/configure @@ -38,6 +38,9 @@ ac_help="$ac_help --enable-64bit Enable 64-bit support (on certain platforms)" ac_help="$ac_help --enable-mdupdate Enable use of certain compilers' mdupdate feature" +ac_help="$ac_help + --enable-macos-target=VER (default=10.1) + Set the minimum MacOS version needed at runtime" ac_help="$ac_help --enable-strip Enable stripping of shared libs and programs" ac_help="$ac_help @@ -614,7 +617,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:618: checking host system type" >&5 +echo "configure:621: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -635,7 +638,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:639: checking target system type" >&5 +echo "configure:642: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -653,7 +656,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:657: checking build system type" >&5 +echo "configure:660: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -677,8 +680,8 @@ test "$host_alias" != "$target_alias" && MOD_MAJOR_VERSION=4 -MOD_MINOR_VERSION=2 -MOD_REVISION_VERSION=0 +MOD_MINOR_VERSION=3 +MOD_PATCH_VERSION=0 NSPR_MODNAME=nspr20 _HAVE_PTHREADS= USE_PTHREADS= @@ -689,6 +692,7 @@ USE_64= USE_CPLUS= USE_IPV6= USE_MDUPDATE= +MACOS_DEPLOYMENT_TARGET= _OPTIMIZE_FLAGS=-O _DEBUG_FLAGS=-g MOZ_DEBUG=1 @@ -700,6 +704,7 @@ NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' NOSUCHFILE=/no-such-file LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)' LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)' +CYGWIN_WRAPPER= RESOLVE_LINK_SYMBOLS= @@ -710,16 +715,51 @@ HOST_CFLAGS="${HOST_CFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" case "$target" in -*-cygwin*) +*-cygwin*|*-mingw*) # Check to see if we are really running in a msvc environemnt _WIN32_MSVC= - if test "$CC" = "cl" || test "$CXX" = "cl"; then - _WIN32_MSVC=1 - elif test -z "$CC"; then + for ac_prog in cl +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:727: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$CC" && break +done + + if test "$CC" = "cl"; then echo 'main() { return 0; }' > dummy.c - cl -o dummy dummy.c + ${CC} -o dummy dummy.c >/dev/null 2>&1 if test $? = 0; then _WIN32_MSVC=1 + CXX=$CC + else + echo "configure: warning: $(CC) test failed. Using normal feature tests" 1>&2 fi rm -f dummy dummy.o dummy.obj dummy.exe dummy.c fi @@ -727,7 +767,7 @@ case "$target" in *-msvc*) _WIN32_MSVC=1 ;; -*-mksnt*) +*-mks*) _WIN32_MSVC=1 ;; esac @@ -871,6 +911,15 @@ if test "${enable_mdupdate+set}" = set; then fi +# Check whether --enable-macos-target or --disable-macos-target was given. +if test "${enable_macos_target+set}" = set; then + enableval="$enable_macos_target" + MACOS_DEPLOYMENT_TARGET_STR=$enableval +else + MACOS_DEPLOYMENT_TARGET_STR=10.1 +fi + + case "$target" in *-aix*) @@ -905,6 +954,10 @@ if test -z "$CC"; then CC=cc ;; + *-openvms*) + CC=cc + ;; + *-osf*) CC=cc ;; @@ -945,6 +998,10 @@ if test -z "$CXX"; then CXX=CC ;; + *-openvms*) + CXX=cxx + ;; + *-osf*) CXX=cxx ;; @@ -960,7 +1017,7 @@ if test -z "$SKIP_PATH_CHECKS"; then # Extract the first word of "$WHOAMI whoami", so it can be a program name with args. set dummy $WHOAMI whoami; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:964: checking for $ac_word" >&5 +echo "configure:1021: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_WHOAMI'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -993,20 +1050,26 @@ else echo "$ac_t""no" 1>&6 fi -elif test -z "$WHOAMI"; then - WHOAMI=whoami fi if test -n "$MOZ_DEBUG"; then cat >> confdefs.h <<\EOF #define DEBUG 1 -EOF - - cat >> confdefs.h <> confdefs.h <<\EOF #define NDEBUG 1 @@ -1025,14 +1088,14 @@ if test "$target" != "$host"; then _SAVE_LDFLAGS="$LDFLAGS" echo $ac_n "checking for $host compiler""... $ac_c" 1>&6 -echo "configure:1029: checking for $host compiler" >&5 +echo "configure:1092: checking for $host compiler" >&5 if test -z "$HOST_CC"; then for ac_prog in gcc cc /usr/ucb/cc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1036: checking for $ac_word" >&5 +echo "configure:1099: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_HOST_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1079,16 +1142,16 @@ test -n "$HOST_CC" || HOST_CC="""" LDFLAGS="$HOST_LDFLAGS" echo $ac_n "checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1083: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5 +echo "configure:1146: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_prog_host_cc_works=1 echo "$ac_t""yes" 1>&6 else @@ -1109,7 +1172,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1113: checking for $ac_word" >&5 +echo "configure:1176: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1144,7 +1207,7 @@ test -n "$CC" || CC="echo" # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1148: checking for $ac_word" >&5 +echo "configure:1211: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1174,7 +1237,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1178: checking for $ac_word" >&5 +echo "configure:1241: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1225,7 +1288,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1229: checking for $ac_word" >&5 +echo "configure:1292: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1257,7 +1320,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1261: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1324: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1268,12 +1331,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1272 "configure" +#line 1335 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1299,12 +1362,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1303: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1366: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1308: checking whether we are using GNU C" >&5 +echo "configure:1371: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1313,7 +1376,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1317: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1380: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1332,7 +1395,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1336: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1399: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1369,7 +1432,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1373: checking for $ac_word" >&5 +echo "configure:1436: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1406,7 +1469,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1410: checking for $ac_word" >&5 +echo "configure:1473: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1438,7 +1501,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1442: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1505: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1449,12 +1512,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1453 "configure" +#line 1516 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1480,12 +1543,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1484: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1547: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1489: checking whether we are using GNU C++" >&5 +echo "configure:1552: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1494,7 +1557,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1561: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1513,7 +1576,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1517: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1580: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1550,7 +1613,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1554: checking for $ac_word" >&5 +echo "configure:1617: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1587,7 +1650,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1591: checking for $ac_word" >&5 +echo "configure:1654: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1624,7 +1687,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1628: checking for $ac_word" >&5 +echo "configure:1691: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1661,7 +1724,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1665: checking for $ac_word" >&5 +echo "configure:1728: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1698,7 +1761,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1702: checking for $ac_word" >&5 +echo "configure:1765: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1728,43 +1791,6 @@ test -n "$STRIP" && break done test -n "$STRIP" || STRIP="echo" - fi - if test -z "$DLLTOOL"; then - for ac_prog in "${target_alias}-dlltool" "${target}-dlltool" -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1739: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_prog_DLLTOOL="$ac_prog" - break - fi - done - IFS="$ac_save_ifs" -fi -fi -DLLTOOL="$ac_cv_prog_DLLTOOL" -if test -n "$DLLTOOL"; then - echo "$ac_t""$DLLTOOL" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$DLLTOOL" && break -done -test -n "$DLLTOOL" || DLLTOOL="echo" - fi if test -z "$WINDRES"; then for ac_prog in "${target_alias}-windres" "${target}-windres" @@ -1772,7 +1798,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1776: checking for $ac_word" >&5 +echo "configure:1802: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1810,7 +1836,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1814: checking for $ac_word" >&5 +echo "configure:1840: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1842,7 +1868,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1846: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1872: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1853,12 +1879,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1857 "configure" +#line 1883 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cxx_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1884,12 +1910,12 @@ if test $ac_cv_prog_cxx_works = no; then { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1888: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1914: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6 cross_compiling=$ac_cv_prog_cxx_cross echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1893: checking whether we are using GNU C++" >&5 +echo "configure:1919: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1898,7 +1924,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1928: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1917,7 +1943,7 @@ ac_test_CXXFLAGS="${CXXFLAGS+set}" ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1921: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1947: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1954,7 +1980,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1958: checking for $ac_word" >&5 +echo "configure:1984: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1984,7 +2010,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1988: checking for $ac_word" >&5 +echo "configure:2014: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2035,7 +2061,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2039: checking for $ac_word" >&5 +echo "configure:2065: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2067,7 +2093,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:2071: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:2097: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2078,12 +2104,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2082 "configure" +#line 2108 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2087: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -2109,12 +2135,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2113: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:2139: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:2118: checking whether we are using GNU C" >&5 +echo "configure:2144: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2123,7 +2149,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2127: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2153: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -2142,7 +2168,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:2146: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:2172: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2175,7 +2201,7 @@ fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:2179: checking how to run the C preprocessor" >&5 +echo "configure:2205: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -2190,13 +2216,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2226: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2207,13 +2233,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2224,13 +2250,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2260: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -2257,7 +2283,7 @@ echo "$ac_t""$CPP" 1>&6 # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2261: checking for $ac_word" >&5 +echo "configure:2287: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2289,7 +2315,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2293: checking for $ac_word" >&5 +echo "configure:2319: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2330,7 +2356,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2334: checking for $ac_word" >&5 +echo "configure:2360: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2371,7 +2397,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2375: checking for $ac_word" >&5 +echo "configure:2401: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2412,7 +2438,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2416: checking for $ac_word" >&5 +echo "configure:2442: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2448,53 +2474,12 @@ test -n "$STRIP" && break done test -n "$STRIP" || STRIP="echo not_strip" - for ac_prog in dlltool -do -# Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2457: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_DLLTOOL'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$DLLTOOL" in - /*) - ac_cv_path_DLLTOOL="$DLLTOOL" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_DLLTOOL="$DLLTOOL" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_DLLTOOL="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - ;; -esac -fi -DLLTOOL="$ac_cv_path_DLLTOOL" -if test -n "$DLLTOOL"; then - echo "$ac_t""$DLLTOOL" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -test -n "$DLLTOOL" && break -done -test -n "$DLLTOOL" || DLLTOOL="echo not_dlltool" - for ac_prog in windres do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2498: checking for $ac_word" >&5 +echo "configure:2483: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2544,7 +2529,7 @@ fi if test "$GXX" = "yes"; then GNU_CXX=1 fi -if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then GNU_AS=1 fi rm -f a.out @@ -2556,10 +2541,10 @@ else fi echo $ac_n "checking for gcc -pipe support""... $ac_c" 1>&6 -echo "configure:2560: checking for gcc -pipe support" >&5 +echo "configure:2545: checking for gcc -pipe support" >&5 if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then echo '#include ' > dummy-hello.c - echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c + echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 if test $? = 0; then @@ -2571,14 +2556,14 @@ if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then _SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -pipe" cat > conftest.$ac_ext < int main() { printf("Hello World\n"); ; return 0; } EOF -if { (eval echo configure:2582: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* _res_gcc_pipe="yes" else @@ -2611,7 +2596,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2615: checking for $ac_word" >&5 +echo "configure:2600: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2671,12 +2656,21 @@ if test "$OS_ARCH" = "IRIX64"; then OS_ARCH=IRIX fi +if test "$OS_ARCH" = "AIX"; then + OS_RELEASE=`uname -v`.`uname -r` +fi + +if test "$OS_ARCH" = "FreeBSD"; then + OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` +fi + if test "$OS_ARCH" = "Linux"; then OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` + OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'` fi -if test "$OS_ARCH" = "POSIX_for_OpenVMS_AXP"; then - OS_ARCH=OpenVMS +if test "$OS_ARCH" = "OpenVMS"; then + OS_RELEASE=`uname -v` fi ####################################################################### @@ -2714,10 +2708,7 @@ elif test "$OS_ARCH" = 'Windows_95'; then elif test "$OS_ARCH" = 'Windows_98'; then OS_ARCH=Windows_NT OS_TARGET=WIN95 -elif test "$OS_ARCH" = "CYGWIN_95-4.0"; then - OS_ARCH='CYGWIN_NT-4.0' - OS_TARGET=WIN95 -elif test "$OS_ARCH" = "CYGWIN_98-4.10"; then +elif test "`echo $OS_ARCH | egrep -c '^(CYGWIN_9|CYGWIN_ME)' 2>/dev/null`" != 0; then OS_ARCH='CYGWIN_NT-4.0' OS_TARGET=WIN95 elif test "$OS_ARCH" = "OS_2"; then @@ -2805,7 +2796,7 @@ OS_CONFIG="${OS_TARGET}${OS_RELEASE}" case "$host" in -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) ;; *-beos*) HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" @@ -2835,17 +2826,17 @@ EOF DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall' ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6 -echo "configure:2839: checking for sys/atomic_op.h" >&5 +echo "configure:2830: checking for sys/atomic_op.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2849: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2840: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2922,7 +2913,7 @@ EOF EOF cat >> confdefs.h <<\EOF -#define AIX4_3 1 +#define AIX4_3_PLUS 1 EOF cat >> confdefs.h <<\EOF @@ -2943,6 +2934,10 @@ EOF cat >> confdefs.h <<\EOF #define _PR_HAVE_OFF64_T 1 +EOF + + cat >> confdefs.h <<\EOF +#define AIX4_3_PLUS 1 EOF cat >> confdefs.h <<\EOF @@ -2967,11 +2962,7 @@ EOF MDCPUCFG_H=_aix64.cfg OBJECT_MODE=64 else - if test -n "$USE_IPV6"; then - MDCPUCFG_H=_aix32in6.cfg - else - MDCPUCFG_H=_aix32.cfg - fi + MDCPUCFG_H=_aix32.cfg fi PR_MD_CSRCS=aix.c RESOLVE_LINK_SYMBOLS=1 @@ -3000,10 +2991,50 @@ EOF PR_MD_ARCH_DIR=beos RESOLVE_LINK_SYMBOLS=1 case "${target_cpu}" in - i?86) + i*86) _OPTIMIZE_FLAGS=-O2 _DEBUG_FLAGS='-gdwarf-2 -O0' MKSHLIB='$(CCC) $(DSO_LDOPTS) -o $@' + echo $ac_n "checking for gethostbyaddr in -lbind""... $ac_c" 1>&6 +echo "configure:3000: checking for gethostbyaddr in -lbind" >&5 +ac_lib_var=`echo bind'_'gethostbyaddr | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lbind $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + OS_LIBS="$OS_LIBS -lbind -lsocket" +else + echo "$ac_t""no" 1>&6 +fi + ;; powerpc) CC=mwcc @@ -3087,7 +3118,7 @@ EOF PR_MD_ASFILES=os_BSD_OS_386_2.s ;; - bsdi4.*) + bsdi4.* | bsdi5.*) cat >> confdefs.h <<\EOF #define _PR_SELECT_CONST_TIMEVAL 1 EOF @@ -3113,7 +3144,7 @@ EOF DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)' STRIP="$STRIP -d" case "$target_os" in - bsdi4.2*) + bsdi4.2* | bsdi4.3* | bsdi5.*) cat >> confdefs.h <<\EOF #define _PR_HAVE_GETPROTO_R 1 EOF @@ -3166,7 +3197,6 @@ EOF CFLAGS="$CFLAGS -Wmost -fno-common" if echo $OS_TEST | grep -c 86 2>/dev/null; then - CFLAGS="$CFLAGS -mno-486" cat >> confdefs.h <<\EOF #define i386 1 EOF @@ -3188,6 +3218,34 @@ EOF USE_PTHREADS=1 MDCPUCFG_H=_darwin.cfg PR_MD_CSRCS=darwin.c + if test "$CPU_ARCH" = "ppc"; then + PR_MD_ASFILES=os_Darwin_ppc.s + fi + + # Add Mac OS X support for loading CFM & CFBundle plugins + if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then + cat >> confdefs.h <<\EOF +#define XP_MACOSX 1 +EOF + + OS_TARGET=MacOSX + + + MACOS_VERSION_MAJOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 1` + MACOS_VERSION_MINOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 2` + MACOS_VERSION_MICRO=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 3` + if test -z "$MACOS_VERSION_MINOR"; then + MACOS_VERSION_MINOR=0 + fi + if test -z "$MACOS_VERSION_MICRO"; then + MACOS_VERSION_MICRO=0 + fi + MACOS_DEPLOYMENT_TARGET=`printf "%02d%02d%02d" "$MACOS_VERSION_MAJOR" "$MACOS_VERSION_MINOR" "$MACOS_VERSION_MICRO"` + cat >> confdefs.h <> confdefs.h <<\EOF #define hppa 1 +EOF + + # OSF1 and HPUX report the POLLHUP event for a socket when the + # shutdown(SHUT_WR) operation is called for the remote end, even though + # the socket is still writeable. Use select(), instead of poll(), to + # workaround this problem. + cat >> confdefs.h <<\EOF +#define _PR_POLL_WITH_SELECT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _USE_BIG_FDS 1 EOF DLL_SUFFIX=sl DSO_LDOPTS='-b +h $(notdir $@)' PR_MD_CSRCS=hpux.c - PR_MD_ASFILES=os_HPUX.s + if test "$OS_TEST" != "ia64"; then + PR_MD_ASFILES=os_HPUX.s + fi if test -n "$USE_64"; then MDCPUCFG_H=_hpux64.cfg else @@ -3284,8 +3357,6 @@ EOF if test -z "$GNU_CC"; then CC="$CC -Ae" CXX="$CXX -ext" - CFLAGS="$CFLAGS +ESlit" - CXXFLAGS="$CXXFLAGS +ESlit" DSO_CFLAGS=+Z else DSO_CFLAGS=-fPIC @@ -3329,13 +3400,22 @@ EOF fi - if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11)' >/dev/null; then + if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then cat >> confdefs.h <<\EOF #define HAVE_POINTER_LOCALTIME_R 1 EOF fi + # HP-UX 11i (B.11.11) or higher + + case "$OS_RELEASE" in + [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[2-9]*|B.11.1[1-9]*) + USE_IPV6=1 + ;; + esac + + if test "$OS_RELEASE" = "B.10.01"; then cat >> confdefs.h <<\EOF #define HPUX10 1 @@ -3388,7 +3468,7 @@ EOF DEFAULT_IMPL_STRATEGY=_PTH fi - if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then + if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then cat >> confdefs.h <<\EOF #define HPUX10 1 EOF @@ -3411,11 +3491,21 @@ EOF if test -z "$GNU_CC"; then if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DAportable +DS2.0" - CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + if test "$OS_TEST" = "ia64"; then + CFLAGS="$CFLAGS +DD32" + CXXFLAGS="$CXXFLAGS +DD32" + else + CFLAGS="$CFLAGS +DAportable +DS2.0" + CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + fi else - CFLAGS="$CFLAGS +DA2.0W +DS2.0" - CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + if test "$OS_TEST" = "ia64"; then + CFLAGS="$CFLAGS +DD64" + CXXFLAGS="$CXXFLAGS +DD64" + else + CFLAGS="$CFLAGS +DA2.0W +DS2.0" + CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + fi fi fi DEFAULT_IMPL_STRATEGY=_PTH @@ -3509,7 +3599,7 @@ EOF if test "$USE_MDUPDATE"; then CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" fi - case "$target}" in + case "${target}" in *-irix6.*) CFLAGS="$CFLAGS -multigot" DSO_LDOPTS="-no_unresolved" @@ -3595,10 +3685,6 @@ EOF cat >> confdefs.h <<\EOF #define LINUX 1 -EOF - - cat >> confdefs.h <<\EOF -#define linux 1 EOF CFLAGS="$CFLAGS -ansi -Wall" @@ -3608,8 +3694,11 @@ EOF MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' DSO_CFLAGS=-fPIC DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - OS_LIBS="$OS_LIBS -lc" _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that + # combo is not yet good at debugging inlined + # functions (even when using DWARF2 as the + # debugging format) COMPILER_TAG=_glibc if echo "$OS_TEST" | grep -c 86 >/dev/null; then CPU_ARCH=x86 @@ -3630,7 +3719,7 @@ EOF CFLAGS="$CFLAGS -mieee" CXXFLAGS="$CXXFLAGS -mieee" ;; - i?86) + i*86) cat >> confdefs.h <<\EOF #define i386 1 EOF @@ -3641,19 +3730,13 @@ EOF PR_MD_ASFILES=os_Linux_ia64.s ;; m68k) - CFLAGS="$CFLAGS -m68020-40" - CXXFLAGS="$CXXFLAGS -m68020-40" - # - # gcc on Linux/m68k either has a bug or triggers a code-sequence - # bug in the 68060 which causes gcc to crash. The simplest way to - # avoid this is to enable a minimum level of optimization. - # - _DEBUG_FLAGS="$_DEBUG_FLAGS -O" + CFLAGS="$CFLAGS -m68020-60" + CXXFLAGS="$CXXFLAGS -m68020-60" ;; esac ;; -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) cat >> confdefs.h <<\EOF #define XP_PC 1 EOF @@ -3664,13 +3747,18 @@ EOF PR_MD_ARCH_DIR=windows RESOLVE_LINK_SYMBOLS=1 + NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' + if test `echo "${PATH}" | grep -c \;` = 0; then + CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper' + fi if test -n "$GNU_CC"; then - cat >> confdefs.h <<\EOF -#define NONAMELESSUNION 1 -EOF - - MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@' + CC="$CC -mno-cygwin" + CXX="$CXX -mno-cygwin" + DLL_SUFFIX=dll + MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))' + RC=$WINDRES + RCFLAGS='-O coff' else CC=cl CXX=cl @@ -3679,12 +3767,11 @@ EOF AR_FLAGS= RANLIB='echo not_ranlib' STRIP='echo not_strip' - NSINSTALL=nsinstall RC=rc.exe GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' - OBJ_SUFFIX=obj - LIB_SUFFIX=lib - DLL_SUFFIX=dll + OBJ_SUFFIX=obj + LIB_SUFFIX=lib + DLL_SUFFIX=dll CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" @@ -3756,6 +3843,8 @@ EOF #define WIN95 1 EOF + # undefine WINNT as some versions of mingw gcc define it by default + DEFINES="$DEFINES -UWINNT" cat >> confdefs.h <<\EOF #define _PR_GLOBAL_THREADS_ONLY 1 EOF @@ -3790,7 +3879,7 @@ EOF esac case "$target_cpu" in - i?86) + i*86) cat >> confdefs.h <<\EOF #define _X86_ 1 EOF @@ -4059,31 +4148,19 @@ EOF EOF cat >> confdefs.h <<\EOF -#define VMS_AS_IS 1 -EOF - - cat >> confdefs.h <<\EOF -#define _SOCKADDR_LEN 1 -EOF - - cat >> confdefs.h <<\EOF -#define GENERIC_PTHREAD_REDEFINES 1 +#define PR_GETIPNODE_NOT_THREADSAFE 1 EOF RESOLVE_LINK_SYMBOLS=1 - CROSS_COMPILE=1 - _HAVE_PTHREADS=1 - HOST_CC=c89 - HOST_CXX=cxx - HOST_CFLAGS=-O - HOST_CXXFLAGS=-O - CC=ccc - CXX=ccc - CFLAGS="$CFLAGS -Wc,names=\(short,as\)" - CXXFLAGS="$CXXFLAGS -Wc,names=\(short,as\)" + AR_FLAGS='c $@' MDCPUCFG_H=_openvms.cfg PR_MD_CSRCS=openvms.c - MKSHLIB='vmsld $(OPTIMIZER)' + DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS)' + if test -n "$MOZ_DEBUG"; then + DSO_LDOPTS="$DSO_LDOPTS $_DEBUG_FLAGS" + else + DSO_LDOPTS="$DSO_LDOPTS $_OPTIMIZE_FLAGS" + fi ;; *-osf*) @@ -4100,19 +4177,38 @@ EOF #define _REENTRANT 1 EOF - ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` + # OSF1 and HPUX report the POLLHUP event for a socket when the + # shutdown(SHUT_WR) operation is called for the remote end, even though + # the socket is still writeable. Use select(), instead of poll(), to + # workaround this problem. + cat >> confdefs.h <<\EOF +#define _PR_POLL_WITH_SELECT 1 +EOF + + + if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then + USE_NSPR_THREADS=1 + fi + + if test -z "$GNU_CC"; then + CC="$CC -std1 -ieee_with_inexact" + if test "$OS_RELEASE" != "V2.0"; then + CC="$CC -readonly_strings" + fi + _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" + ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 -echo "configure:4106: checking for machine/builtins.h" >&5 +echo "configure:4202: checking for machine/builtins.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4116: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4212: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4136,17 +4232,9 @@ else echo "$ac_t""no" 1>&6 fi - - if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then - USE_NSPR_THREADS=1 - fi - - if test -z "$GNU_CC"; then - CC="$CC -std1 -ieee_with_inexact" - if test "$OS_RELEASE" != "V2.0"; then - CC="$CC -readonly_strings" - fi - _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" + else + CFLAGS="$CFLAGS -mieee" + CXXFLAGS="$CXXFLAGS -mieee" fi if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then @@ -4355,11 +4443,18 @@ EOF MDCPUCFG_H=_solaris32.cfg fi PR_MD_CSRCS=solaris.c - DSO_LDOPTS='-G -h $(notdir $@)' + LD=/usr/ccs/bin/ld + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + RESOLVE_LINK_SYMBOLS=1 if test -n "$GNU_CC"; then DSO_CFLAGS=-fPIC + if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then + GCC_USE_GNU_LD=1 + fi + DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs' else DSO_CFLAGS=-KPIC + DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs' fi if test -z "$GNU_AS"; then ASFLAGS="$ASFLAGS -Wa,-P" @@ -4372,12 +4467,13 @@ EOF CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" fi else - CC="$CC -xstrconst" - CXX="$CXX -Qoption cg -xstrconst" + CFLAGS="$CFLAGS -xstrconst" + CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst" if test -z "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS -xs" CXXFLAGS="$CXXFLAGS -xs" fi + _OPTIMIZE_FLAGS=-xO4 fi if test -n "$USE_64" && test -z "$GNU_CC"; then CC="$CC -xarch=v9" @@ -4443,11 +4539,14 @@ EOF # 64-bit Solaris requires SPARC V9 architecture, so the following # is not needed. if test -z "$USE_64"; then - ULTRASPARC_LIBRARY=ultrasparc - ULTRASPARC_FILTER_LIBRARY=libatomic.so - DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' + ULTRASPARC_LIBRARY=nspr_flt fi fi + # Purify requires that binaries linked against nspr also + # be linked against -lrt (or -lposix4) so add it to OS_LIBS + _rev=`uname -r` + _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'` + OS_LIBS="$OS_LIBS $_librt" ;; *-sco-sysv5*) @@ -4502,22 +4601,19 @@ EOF EOF cat >> confdefs.h <<\EOF -#define BSD_SELECT 1 +#define XP_PC 1 EOF cat >> confdefs.h <<\EOF -#define XP_PC 1 +#define BSD_SELECT 1 EOF cat >> confdefs.h <<\EOF #define _PR_GLOBAL_THREADS_ONLY 1 EOF - OBJ_SUFFIX=obj LIB_SUFFIX=lib DLL_SUFFIX=dll - ASM_SUFFIX=asm - DLLTOOL='' RC=rc.exe PR_MD_ARCH_DIR=os2 PROG_SUFFIX=.exe @@ -4526,7 +4622,7 @@ EOF RESOLVE_LINK_SYMBOLS=1 # EMX/GCC build - if test "$GNU_CC"; then + if test -n "$GNU_CC"; then cat >> confdefs.h <<\EOF #define XP_OS2_EMX 1 EOF @@ -4537,29 +4633,30 @@ EOF AR=emxomfar AR_FLAGS='-p256 r $@' - CFLAGS="-Zmtd -Zomf" - HOST_CFLAGS="$CFLAGS" - CXXFLAGS="-Zmtd -Zomf" + CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll -Zmtd' + _OPTIMIZE_FLAGS="-O2 -s" + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi OS_LIBS="-lsocket -lemxio" - LD='$(CC)' IMPLIB='emximp -o' - FILTER='emxexp' - OS_DLLFLAGS='$(DSO_LDOPTS) -o $@' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS=-g - if test -n "$MOZ_DEBUG"; then - DLLFLAGS='-g' - EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@' - DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' - else - DLLFLAGS= - EXEFLAGS='-Zmtd -o $@' - DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' + FILTER='emxexp -o' + + if test -z "$EMXOMFLD_LINKER"; then + # using LINK386.EXE + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" fi - fi - + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + # Visual Age C++ build - if test "$VACPP" = "yes"; then + elif test "$VACPP" = "yes"; then cat >> confdefs.h <<\EOF #define XP_OS2_VACPP 1 EOF @@ -4576,8 +4673,10 @@ EOF #define _X86_ 1 EOF + OBJ_SUFFIX=obj AS=alp ASFLAGS='-Mb' + ASM_SUFFIX=asm AR=-ilib AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' @@ -4590,7 +4689,7 @@ EOF MKSHLIB='$(LD) $(DSO_LDOPTS)' IMPLIB='implib -nologo -noignorecase' FILTER='cppfilt -q -B -P' - _OPTIMIZE_FLAGS='/O+ /Gl+ /Gx+ /qtune=pentium /qarch=pentium' + _OPTIMIZE_FLAGS='/O+ /Gl+ /qtune=pentium /qarch=pentium' _DEBUG_FLAGS='/Ti+ ' LDFLAGS='/NOL /M /L' DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /L /NOL' @@ -4621,55 +4720,14 @@ esac if test -z "$SKIP_LIBRARY_CHECKS"; then -echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4626: checking for dlopen" >&5 -if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char dlopen(); - -int main() { -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_dlopen) || defined (__stub___dlopen) -choke me -#else -dlopen(); -#endif -; return 0; } -EOF -if { (eval echo configure:4654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_dlopen=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_dlopen=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then - echo "$ac_t""yes" 1>&6 - : -else - echo "$ac_t""no" 1>&6 - - echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4673: checking for dlopen in -ldl" >&5 +case $target in +*-darwin*) + ;; +*) + echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "configure:4731: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -4677,7 +4735,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4750: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -4702,27 +4760,59 @@ LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 +echo "configure:4767: checking for dlfcn.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:4777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 OS_LIBS="-ldl $OS_LIBS" else echo "$ac_t""no" 1>&6 fi - +else + echo "$ac_t""no" 1>&6 fi + ;; +esac + if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4720: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:4810: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -4740,7 +4830,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -4764,12 +4854,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4768: checking for $ac_func" >&5 +echo "configure:4858: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4886: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -4826,20 +4916,55 @@ if test "${enable_strip+set}" = set; then fi +case "${target_os}" in +hpux*) +if test -z "$GNU_CC"; then + + echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 +echo "configure:4925: checking for +Olit support" >&5 +if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_hpux_usable_olit_option=no + rm -f conftest* + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then + ac_cv_hpux_usable_olit_option=yes + fi + fi + rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_hpux_usable_olit_option" 1>&6 + + if test "$ac_cv_hpux_usable_olit_option" = "yes"; then + CFLAGS="$CFLAGS +Olit=all" + CXXFLAGS="$CXXFLAGS +Olit=all" + else + CFLAGS="$CFLAGS +ESlit" + CXXFLAGS="$CXXFLAGS +ESlit" + fi +fi +;; +esac + echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:4834: checking for pthread_create in -lpthreads" >&5 +echo "configure:4959: checking for pthread_create in -lpthreads" >&5 echo " #include - void *foo(void *v) { int a = 1; } + void *foo(void *v) { return v; } int main() { pthread_t t; if (!pthread_create(&t, 0, &foo, 0)) { pthread_join(t, 0); } - exit(0); + return 0; }" > dummy.c ; echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS" 1>&5; ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthreads $LDFLAGS $LIBS 2>&5; @@ -4852,16 +4977,16 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:4856: checking for pthread_create in -lpthread" >&5 +echo "configure:4981: checking for pthread_create in -lpthread" >&5 echo " #include - void *foo(void *v) { int a = 1; } + void *foo(void *v) { return v; } int main() { pthread_t t; if (!pthread_create(&t, 0, &foo, 0)) { pthread_join(t, 0); } - exit(0); + return 0; }" > dummy.c ; echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS" 1>&5; ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lpthread $LDFLAGS $LIBS 2>&5; @@ -4874,16 +4999,16 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:4878: checking for pthread_create in -lc_r" >&5 +echo "configure:5003: checking for pthread_create in -lc_r" >&5 echo " #include - void *foo(void *v) { int a = 1; } + void *foo(void *v) { return v; } int main() { pthread_t t; if (!pthread_create(&t, 0, &foo, 0)) { pthread_join(t, 0); } - exit(0); + return 0; }" > dummy.c ; echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS" 1>&5; ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc_r $LDFLAGS $LIBS 2>&5; @@ -4896,16 +5021,16 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:4900: checking for pthread_create in -lc" >&5 +echo "configure:5025: checking for pthread_create in -lc" >&5 echo " #include - void *foo(void *v) { int a = 1; } + void *foo(void *v) { return v; } int main() { pthread_t t; if (!pthread_create(&t, 0, &foo, 0)) { pthread_join(t, 0); } - exit(0); + return 0; }" > dummy.c ; echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS" 1>&5; ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -lc $LDFLAGS $LIBS 2>&5; @@ -4946,7 +5071,7 @@ if test "${with_pthreads+set}" = set; then _PTHREAD_LDFLAGS= fi else - if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then + if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then USE_PTHREADS=1 USE_USER_PTHREADS= USE_NSPR_THREADS= @@ -5024,6 +5149,8 @@ if test "${enable_ipv6+set}" = set; then enableval="$enable_ipv6" if test "$enableval" = "yes"; then USE_IPV6=1 + else + USE_IPV6= fi fi @@ -5046,14 +5173,21 @@ if test -n "$USE_PTHREADS"; then rm -f conftest* ac_cv_have_dash_pthread=no echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6 -echo "configure:5050: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5177: checking whether ${CC-cc} accepts -pthread" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then ac_cv_have_dash_pthread=yes - CFLAGS="$CFLAGS -pthread" - CXXFLAGS="$CXXFLAGS -pthread" + case "$target_os" in + freebsd*) +# Freebsd doesn't use -pthread for compiles, it uses them for linking + ;; + *) + CFLAGS="$CFLAGS -pthread" + CXXFLAGS="$CXXFLAGS -pthread" + ;; + esac fi fi rm -f conftest* @@ -5062,7 +5196,7 @@ echo "configure:5050: checking whether ${CC-cc} accepts -pthread" >&5 ac_cv_have_dash_pthreads=no if test "$ac_cv_have_dash_pthread" = "no"; then echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 -echo "configure:5066: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5200: checking whether ${CC-cc} accepts -pthreads" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then @@ -5082,7 +5216,22 @@ echo "configure:5066: checking whether ${CC-cc} accepts -pthreads" >&5 _PTHREAD_LDFLAGS= fi ;; - *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) + *-freebsd*) + cat >> confdefs.h <<\EOF +#define _REENTRANT 1 +EOF + + cat >> confdefs.h <<\EOF +#define _THREAD_SAFE 1 +EOF + + if test "$ac_cv_have_dash_pthread" = "yes"; then + _PTHREAD_LDFLAGS="-pthread" + else + _PTHREAD_LDFLAGS="-lc_r" + fi + ;; + *-openbsd*|*-bsdi*|*-netbsd*) cat >> confdefs.h <<\EOF #define _THREAD_SAFE 1 EOF @@ -5143,6 +5292,20 @@ EOF if test -n "$USE_PTHREADS"; then cat >> confdefs.h <<\EOF #define _PR_HAVE_THREADSAFE_GETHOST 1 +EOF + + fi + ;; + *) + if test -z "$USE_NSPR_THREADS"; then + cat >> confdefs.h <<\EOF +#define HAVE_POINTER_LOCALTIME_R 1 +EOF + + fi + if test -n "$USE_PTHREADS"; then + cat >> confdefs.h <<\EOF +#define _PR_HAVE_THREADSAFE_GETHOST 1 EOF fi @@ -5222,12 +5385,12 @@ EOF fi ;; -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) USE_PTHREADS= _PTHREAD_LDFLAGS= USE_USER_PTHREADS= ;; -*-netbsd*) +*-netbsd*|*-openbsd*) if test -n "$USE_NSPR_THREADS"; then cat >> confdefs.h <<\EOF #define _PR_LOCAL_THREADS_ONLY 1 @@ -5328,6 +5491,15 @@ fi RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}" +case "$target_os" in +mingw*|cygwin*|msvc*|mks*) + CC="\$(CYGWIN_WRAPPER) $CC" + CXX="\$(CYGWIN_WRAPPER) $CXX" + RC="\$(CYGWIN_WRAPPER) $RC" + ;; +esac + + @@ -5430,6 +5602,11 @@ lib/libc/Makefile lib/libc/include/Makefile lib/libc/src/Makefile lib/tests/Makefile +pkg/Makefile +pkg/linux/Makefile +pkg/solaris/Makefile +pkg/solaris/SUNWpr/Makefile +pkg/solaris/SUNWprx/Makefile pr/Makefile pr/include/Makefile pr/include/md/Makefile @@ -5620,20 +5797,19 @@ s%@build_alias@%$build_alias%g s%@build_cpu@%$build_cpu%g s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g +s%@CC@%$CC%g s%@dist_prefix@%$dist_prefix%g s%@dist_bindir@%$dist_bindir%g s%@dist_includedir@%$dist_includedir%g s%@dist_libdir@%$dist_libdir%g s%@WHOAMI@%$WHOAMI%g s%@HOST_CC@%$HOST_CC%g -s%@CC@%$CC%g s%@CXX@%$CXX%g s%@RANLIB@%$RANLIB%g s%@AR@%$AR%g s%@AS@%$AS%g s%@LD@%$LD%g s%@STRIP@%$STRIP%g -s%@DLLTOOL@%$DLLTOOL%g s%@WINDRES@%$WINDRES%g s%@CPP@%$CPP%g s%@PERL@%$PERL%g @@ -5641,6 +5817,7 @@ s%@SHELL_OVERRIDE@%$SHELL_OVERRIDE%g s%@MOZILLA_CLIENT@%$MOZILLA_CLIENT%g s%@HOST_CFLAGS@%$HOST_CFLAGS%g s%@GNU_CC@%$GNU_CC%g +s%@GCC_USE_GNU_LD@%$GCC_USE_GNU_LD%g s%@CROSS_COMPILE@%$CROSS_COMPILE%g s%@MOZ_OPTIMIZE@%$MOZ_OPTIMIZE%g s%@USE_CPLUS@%$USE_CPLUS%g @@ -5659,7 +5836,7 @@ s%@LIBNSPR@%$LIBNSPR%g s%@LIBPLC@%$LIBPLC%g s%@MOD_MAJOR_VERSION@%$MOD_MAJOR_VERSION%g s%@MOD_MINOR_VERSION@%$MOD_MINOR_VERSION%g -s%@MOD_REVISION_VERSION@%$MOD_REVISION_VERSION%g +s%@MOD_PATCH_VERSION@%$MOD_PATCH_VERSION%g s%@NSPR_MODNAME@%$NSPR_MODNAME%g s%@MDCPUCFG_H@%$MDCPUCFG_H%g s%@PR_MD_CSRCS@%$PR_MD_CSRCS%g @@ -5677,6 +5854,7 @@ s%@OS_TARGET@%$OS_TARGET%g s%@OS_ARCH@%$OS_ARCH%g s%@OS_RELEASE@%$OS_RELEASE%g s%@OS_TEST@%$OS_TEST%g +s%@MACOS_DEPLOYMENT_TARGET@%$MACOS_DEPLOYMENT_TARGET%g s%@DEFINES@%$DEFINES%g s%@AR_FLAGS@%$AR_FLAGS%g s%@ASFLAGS@%$ASFLAGS%g @@ -5688,16 +5866,17 @@ s%@AIX_LINK_OPTS@%$AIX_LINK_OPTS%g s%@NOSUCHFILE@%$NOSUCHFILE%g s%@MOZ_OBJFORMAT@%$MOZ_OBJFORMAT%g s%@ULTRASPARC_LIBRARY@%$ULTRASPARC_LIBRARY%g -s%@ULTRASPARC_FILTER_LIBRARY@%$ULTRASPARC_FILTER_LIBRARY%g s%@OBJDIR@%$OBJDIR%g s%@OBJDIR_NAME@%$OBJDIR_NAME%g s%@RELEASE_OBJDIR_NAME@%$RELEASE_OBJDIR_NAME%g s%@NSINSTALL@%$NSINSTALL%g s%@OPTIMIZER@%$OPTIMIZER%g s%@RC@%$RC%g +s%@RCFLAGS@%$RCFLAGS%g s%@DLLFLAGS@%$DLLFLAGS%g s%@EXEFLAGS@%$EXEFLAGS%g s%@OS_DLLFLAGS@%$OS_DLLFLAGS%g +s%@CYGWIN_WRAPPER@%$CYGWIN_WRAPPER%g CEOF EOF diff --git a/configure.in b/configure.in index 462e62e0..f4cc9e0e 100644 --- a/configure.in +++ b/configure.in @@ -43,8 +43,8 @@ dnl ======================================================== dnl = Defaults dnl ======================================================== MOD_MAJOR_VERSION=4 -MOD_MINOR_VERSION=2 -MOD_REVISION_VERSION=0 +MOD_MINOR_VERSION=3 +MOD_PATCH_VERSION=0 NSPR_MODNAME=nspr20 _HAVE_PTHREADS= USE_PTHREADS= @@ -55,6 +55,7 @@ USE_64= USE_CPLUS= USE_IPV6= USE_MDUPDATE= +MACOS_DEPLOYMENT_TARGET= _OPTIMIZE_FLAGS=-O _DEBUG_FLAGS=-g MOZ_DEBUG=1 @@ -66,6 +67,7 @@ NSINSTALL='$(MOD_DEPTH)/config/$(OBJDIR_NAME)/nsinstall' NOSUCHFILE=/no-such-file LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)' LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)' +CYGWIN_WRAPPER= dnl Link in libraries necessary to resolve all symbols for shared libs RESOLVE_LINK_SYMBOLS= @@ -84,16 +86,18 @@ HOST_CFLAGS="${HOST_CFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" case "$target" in -*-cygwin*) +*-cygwin*|*-mingw*) # Check to see if we are really running in a msvc environemnt _WIN32_MSVC= - if test "$CC" = "cl" || test "$CXX" = "cl"; then - _WIN32_MSVC=1 - elif test -z "$CC"; then + AC_CHECK_PROGS(CC, cl) + if test "$CC" = "cl"; then echo 'main() { return 0; }' > dummy.c - cl -o dummy dummy.c + ${CC} -o dummy dummy.c >/dev/null 2>&1 if test $? = 0; then _WIN32_MSVC=1 + CXX=$CC + else + AC_MSG_WARN([$(CC) test failed. Using normal feature tests]) fi rm -f dummy dummy.o dummy.obj dummy.exe dummy.c fi @@ -101,7 +105,7 @@ case "$target" in *-msvc*) _WIN32_MSVC=1 ;; -*-mksnt*) +*-mks*) _WIN32_MSVC=1 ;; esac @@ -212,6 +216,12 @@ AC_ARG_ENABLE(mdupdate, USE_MDUPDATE=1 fi ]) +AC_ARG_ENABLE(macos-target, + [ --enable-macos-target=VER (default=10.1) + Set the minimum MacOS version needed at runtime], + [MACOS_DEPLOYMENT_TARGET_STR=$enableval], + [MACOS_DEPLOYMENT_TARGET_STR=10.1]) + dnl ======================================================== dnl = dnl = Set the threading model @@ -256,6 +266,10 @@ if test -z "$CC"; then CC=cc ;; + *-openvms*) + CC=cc + ;; + *-osf*) CC=cc ;; @@ -301,6 +315,10 @@ if test -z "$CXX"; then CXX=CC ;; + *-openvms*) + CXX=cxx + ;; + *-osf*) CXX=cxx ;; @@ -314,14 +332,23 @@ fi if test -z "$SKIP_PATH_CHECKS"; then AC_PATH_PROG(WHOAMI, $WHOAMI whoami, echo not_whoami) -elif test -z "$WHOAMI"; then - WHOAMI=whoami fi if test -n "$MOZ_DEBUG"; then AC_DEFINE(DEBUG) - AC_DEFINE_UNQUOTED(DEBUG_`$WHOAMI`) DEFINES="$DEFINES -UNDEBUG" + + case "${target_os}" in + beos*) + DEFINES="$DEFINES -DDEBUG_${USER}" + ;; + msvc*|mks*|cygwin*|mingw*|os2*) + DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" + ;; + *) + DEFINES="$DEFINES -DDEBUG_`$WHOAMI`" + ;; + esac else AC_DEFINE(NDEBUG) DEFINES="$DEFINES -UDEBUG" @@ -392,9 +419,6 @@ if test "$target" != "$host"; then if test -z "$STRIP"; then AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", echo) fi - if test -z "$DLLTOOL"; then - AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", echo) - fi if test -z "$WINDRES"; then AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", echo) fi @@ -412,7 +436,6 @@ else AC_PATH_PROGS(AR, ar, echo not_ar) AC_PATH_PROGS(LD, ld link, echo not_ld) AC_PATH_PROGS(STRIP, strip, echo not_strip) - AC_PATH_PROGS(DLLTOOL, dlltool, echo not_dlltool) AC_PATH_PROGS(WINDRES, windres, echo not_windres) if test -z "$HOST_CC"; then HOST_CC="$CC" @@ -428,7 +451,7 @@ fi if test "$GXX" = "yes"; then GNU_CXX=1 fi -if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then GNU_AS=1 fi rm -f a.out @@ -445,7 +468,7 @@ dnl ======================================================== AC_MSG_CHECKING([for gcc -pipe support]) if test -n "$GNU_CC" && test -n "$GNU_CXX" && test -n "$GNU_AS"; then echo '#include ' > dummy-hello.c - echo 'int main() { printf("Hello World\n"); exit(0); }' >> dummy-hello.c + echo 'int main() { printf("Hello World\n"); return 0; }' >> dummy-hello.c ${CC} -S dummy-hello.c -o dummy-hello.s 2>&5 cat dummy-hello.s | ${AS} -o dummy-hello.S - 2>&5 if test $? = 0; then @@ -509,12 +532,21 @@ if test "$OS_ARCH" = "IRIX64"; then OS_ARCH=IRIX fi +if test "$OS_ARCH" = "AIX"; then + OS_RELEASE=`uname -v`.`uname -r` +fi + +if test "$OS_ARCH" = "FreeBSD"; then + OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` +fi + if test "$OS_ARCH" = "Linux"; then OS_RELEASE=`echo $OS_RELEASE | sed 's/-.*//'` + OS_RELEASE=`echo $OS_RELEASE | awk -F\. '{ print $1 "." $2 }'` fi -if test "$OS_ARCH" = "POSIX_for_OpenVMS_AXP"; then - OS_ARCH=OpenVMS +if test "$OS_ARCH" = "OpenVMS"; then + OS_RELEASE=`uname -v` fi ####################################################################### @@ -552,10 +584,7 @@ elif test "$OS_ARCH" = 'Windows_95'; then elif test "$OS_ARCH" = 'Windows_98'; then OS_ARCH=Windows_NT OS_TARGET=WIN95 -elif test "$OS_ARCH" = "CYGWIN_95-4.0"; then - OS_ARCH='CYGWIN_NT-4.0' - OS_TARGET=WIN95 -elif test "$OS_ARCH" = "CYGWIN_98-4.10"; then +elif test "`echo $OS_ARCH | egrep -c '^(CYGWIN_9|CYGWIN_ME)' 2>/dev/null`" != 0; then OS_ARCH='CYGWIN_NT-4.0' OS_TARGET=WIN95 elif test "$OS_ARCH" = "OS_2"; then @@ -647,7 +676,7 @@ dnl ======================================================== dnl Override of system specific host options dnl ======================================================== case "$host" in -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) ;; *-beos*) HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE" @@ -695,7 +724,7 @@ case "$target" in aix4.3*) AC_DEFINE(AIX_TIMERS) AC_DEFINE(_PR_HAVE_OFF64_T) - AC_DEFINE(AIX4_3) + AC_DEFINE(AIX4_3_PLUS) AC_DEFINE(HAVE_SOCKLEN_T) AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) USE_IPV6=1 @@ -704,6 +733,7 @@ case "$target" in *) AC_DEFINE(AIX_TIMERS) AC_DEFINE(_PR_HAVE_OFF64_T) + AC_DEFINE(AIX4_3_PLUS) AC_DEFINE(HAVE_SOCKLEN_T) AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) USE_IPV6=1 @@ -720,11 +750,7 @@ case "$target" in MDCPUCFG_H=_aix64.cfg OBJECT_MODE=64 else - if test -n "$USE_IPV6"; then - MDCPUCFG_H=_aix32in6.cfg - else - MDCPUCFG_H=_aix32.cfg - fi + MDCPUCFG_H=_aix32.cfg fi PR_MD_CSRCS=aix.c RESOLVE_LINK_SYMBOLS=1 @@ -741,10 +767,11 @@ case "$target" in PR_MD_ARCH_DIR=beos RESOLVE_LINK_SYMBOLS=1 case "${target_cpu}" in - i?86) + 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 @@ -795,7 +822,7 @@ case "$target" in PR_MD_ASFILES=os_BSD_OS_386_2.s ;; - bsdi4.*) + bsdi4.* | bsdi5.*) AC_DEFINE(_PR_SELECT_CONST_TIMEVAL) AC_DEFINE(_PR_BSDI_JMPBUF_IS_STRUCT) AC_DEFINE(HAVE_DLL) @@ -806,7 +833,7 @@ case "$target" in DSO_LDOPTS='-shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so)' STRIP="$STRIP -d" case "$target_os" in - bsdi4.2*) + bsdi4.2* | bsdi4.3* | bsdi5.*) AC_DEFINE(_PR_HAVE_GETPROTO_R) AC_DEFINE(_PR_HAVE_GETPROTO_R_POINTER) ;; @@ -829,7 +856,6 @@ case "$target" in AC_DEFINE(HAVE_BSD_FLOCK) CFLAGS="$CFLAGS -Wmost -fno-common" if echo $OS_TEST | grep -c 86 2>/dev/null; then - CFLAGS="$CFLAGS -mno-486" AC_DEFINE(i386) CPU_ARCH=i386 else @@ -845,6 +871,31 @@ case "$target" in USE_PTHREADS=1 MDCPUCFG_H=_darwin.cfg PR_MD_CSRCS=darwin.c + if test "$CPU_ARCH" = "ppc"; then + PR_MD_ASFILES=os_Darwin_ppc.s + fi + + # Add Mac OS X support for loading CFM & CFBundle plugins + if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then + AC_DEFINE(XP_MACOSX) + OS_TARGET=MacOSX + + dnl The C preprocessor can only handle integers in comparisons, so + dnl convert the version to the form AABBCC where AA=major release, + dnl BB=minor release, and CC=point/micro release. + + MACOS_VERSION_MAJOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 1` + MACOS_VERSION_MINOR=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 2` + MACOS_VERSION_MICRO=`echo $MACOS_DEPLOYMENT_TARGET_STR | cut -d . -f 3` + if test -z "$MACOS_VERSION_MINOR"; then + MACOS_VERSION_MINOR=0 + fi + if test -z "$MACOS_VERSION_MICRO"; then + MACOS_VERSION_MICRO=0 + fi + MACOS_DEPLOYMENT_TARGET=`printf "%02d%02d%02d" "$MACOS_VERSION_MAJOR" "$MACOS_VERSION_MINOR" "$MACOS_VERSION_MICRO"` + AC_DEFINE_UNQUOTED(MACOS_DEPLOYMENT_TARGET, $MACOS_DEPLOYMENT_TARGET) + fi ;; *-dgux*) @@ -876,8 +927,9 @@ case "$target" in else DLL_SUFFIX=so.1.0 fi + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' DSO_CFLAGS=-fPIC - DSO_LDOPTS=-Bshareable + DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' MDCPUCFG_H=_freebsd.cfg PR_MD_CSRCS=freebsd.c ;; @@ -887,10 +939,18 @@ case "$target" in AC_DEFINE(HPUX) AC_DEFINE(_HPUX_SOURCE) AC_DEFINE(hppa) + # OSF1 and HPUX report the POLLHUP event for a socket when the + # shutdown(SHUT_WR) operation is called for the remote end, even though + # the socket is still writeable. Use select(), instead of poll(), to + # workaround this problem. + AC_DEFINE(_PR_POLL_WITH_SELECT) + AC_DEFINE(_USE_BIG_FDS) DLL_SUFFIX=sl DSO_LDOPTS='-b +h $(notdir $@)' PR_MD_CSRCS=hpux.c - PR_MD_ASFILES=os_HPUX.s + if test "$OS_TEST" != "ia64"; then + PR_MD_ASFILES=os_HPUX.s + fi if test -n "$USE_64"; then MDCPUCFG_H=_hpux64.cfg else @@ -899,8 +959,6 @@ case "$target" in if test -z "$GNU_CC"; then CC="$CC -Ae" CXX="$CXX -ext" - CFLAGS="$CFLAGS +ESlit" - CXXFLAGS="$CXXFLAGS +ESlit" DSO_CFLAGS=+Z else DSO_CFLAGS=-fPIC @@ -929,10 +987,19 @@ case "$target" in AC_DEFINE(HAVE_INT_LOCALTIME_R) fi - if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11.00|B.11.11)' >/dev/null; then + if echo "$OS_RELEASE" | egrep '^(B.10.30|B.11)' >/dev/null; then AC_DEFINE(HAVE_POINTER_LOCALTIME_R) fi + # HP-UX 11i (B.11.11) or higher + changequote(<<,>>) + case "$OS_RELEASE" in + [C-Z]*|B.[2-9]*|B.1[2-9]*|B.11.[2-9]*|B.11.1[1-9]*) + USE_IPV6=1 + ;; + esac + changequote([,]) + if test "$OS_RELEASE" = "B.10.01"; then AC_DEFINE(HPUX10) DEFAULT_IMPL_STRATEGY=_EMU @@ -964,7 +1031,7 @@ case "$target" in DEFAULT_IMPL_STRATEGY=_PTH fi - if echo "$OS_RELEASE" | egrep '^(B.11.00|B.11.11)' >/dev/null; then + if echo "$OS_RELEASE" | grep ^B.11 >/dev/null; then AC_DEFINE(HPUX10) AC_DEFINE(HPUX11) AC_DEFINE(_LARGEFILE64_SOURCE) @@ -972,11 +1039,21 @@ case "$target" in AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) if test -z "$GNU_CC"; then if test -z "$USE_64"; then - CFLAGS="$CFLAGS +DAportable +DS2.0" - CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + if test "$OS_TEST" = "ia64"; then + CFLAGS="$CFLAGS +DD32" + CXXFLAGS="$CXXFLAGS +DD32" + else + CFLAGS="$CFLAGS +DAportable +DS2.0" + CXXFLAGS="$CXXFLAGS +DAportable +DS2.0" + fi else - CFLAGS="$CFLAGS +DA2.0W +DS2.0" - CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + if test "$OS_TEST" = "ia64"; then + CFLAGS="$CFLAGS +DD64" + CXXFLAGS="$CXXFLAGS +DD64" + else + CFLAGS="$CFLAGS +DA2.0W +DS2.0" + CXXFLAGS="$CXXFLAGS +DA2.0W +DS2.0" + fi fi fi DEFAULT_IMPL_STRATEGY=_PTH @@ -1056,7 +1133,7 @@ case "$target" in if test "$USE_MDUPDATE"; then CFLAGS="$CFLAGS -MDupdate \$(DEPENDENCIES)" fi - case "$target}" in + case "${target}" in *-irix6.*) CFLAGS="$CFLAGS -multigot" DSO_LDOPTS="-no_unresolved" @@ -1108,7 +1185,6 @@ case "$target" in AC_DEFINE(_LARGEFILE64_SOURCE) AC_DEFINE(HAVE_FCNTL_FILE_LOCKING) AC_DEFINE(LINUX) - AC_DEFINE(linux) CFLAGS="$CFLAGS -ansi -Wall" CXXFLAGS="$CXXFLAGS -ansi -Wall" MDCPUCFG_H=_linux.cfg @@ -1116,8 +1192,11 @@ case "$target" in MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' DSO_CFLAGS=-fPIC DSO_LDOPTS='-shared -Wl,-soname -Wl,$(notdir $@)' - OS_LIBS="$OS_LIBS -lc" _OPTIMIZE_FLAGS=-O2 + _DEBUG_FLAGS="-g -fno-inline" # most people on linux use gcc/gdb, and that + # combo is not yet good at debugging inlined + # functions (even when using DWARF2 as the + # debugging format) COMPILER_TAG=_glibc if echo "$OS_TEST" | grep -c 86 >/dev/null; then CPU_ARCH=x86 @@ -1132,7 +1211,7 @@ case "$target" in CFLAGS="$CFLAGS -mieee" CXXFLAGS="$CXXFLAGS -mieee" ;; - i?86) + i*86) AC_DEFINE(i386) PR_MD_ASFILES=os_Linux_x86.s ;; @@ -1140,27 +1219,29 @@ case "$target" in PR_MD_ASFILES=os_Linux_ia64.s ;; m68k) - CFLAGS="$CFLAGS -m68020-40" - CXXFLAGS="$CXXFLAGS -m68020-40" - # - # gcc on Linux/m68k either has a bug or triggers a code-sequence - # bug in the 68060 which causes gcc to crash. The simplest way to - # avoid this is to enable a minimum level of optimization. - # - _DEBUG_FLAGS="$_DEBUG_FLAGS -O" + CFLAGS="$CFLAGS -m68020-60" + CXXFLAGS="$CXXFLAGS -m68020-60" ;; esac ;; -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) AC_DEFINE(XP_PC) AC_DEFINE(WIN32) PR_MD_ARCH_DIR=windows RESOLVE_LINK_SYMBOLS=1 + NSINSTALL='$(CYGWIN_WRAPPER) nsinstall' + if test `echo "${PATH}" | grep -c \;` = 0; then + CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper' + fi if test -n "$GNU_CC"; then - AC_DEFINE(NONAMELESSUNION) - MKSHLIB='$(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib $@' + CC="$CC -mno-cygwin" + CXX="$CXX -mno-cygwin" + DLL_SUFFIX=dll + MKSHLIB='$(CC) -shared -Wl,--export-all-symbols -Wl,--out-implib -Wl,$(IMPORT_LIBRARY) $(DLLBASE) -o $(subst $(OBJDIR)/,,$(SHARED_LIBRARY))' + RC=$WINDRES + RCFLAGS='-O coff' else CC=cl CXX=cl @@ -1169,12 +1250,11 @@ case "$target" in AR_FLAGS= RANLIB='echo not_ranlib' STRIP='echo not_strip' - NSINSTALL=nsinstall RC=rc.exe GARBAGE='$(OBJDIR)/vc20.pdb $(OBJDIR)/vc40.pdb' - OBJ_SUFFIX=obj - LIB_SUFFIX=lib - DLL_SUFFIX=dll + OBJ_SUFFIX=obj + LIB_SUFFIX=lib + DLL_SUFFIX=dll CFLAGS="$CFLAGS -W3 -nologo -GF -Gy" @@ -1234,6 +1314,8 @@ case "$target" in AC_DEFINE(WINNT) else AC_DEFINE(WIN95) + # undefine WINNT as some versions of mingw gcc define it by default + DEFINES="$DEFINES -UWINNT" AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) fi @@ -1265,7 +1347,7 @@ case "$target" in esac case "$target_cpu" in - i?86) + i*86) AC_DEFINE(_X86_) ;; alpha) @@ -1419,23 +1501,17 @@ mips-sony-newsos*) *-openvms*) AC_DEFINE(XP_UNIX) AC_DEFINE(VMS) - AC_DEFINE(VMS_AS_IS) - AC_DEFINE(_SOCKADDR_LEN) - AC_DEFINE(GENERIC_PTHREAD_REDEFINES) + AC_DEFINE(PR_GETIPNODE_NOT_THREADSAFE) RESOLVE_LINK_SYMBOLS=1 - CROSS_COMPILE=1 - _HAVE_PTHREADS=1 - HOST_CC=c89 - HOST_CXX=cxx - HOST_CFLAGS=-O - HOST_CXXFLAGS=-O - CC=ccc - CXX=ccc - CFLAGS="$CFLAGS -Wc,names=\(short,as\)" - CXXFLAGS="$CXXFLAGS -Wc,names=\(short,as\)" + AR_FLAGS='c $@' MDCPUCFG_H=_openvms.cfg PR_MD_CSRCS=openvms.c - MKSHLIB='vmsld $(OPTIMIZER)' + DSO_LDOPTS='-shared -auto_symvec $(LDFLAGS)' + if test -n "$MOZ_DEBUG"; then + DSO_LDOPTS="$DSO_LDOPTS $_DEBUG_FLAGS" + else + DSO_LDOPTS="$DSO_LDOPTS $_OPTIMIZE_FLAGS" + fi ;; *-osf*) @@ -1443,7 +1519,11 @@ mips-sony-newsos*) AC_DEFINE(XP_UNIX) AC_DEFINE(OSF1) AC_DEFINE(_REENTRANT) - AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)) + # OSF1 and HPUX report the POLLHUP event for a socket when the + # shutdown(SHUT_WR) operation is called for the remote end, even though + # the socket is still writeable. Use select(), instead of poll(), to + # workaround this problem. + AC_DEFINE(_PR_POLL_WITH_SELECT) if echo "$OS_RELEASE" | egrep -c '(V2.0|V3.2)' 2>/dev/null ; then USE_NSPR_THREADS=1 @@ -1455,6 +1535,10 @@ mips-sony-newsos*) CC="$CC -readonly_strings" fi _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" + AC_CHECK_HEADER(machine/builtins.h, AC_DEFINE(OSF1_HAVE_MACHINE_BUILTINS_H)) + else + CFLAGS="$CFLAGS -mieee" + CXXFLAGS="$CXXFLAGS -mieee" fi if echo $OS_RELEASE | egrep -c '(V2.0|V3.2)' 2>/dev/null; then @@ -1573,11 +1657,18 @@ mips-sony-newsos*) MDCPUCFG_H=_solaris32.cfg fi PR_MD_CSRCS=solaris.c - DSO_LDOPTS='-G -h $(notdir $@)' + LD=/usr/ccs/bin/ld + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + RESOLVE_LINK_SYMBOLS=1 if test -n "$GNU_CC"; then DSO_CFLAGS=-fPIC + if `$CC -print-prog-name=ld` -v 2>&1 | grep -c GNU >/dev/null; then + GCC_USE_GNU_LD=1 + fi + DSO_LDOPTS='-shared -Wl,-h,$(notdir $@),-z,combreloc,-z,defs' else DSO_CFLAGS=-KPIC + DSO_LDOPTS='-G -h $(notdir $@) -z combreloc -z defs' fi if test -z "$GNU_AS"; then ASFLAGS="$ASFLAGS -Wa,-P" @@ -1590,12 +1681,13 @@ mips-sony-newsos*) CXXFLAGS="$CXXFLAGS -MDupdate \$(DEPENDENCIES)" fi else - CC="$CC -xstrconst" - CXX="$CXX -Qoption cg -xstrconst" + CFLAGS="$CFLAGS -xstrconst" + CXXFLAGS="$CXXFLAGS -Qoption cg -xstrconst" if test -z "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS -xs" CXXFLAGS="$CXXFLAGS -xs" fi + _OPTIMIZE_FLAGS=-xO4 fi if test -n "$USE_64" && test -z "$GNU_CC"; then CC="$CC -xarch=v9" @@ -1643,11 +1735,14 @@ mips-sony-newsos*) # 64-bit Solaris requires SPARC V9 architecture, so the following # is not needed. if test -z "$USE_64"; then - ULTRASPARC_LIBRARY=ultrasparc - ULTRASPARC_FILTER_LIBRARY=libatomic.so - DSO_LDOPTS="$DSO_LDOPTS -f "'$(ULTRASPARC_FILTER_LIBRARY)' + ULTRASPARC_LIBRARY=nspr_flt fi fi + # Purify requires that binaries linked against nspr also + # be linked against -lrt (or -lposix4) so add it to OS_LIBS + _rev=`uname -r` + _librt=`echo $_rev 5.6 | awk '{ if ($1 > $2) print "-lrt"; else print "-lposix4" }'` + OS_LIBS="$OS_LIBS $_librt" ;; *-sco-sysv5*) @@ -1674,14 +1769,11 @@ mips-sony-newsos*) *-os2*) AC_DEFINE(XP_OS2) - AC_DEFINE(BSD_SELECT) AC_DEFINE(XP_PC) + AC_DEFINE(BSD_SELECT) AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) - OBJ_SUFFIX=obj LIB_SUFFIX=lib DLL_SUFFIX=dll - ASM_SUFFIX=asm - DLLTOOL='' RC=rc.exe PR_MD_ARCH_DIR=os2 PROG_SUFFIX=.exe @@ -1690,40 +1782,43 @@ mips-sony-newsos*) RESOLVE_LINK_SYMBOLS=1 # EMX/GCC build - if test "$GNU_CC"; then + if test -n "$GNU_CC"; then AC_DEFINE(XP_OS2_EMX) AC_DEFINE(OS2) AR=emxomfar AR_FLAGS='-p256 r $@' - CFLAGS="-Zmtd -Zomf" - HOST_CFLAGS="$CFLAGS" - CXXFLAGS="-Zmtd -Zomf" + CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll -Zmtd' + _OPTIMIZE_FLAGS="-O2 -s" + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi OS_LIBS="-lsocket -lemxio" - LD='$(CC)' IMPLIB='emximp -o' - FILTER='emxexp' - OS_DLLFLAGS='$(DSO_LDOPTS) -o $@' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS=-g - if test -n "$MOZ_DEBUG"; then - DLLFLAGS='-g' - EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@' - DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' - else - DLLFLAGS= - EXEFLAGS='-Zmtd -o $@' - DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' + FILTER='emxexp -o' + + if test -z "$EMXOMFLD_LINKER"; then + # using LINK386.EXE + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" fi - fi - + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + # Visual Age C++ build - if test "$VACPP" = "yes"; then + elif test "$VACPP" = "yes"; then AC_DEFINE(XP_OS2_VACPP) AC_DEFINE(OS2,4) AC_DEFINE(TCPV40HDRS) AC_DEFINE(_X86_) + OBJ_SUFFIX=obj AS=alp ASFLAGS='-Mb' + ASM_SUFFIX=asm AR=-ilib AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' @@ -1736,7 +1831,7 @@ mips-sony-newsos*) MKSHLIB='$(LD) $(DSO_LDOPTS)' IMPLIB='implib -nologo -noignorecase' FILTER='cppfilt -q -B -P' - _OPTIMIZE_FLAGS='/O+ /Gl+ /Gx+ /qtune=pentium /qarch=pentium' + _OPTIMIZE_FLAGS='/O+ /Gl+ /qtune=pentium /qarch=pentium' _DEBUG_FLAGS='/Ti+ ' LDFLAGS='/NOL /M /L' DLLFLAGS='/O:$@ /DLL /INC:_dllentry /MAP:$(@:.dll=.map) /L /NOL' @@ -1790,9 +1885,20 @@ dnl AC_CHECK_LIB(svld, main) dnl AC_CHECK_LIB(thread, main) dnl AC_CHECK_LIB(vms_jackets, main) -AC_CHECK_FUNC(dlopen,,[ - AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"]) -]) + +dnl We don't want anything to link with libdl even if it's present on OS X, +dnl since it's not used and not part of the default installation. + +case $target in +*-darwin*) + ;; +*) + AC_CHECK_LIB(dl, dlopen, + AC_CHECK_HEADER(dlfcn.h, + OS_LIBS="-ldl $OS_LIBS")) + ;; +esac + dnl ======================================================== dnl Check for system header files. @@ -1847,6 +1953,38 @@ AC_ARG_ENABLE(strip, [ --enable-strip Enable stripping of shared libs and programs], [ ENABLE_STRIP=1 ]) +dnl Check for hpux options +case "${target_os}" in +hpux*) +if test -z "$GNU_CC"; then + + AC_CACHE_CHECK(for +Olit support, + ac_cv_hpux_usable_olit_option, + dnl since aCC doesn't throw an error on invalid options, + dnl we have to test this the hard way + [ac_cv_hpux_usable_olit_option=no + rm -f conftest* + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out`"; then + ac_cv_hpux_usable_olit_option=yes + fi + fi + rm -f conftest* + ]) + + if test "$ac_cv_hpux_usable_olit_option" = "yes"; then + CFLAGS="$CFLAGS +Olit=all" + CXXFLAGS="$CXXFLAGS +Olit=all" + else + CFLAGS="$CFLAGS +ESlit" + CXXFLAGS="$CXXFLAGS +ESlit" + fi +fi +;; +esac + dnl dnl Apparently, some systems cannot properly check for the pthread dnl library unless is included so we need to test @@ -1858,13 +1996,13 @@ AC_DEFUN(MOZ_CHECK_PTHREADS, AC_MSG_CHECKING([for pthread_create in -l$1]) echo " #include - void *foo(void *v) { int a = 1; } + void *foo(void *v) { return v; } int main() { pthread_t t; if (!pthread_create(&t, 0, &foo, 0)) { pthread_join(t, 0); } - exit(0); + return 0; }" > dummy.c ; echo "${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS" 1>&5; ${CC-cc} -o dummy${ac_exeext} dummy.c $CFLAGS $CPPFLAGS -l[$1] $LDFLAGS $LIBS 2>&5; @@ -1906,7 +2044,7 @@ AC_ARG_WITH(pthreads, USE_PTHREADS= _PTHREAD_LDFLAGS= fi], - [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USER_NSPR_THREADS"; then + [ if test -n "$_HAVE_PTHREADS" && test -z "$USE_USER_PTHREADS" && test -z "$USE_NSPR_THREADS"; then USE_PTHREADS=1 USE_USER_PTHREADS= USE_NSPR_THREADS= @@ -1966,6 +2104,8 @@ AC_ARG_ENABLE(ipv6, [ --enable-ipv6 Compile ipv6 support], [ if test "$enableval" = "yes"; then USE_IPV6=1 + else + USE_IPV6= fi]) @@ -1986,8 +2126,15 @@ if test -n "$USE_PTHREADS"; then if test $? -eq 0; then if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then ac_cv_have_dash_pthread=yes - CFLAGS="$CFLAGS -pthread" - CXXFLAGS="$CXXFLAGS -pthread" + case "$target_os" in + freebsd*) +# Freebsd doesn't use -pthread for compiles, it uses them for linking + ;; + *) + CFLAGS="$CFLAGS -pthread" + CXXFLAGS="$CXXFLAGS -pthread" + ;; + esac fi fi rm -f conftest* @@ -2018,7 +2165,17 @@ if test -n "$USE_PTHREADS"; then _PTHREAD_LDFLAGS= fi ;; - *-freebsd*|*-openbsd*|*-bsdi*|*-netbsd*) + *-freebsd*) + AC_DEFINE(_REENTRANT) + AC_DEFINE(_THREAD_SAFE) + dnl -pthread links in -lc_r, so don't specify it explicitly. + if test "$ac_cv_have_dash_pthread" = "yes"; then + _PTHREAD_LDFLAGS="-pthread" + else + _PTHREAD_LDFLAGS="-lc_r" + fi + ;; + *-openbsd*|*-bsdi*|*-netbsd*) AC_DEFINE(_THREAD_SAFE) dnl -pthread links in -lc_r, so don't specify it explicitly. if test "$ac_cv_have_dash_pthread" = "yes"; then @@ -2064,6 +2221,14 @@ case "$target" in AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) fi ;; + *) + if test -z "$USE_NSPR_THREADS"; then + AC_DEFINE(HAVE_POINTER_LOCALTIME_R) + fi + if test -n "$USE_PTHREADS"; then + AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST) + fi + ;; esac ;; *-bsdi*) @@ -2106,13 +2271,13 @@ case "$target" in AC_DEFINE(_PR_LOCAL_THREADS_ONLY) fi ;; -*-mingw*|*-cygwin*|*-msvc*|*-mksnt*) +*-mingw*|*-cygwin*|*-msvc*|*-mks*) dnl win32 does not use pthreads USE_PTHREADS= _PTHREAD_LDFLAGS= USE_USER_PTHREADS= ;; -*-netbsd*) +*-netbsd*|*-openbsd*) if test -n "$USE_NSPR_THREADS"; then AC_DEFINE(_PR_LOCAL_THREADS_ONLY) fi @@ -2188,6 +2353,17 @@ fi RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}" +dnl ======================================================== +dnl Use cygwin wrapper for win32 builds +dnl ======================================================== +case "$target_os" in +mingw*|cygwin*|msvc*|mks*) + CC="\$(CYGWIN_WRAPPER) $CC" + CXX="\$(CYGWIN_WRAPPER) $CXX" + RC="\$(CYGWIN_WRAPPER) $RC" + ;; +esac + dnl ======================================================== dnl Substitution of found variables. dnl ======================================================== @@ -2203,6 +2379,7 @@ AC_SUBST(HOST_CC) AC_SUBST(HOST_CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(GNU_CC) +AC_SUBST(GCC_USE_GNU_LD) AC_SUBST(CROSS_COMPILE) AC_SUBST(MOZ_OPTIMIZE) @@ -2226,7 +2403,7 @@ AC_SUBST(LIBPLC) AC_SUBST(MOD_MAJOR_VERSION) AC_SUBST(MOD_MINOR_VERSION) -AC_SUBST(MOD_REVISION_VERSION) +AC_SUBST(MOD_PATCH_VERSION) AC_SUBST(NSPR_MODNAME) AC_SUBST(MDCPUCFG_H) AC_SUBST(PR_MD_CSRCS) @@ -2246,6 +2423,7 @@ AC_SUBST(OS_TARGET) AC_SUBST(OS_ARCH) AC_SUBST(OS_RELEASE) AC_SUBST(OS_TEST) +AC_SUBST(MACOS_DEPLOYMENT_TARGET) AC_SUBST(DEFINES) AC_SUBST(DEFS) @@ -2254,8 +2432,6 @@ AC_SUBST(AR_FLAGS) AC_SUBST(AS) AC_SUBST(ASFLAGS) AC_SUBST(LD) -AC_SUBST(DLLTOOL) -AC_SUBST(WINDRES) AC_SUBST(RANLIB) AC_SUBST(PERL) AC_SUBST(STRIP) @@ -2268,7 +2444,6 @@ AC_SUBST(AIX_LINK_OPTS) AC_SUBST(NOSUCHFILE) AC_SUBST(MOZ_OBJFORMAT) AC_SUBST(ULTRASPARC_LIBRARY) -AC_SUBST(ULTRASPARC_FILTER_LIBRARY) AC_SUBST(OBJDIR) AC_SUBST(OBJDIR_NAME) @@ -2276,9 +2451,11 @@ AC_SUBST(RELEASE_OBJDIR_NAME) AC_SUBST(NSINSTALL) AC_SUBST(OPTIMIZER) AC_SUBST(RC) +AC_SUBST(RCFLAGS) AC_SUBST(DLLFLAGS) AC_SUBST(EXEFLAGS) AC_SUBST(OS_DLLFLAGS) +AC_SUBST(CYGWIN_WRAPPER) dnl ======================================================== dnl Generate output files. @@ -2296,6 +2473,11 @@ lib/libc/Makefile lib/libc/include/Makefile lib/libc/src/Makefile lib/tests/Makefile +pkg/Makefile +pkg/linux/Makefile +pkg/solaris/Makefile +pkg/solaris/SUNWpr/Makefile +pkg/solaris/SUNWprx/Makefile pr/Makefile pr/include/Makefile pr/include/md/Makefile diff --git a/lib/ds/Makefile.in b/lib/ds/Makefile.in index b6aa7676..4e7234fd 100644 --- a/lib/ds/Makefile.in +++ b/lib/ds/Makefile.in @@ -59,10 +59,13 @@ HEADERS = \ HEADERS := $(addprefix $(srcdir)/, $(HEADERS)) ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +DLLBASE=-Wl,--image-base -Wl,0x30000000 +else DLLBASE=/BASE:0x30000000 +endif # GCC RES=$(OBJDIR)/plds.res RESNAME=plds.rc -OS_LIBS = user32.lib endif # WINNT ifeq ($(OS_ARCH), AIX) @@ -77,6 +80,27 @@ ifeq ($(OS_ARCH),IRIX) OS_LIBS = -lc endif +ifeq ($(OS_ARCH),SunOS) +OS_LIBS = -lc +MAPFILE = $(OBJDIR)/pldsmap.sun +GARBAGE += $(MAPFILE) +ifdef NS_USE_GCC +ifdef GCC_USE_GNU_LD +MKSHLIB += -Wl,--version-script,$(MAPFILE) +else +MKSHLIB += -Wl,-M,$(MAPFILE) +endif +else +MKSHLIB += -M $(MAPFILE) +endif +endif + +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + EXTRA_LIBS = $(LIBNSPR) # On NCR and SCOOS, we can't link with extra libraries when @@ -113,7 +137,7 @@ NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now SH_DATE = $(shell date "+%Y-%m-%d %T") SH_NOW = $(shell $(NOW)) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) SUF = i64 else SUF = LL @@ -133,7 +157,7 @@ $(TINC): $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $< else ifeq ($(MOZ_OS2_TOOLS), VACPP) diff --git a/lib/ds/plarena.c b/lib/ds/plarena.c index ad541a5d..ad26f4a3 100644 --- a/lib/ds/plarena.c +++ b/lib/ds/plarena.c @@ -165,7 +165,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) do { if ( a->avail +nb <= a->limit ) { pool->current = a; - rp = (void *)a->avail; + rp = (char *)a->avail; a->avail += nb; return rp; } @@ -188,7 +188,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) p->next = a->next; UnlockArena(); a->avail = a->base; - rp = (void *)a->avail; + rp = (char *)a->avail; a->avail += nb; /* the newly allocated arena is linked after pool->current * and becomes pool->current */ @@ -211,7 +211,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb) if ( NULL != a ) { a->limit = (PRUword)a + sz; a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1); - rp = (void *)a->avail; + rp = (char *)a->avail; a->avail += nb; /* the newly allocated arena is linked after pool->current * and becomes pool->current */ @@ -339,7 +339,7 @@ PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap) #endif } -PR_IMPLEMENT(void) PL_ArenaFinish() +PR_IMPLEMENT(void) PL_ArenaFinish(void) { PLArena *a, *next; diff --git a/lib/ds/plds.def b/lib/ds/plds.def new file mode 100644 index 00000000..9e0b505a --- /dev/null +++ b/lib/ds/plds.def @@ -0,0 +1,78 @@ +;+# +;+# The contents of this file are subject to the Mozilla Public +;+# License Version 1.1 (the "License"); you may not use this file +;+# except in compliance with the License. You may obtain a copy of +;+# the License at http://www.mozilla.org/MPL/ +;+# +;+# Software distributed under the License is distributed on an "AS +;+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +;+# implied. See the License for the specific language governing +;+# rights and limitations under the License. +;+# +;+# The Original Code is the Netscape Portable Runtime (NSPR). +;+# +;+# The Initial Developer of the Original Code is Netscape +;+# Communications Corporation. Portions created by Netscape are +;+# Copyright (C) 2002-2003 Netscape Communications Corporation. All +;+# Rights Reserved. +;+# +;+# Contributor(s): +;+# +;+# Alternatively, the contents of this file may be used under the +;+# terms of the GNU General Public License Version 2 or later (the +;+# "GPL"), in which case the provisions of the GPL are applicable +;+# instead of those above. If you wish to allow use of your +;+# version of this file only under the terms of the GPL and not to +;+# allow others to use your version of this file under the MPL, +;+# indicate your decision by deleting the provisions above and +;+# replace them with the notice and other provisions required by +;+# the GPL. If you do not delete the provisions above, a recipient +;+# may use your version of this file under either the MPL or the +;+# GPL. +;+# +;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS +;+# 1. For all unix platforms, the string ";-" means "remove this line" +;+# 2. For all unix platforms, the string " DATA " will be removed from any +;+# line on which it occurs. +;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX. +;+# On AIX, lines containing ";+" will be removed. +;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed. +;+# 5. For all unix platforms, after the above processing has taken place, +;+# all characters after the first ";" on the line will be removed. +;+# And for AIX, the first ";" will also be removed. +;+# This file is passed directly to windows. Since ';' is a comment, all UNIX +;+# directives are hidden behind ";", ";+", and ";-" +;+NSPR_4.0 { +;+ global: +LIBRARY plds4 ;- +EXPORTS ;- +PL_ArenaAllocate; +PL_ArenaFinish; +PL_ArenaGrow; +PL_ArenaRelease; +PL_CompactArenaPool; +PL_CompareStrings; +PL_CompareValues; +PL_FinishArenaPool; +PL_FreeArenaPool; +PL_HashString; +PL_HashTableAdd; +PL_HashTableDestroy; +PL_HashTableDump; +PL_HashTableEnumerateEntries; +PL_HashTableLookup; +PL_HashTableRawAdd; +PL_HashTableRawLookup; +PL_HashTableRawRemove; +PL_HashTableRemove; +PL_InitArenaPool; +PL_NewHashTable; +libVersionPoint; +;+ local: *; +;+}; +;+ +;+NSPR_4.1 { +;+ global: +PL_HashTableLookupConst; +PL_HashTableRawLookupConst; +;+} NSPR_4.0; diff --git a/lib/ds/plds_symvec.opt b/lib/ds/plds_symvec.opt new file mode 100644 index 00000000..71784540 --- /dev/null +++ b/lib/ds/plds_symvec.opt @@ -0,0 +1,37 @@ +! Fixed section of symbol vector for LIBPLDS4 +! +GSMATCH=LEQUAL,2,2 +case_sensitive=YES +! +! -------------------------------------------------------------------------- +! Ident 2,2 introduced for Mozilla 1.3 +! Previously this was empty. Now we include everything that's specified in +! plds.def. +! -------------------------------------------------------------------------- +! +! NSPR 4.0 +SYMBOL_VECTOR=(PL_ArenaAllocate=PROCEDURE) +SYMBOL_VECTOR=(PL_ArenaFinish=PROCEDURE) +SYMBOL_VECTOR=(PL_ArenaGrow=PROCEDURE) +SYMBOL_VECTOR=(PL_ArenaRelease=PROCEDURE) +SYMBOL_VECTOR=(PL_CompactArenaPool=PROCEDURE) +SYMBOL_VECTOR=(PL_CompareStrings=PROCEDURE) +SYMBOL_VECTOR=(PL_CompareValues=PROCEDURE) +SYMBOL_VECTOR=(PL_FinishArenaPool=PROCEDURE) +SYMBOL_VECTOR=(PL_FreeArenaPool=PROCEDURE) +SYMBOL_VECTOR=(PL_HashString=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableAdd=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableDestroy=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableDump=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableEnumerateEntries=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableLookup=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableRawAdd=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableRawLookup=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableRawRemove=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableRemove=PROCEDURE) +SYMBOL_VECTOR=(PL_InitArenaPool=PROCEDURE) +SYMBOL_VECTOR=(PL_NewHashTable=PROCEDURE) +SYMBOL_VECTOR=(libVersionPoint=PROCEDURE) +! NSPR 4.1 +SYMBOL_VECTOR=(PL_HashTableLookupConst=PROCEDURE) +SYMBOL_VECTOR=(PL_HashTableRawLookupConst=PROCEDURE) diff --git a/lib/ds/plhash.c b/lib/ds/plhash.c index f02b5132..8cfce081 100644 --- a/lib/ds/plhash.c +++ b/lib/ds/plhash.c @@ -179,7 +179,7 @@ PL_HashTableDestroy(PLHashTable *ht) /* ** Multiplicative hash, from Knuth 6.4. */ -#define GOLDEN_RATIO 0x9E3779B9U +#define GOLDEN_RATIO 0x9E3779B9U /* 2/(1+sqrt(5))*(2^32) */ PR_IMPLEMENT(PLHashEntry **) PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key) diff --git a/lib/libc/src/Makefile.in b/lib/libc/src/Makefile.in index 2977399e..17a4dfa1 100644 --- a/lib/libc/src/Makefile.in +++ b/lib/libc/src/Makefile.in @@ -69,7 +69,11 @@ LIBRARY_VERSION = $(MOD_MAJOR_VERSION) RELEASE_LIBS = $(TARGETS) ifeq ($(OS_ARCH),WINNT) +ifdef NS_USE_GCC +DLLBASE=-Wl,--image-base -Wl,0x30000000 +else DLLBASE=/BASE:0x30000000 +endif RES=$(OBJDIR)/plc.res RESNAME=plc.rc endif # WINNT @@ -86,6 +90,27 @@ ifeq ($(OS_ARCH),IRIX) OS_LIBS = -lc endif +ifeq ($(OS_ARCH),SunOS) +OS_LIBS = -lc +MAPFILE = $(OBJDIR)/plcmap.sun +GARBAGE += $(MAPFILE) +ifdef NS_USE_GCC +ifdef GCC_USE_GNU_LD +MKSHLIB += -Wl,--version-script,$(MAPFILE) +else +MKSHLIB += -Wl,-M,$(MAPFILE) +endif +else +MKSHLIB += -M $(MAPFILE) +endif +endif + +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + EXTRA_LIBS = $(LIBNSPR) # On NCR and SCOOS, we can't link with extra libraries when @@ -115,7 +140,7 @@ NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now SH_DATE = $(shell date "+%Y-%m-%d %T") SH_NOW = $(shell $(NOW)) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) SUF = i64 else SUF = LL @@ -135,7 +160,7 @@ $(TINC): $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $< else ifeq ($(MOZ_OS2_TOOLS), VACPP) diff --git a/lib/libc/src/base64.c b/lib/libc/src/base64.c index 749965f7..00f19ab2 100644 --- a/lib/libc/src/base64.c +++ b/lib/libc/src/base64.c @@ -383,7 +383,7 @@ PL_Base64Decode srclen = PL_strlen(src); } - if( 0 == (srclen & 3) ) + if( srclen && (0 == (srclen & 3)) ) { if( (char)'=' == src[ srclen-1 ] ) { diff --git a/lib/libc/src/plc.def b/lib/libc/src/plc.def new file mode 100644 index 00000000..39eba5b7 --- /dev/null +++ b/lib/libc/src/plc.def @@ -0,0 +1,94 @@ +;+# +;+# The contents of this file are subject to the Mozilla Public +;+# License Version 1.1 (the "License"); you may not use this file +;+# except in compliance with the License. You may obtain a copy of +;+# the License at http://www.mozilla.org/MPL/ +;+# +;+# Software distributed under the License is distributed on an "AS +;+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +;+# implied. See the License for the specific language governing +;+# rights and limitations under the License. +;+# +;+# The Original Code is the Netscape Portable Runtime (NSPR). +;+# +;+# The Initial Developer of the Original Code is Netscape +;+# Communications Corporation. Portions created by Netscape are +;+# Copyright (C) 2002-2003 Netscape Communications Corporation. All +;+# Rights Reserved. +;+# +;+# Contributor(s): +;+# +;+# Alternatively, the contents of this file may be used under the +;+# terms of the GNU General Public License Version 2 or later (the +;+# "GPL"), in which case the provisions of the GPL are applicable +;+# instead of those above. If you wish to allow use of your +;+# version of this file only under the terms of the GPL and not to +;+# allow others to use your version of this file under the MPL, +;+# indicate your decision by deleting the provisions above and +;+# replace them with the notice and other provisions required by +;+# the GPL. If you do not delete the provisions above, a recipient +;+# may use your version of this file under either the MPL or the +;+# GPL. +;+# +;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS +;+# 1. For all unix platforms, the string ";-" means "remove this line" +;+# 2. For all unix platforms, the string " DATA " will be removed from any +;+# line on which it occurs. +;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX. +;+# On AIX, lines containing ";+" will be removed. +;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed. +;+# 5. For all unix platforms, after the above processing has taken place, +;+# all characters after the first ";" on the line will be removed. +;+# And for AIX, the first ";" will also be removed. +;+# This file is passed directly to windows. Since ';' is a comment, all UNIX +;+# directives are hidden behind ";", ";+", and ";-" +;+NSPR_4.0 { +;+ global: +LIBRARY plc4 ;- +EXPORTS ;- +PL_Base64Decode; +PL_Base64Encode; +PL_CreateOptState; +PL_DestroyOptState; +PL_FPrintError; +PL_GetNextOpt; +PL_PrintError; +PL_strcasecmp; +PL_strcaserstr; +PL_strcasestr; +PL_strcat; +PL_strcatn; +PL_strchr; +PL_strcmp; +PL_strcpy; +PL_strdup; +PL_strfree; +PL_strlen; +PL_strncasecmp; +PL_strncaserstr; +PL_strncasestr; +PL_strncat; +PL_strnchr; +PL_strncmp; +PL_strncpy; +PL_strncpyz; +PL_strndup; +PL_strnlen; +PL_strnpbrk; +PL_strnprbrk; +PL_strnrchr; +PL_strnrstr; +PL_strnstr; +PL_strpbrk; +PL_strprbrk; +PL_strrchr; +PL_strrstr; +PL_strstr; +libVersionPoint; +;+ local: *; +;+}; +;+ +;+NSPR_4.2 { +;+ global: +PL_strtok_r; +;+} NSPR_4.0; diff --git a/lib/libc/src/plc_symvec.opt b/lib/libc/src/plc_symvec.opt new file mode 100644 index 00000000..8bc769e0 --- /dev/null +++ b/lib/libc/src/plc_symvec.opt @@ -0,0 +1,53 @@ +! Fixed section of symbol vector for LIBPLC4 +! +GSMATCH=LEQUAL,2,2 +case_sensitive=YES +! +! -------------------------------------------------------------------------- +! Ident 2,2 introduced for Mozilla 1.3 +! Previously this was empty. Now we include everything that's specified in +! plc.def. +! -------------------------------------------------------------------------- +! +! NSPR 4.0 +SYMBOL_VECTOR=(PL_Base64Decode=PROCEDURE) +SYMBOL_VECTOR=(PL_Base64Encode=PROCEDURE) +SYMBOL_VECTOR=(PL_CreateOptState=PROCEDURE) +SYMBOL_VECTOR=(PL_DestroyOptState=PROCEDURE) +SYMBOL_VECTOR=(PL_FPrintError=PROCEDURE) +SYMBOL_VECTOR=(PL_GetNextOpt=PROCEDURE) +SYMBOL_VECTOR=(PL_PrintError=PROCEDURE) +SYMBOL_VECTOR=(PL_strcasecmp=PROCEDURE) +SYMBOL_VECTOR=(PL_strcaserstr=PROCEDURE) +SYMBOL_VECTOR=(PL_strcasestr=PROCEDURE) +SYMBOL_VECTOR=(PL_strcat=PROCEDURE) +SYMBOL_VECTOR=(PL_strcatn=PROCEDURE) +SYMBOL_VECTOR=(PL_strchr=PROCEDURE) +SYMBOL_VECTOR=(PL_strcmp=PROCEDURE) +SYMBOL_VECTOR=(PL_strcpy=PROCEDURE) +SYMBOL_VECTOR=(PL_strdup=PROCEDURE) +SYMBOL_VECTOR=(PL_strfree=PROCEDURE) +SYMBOL_VECTOR=(PL_strlen=PROCEDURE) +SYMBOL_VECTOR=(PL_strncasecmp=PROCEDURE) +SYMBOL_VECTOR=(PL_strncaserstr=PROCEDURE) +SYMBOL_VECTOR=(PL_strncasestr=PROCEDURE) +SYMBOL_VECTOR=(PL_strncat=PROCEDURE) +SYMBOL_VECTOR=(PL_strnchr=PROCEDURE) +SYMBOL_VECTOR=(PL_strncmp=PROCEDURE) +SYMBOL_VECTOR=(PL_strncpy=PROCEDURE) +SYMBOL_VECTOR=(PL_strncpyz=PROCEDURE) +SYMBOL_VECTOR=(PL_strndup=PROCEDURE) +SYMBOL_VECTOR=(PL_strnlen=PROCEDURE) +SYMBOL_VECTOR=(PL_strnpbrk=PROCEDURE) +SYMBOL_VECTOR=(PL_strnprbrk=PROCEDURE) +SYMBOL_VECTOR=(PL_strnrchr=PROCEDURE) +SYMBOL_VECTOR=(PL_strnrstr=PROCEDURE) +SYMBOL_VECTOR=(PL_strnstr=PROCEDURE) +SYMBOL_VECTOR=(PL_strpbrk=PROCEDURE) +SYMBOL_VECTOR=(PL_strprbrk=PROCEDURE) +SYMBOL_VECTOR=(PL_strrchr=PROCEDURE) +SYMBOL_VECTOR=(PL_strrstr=PROCEDURE) +SYMBOL_VECTOR=(PL_strstr=PROCEDURE) +SYMBOL_VECTOR=(libVersionPoint=PROCEDURE) +! NSPR 4.2 +SYMBOL_VECTOR=(PL_strtok_r=PROCEDURE) diff --git a/lib/libc/src/strstr.c b/lib/libc/src/strstr.c index 3f38a34f..fe658c1b 100644 --- a/lib/libc/src/strstr.c +++ b/lib/libc/src/strstr.c @@ -57,13 +57,15 @@ PL_strrstr(const char *big, const char *little) { const char *p; PRUint32 ll; + PRUint32 bl; if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; ll = PL_strlen(little); - p = &big[ PL_strlen(big) - ll ]; - if( p < big ) return (char *)0; + bl = PL_strlen(big); + if( bl < ll ) return (char *)0; + p = &big[ bl - ll ]; for( ; p >= big; p-- ) if( *little == *p ) diff --git a/lib/msgc/src/Makefile.in b/lib/msgc/src/Makefile.in index 355f1489..28a971e5 100644 --- a/lib/msgc/src/Makefile.in +++ b/lib/msgc/src/Makefile.in @@ -65,7 +65,11 @@ EXTRA_LIBS += $(OS_LIBS) endif ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +DLLBASE=-Wl,--image-base -Wl,0x30000000 +else DLLBASE=/BASE:0x30000000 +endif # GCC #RES=$(OBJDIR)/ds.res #RESNAME=$(MOD_DEPTH)/pr/src/nspr.rc #OS_LIBS = user32.lib diff --git a/macbuild/NSPR.Debug.Prefix b/macbuild/NSPR.Debug.Prefix deleted file mode 100644 index ae6233ee..00000000 --- a/macbuild/NSPR.Debug.Prefix +++ /dev/null @@ -1 +0,0 @@ -// // NSPR.Prefix // // Global prefix file for the debug NSPR project. // // #define DEBUG 1 #include "NSPRConfig.h" \ No newline at end of file diff --git a/macbuild/NSPR.Prefix b/macbuild/NSPR.Prefix deleted file mode 100644 index a3947318..00000000 --- a/macbuild/NSPR.Prefix +++ /dev/null @@ -1 +0,0 @@ -// // NSPR.Prefix // // Global prefix file for the non-debug NSPR project. // // #include "NSPRConfig.h" \ No newline at end of file diff --git a/macbuild/NSPR20.toc b/macbuild/NSPR20.toc deleted file mode 100644 index aaa20253..00000000 --- a/macbuild/NSPR20.toc +++ /dev/null @@ -1,69 +0,0 @@ -# target: NSPR20Debug.shlb -mozilla/nsprpub/lib/ds/plarena.c -mozilla/nsprpub/lib/ds/plevent.c -mozilla/nsprpub/lib/ds/plhash.c -mozilla/nsprpub/lib/libc/src/base64.c -mozilla/nsprpub/lib/libc/src/plerror.c -mozilla/nsprpub/lib/libc/src/plgetopt.c -mozilla/nsprpub/lib/libc/src/strcat.c -mozilla/nsprpub/lib/libc/src/strccmp.c -mozilla/nsprpub/lib/libc/src/strchr.c -mozilla/nsprpub/lib/libc/src/strcmp.c -mozilla/nsprpub/lib/libc/src/strcpy.c -mozilla/nsprpub/lib/libc/src/strcstr.c -mozilla/nsprpub/lib/libc/src/strdup.c -mozilla/nsprpub/lib/libc/src/strlen.c -mozilla/nsprpub/lib/libc/src/strpbrk.c -mozilla/nsprpub/lib/libc/src/strstr.c -mozilla/nsprpub/pr/src/io/prdir.c -mozilla/nsprpub/pr/src/io/prfdcach.c -mozilla/nsprpub/pr/src/io/prfile.c -mozilla/nsprpub/pr/src/io/prio.c -mozilla/nsprpub/pr/src/io/priometh.c -mozilla/nsprpub/pr/src/io/prlayer.c -mozilla/nsprpub/pr/src/io/prlog.c -mozilla/nsprpub/pr/src/io/prmapopt.c -mozilla/nsprpub/pr/src/io/prmmap.c -mozilla/nsprpub/pr/src/io/prmwait.c -mozilla/nsprpub/pr/src/io/prpolevt.c -mozilla/nsprpub/pr/src/io/prprf.c -mozilla/nsprpub/pr/src/io/prscanf.c -mozilla/nsprpub/pr/src/io/prsocket.c -mozilla/nsprpub/pr/src/io/prstdio.c -mozilla/nsprpub/pr/src/linking/prlink.c -mozilla/nsprpub/pr/src/malloc/prmem.c -mozilla/nsprpub/pr/src/md/mac/macdll.c -mozilla/nsprpub/pr/src/md/mac/macio.c -mozilla/nsprpub/pr/src/md/mac/macsockotpt.c -mozilla/nsprpub/pr/src/md/mac/macthr.c -mozilla/nsprpub/pr/src/md/mac/mactime.c -mozilla/nsprpub/pr/src/md/mac/mdmac.c -mozilla/nsprpub/pr/src/md/prosdep.c -mozilla/nsprpub/pr/src/memory/prseg.c -mozilla/nsprpub/pr/src/misc/pralarm.c -mozilla/nsprpub/pr/src/misc/pratom.c -mozilla/nsprpub/pr/src/misc/prcountr.c -mozilla/nsprpub/pr/src/misc/prdtoa.c -mozilla/nsprpub/pr/src/misc/prenv.c -mozilla/nsprpub/pr/src/misc/prerror.c -mozilla/nsprpub/pr/src/misc/prinit.c -mozilla/nsprpub/pr/src/misc/prinrval.c -mozilla/nsprpub/pr/src/misc/prlog2.c -mozilla/nsprpub/pr/src/misc/prlong.c -mozilla/nsprpub/pr/src/misc/prnetdb.c -mozilla/nsprpub/pr/src/misc/prolock.c -mozilla/nsprpub/pr/src/misc/prsystem.c -mozilla/nsprpub/pr/src/misc/prthinfo.c -mozilla/nsprpub/pr/src/misc/prtime.c -mozilla/nsprpub/pr/src/misc/prtrace.c -mozilla/nsprpub/pr/src/threads/combined/prucpu.c -mozilla/nsprpub/pr/src/threads/combined/prucv.c -mozilla/nsprpub/pr/src/threads/combined/prulock.c -mozilla/nsprpub/pr/src/threads/combined/prustack.c -mozilla/nsprpub/pr/src/threads/combined/pruthr.c -mozilla/nsprpub/pr/src/threads/prcmon.c -mozilla/nsprpub/pr/src/threads/prcthr.c -mozilla/nsprpub/pr/src/threads/prdump.c -mozilla/nsprpub/pr/src/threads/prmon.c -mozilla/nsprpub/pr/src/threads/prsem.c -mozilla/nsprpub/pr/src/threads/prtpd.c diff --git a/macbuild/NSPR20PPC.mcp b/macbuild/NSPR20PPC.mcp deleted file mode 100644 index 28ec6ebb..00000000 Binary files a/macbuild/NSPR20PPC.mcp and /dev/null differ diff --git a/macbuild/NSPRCarbon.Prefix b/macbuild/NSPRCarbon.Prefix deleted file mode 100644 index d36f5663..00000000 --- a/macbuild/NSPRCarbon.Prefix +++ /dev/null @@ -1,11 +0,0 @@ -// -// NSPR.Prefix -// -// Global prefix file for the non-debug NSPR project. -// -// - - -#include "NSPRConfig.h" - -#define TARGET_CARBON 1 diff --git a/macbuild/NSPRCarbonDebug.Prefix b/macbuild/NSPRCarbonDebug.Prefix deleted file mode 100644 index 4a67d9ef..00000000 --- a/macbuild/NSPRCarbonDebug.Prefix +++ /dev/null @@ -1,12 +0,0 @@ -// -// NSPR.Prefix -// -// Global prefix file for the debug NSPR project. -// -// - - -#define DEBUG 1 -#define DEVELOPER_DEBUG 1 -#include "NSPRConfig.h" -#define TARGET_CARBON 1 diff --git a/macbuild/NSPRConfig.h b/macbuild/NSPRConfig.h deleted file mode 100644 index 4f2adf89..00000000 --- a/macbuild/NSPRConfig.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998-2000 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the - * terms of the GNU General Public License Version 2 or later (the - * "GPL"), in which case the provisions of the GPL are applicable - * instead of those above. If you wish to allow use of your - * version of this file only under the terms of the GPL and not to - * allow others to use your version of this file under the MPL, - * indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by - * the GPL. If you do not delete the provisions above, a recipient - * may use your version of this file under either the MPL or the - * GPL. - */ - -#define OLDROUTINELOCATIONS 0 - -#define XP_MAC 1 -#define _PR_NO_PREEMPT 1 -#define _NO_FAST_STRING_INLINES_ 1 -#define FORCE_PR_LOG 1 -#define NSPR20 1 -#define NSPR_AS_SHARED_LIB diff --git a/macbuild/NSPRDebug.Prefix b/macbuild/NSPRDebug.Prefix deleted file mode 100644 index a656aa49..00000000 --- a/macbuild/NSPRDebug.Prefix +++ /dev/null @@ -1,11 +0,0 @@ -// -// NSPR.Prefix -// -// Global prefix file for the debug NSPR project. -// -// - - -#define DEBUG 1 -#define DEVELOPER_DEBUG 1 -#include "NSPRConfig.h" \ No newline at end of file diff --git a/pkg/Makefile.in b/pkg/Makefile.in new file mode 100644 index 00000000..d12db9b6 --- /dev/null +++ b/pkg/Makefile.in @@ -0,0 +1,54 @@ +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +#! gmake + +MOD_DEPTH = .. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +DIRS = +ifeq ($(OS_TARGET),Linux) +DIRS = linux +endif +ifeq ($(OS_TARGET),SunOS) +DIRS = solaris +endif + +publish:: + +$(LOOP_OVER_DIRS) + +include $(topsrcdir)/config/rules.mk diff --git a/pkg/linux/Makefile.in b/pkg/linux/Makefile.in new file mode 100644 index 00000000..aac22aab --- /dev/null +++ b/pkg/linux/Makefile.in @@ -0,0 +1,44 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +MOD_DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +NAME = sun-nspr +RELEASE = 1 +TOPDIR = /usr/src/redhat +VERSION = `grep PR_VERSION $(dist_includedir)/prinit.h \ + | sed -e 's/"$$//' -e 's/.*"//' -e 's/ .*//'` + +include $(MOD_DEPTH)/config/autoconf.mk + +publish: + $(MAKE) clean + mkdir -p usr/lib/mps + cp -L $(MOD_DEPTH)/dist/lib/* usr/lib/mps + mkdir -p usr/include/mps + cp -Lr $(MOD_DEPTH)/dist/include/* usr/include/mps + tar czvf $(NAME)-$(VERSION).tar.gz usr + echo "%define name $(NAME)" >$(NAME).spec + echo "%define version $(VERSION)" >>$(NAME).spec + echo "%define release $(RELEASE)" >>$(NAME).spec + + cat $(srcdir)/$(NAME).spec >>$(NAME).spec + cp $(NAME)-$(VERSION).tar.gz $(TOPDIR)/SOURCES + rpm -ba $(NAME).spec + if [ ! -d RPMS ] ; then mkdir -p RPMS ; fi + if [ ! -d SRPMS ] ; then mkdir -p SRPMS ; fi + cp -v $(TOPDIR)/RPMS/i386/$(NAME)-$(VERSION)-* RPMS + cp -v $(TOPDIR)/RPMS/i386/$(NAME)-devel-$(VERSION)-* RPMS + cp -v $(TOPDIR)/SRPMS/$(NAME)-$(VERSION)-* SRPMS + +clean: + rm -rf $(TOPDIR)/BUILD/$(NAME) + rm -rf RPMS SRPMS usr + rm -f $(NAME)-$(VERSION).tar.gz diff --git a/pkg/linux/sun-nspr.spec b/pkg/linux/sun-nspr.spec new file mode 100644 index 00000000..1fed5048 --- /dev/null +++ b/pkg/linux/sun-nspr.spec @@ -0,0 +1,122 @@ +Summary: Netscape Portable Runtime +Name: %{name} +Vendor: Sun Microsystems +Version: %{version} +Release: %{release} +Copyright: MPL/GPL +Group: System Environment/Base +Source: %{name}-%{version}.tar.gz +ExclusiveOS: Linux +BuildRoot: /var/tmp/%{name}-root + +%description + +NSPR provides platform independence for non-GUI operating system +facilities. These facilities include threads, thread synchronization, +normal file and network I/O, interval timing and calendar time, basic +memory management (malloc and free) and shared library linking. + +See: http://www.mozilla.org/projects/nspr/about-nspr.html + +%package devel +Summary: Development Libraries for the Netscape Portable Runtime +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Header files for doing development with the Netscape Portable Runtime. + +%prep +%setup -c + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir $RPM_BUILD_ROOT +cd $RPM_BUILD_ROOT +tar xvzf $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%dir /usr +%dir /usr/lib +%dir /usr/lib/mps +/usr/lib/mps/libnspr4.so +/usr/lib/mps/libplc4.so +/usr/lib/mps/libplds4.so + +%files devel +%defattr(-,root,root) +/usr/lib/mps/libnspr4.a +/usr/lib/mps/libplc4.a +/usr/lib/mps/libplds4.a +%dir /usr +%dir /usr/include +%dir /usr/include/mps +%dir /usr/include/mps/nspr +%dir /usr/include/mps/nspr/obsolete +%dir /usr/include/mps/nspr/private +/usr/include/mps/nspr/private/pprio.h +/usr/include/mps/nspr/private/pprthred.h +/usr/include/mps/nspr/private/prpriv.h +/usr/include/mps/nspr/prcpucfg.h +/usr/include/mps/nspr/obsolete/pralarm.h +/usr/include/mps/nspr/obsolete/probslet.h +/usr/include/mps/nspr/obsolete/protypes.h +/usr/include/mps/nspr/obsolete/prsem.h +/usr/include/mps/nspr/nspr.h +/usr/include/mps/nspr/pratom.h +/usr/include/mps/nspr/prbit.h +/usr/include/mps/nspr/prclist.h +/usr/include/mps/nspr/prcmon.h +/usr/include/mps/nspr/prcountr.h +/usr/include/mps/nspr/prcvar.h +/usr/include/mps/nspr/prdtoa.h +/usr/include/mps/nspr/prenv.h +/usr/include/mps/nspr/prerr.h +/usr/include/mps/nspr/prerror.h +/usr/include/mps/nspr/prinet.h +/usr/include/mps/nspr/prinit.h +/usr/include/mps/nspr/prinrval.h +/usr/include/mps/nspr/prio.h +/usr/include/mps/nspr/pripcsem.h +/usr/include/mps/nspr/prlink.h +/usr/include/mps/nspr/prlock.h +/usr/include/mps/nspr/prlog.h +/usr/include/mps/nspr/prlong.h +/usr/include/mps/nspr/prmem.h +/usr/include/mps/nspr/prmon.h +/usr/include/mps/nspr/prmwait.h +/usr/include/mps/nspr/prnetdb.h +/usr/include/mps/nspr/prolock.h +/usr/include/mps/nspr/prpdce.h +/usr/include/mps/nspr/prprf.h +/usr/include/mps/nspr/prproces.h +/usr/include/mps/nspr/prrng.h +/usr/include/mps/nspr/prrwlock.h +/usr/include/mps/nspr/prshma.h +/usr/include/mps/nspr/prshm.h +/usr/include/mps/nspr/prsystem.h +/usr/include/mps/nspr/prthread.h +/usr/include/mps/nspr/prtime.h +/usr/include/mps/nspr/prtpool.h +/usr/include/mps/nspr/prtrace.h +/usr/include/mps/nspr/prtypes.h +/usr/include/mps/nspr/prvrsion.h +/usr/include/mps/nspr/prwin16.h +/usr/include/mps/nspr/plarenas.h +/usr/include/mps/nspr/plarena.h +/usr/include/mps/nspr/plhash.h +/usr/include/mps/nspr/plbase64.h +/usr/include/mps/nspr/plerror.h +/usr/include/mps/nspr/plgetopt.h +/usr/include/mps/nspr/plresolv.h +/usr/include/mps/nspr/plstr.h + +%changelog +* Sat Jan 18 2003 Kirk Erickson +- http://bugzilla.mozilla.org/show_bug.cgi?id=189501 diff --git a/pkg/solaris/Makefile.com b/pkg/solaris/Makefile.com new file mode 100644 index 00000000..523460be --- /dev/null +++ b/pkg/solaris/Makefile.com @@ -0,0 +1,32 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +MACH = $(shell mach) + +PUBLISH_ROOT = $(DIST) +ifeq ($(MOD_DEPTH),../..) +ROOT = ROOT +else +ROOT = $(subst ../../,,$(MOD_DEPTH))/ROOT +endif + +PKGARCHIVE = $(dist_libdir)/pkgarchive +DATAFILES = copyright +FILES = $(DATAFILES) pkginfo prototype + +PACKAGE = $(shell basename `pwd`) + +PRODUCT_VERSION = $(shell grep PR_VERSION $(dist_includedir)/prinit.h \ + | sed -e 's/"$$//' -e 's/.*"//' -e 's/ .*//') + +LN = /usr/bin/ln + +CLOBBERFILES = $(FILES) + +include $(topsrcdir)/config/rules.mk + +# vim: ft=make diff --git a/pkg/solaris/Makefile.in b/pkg/solaris/Makefile.in new file mode 100644 index 00000000..b5c0acbe --- /dev/null +++ b/pkg/solaris/Makefile.in @@ -0,0 +1,60 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +MOD_DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +%: %.ksh + $(RM) $@ + cp $< $@ + chmod +x $@ + +ifeq ($(USE_64), 1) +DIRS = \ + SUNWprx +else +DIRS = \ + SUNWpr +endif + +PROTO = \ + $(ROOT) \ + $(ROOT)/usr \ + $(ROOT)/usr/lib \ + $(ROOT)/usr/lib/mps + +ifdef USE_64 +PROTO += $(ROOT)/usr/lib/mps/sparcv9 +endif + +include $(srcdir)/Makefile.com + +awk_pkginfo: bld_awk_pkginfo + ./bld_awk_pkginfo -m $(MACH) -p "$(PRODUCT_VERSION)" -o $@ -v $(PRODUCT_VERSION) + +all:: awk_pkginfo $(PROTO) +publish: awk_pkginfo $(PROTO) + +$(LOOP_OVER_DIRS) + +clean clobber:: + $(RM) awk_pkginfo bld_awk_pkginfo + $(RM) -r $(ROOT) + +$(ROOT) $(ROOT)/%: + mkdir -p $@ + +ifdef USE_64 +$(ROOT)/usr/lib/mps/sparcv9: + $(LN) -sf ../../../../$(dist_libdir) $@ +else +$(ROOT)/usr/lib/mps: + $(LN) -sf ../../../$(dist_libdir) $@ +endif diff --git a/pkg/solaris/Makefile.targ b/pkg/solaris/Makefile.targ new file mode 100644 index 00000000..55ca5238 --- /dev/null +++ b/pkg/solaris/Makefile.targ @@ -0,0 +1,40 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +pkginfo: pkginfo.tmpl ../awk_pkginfo + $(RM) $@; nawk -f ../awk_pkginfo $< > $@ + +# we need to copy prototype_sparc to current too find copyright in current +prototype: $(srcdir)/prototype_com $(srcdir)/prototype_$(MACH) + cat $(srcdir)/prototype_$(MACH) | sed -e \ +'/^!include[ ][ ]*prototype_com/ r ./prototype_com' \ +-e 's/^!include[ ][ ]*prototype_com//g' >prototype + + + +pkg: $(PKGARCHIVE) prototype + cp $(srcdir)/prototype_com . + cp $(srcdir)/prototype_$(MACH) . + cp $(srcdir)/depend . + pkgmk -f prototype_$(MACH) -d $(PKGARCHIVE) -r $(ROOT) -o $(PACKAGE) + +$(PKGARCHIVE): + [ -d $(PKGARCHIVE) ] || mkdir -p $(PKGARCHIVE) + +$(DATAFILES): %: $(srcdir)/../common_files/% + $(RM) $@; cp $(srcdir)/../common_files/$@ $@ + +#$(MACHDATAFILES): %: $(srcdir)/../common_files/%_$(MACH) +# $(RM) $@; cp $(srcdir)/../common_files/$@_$(MACH) $@ +# +#$(MACHDATAFILES): %: $(srcdir)/%_$(MACH) +# $(RM) $@; cp $(srcdir)/$@_$(MACH) $@ + +clobber clean:: + -$(RM) $(CLOBBERFILES) $(CLEANFILES) + +.PHONY: pkg diff --git a/pkg/solaris/SUNWpr/Makefile.in b/pkg/solaris/SUNWpr/Makefile.in new file mode 100644 index 00000000..84b8bb2c --- /dev/null +++ b/pkg/solaris/SUNWpr/Makefile.in @@ -0,0 +1,22 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +MOD_DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +include $(srcdir)/../Makefile.com + +DATAFILES += + +all:: $(FILES) +publish:: all pkg + +include $(srcdir)/../Makefile.targ diff --git a/pkg/solaris/SUNWpr/depend b/pkg/solaris/SUNWpr/depend new file mode 100644 index 00000000..11d87b87 --- /dev/null +++ b/pkg/solaris/SUNWpr/depend @@ -0,0 +1,27 @@ +# Copyright 2002 Microsystems, Inc. All Rights Reserved. +# Use is subject to license terms. +# +# $Id$ +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# see pkginfo(4), PKG parameter +# see pkginfo(4), NAME parameter +# see pkginfo(4), VERSION parameter +# see pkginfo(4), ARCH parameter +# +# () +# () +# ... +# +# ... + +P SUNWcar Core Architecture, (Root) +P SUNWkvm Core Architecture, (Kvm) +P SUNWcsr Core Solaris, (Root) +P SUNWcsu Core Solaris, (Usr) +P SUNWcsd Core Solaris Devices +P SUNWcsl Core Solaris Libraries diff --git a/pkg/solaris/SUNWpr/pkginfo.tmpl b/pkg/solaris/SUNWpr/pkginfo.tmpl new file mode 100644 index 00000000..0523c8ef --- /dev/null +++ b/pkg/solaris/SUNWpr/pkginfo.tmpl @@ -0,0 +1,34 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# +PKG="SUNWpr" +NAME="Netscape Portable Runtime" +ARCH="ISA" +VERSION="NSPRVERS,REV=0.0.0" +SUNW_PRODNAME="Netscape Portable Runtime" +SUNW_PRODVERS="NSPRVERS" +SUNW_PKGTYPE="usr" +MAXINST="1000" +CATEGORY="system" +DESC="Netscape Portable Runtime Interface" +VENDOR="Sun Microsystems, Inc." +HOTLINE="Please contact your local service provider" +EMAIL="" +CLASSES="none" +BASEDIR=/ +SUNW_PKGVERS="1.0" +#VSTOCK="" +#ISTATES="" +#RSTATES='' +#ULIMIT="" +#ORDER="" +#PSTAMP="" +#INTONLY="" diff --git a/pkg/solaris/SUNWpr/prototype_com b/pkg/solaris/SUNWpr/prototype_com new file mode 100644 index 00000000..1462665f --- /dev/null +++ b/pkg/solaris/SUNWpr/prototype_com @@ -0,0 +1,31 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search # where to find pkg objects +#!include # include another 'prototype' file +#!default # default used if not specified on entry +#!= # puts parameter in pkg environment + +# packaging files +i copyright +i pkginfo +i depend +# +# source locations relative to the prototype file +# +# SUNWpr +# +d none usr 755 root sys +d none usr/lib 755 root bin +d none usr/lib/mps 755 root bin +f none usr/lib/mps/libnspr4.so 755 root bin +f none usr/lib/mps/libplc4.so 755 root bin +f none usr/lib/mps/libplds4.so 755 root bin diff --git a/pkg/solaris/SUNWpr/prototype_i386 b/pkg/solaris/SUNWpr/prototype_i386 new file mode 100644 index 00000000..8991af81 --- /dev/null +++ b/pkg/solaris/SUNWpr/prototype_i386 @@ -0,0 +1,30 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search # where to find pkg objects +#!include # include another 'prototype' file +#!default # default used if not specified on entry +#!= # puts parameter in pkg environment + +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are i386 specific here +# +# source locations relative to the prototype file +# +# +# SUNWpr +# diff --git a/pkg/solaris/SUNWpr/prototype_sparc b/pkg/solaris/SUNWpr/prototype_sparc new file mode 100644 index 00000000..40bc6dcd --- /dev/null +++ b/pkg/solaris/SUNWpr/prototype_sparc @@ -0,0 +1,33 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search # where to find pkg objects +#!include # include another 'prototype' file +#!default # default used if not specified on entry +#!= # puts parameter in pkg environment + +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWpr +# +d none usr/lib/mps/cpu 755 root bin +d none usr/lib/mps/cpu/sparcv8plus 755 root bin +f none usr/lib/mps/cpu/sparcv8plus/libnspr_flt4.so 755 root bin diff --git a/pkg/solaris/SUNWprx/Makefile.in b/pkg/solaris/SUNWprx/Makefile.in new file mode 100644 index 00000000..84b8bb2c --- /dev/null +++ b/pkg/solaris/SUNWprx/Makefile.in @@ -0,0 +1,22 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# + +MOD_DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(MOD_DEPTH)/config/autoconf.mk + +include $(srcdir)/../Makefile.com + +DATAFILES += + +all:: $(FILES) +publish:: all pkg + +include $(srcdir)/../Makefile.targ diff --git a/pkg/solaris/SUNWprx/depend b/pkg/solaris/SUNWprx/depend new file mode 100644 index 00000000..d9ce16a6 --- /dev/null +++ b/pkg/solaris/SUNWprx/depend @@ -0,0 +1,30 @@ +# Copyright 2002 Microsystems, Inc. All Rights Reserved. +# Use is subject to license terms. +# +# $Id$ +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# see pkginfo(4), PKG parameter +# see pkginfo(4), NAME parameter +# see pkginfo(4), VERSION parameter +# see pkginfo(4), ARCH parameter +# +# () +# () +# ... +# +# ... + +P SUNWcar Core Architecture, (Root) +P SUNWkvm Core Architecture, (Kvm) +P SUNWcsr Core Solaris, (Root) +P SUNWcsu Core Solaris, (Usr) +P SUNWcsd Core Solaris Devices +P SUNWcsl Core Solaris Libraries +P SUNWcarx Core Architecture, (Root) (64-bit) +P SUNWcsxu Core Solaris (Usr) (64-bit) +P SUNWcslx Core Solaris Libraries (64-bit) diff --git a/pkg/solaris/SUNWprx/pkginfo.tmpl b/pkg/solaris/SUNWprx/pkginfo.tmpl new file mode 100644 index 00000000..eb5b90d1 --- /dev/null +++ b/pkg/solaris/SUNWprx/pkginfo.tmpl @@ -0,0 +1,35 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# +PKG="SUNWprx" +NAME="Netscape Portable Runtime (64-bit)" +ARCH="ISA" +SUNW_ISA="sparcv9" +VERSION="NSPRVERS,REV=0.0.0" +SUNW_PRODNAME="Netscape Portable Runtime" +SUNW_PRODVERS="NSPRVERS" +SUNW_PKGTYPE="usr" +MAXINST="1000" +CATEGORY="system" +DESC="Netscape Portable Runtime Interface (64-bit)" +VENDOR="Sun Microsystems, Inc." +HOTLINE="Please contact your local service provider" +EMAIL="" +CLASSES="none" +BASEDIR=/ +SUNW_PKGVERS="1.0" +#VSTOCK="" +#ISTATES="" +#RSTATES='' +#ULIMIT="" +#ORDER="" +#PSTAMP="" +#INTONLY="" diff --git a/pkg/solaris/SUNWprx/prototype_com b/pkg/solaris/SUNWprx/prototype_com new file mode 100644 index 00000000..da07baba --- /dev/null +++ b/pkg/solaris/SUNWprx/prototype_com @@ -0,0 +1,28 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search # where to find pkg objects +#!include # include another 'prototype' file +#!default # default used if not specified on entry +#!= # puts parameter in pkg environment + +# packaging files +i copyright +i pkginfo +i depend +# +# source locations relative to the prototype file +# +# SUNWprx +# +d none usr 755 root sys +d none usr/lib 755 root bin +d none usr/lib/mps 755 root bin diff --git a/pkg/solaris/SUNWprx/prototype_sparc b/pkg/solaris/SUNWprx/prototype_sparc new file mode 100644 index 00000000..2bcbd5ec --- /dev/null +++ b/pkg/solaris/SUNWprx/prototype_sparc @@ -0,0 +1,35 @@ +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "$Id$" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search # where to find pkg objects +#!include # include another 'prototype' file +#!default # default used if not specified on entry +#!= # puts parameter in pkg environment + +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWprx +# +s none usr/lib/mps/64=sparcv9 +d none usr/lib/mps/sparcv9 755 root bin +f none usr/lib/mps/sparcv9/libnspr4.so 755 root bin +f none usr/lib/mps/sparcv9/libplc4.so 755 root bin +f none usr/lib/mps/sparcv9/libplds4.so 755 root bin diff --git a/pkg/solaris/bld_awk_pkginfo.ksh b/pkg/solaris/bld_awk_pkginfo.ksh new file mode 100644 index 00000000..e3d33a7f --- /dev/null +++ b/pkg/solaris/bld_awk_pkginfo.ksh @@ -0,0 +1,105 @@ +#!/usr/bin/ksh -p +# +#ident "$Id$" +# +# Copyright 2002 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# Simple script which builds the awk_pkginfo awk script. This awk script +# is used to convert the pkginfo.tmpl files into pkginfo files +# for the build. +# + +usage() +{ + cat <<-EOF +usage: bld_awk_pkginfo -p -m -o [-v ] +EOF +} + +# +# Awk strings +# +# two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n +# the first has one '=' the second has two or more '=' +# +VERSION1="VERSION=[^=]*$" +VERSION2="VERSION=[^=]*=.*$" +PRODVERS="^SUNW_PRODVERS=" +ARCH='ARCH=\"ISA\"' + +# +# parse command line +# +mach="" +prodver="" +awk_script="" +version="NSPRVERS" + +while getopts o:p:m:v: c +do + case $c in + o) + awk_script=$OPTARG + ;; + m) + mach=$OPTARG + ;; + p) + prodver=$OPTARG + ;; + v) + version=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]] +then + usage + exit 1 +fi + +if [[ -f $awk_script ]] +then + rm -f $awk_script +fi + +# +# Build REV= field based on date +# +rev=$(date "+%Y.%m.%d.%H.%M") + +# +# Build awk script which will process all the +# pkginfo.tmpl files. +# +# the first VERSION pattern is replaced with a leading quotation mark +# +rm -f $awk_script +cat << EOF > $awk_script +/$VERSION1/ { + sub(/\=[^=]*$/,"=\"$rev\"") + print + next + } +/$VERSION2/ { + sub(/\=[^=]*$/,"=$rev\"") + sub(/NSPRVERS/,"$version") + print + next + } +/$PRODVERS/ { + printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" + next + } +/$ARCH/ { + printf "ARCH=\"%s\"\n", "$mach" + next + } +{ print } +EOF diff --git a/pkg/solaris/common_files/copyright b/pkg/solaris/common_files/copyright new file mode 100644 index 00000000..1e0f6ce3 --- /dev/null +++ b/pkg/solaris/common_files/copyright @@ -0,0 +1,28 @@ +The contents of this package are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this package except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is the Netscape Portable Runtime (NSPR). + +The Initial Developer of the Original Code is Netscape Communications +Corporation. Portions created by Netscape are Copyright (C) 1998-2000 +Netscape Communications Corporation. All Rights Reserved. + +Contributor(s): + +Alternatively, the contents of this package may be used under the terms +of the GNU General Public License Version 2 or later (the "GPL"), in +which case the provisions of the GPL are applicable instead of those +above. If you wish to allow use of your version of this package only +under the terms of the GPL and not to allow others to use your version +of this package under the MPL, indicate your decision by deleting the +provisions above and replace them with the notice and other provisions +required by the GPL. If you do not delete the provisions above, a +recipient may use your version of this package under either the MPL or +the GPL. diff --git a/pr/include/md/Makefile.in b/pr/include/md/Makefile.in index 316c4540..5f8f0f71 100644 --- a/pr/include/md/Makefile.in +++ b/pr/include/md/Makefile.in @@ -46,21 +46,22 @@ CONFIGS = $(wildcard $(srcdir)/*.cfg) include $(topsrcdir)/config/rules.mk export:: $(MDCPUCFG_H) - $(INSTALL) -m 444 $(srcdir)/$(MDCPUCFG_H) $(dist_includedir) $(INSTALL) -m 444 $(CONFIGS) $(HEADERS) $(dist_includedir)/md -ifneq ($(OS_ARCH),OpenVMS) - mv -f $(dist_includedir)/$(MDCPUCFG_H) $(dist_includedir)/prcpucfg.h + $(INSTALL) -m 444 $(srcdir)/$(MDCPUCFG_H) $(dist_includedir) +ifeq ($(OS_ARCH),OpenVMS) +# On OpenVMS mv updates the file's modified time, so we create a hard link. + cd $(dist_includedir); \ + if test ! -f prcpucfg.h; then \ + dcl set file /enter=prcpucfg.h $(MDCPUCFG_H); \ + fi else -# mv'ing a link causes the file itself to move, not the link. - rm -f $(dist_includedir)/$(MDCPUCFG_H) - rm -f $(dist_includedir)/prcpucfg.h - ln -fs $(srcdir)/$(MDCPUCFG_H) $(dist_includedir)/prcpucfg.h + mv -f $(dist_includedir)/$(MDCPUCFG_H) $(dist_includedir)/prcpucfg.h endif real_install:: $(NSINSTALL) -D $(DESTDIR)$(includedir)/md cp $(srcdir)/$(MDCPUCFG_H) $(DESTDIR)$(includedir)/prcpucfg.h - $(NSINSTALL) -t -m 644 $(CONFIG) $(HEADERS) $(DESTDIR)$(includedir)/md + $(NSINSTALL) -t -m 644 $(HEADERS) $(DESTDIR)$(includedir)/md release:: export @echo "Copying machine-dependent prcpucfg.h" diff --git a/pr/include/md/_aix.h b/pr/include/md/_aix.h index d8d79eeb..2ef0fc1d 100644 --- a/pr/include/md/_aix.h +++ b/pr/include/md/_aix.h @@ -57,7 +57,8 @@ #define _PR_VMBASE 0x30000000 #define _PR_STACK_VMBASE 0x50000000 -#define _MD_DEFAULT_STACK_SIZE 65536L +#define _MD_DEFAULT_STACK_SIZE (2*65536L) +#define _MD_MINIMUM_STACK_SIZE (2*65536L) #define _MD_MMAP_FLAGS MAP_PRIVATE #define NEED_TIME_R @@ -71,6 +72,7 @@ #define _PR_USE_POLL #define _PR_STAT_HAS_ONLY_ST_ATIME #ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP #define _PR_HAVE_GETHOSTBYNAME2 #endif #define _PR_HAVE_SYSV_SEMAPHORES @@ -243,4 +245,6 @@ struct _MDCPU { #define _MD_POLL poll #endif +extern void _MD_aix_map_sendfile_error(int err); + #endif /* nspr_aix_defs_h___ */ diff --git a/pr/include/md/_aix32.cfg b/pr/include/md/_aix32.cfg index 8047bb98..0bf01957 100644 --- a/pr/include/md/_aix32.cfg +++ b/pr/include/md/_aix32.cfg @@ -134,6 +134,9 @@ #define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 #define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 +/* used by protypes.h only */ +#define _PR_AIX_HAVE_BSD_INT_TYPES + #endif /* NO_NSPR_10_SUPPORT */ #endif /* nspr_cpucfg___ */ diff --git a/pr/include/md/_aix32in6.cfg b/pr/include/md/_aix32in6.cfg deleted file mode 100644 index 0bf01957..00000000 --- a/pr/include/md/_aix32in6.cfg +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * The contents of this file are subject to the Mozilla Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998-2000 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the - * terms of the GNU General Public License Version 2 or later (the - * "GPL"), in which case the provisions of the GPL are applicable - * instead of those above. If you wish to allow use of your - * version of this file only under the terms of the GPL and not to - * allow others to use your version of this file under the MPL, - * indicate your decision by deleting the provisions above and - * replace them with the notice and other provisions required by - * the GPL. If you do not delete the provisions above, a recipient - * may use your version of this file under either the MPL or the - * GPL. - */ - -#ifndef nspr_cpucfg___ -#define nspr_cpucfg___ - -#ifndef XP_UNIX -#define XP_UNIX -#endif - -#ifndef AIX -#define AIX -#endif - -#undef IS_LITTLE_ENDIAN -#define IS_BIG_ENDIAN 1 - -#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 8 -#define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_DOUBLE 4 -#define PR_ALIGN_OF_POINTER 4 - -#define HAVE_LONG_LONG -#undef HAVE_ALIGNED_DOUBLES -#undef HAVE_ALIGNED_LONGLONGS - -#define PR_AF_INET6 24 /* same as AF_INET6 */ - -#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 - -/* used by protypes.h only */ -#define _PR_AIX_HAVE_BSD_INT_TYPES - -#endif /* NO_NSPR_10_SUPPORT */ - -#endif /* nspr_cpucfg___ */ diff --git a/pr/include/md/_beos.h b/pr/include/md/_beos.h index 232fea3c..1f69bd66 100644 --- a/pr/include/md/_beos.h +++ b/pr/include/md/_beos.h @@ -51,6 +51,10 @@ * Internal configuration macros */ +#ifdef BONE_VERSION +#define _PR_HAVE_SOCKADDR_LEN +#endif + #define PR_LINKER_ARCH "beos" #define _PR_SI_SYSNAME "BEOS" #ifdef __powerpc__ @@ -87,6 +91,7 @@ #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 threading functions and objects as native BeOS */ struct _MDThread { @@ -141,17 +146,21 @@ struct _MDSegment { ** 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 { @@ -175,14 +184,17 @@ struct _MDFileMap { * 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 */ @@ -192,6 +204,7 @@ struct protoent { struct protoent* getprotobyname(const char* name); struct protoent* getprotobynumber(int number); +#endif /* * malloc() related definitions. @@ -304,6 +317,7 @@ struct protoent* getprotobynumber(int number); #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 @@ -509,7 +523,7 @@ 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, struct PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout); +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); diff --git a/pr/include/md/_bsdi.h b/pr/include/md/_bsdi.h index c529649f..346f1049 100644 --- a/pr/include/md/_bsdi.h +++ b/pr/include/md/_bsdi.h @@ -39,6 +39,8 @@ * Internal configuration macros */ +#include /* for _BSDI_VERSION */ + #define PR_LINKER_ARCH "bsdi" #define _PR_SI_SYSNAME "BSDI" #if defined(__i386__) @@ -61,6 +63,15 @@ #define USE_SETJMP +/* BSD/OS 4.3 and newer all have IPv6 support */ +#if _BSDI_VERSION >= 200105 +#define _PR_INET6 +#define _PR_HAVE_INET_NTOP +#define _PR_HAVE_GETIPNODEBYNAME +#define _PR_HAVE_GETIPNODEBYADDR +#define _PR_INET6_PROBE +#endif + #ifndef _PR_PTHREADS #include diff --git a/pr/include/md/_darwin.cfg b/pr/include/md/_darwin.cfg index d06492b8..22fc1083 100644 --- a/pr/include/md/_darwin.cfg +++ b/pr/include/md/_darwin.cfg @@ -39,10 +39,6 @@ #define XP_UNIX #endif -#ifndef DARWIN -#define DARWIN -#endif - #define PR_AF_INET6 30 /* same as AF_INET6 */ #if defined(i386) diff --git a/pr/include/md/_darwin.h b/pr/include/md/_darwin.h index d262849c..bad90a65 100644 --- a/pr/include/md/_darwin.h +++ b/pr/include/md/_darwin.h @@ -61,6 +61,40 @@ #define _PR_NO_LARGE_FILES #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY +#define _PR_INET6 +/* + * I'd prefer to use getipnodebyname and getipnodebyaddr but the + * getipnodebyname(3) man page on Mac OS X 10.2 says they are not + * thread-safe. AI_V4MAPPED|AI_ADDRCONFIG doesn't work either. + */ +#define _PR_HAVE_GETHOSTBYNAME2 +/* + * On Mac OS X 10.2, gethostbyaddr fails with h_errno=NO_RECOVERY + * if you pass an IPv4-mapped IPv6 address to it. + */ +#define _PR_GHBA_DISALLOW_V4MAPPED +/* socket(AF_INET6) fails with EPROTONOSUPPORT on Mac OS X 10.1. */ +#if MACOS_DEPLOYMENT_TARGET < 100200 +#define _PR_INET6_PROBE +#endif +/* Mac OS X 10.2 has inet_ntop and inet_pton. */ +#if MACOS_DEPLOYMENT_TARGET >= 100200 +#define _PR_HAVE_INET_NTOP +#endif + +#if defined(__ppc__) +#define _PR_HAVE_ATOMIC_OPS +#define _MD_INIT_ATOMIC() +extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32 *val); +#define _MD_ATOMIC_INCREMENT(val) _PR_DarwinPPC_AtomicIncrement(val) +extern PRInt32 _PR_DarwinPPC_AtomicDecrement(PRInt32 *val); +#define _MD_ATOMIC_DECREMENT(val) _PR_DarwinPPC_AtomicDecrement(val) +extern PRInt32 _PR_DarwinPPC_AtomicSet(PRInt32 *val, PRInt32 newval); +#define _MD_ATOMIC_SET(val, newval) _PR_DarwinPPC_AtomicSet(val, newval) +extern PRInt32 _PR_DarwinPPC_AtomicAdd(PRInt32 *ptr, PRInt32 val); +#define _MD_ATOMIC_ADD(ptr, val) _PR_DarwinPPC_AtomicAdd(ptr, val) +#endif /* __ppc__ */ + #define USE_SETJMP #if !defined(_PR_PTHREADS) diff --git a/pr/include/md/_freebsd.cfg b/pr/include/md/_freebsd.cfg index ad04ca20..7177478d 100644 --- a/pr/include/md/_freebsd.cfg +++ b/pr/include/md/_freebsd.cfg @@ -43,16 +43,16 @@ #define FREEBSD #endif +#define PR_AF_INET6 28 /* same as AF_INET6 */ + +#if defined(__i386__) + #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN #define HAVE_LONG_LONG #undef HAVE_ALIGNED_DOUBLES #undef HAVE_ALIGNED_LONGLONGS -#define PR_AF_INET6 28 /* same as AF_INET6 */ - -#if defined(__i386__) - #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 #define PR_BYTES_PER_INT 4 @@ -98,6 +98,7 @@ #define HAVE_LONG_LONG #define HAVE_ALIGNED_DOUBLES #define HAVE_ALIGNED_LONGLONGS +#define IS_64 #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 diff --git a/pr/include/md/_freebsd.h b/pr/include/md/_freebsd.h index 0671b60f..68542336 100644 --- a/pr/include/md/_freebsd.h +++ b/pr/include/md/_freebsd.h @@ -37,6 +37,9 @@ #include "prthread.h" +#if __FreeBSD__ >= 2 +#include /* for __FreeBSD_version */ +#endif #include #define PR_LINKER_ARCH "freebsd" @@ -65,19 +68,33 @@ #define _PR_HAVE_SOCKADDR_LEN #define _PR_STAT_HAS_ST_ATIMESPEC #define _PR_NO_LARGE_FILES -#if ( __FreeBSD__ > 2 ) -#if !defined(_PR_PTHREADS) + +#if defined(_PR_PTHREADS) +#if __FreeBSD_version >= 400008 /* - * libc_r doesn't have poll(). Although libc has poll(), it is not - * thread-safe so we can't use it in the pthreads version. + * libc_r before this version of FreeBSD doesn't have poll(). + * Although libc has poll(), it is not thread-safe so we can't + * use it in the pthreads version. */ #define _PR_POLL_AVAILABLE +#endif +#else +#if __FreeBSD_version >= 300000 +#define _PR_POLL_AVAILABLE #define _PR_USE_POLL #endif #endif + #define _PR_HAVE_SYSV_SEMAPHORES #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY +#if __FreeBSD_version >= 400014 +#define _PR_INET6 +#define _PR_HAVE_INET_NTOP +#define _PR_HAVE_GETHOSTBYNAME2 +#define _PR_INET6_PROBE +#endif + #define USE_SETJMP #ifndef _PR_PTHREADS diff --git a/pr/include/md/_hpux.h b/pr/include/md/_hpux.h index c83e7c3c..2341d973 100644 --- a/pr/include/md/_hpux.h +++ b/pr/include/md/_hpux.h @@ -46,7 +46,14 @@ #define _PR_VMBASE 0x30000000 #define _PR_STACK_VMBASE 0x50000000 -#define _MD_DEFAULT_STACK_SIZE 65536L +/* + * _USE_BIG_FDS increases the size of fd_set from 256 bytes to + * about 7500 bytes. PR_Poll allocates three fd_sets on the + * stack, so it is safer to also increase the default thread + * stack size. + */ +#define _MD_DEFAULT_STACK_SIZE (2*65536L) +#define _MD_MINIMUM_STACK_SIZE (2*65536L) #define _MD_MMAP_FLAGS MAP_PRIVATE #define NEED_TIME_R @@ -55,19 +62,16 @@ #undef HAVE_WEAK_IO_SYMBOLS #undef HAVE_WEAK_MALLOC_SYMBOLS #define HAVE_DLL +#ifdef IS_64 +#define USE_DLFCN +#else #define USE_HPSHL +#endif #ifndef HAVE_STRERROR #define HAVE_STRERROR #endif #define _PR_POLL_AVAILABLE #define _PR_USE_POLL -/* - * OSF1 and HPUX report the POLLHUP event for a socket when the - * shutdown(SHUT_WR) operation is called for the remote end, even though - * the socket is still writeable. Use select(), instead of poll(), to - * workaround this problem. - */ -#define _PR_POLL_WITH_SELECT #define _PR_STAT_HAS_ONLY_ST_ATIME #define _PR_HAVE_POSIX_SEMAPHORES #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY @@ -75,6 +79,13 @@ #undef _PR_HAVE_ATOMIC_OPS +#ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP +#define _PR_HAVE_GETIPNODEBYNAME +#define _PR_HAVE_GETIPNODEBYADDR +#define _PR_INET6_PROBE +#endif + #if !defined(_PR_PTHREADS) #include diff --git a/pr/include/md/_hpux64.cfg b/pr/include/md/_hpux64.cfg index bacd0272..338e3016 100644 --- a/pr/include/md/_hpux64.cfg +++ b/pr/include/md/_hpux64.cfg @@ -82,8 +82,8 @@ #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_LONG 8 +#define PR_ALIGN_OF_INT64 8 #define PR_ALIGN_OF_FLOAT 4 #define PR_ALIGN_OF_DOUBLE 8 #define PR_ALIGN_OF_POINTER 8 diff --git a/pr/include/md/_irix.h b/pr/include/md/_irix.h index 09067002..5e7b624c 100644 --- a/pr/include/md/_irix.h +++ b/pr/include/md/_irix.h @@ -78,6 +78,12 @@ #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY #define _PR_ACCEPT_INHERIT_NONBLOCK +#ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP +#define _PR_HAVE_GETIPNODEBYNAME +#define _PR_HAVE_GETIPNODEBYADDR +#endif + /* Initialization entry points */ NSPR_API(void) _MD_EarlyInit(void); #define _MD_EARLY_INIT _MD_EarlyInit diff --git a/pr/include/md/_linux.cfg b/pr/include/md/_linux.cfg index 301f4590..70f1f9d7 100644 --- a/pr/include/md/_linux.cfg +++ b/pr/include/md/_linux.cfg @@ -414,6 +414,97 @@ #define PR_BYTES_PER_WORD_LOG2 2 #define PR_BYTES_PER_DWORD_LOG2 3 +#elif defined(__s390__) + +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN + +#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_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 4 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 +#define PR_ALIGN_OF_WORD 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(__s390x__) + +#define IS_BIG_ENDIAN 1 +#undef IS_LITTLE_ENDIAN +#define IS_64 + +#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 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#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 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#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 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + #else #error "Unknown CPU architecture" diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h index 86ea248c..df2cfd40 100644 --- a/pr/include/md/_linux.h +++ b/pr/include/md/_linux.h @@ -59,6 +59,10 @@ #define _PR_SI_ARCHITECTURE "mips" #elif defined(__arm__) #define _PR_SI_ARCHITECTURE "arm" +#elif defined(__s390__) +#define _PR_SI_ARCHITECTURE "s390" +#elif defined(__s390x__) +#define _PR_SI_ARCHITECTURE "s390x" #else #error "Unknown CPU architecture" #endif @@ -118,6 +122,7 @@ extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval); #endif #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) #define _PR_INET6 +#define _PR_HAVE_INET_NTOP #define _PR_HAVE_GETHOSTBYNAME2 #define _PR_INET6_PROBE #endif @@ -470,4 +475,6 @@ extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds, /* For writev() */ #include +extern void _MD_linux_map_sendfile_error(int err); + #endif /* nspr_linux_defs_h___ */ diff --git a/pr/include/md/_macos.h b/pr/include/md/_macos.h index f1f0f8aa..90eb07db 100644 --- a/pr/include/md/_macos.h +++ b/pr/include/md/_macos.h @@ -65,6 +65,7 @@ #include #include +#include #define _PR_HAVE_PEEK_BUFFER #define _PR_PEEK_BUFFER_MAX (16 * 1024) @@ -105,7 +106,9 @@ struct _MDSegment { }; struct _MDCPU { - PRInt8 notused; + AbsoluteTime lastThreadSwitch; + AbsoluteTime lastWakeUpProcess; + PRBool trackScheduling; }; typedef struct _MDSocketCallerInfo { @@ -114,19 +117,22 @@ typedef struct _MDSocketCallerInfo { } _MDSocketCallerInfo; struct _MDFileDesc { - PRInt32 osfd; - PRBool orderlyDisconnect; - PRBool readReady; - PRBool writeReady; - PRBool exceptReady; - PRLock * miscLock; - - /* Server sockets: listen bit tells the notifier func what to do */ - PRBool doListen; - - _MDSocketCallerInfo misc; - _MDSocketCallerInfo read; - _MDSocketCallerInfo write; + PRInt32 osfd; + PRPackedBool orderlyDisconnect; + PRPackedBool readReady; + PRPackedBool writeReady; + PRPackedBool exceptReady; + PRLock * miscLock; + + /* Server sockets: listen bit tells the notifier func what to do */ + PRBool doListen; + + /* stored error for non-blocking connects, as a Unix-style error code */ + OTReason disconnectError; + + _MDSocketCallerInfo misc; + _MDSocketCallerInfo read; + _MDSocketCallerInfo write; }; /* @@ -172,7 +178,7 @@ extern void _MD_SetIntsOff(PRInt32 ints); #define _MD_CLEANUP_BEFORE_EXIT() #define _MD_EXIT(status) exit(status) #define _MD_INIT_CPUS() -#define _MD_INIT_RUNNING_CPU(cpu) +#define _MD_INIT_RUNNING_CPU(cpu) _MD_InitRunningCPU(cpu) /* ** Process Related definitions @@ -296,16 +302,20 @@ extern PRStatus _MD_InitThread(PRThread *thread); ** context switch because it might have changed. */ /* ResetTimer(); before _PR_Schedule() */ -#define _MD_SWITCH_CONTEXT(_thread) \ - PR_BEGIN_MACRO \ - PR_ASSERT(_thread->no_sched); \ - if (!setjmp(_thread->md.jb)) { \ - _MD_SET_LAST_THREAD(_thread); \ - _PR_Schedule(); \ - } else { \ - PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \ - _MD_LAST_THREAD()->no_sched = 0; \ - } \ + + +#define _MD_SWITCH_CONTEXT(_thread) \ + PR_BEGIN_MACRO \ + PR_ASSERT(_thread->no_sched); \ + if (!setjmp(_thread->md.jb)) { \ + _MD_SET_LAST_THREAD(_thread); \ + if (_PR_MD_CURRENT_CPU()->md.trackScheduling) \ + _PR_MD_CURRENT_CPU()->md.lastThreadSwitch = UpTime(); \ + _PR_Schedule(); \ + } else { \ + PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \ + _MD_LAST_THREAD()->no_sched = 0; \ + } \ PR_END_MACRO /* @@ -473,6 +483,7 @@ extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, c */ extern PRStatus _MD_gethostname(char *name, int namelen); #define _MD_GETHOSTNAME _MD_gethostname +#define _PR_GET_HOST_ADDR_AS_NAME /* XXX _MD_WRITEV, _MD_SHUTDOWN & _MD_GETPEERNAME not done yet!!! @@ -514,7 +525,6 @@ extern PRStatus _MD_gethostname(char *name, int namelen); ** Time Related definitions */ -#define kMacTimerInMiliSecs 8L #define _MD_GET_INTERVAL _MD_GetInterval #define _MD_INTERVAL_PER_SEC() PR_MSEC_PER_SEC #define _MD_INTERVAL_INIT() @@ -647,7 +657,7 @@ extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap); #define _MD_CLOSE_FILE_MAP _MD_CloseFileMap extern void SetLogFileTypeCreator(const char *logFile); -extern int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd); +extern int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd); /* @@ -681,6 +691,18 @@ extern void LeaveCritialRegion(); #endif + +/* + * CPU Idle support + */ + +extern void InitIdleSemaphore(); +extern void TermIdleSemaphore(); + +extern void WaitOnIdleSemaphore(); +extern void SignalIdleSemaphore(); + + /* * Atomic operations */ diff --git a/pr/include/md/_netbsd.h b/pr/include/md/_netbsd.h index 1e70994d..0ccc2399 100644 --- a/pr/include/md/_netbsd.h +++ b/pr/include/md/_netbsd.h @@ -80,6 +80,7 @@ #if __NetBSD_Version__ >= 105000000 #define _PR_INET6 +#define _PR_HAVE_INET_NTOP #define _PR_HAVE_GETHOSTBYNAME2 #define _PR_INET6_PROBE #endif diff --git a/pr/include/md/_nto.h b/pr/include/md/_nto.h index de6b8033..cd6213bf 100644 --- a/pr/include/md/_nto.h +++ b/pr/include/md/_nto.h @@ -212,4 +212,6 @@ struct _MDCPU { */ #define _MD_SELECT select +#define SA_RESTART 0 + #endif /* nspr_nto_defs_h___ */ diff --git a/pr/include/md/_openvms.h b/pr/include/md/_openvms.h index b0a2af6f..4b3fb92a 100644 --- a/pr/include/md/_openvms.h +++ b/pr/include/md/_openvms.h @@ -97,6 +97,7 @@ struct ip_mreq { #define _PR_USE_POLL #define _PR_STAT_HAS_ONLY_ST_ATIME #define _PR_NO_LARGE_FILES +#define _PR_STRICT_ADDR_LEN /* IPv6 support */ #ifdef _SOCKADDR_LEN @@ -105,7 +106,9 @@ struct ip_mreq { #define _PR_HAVE_GETIPNODEBYNAME #define _PR_HAVE_GETIPNODEBYADDR #define _PR_INET6_PROBE -#ifndef _PR_INET6 +#ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP +#else #define AF_INET6 26 #define AI_V4MAPPED 0x00000010 #define AI_ALL 0x00000008 diff --git a/pr/include/md/_os2.h b/pr/include/md/_os2.h index d98262d1..dc50982a 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -47,18 +47,45 @@ #include +#ifdef XP_OS2_VACPP +/* TODO RAMSEMs need to be written for GCC/EMX */ +#define USE_RAMSEM +#endif + +#ifdef USE_RAMSEM +#pragma pack(4) + +#pragma pack(2) +typedef struct _RAMSEM +{ + ULONG ulTIDPID; + ULONG hevSem; + ULONG cLocks; + USHORT cWaiting; + USHORT cPosts; +} RAMSEM, *PRAMSEM; + +typedef struct _CRITICAL_SECTION +{ + ULONG ulReserved[4]; /* Same size as RAMSEM */ +} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION; +#pragma pack(4) + +APIRET _Optlink SemRequest486(PRAMSEM, ULONG); +APIRET _Optlink SemReleasex86(PRAMSEM, ULONG); +#endif + #ifdef XP_OS2_EMX /* * EMX-specific tweaks: - * o Use stricmp instead of strcmpi. * o Use errno rather than sock_errno() * o Use close rather than soclose * o Ignore sock_init calls. */ -#define strcmpi stricmp #define sock_errno() errno #define soclose close #define sock_init() +#include #endif /* @@ -162,7 +189,11 @@ struct _MDNotified { }; struct _MDLock { - HMTX mutex; /* this is recursive on NT */ +#ifdef USE_RAMSEM + CRITICAL_SECTION mutex; /* this is recursive on NT */ +#else + HMTX mutex; /* this is recursive on NT */ +#endif /* * When notifying cvars, there is no point in actually @@ -258,7 +289,7 @@ extern void _MD_MakeNonblock(PRFileDesc *f); #define _MD_INIT_FD_INHERITABLE (_PR_MD_INIT_FD_INHERITABLE) #define _MD_QUERY_FD_INHERITABLE (_PR_MD_QUERY_FD_INHERITABLE) #define _MD_SHUTDOWN (_PR_MD_SHUTDOWN) -#define _MD_LISTEN(s, backlog) listen(s->secret->md.osfd,backlog) +#define _MD_LISTEN _PR_MD_LISTEN extern PRInt32 _MD_CloseSocket(PRInt32 osfd); #define _MD_CLOSE_SOCKET _MD_CloseSocket #define _MD_SENDTO (_PR_MD_SENDTO) @@ -279,11 +310,13 @@ extern PRInt32 _MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, #define _MD_FSYNC _PR_MD_FSYNC #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) +#ifdef _PR_HAVE_ATOMIC_OPS #define _MD_INIT_ATOMIC() #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT #define _MD_ATOMIC_SET _PR_MD_ATOMIC_SET +#endif #define _MD_INIT_IO (_PR_MD_INIT_IO) #define _MD_PR_POLL (_PR_MD_PR_POLL) @@ -349,11 +382,33 @@ extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, #define _PR_LOCK _MD_LOCK #define _PR_UNLOCK _MD_UNLOCK +#ifdef USE_RAMSEM #define _MD_NEW_LOCK (_PR_MD_NEW_LOCK) -#define _MD_FREE_LOCK (_PR_MD_FREE_LOCK) -#define _MD_LOCK (_PR_MD_LOCK) -#define _MD_TEST_AND_LOCK (_PR_MD_TEST_AND_LOCK) -#define _MD_UNLOCK (_PR_MD_UNLOCK) +#define _MD_FREE_LOCK(lock) (DosCloseEventSem(((PRAMSEM)(&((lock)->mutex)))->hevSem)) +#define _MD_LOCK(lock) (SemRequest486(&((lock)->mutex), -1)) +#define _MD_TEST_AND_LOCK(lock) (SemRequest486(&((lock)->mutex), -1),0) +#define _MD_UNLOCK(lock) \ + PR_BEGIN_MACRO \ + if (0 != (lock)->notified.length) { \ + md_UnlockAndPostNotifies((lock), NULL, NULL); \ + } else { \ + SemReleasex86( &(lock)->mutex, 0 ); \ + } \ + PR_END_MACRO +#else +#define _MD_NEW_LOCK (_PR_MD_NEW_LOCK) +#define _MD_FREE_LOCK(lock) (DosCloseMutexSem((lock)->mutex)) +#define _MD_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT)) +#define _MD_TEST_AND_LOCK(lock) (DosRequestMutexSem((lock)->mutex, SEM_INDEFINITE_WAIT),0) +#define _MD_UNLOCK(lock) \ + PR_BEGIN_MACRO \ + if (0 != (lock)->notified.length) { \ + md_UnlockAndPostNotifies((lock), NULL, NULL); \ + } else { \ + DosReleaseMutexSem((lock)->mutex); \ + } \ + PR_END_MACRO +#endif /* --- lock and cv waiting --- */ #define _MD_WAIT (_PR_MD_WAIT) @@ -431,7 +486,8 @@ typedef struct __NSPR_TLS extern _NSPR_TLS* pThreadLocalStorage; NSPR_API(void) _PR_MD_ENSURE_TLS(void); -#define _MD_CURRENT_THREAD() pThreadLocalStorage->_pr_currentThread +#define _MD_GET_ATTACHED_THREAD() pThreadLocalStorage->_pr_currentThread +extern struct PRThread * _MD_CURRENT_THREAD(void); #define _MD_SET_CURRENT_THREAD(_thread) _PR_MD_ENSURE_TLS(); pThreadLocalStorage->_pr_currentThread = (_thread) #define _MD_LAST_THREAD() pThreadLocalStorage->_pr_thread_last_run @@ -537,4 +593,6 @@ unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long fla #define FreeLibrary(x) DosFreeModule((HMODULE)x) #define OutputDebugString(x) +extern int _MD_os2_get_nonblocking_connect_error(int osfd); + #endif /* nspr_os2_defs_h___ */ diff --git a/pr/include/md/_os2_errors.h b/pr/include/md/_os2_errors.h index f77e8f6e..f196a201 100644 --- a/pr/include/md/_os2_errors.h +++ b/pr/include/md/_os2_errors.h @@ -40,14 +40,17 @@ #include #endif +NSPR_API(void) _MD_os2_map_default_error(PRInt32 err); +#define _PR_MD_MAP_DEFAULT_ERROR _MD_os2_map_default_error + NSPR_API(void) _MD_os2_map_opendir_error(PRInt32 err); #define _PR_MD_MAP_OPENDIR_ERROR _MD_os2_map_opendir_error NSPR_API(void) _MD_os2_map_closedir_error(PRInt32 err); #define _PR_MD_MAP_CLOSEDIR_ERROR _MD_os2_map_closedir_error -NSPR_API(void) _MD_unix_readdir_error(PRInt32 err); -#define _PR_MD_MAP_READDIR_ERROR _MD_unix_readdir_error +NSPR_API(void) _MD_os2_readdir_error(PRInt32 err); +#define _PR_MD_MAP_READDIR_ERROR _MD_os2_readdir_error NSPR_API(void) _MD_os2_map_delete_error(PRInt32 err); #define _PR_MD_MAP_DELETE_ERROR _MD_os2_map_delete_error @@ -103,6 +106,9 @@ NSPR_API(void) _MD_os2_map_send_error(PRInt32 err); NSPR_API(void) _MD_os2_map_sendto_error(PRInt32 err); #define _PR_MD_MAP_SENDTO_ERROR _MD_os2_map_sendto_error +NSPR_API(void) _MD_os2_map_writev_error(int err); +#define _PR_MD_MAP_WRITEV_ERROR _MD_os2_map_writev_error + NSPR_API(void) _MD_os2_map_accept_error(PRInt32 err); #define _PR_MD_MAP_ACCEPT_ERROR _MD_os2_map_accept_error diff --git a/pr/include/md/_osf1.h b/pr/include/md/_osf1.h index edf2fa3d..a098a0db 100644 --- a/pr/include/md/_osf1.h +++ b/pr/include/md/_osf1.h @@ -60,19 +60,14 @@ #define _PR_POLL_AVAILABLE #define _PR_USE_POLL -/* - * OSF1 and HPUX report the POLLHUP event for a socket when the - * shutdown(SHUT_WR) operation is called for the remote end, even though - * the socket is still writeable. Use select(), instead of poll(), to - * workaround this problem. - */ -#define _PR_POLL_WITH_SELECT #define _PR_STAT_HAS_ONLY_ST_ATIME #define _PR_HAVE_LARGE_OFF_T #define _PR_HAVE_GETIPNODEBYNAME #define _PR_HAVE_GETIPNODEBYADDR #define _PR_INET6_PROBE -#ifndef _PR_INET6 +#ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP +#else #define AF_INET6 26 #define AI_V4MAPPED 0x00000010 #define AI_ALL 0x00000008 diff --git a/pr/include/md/_pth.h b/pr/include/md/_pth.h index faa50377..3a50899c 100644 --- a/pr/include/md/_pth.h +++ b/pr/include/md/_pth.h @@ -91,7 +91,11 @@ #define _PT_PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_destroy #define _PT_PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), &(a)) #define _PT_PTHREAD_MUTEX_IS_LOCKED(m) (EBUSY == pthread_mutex_trylock(&(m))) +#if defined(DARWIN) +#define _PT_PTHREAD_CONDATTR_INIT(x) 0 +#else #define _PT_PTHREAD_CONDATTR_INIT pthread_condattr_init +#endif #define _PT_PTHREAD_CONDATTR_DESTROY pthread_condattr_destroy #define _PT_PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), &(a)) #endif @@ -182,21 +186,20 @@ #endif /* - * These platforms don't have pthread_atfork() + * These platforms don't have sigtimedwait() */ -#if defined(_PR_DCETHREADS) || defined(FREEBSD) \ - || (defined(LINUX) && defined(__alpha)) \ - || defined(NETBSD) || defined(OPENBSD) -#define PT_NO_ATFORK +#if (defined(AIX) && !defined(AIX4_3_PLUS)) || defined(LINUX) \ + || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ + || defined(BSDI) || defined(VMS) || defined(UNIXWARE) \ + || defined(DARWIN) +#define PT_NO_SIGTIMEDWAIT #endif /* - * These platforms don't have sigtimedwait() + * These platforms don't have pthread_kill() */ -#if (defined(AIX) && !defined(AIX4_3)) || defined(LINUX) \ - || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) || defined(VMS) || defined(UNIXWARE) -#define PT_NO_SIGTIMEDWAIT +#if defined(DARWIN) +#define pthread_kill(thread, sig) ENOSYS #endif #if defined(OSF1) || defined(VMS) @@ -225,7 +228,7 @@ #define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER) #endif /* defined(_PR_DCETHREADS) */ -#elif defined(LINUX) +#elif defined(LINUX) || defined(FREEBSD) #define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER) #define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER) #elif defined(NTO) @@ -245,7 +248,7 @@ */ #define PT_PRIO_MIN 1 #define PT_PRIO_MAX 127 -#elif defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ +#elif defined(NETBSD) || defined(OPENBSD) \ || defined(BSDI) || defined(DARWIN) || defined(UNIXWARE) /* XXX */ #define PT_PRIO_MIN 0 #define PT_PRIO_MAX 126 diff --git a/pr/include/md/_solaris.h b/pr/include/md/_solaris.h index a6412b69..01b5fed4 100644 --- a/pr/include/md/_solaris.h +++ b/pr/include/md/_solaris.h @@ -41,7 +41,13 @@ #define PR_LINKER_ARCH "solaris" #define _PR_SI_SYSNAME "SOLARIS" +#ifdef sparc #define _PR_SI_ARCHITECTURE "sparc" +#elif defined(i386) +#define _PR_SI_ARCHITECTURE "x86" +#else +#error unknown processor +#endif #define PR_DLL_SUFFIX ".so" #define _PR_VMBASE 0x30000000 @@ -105,7 +111,9 @@ #define _PR_HAVE_GETIPNODEBYADDR #define _PR_INET6_PROBE #define _PR_ACCEPT_INHERIT_NONBLOCK -#ifndef _PR_INET6 +#ifdef _PR_INET6 +#define _PR_HAVE_INET_NTOP +#else #define AF_INET6 26 #define AI_V4MAPPED 0x0001 #define AI_ALL 0x0002 @@ -784,5 +792,7 @@ PR_END_EXTERN_C #endif /* _PR_GLOBAL_THREADS_ONLY */ +extern void _MD_solaris_map_sendfile_error(int err); + #endif /* nspr_solaris_defs_h___ */ diff --git a/pr/include/md/_solaris32.cfg b/pr/include/md/_solaris32.cfg index 10cb3364..ec19c4d3 100644 --- a/pr/include/md/_solaris32.cfg +++ b/pr/include/md/_solaris32.cfg @@ -43,12 +43,12 @@ #define SOLARIS #endif -#ifdef sparc +#if defined(sparc) || defined(__sparc) #undef IS_LITTLE_ENDIAN #define IS_BIG_ENDIAN 1 #define PR_ALIGN_OF_INT64 8 #define PR_ALIGN_OF_DOUBLE 8 -#elif defined(i386) +#elif defined(i386) || defined(__i386) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN #define PR_ALIGN_OF_INT64 4 diff --git a/pr/include/md/_solaris64.cfg b/pr/include/md/_solaris64.cfg index 8318b74b..54331c51 100644 --- a/pr/include/md/_solaris64.cfg +++ b/pr/include/md/_solaris64.cfg @@ -43,12 +43,12 @@ #define SOLARIS #endif -#ifdef sparc +#if defined(sparc) || defined(__sparc) #undef IS_LITTLE_ENDIAN #define IS_BIG_ENDIAN 1 #define PR_ALIGN_OF_INT64 8 #define PR_ALIGN_OF_DOUBLE 8 -#elif defined(i386) +#elif defined(i386) || defined(__i386) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN #define PR_ALIGN_OF_INT64 4 diff --git a/pr/include/md/_unixos.h b/pr/include/md/_unixos.h index 345c48d5..25ae239c 100644 --- a/pr/include/md/_unixos.h +++ b/pr/include/md/_unixos.h @@ -145,6 +145,9 @@ extern PRUint32 _pr_md_ioq_timeout; struct _MDFileDesc { int osfd; +#if defined(LINUX) && defined(_PR_PTHREADS) + int tcp_nodelay; /* used by pt_LinuxSendFile */ +#endif }; struct _MDDir { diff --git a/pr/include/md/_win16.h b/pr/include/md/_win16.h index 147ef77a..15edc7db 100644 --- a/pr/include/md/_win16.h +++ b/pr/include/md/_win16.h @@ -442,13 +442,6 @@ NSPR_API(void) _PR_NativeDestroyThread(PRThread *thread); NSPR_API(void) _PR_UserDestroyThread(PRThread *thread); -/* - * _PR_ShutdownLinker unloads all dlls loaded by the application via - * calls to PR_LoadLibrary - */ -void _PR_ShutdownLinker(void); - - /* ** If thread emulation is used, then setjmp/longjmp stores the register ** state of each thread. diff --git a/pr/include/md/_win95.h b/pr/include/md/_win95.h index 6a9bb271..5307a881 100644 --- a/pr/include/md/_win95.h +++ b/pr/include/md/_win95.h @@ -112,6 +112,16 @@ struct _MDDir { PRUint32 magic; /* for debugging */ }; +#ifdef MOZ_UNICODE +struct _MDDirUTF16 { + HANDLE d_hdl; + WIN32_FIND_DATAW d_entry; + PRBool firstEntry; /* Is this the entry returned + * by FindFirstFileW()? */ + PRUint32 magic; /* for debugging */ +}; +#endif /* MOZ_UNICODE */ + struct _MDCVar { PRUint32 magic; struct PRThread *waitHead, *waitTail; /* the wait queue: a doubly- @@ -213,6 +223,15 @@ extern PRInt32 _MD_CloseFile(PRInt32 osfd); #define _MD_TLOCKFILE _PR_MD_TLOCKFILE #define _MD_UNLOCKFILE _PR_MD_UNLOCKFILE +#ifdef MOZ_UNICODE +/* --- UTF16 IO stuff --- */ +#define _MD_OPEN_FILE_UTF16 _PR_MD_OPEN_FILE_UTF16 +#define _MD_OPEN_DIR_UTF16 _PR_MD_OPEN_DIR_UTF16 +#define _MD_READ_DIR_UTF16 _PR_MD_READ_DIR_UTF16 +#define _MD_CLOSE_DIR_UTF16 _PR_MD_CLOSE_DIR_UTF16 +#define _MD_GETFILEINFO64_UTF16 _PR_MD_GETFILEINFO64_UTF16 +#endif /* MOZ_UNICODE */ + /* --- Socket IO stuff --- */ #define _MD_EACCES WSAEACCES #define _MD_EADDRINUSE WSAEADDRINUSE @@ -243,7 +262,7 @@ extern void _MD_MakeNonblock(PRFileDesc *f); #define _MD_INIT_FD_INHERITABLE _PR_MD_INIT_FD_INHERITABLE #define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE #define _MD_SHUTDOWN _PR_MD_SHUTDOWN -#define _MD_LISTEN(s, backlog) listen(s->secret->md.osfd,backlog) +#define _MD_LISTEN _PR_MD_LISTEN extern PRInt32 _MD_CloseSocket(PRInt32 osfd); #define _MD_CLOSE_SOCKET _MD_CloseSocket #define _MD_SENDTO _PR_MD_SENDTO @@ -405,6 +424,9 @@ extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process); #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) +/* --- Time --- */ +extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm); + /* --- Native-Thread Specific Definitions ------------------------------- */ extern struct PRThread * _MD_CURRENT_THREAD(void); diff --git a/pr/include/md/_winnt.h b/pr/include/md/_winnt.h index de8a2cf7..efc60edd 100644 --- a/pr/include/md/_winnt.h +++ b/pr/include/md/_winnt.h @@ -47,6 +47,9 @@ #include #include +#ifdef __MINGW32__ +#include +#endif #include #include "prio.h" @@ -346,6 +349,8 @@ extern int _PR_NTFiberSafeSelect(int, fd_set *, fd_set *, fd_set *, #define _MD_INIT_THREAD _PR_MD_INIT_THREAD #define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD #define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD +#define _MD_JOIN_THREAD _PR_MD_JOIN_THREAD +#define _MD_END_THREAD _PR_MD_END_THREAD #define _MD_YIELD _PR_MD_YIELD #define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY #define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD @@ -449,6 +454,9 @@ extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process); #define _MD_INTERVAL_PER_MILLISEC() (_PR_MD_INTERVAL_PER_SEC() / 1000) #define _MD_INTERVAL_PER_MICROSEC() (_PR_MD_INTERVAL_PER_SEC() / 1000000) +/* --- Time --- */ +extern void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm); + /* --- Native-Thread Specific Definitions ------------------------------- */ extern BOOL _pr_use_static_tls; diff --git a/pr/include/obsolete/Makefile.in b/pr/include/obsolete/Makefile.in index 88342b0b..f2d78313 100644 --- a/pr/include/obsolete/Makefile.in +++ b/pr/include/obsolete/Makefile.in @@ -48,7 +48,7 @@ HEADERS = $(wildcard $(srcdir)/*.h) RELEASE_HEADERS = $(HEADERS) RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/obsolete -includedir := $(includedir)/obsolete +include_subdir = obsolete include $(topsrcdir)/config/rules.mk diff --git a/pr/include/prcountr.h b/pr/include/prcountr.h index 1a7d1456..105135f1 100644 --- a/pr/include/prcountr.h +++ b/pr/include/prcountr.h @@ -116,7 +116,6 @@ typedef void * PRCounterHandle; #define PRCOUNTER_DESC_MAX 255 -#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) /* ----------------------------------------------------------------------- ** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle @@ -135,8 +134,12 @@ typedef void * PRCounterHandle; ** to value. ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_INIT_COUNTER_HANDLE(handle,value)\ (handle) = (PRCounterHandle)(value) +#else +#define PR_INIT_COUNTER_HANDLE(handle,value) +#endif /* ----------------------------------------------------------------------- ** FUNCTION: PR_CreateCounter() -- Create a counter @@ -167,8 +170,12 @@ typedef void * PRCounterHandle; ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_CREATE_COUNTER(handle,qName,rName,description)\ (handle) = PR_CreateCounter((qName),(rName),(description)) +#else +#define PR_CREATE_COUNTER(handle,qName,rName,description) +#endif NSPR_API(PRCounterHandle) PR_CreateCounter( @@ -194,7 +201,11 @@ NSPR_API(PRCounterHandle) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_DESTROY_COUNTER(handle) PR_DestroyCounter((handle)) +#else +#define PR_DESTROY_COUNTER(handle) +#endif NSPR_API(void) PR_DestroyCounter( @@ -222,8 +233,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\ (handle) = PR_GetCounterHandleFromName((qName),(rName)) +#else +#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName) +#endif NSPR_API(PRCounterHandle) PR_GetCounterHandleFromName( @@ -251,8 +266,12 @@ NSPR_API(PRCounterHandle) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\ PR_GetCounterNameFromHandle((handle),(qName),(rName),(description)) +#else +#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description ) +#endif NSPR_API(void) PR_GetCounterNameFromHandle( @@ -279,7 +298,11 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_INCREMENT_COUNTER(handle) PR_IncrementCounter(handle) +#else +#define PR_INCREMENT_COUNTER(handle) +#endif NSPR_API(void) PR_IncrementCounter( @@ -304,7 +327,11 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_DECREMENT_COUNTER(handle) PR_DecrementCounter(handle) +#else +#define PR_DECREMENT_COUNTER(handle) +#endif NSPR_API(void) PR_DecrementCounter( @@ -328,8 +355,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_ADD_TO_COUNTER(handle,value)\ PR_AddToCounter((handle),(value)) +#else +#define PR_ADD_TO_COUNTER(handle,value) +#endif NSPR_API(void) PR_AddToCounter( @@ -358,8 +389,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_SUBTRACT_FROM_COUNTER(handle,value)\ PR_SubtractFromCounter((handle),(value)) +#else +#define PR_SUBTRACT_FROM_COUNTER(handle,value) +#endif NSPR_API(void) PR_SubtractFromCounter( @@ -384,8 +419,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_GET_COUNTER(counter,handle)\ (counter) = PR_GetCounter((handle)) +#else +#define PR_GET_COUNTER(counter,handle) 0 +#endif NSPR_API(PRUint32) PR_GetCounter( @@ -412,7 +451,11 @@ NSPR_API(PRUint32) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value)) +#else +#define PR_SET_COUNTER(handle,value) +#endif NSPR_API(void) PR_SetCounter( @@ -450,8 +493,12 @@ NSPR_API(void) ** operations may cause unpredictable results. ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\ (next) = PR_FindNextCounterQname((handle)) +#else +#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL +#endif NSPR_API(PRCounterHandle) PR_FindNextCounterQname( @@ -489,8 +536,12 @@ NSPR_API(PRCounterHandle) ** operations may cause unpredictable results. ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\ (next) = PR_FindNextCounterRname((rhandle),(qhandle)) +#else +#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle) +#endif NSPR_API(PRCounterHandle) PR_FindNextCounterRname( @@ -498,31 +549,6 @@ NSPR_API(PRCounterHandle) PRCounterHandle qhandle ); - -#else /* ( !(defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)) */ -/* -** When counters are not compiled in, provide macros that -** evaluate to No-Ops. -** -*/ - -#define PR_DEFINE_COUNTER(name) PRCounterHandle name -#define PR_INIT_COUNTER_HANDLE(handle,value) -#define PR_CREATE_COUNTER(handle,qName,rName,description) -#define PR_DESTROY_COUNTER(handle) -#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName) -#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description ) -#define PR_INCREMENT_COUNTER(handle) -#define PR_DECREMENT_COUNTER(handle) -#define PR_ADD_TO_COUNTER(handle,value) -#define PR_SUBTRACT_FROM_COUNTER(handle,value) -#define PR_GET_COUNTER(counter,handle) 0 -#define PR_SET_COUNTER(handle,value) -#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL -#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle) - -#endif /* ( !(defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)) */ - PR_END_EXTERN_C #endif /* prcountr_h___ */ diff --git a/pr/include/prerr.h b/pr/include/prerr.h index 530526b6..5bb6c9e8 100644 --- a/pr/include/prerr.h +++ b/pr/include/prerr.h @@ -263,8 +263,11 @@ /* Host is unreachable */ #define PR_HOST_UNREACHABLE_ERROR (-5927L) +/* The library is not loaded */ +#define PR_LIBRARY_NOT_LOADED_ERROR (-5926L) + /* Placeholder for the end of the list */ -#define PR_MAX_ERROR (-5926L) +#define PR_MAX_ERROR (-5925L) extern void nspr_InitializePRErrorTable(void); #define ERROR_TABLE_BASE_nspr (-6000L) diff --git a/pr/include/prinet.h b/pr/include/prinet.h index f5aea7eb..8dba5cd1 100644 --- a/pr/include/prinet.h +++ b/pr/include/prinet.h @@ -57,7 +57,7 @@ #define prinet_h__ #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) -#ifdef linux +#ifdef LINUX #undef __STRICT_ANSI__ #define __STRICT_ANSI__ #endif diff --git a/pr/include/prinit.h b/pr/include/prinit.h index 0e8e124c..64ca8cc3 100644 --- a/pr/include/prinit.h +++ b/pr/include/prinit.h @@ -60,9 +60,9 @@ PR_BEGIN_EXTERN_C ** The format of the version string is ** ".[.] []" */ -#define PR_VERSION "4.2 Beta" +#define PR_VERSION "4.4 Beta" #define PR_VMAJOR 4 -#define PR_VMINOR 2 +#define PR_VMINOR 4 #define PR_VPATCH 0 #define PR_BETA PR_TRUE @@ -220,11 +220,19 @@ typedef struct PRCallOnceType { typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void); +typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg); + NSPR_API(PRStatus) PR_CallOnce( PRCallOnceType *once, PRCallOnceFN func ); +NSPR_API(PRStatus) PR_CallOnceWithArg( + PRCallOnceType *once, + PRCallOnceWithArgFN func, + void *arg +); + PR_END_EXTERN_C diff --git a/pr/include/prio.h b/pr/include/prio.h index f60e1f1a..42beca33 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -52,6 +52,10 @@ PR_BEGIN_EXTERN_C /* Typedefs */ typedef struct PRDir PRDir; typedef struct PRDirEntry PRDirEntry; +#ifdef MOZ_UNICODE +typedef struct PRDirUTF16 PRDirUTF16; +typedef struct PRDirEntryUTF16 PRDirEntryUTF16; +#endif /* MOZ_UNICODE */ typedef struct PRFileDesc PRFileDesc; typedef struct PRFileInfo PRFileInfo; typedef struct PRFileInfo64 PRFileInfo64; @@ -156,7 +160,7 @@ struct PRIPv6Addr { #define pr_s6_addr _S6_un._S6_u8 #define pr_s6_addr16 _S6_un._S6_u16 #define pr_s6_addr32 _S6_un._S6_u32 -#define pr_s6_addr64 _S6_un._S6_addr64 +#define pr_s6_addr64 _S6_un._S6_u64 typedef struct PRIPv6Addr PRIPv6Addr; @@ -650,6 +654,14 @@ NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode); NSPR_API(PRFileDesc*) PR_OpenFile( const char *name, PRIntn flags, PRIntn mode); +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRFileDesc*) PR_OpenFileUTF16( + const PRUnichar *name, PRIntn flags, PRIntn mode); +#endif /* MOZ_UNICODE */ + /* ************************************************************************** * FUNCTION: PR_Close @@ -830,6 +842,13 @@ struct PRFileInfo64 { NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info); NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info); +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info); +#endif /* MOZ_UNICODE */ + /* ************************************************************************** * FUNCTION: PR_GetOpenFileInfo, PR_GetOpenFileInfo64 @@ -984,6 +1003,13 @@ struct PRDirEntry { const char *name; /* name of entry, relative to directory name */ }; +#ifdef MOZ_UNICODE +struct PRDirEntryUTF16 { + const PRUnichar *name; /* name of entry in UTF16, relative to + * directory name */ +}; +#endif /* MOZ_UNICODE */ + #if !defined(NO_NSPR_10_SUPPORT) #define PR_DirName(dirEntry) (dirEntry->name) #endif @@ -1010,6 +1036,13 @@ struct PRDirEntry { NSPR_API(PRDir*) PR_OpenDir(const char *name); +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar *name); +#endif /* MOZ_UNICODE */ + /* ************************************************************************* * FUNCTION: PR_ReadDir @@ -1043,6 +1076,13 @@ typedef enum PRDirFlags { NSPR_API(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags); +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRDirEntryUTF16*) PR_ReadDirUTF16(PRDirUTF16 *dir, PRDirFlags flags); +#endif /* MOZ_UNICODE */ + /* ************************************************************************* * FUNCTION: PR_CloseDir @@ -1062,6 +1102,13 @@ NSPR_API(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags); NSPR_API(PRStatus) PR_CloseDir(PRDir *dir); +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This function may be removed in a future release. + */ +NSPR_API(PRStatus) PR_CloseDirUTF16(PRDirUTF16 *dir); +#endif /* MOZ_UNICODE */ + /* ************************************************************************* * FUNCTION: PR_MkDir @@ -1240,7 +1287,7 @@ NSPR_API(PRStatus) PR_Connect( * PR_Poll() * RETURN: PRStatus * If the nonblocking connect has successfully completed, - * PR_GetConnectStatus returns PR_SUCCESS. If PR_GetConnectStatus() + * PR_ConnectContinue returns PR_SUCCESS. If PR_ConnectContinue() * returns PR_FAILURE, call PR_GetError(): * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in * progress and has not completed yet. The caller should poll @@ -1880,9 +1927,12 @@ struct PRPollDesc { ** DESCRIPTION: ** ** The call returns as soon as I/O is ready on one or more of the underlying -** file/socket objects. A count of the number of ready descriptors is +** socket objects. A count of the number of ready descriptors is ** returned unless a timeout occurs in which case zero is returned. ** +** PRPollDesc.fd should be set to a pointer to a PRFileDesc object +** representing a socket. This field can be set to NULL to indicate to +** PR_Poll that this PRFileDesc object should be ignored. ** PRPollDesc.in_flags should be set to the desired request ** (read/write/except or some combination). Upon successful return from ** this call PRPollDesc.out_flags will be set to indicate what kind of diff --git a/pr/include/private/Makefile.in b/pr/include/private/Makefile.in index 31c82552..cafb86c8 100644 --- a/pr/include/private/Makefile.in +++ b/pr/include/private/Makefile.in @@ -49,7 +49,7 @@ RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/private HEADERS = $(RELEASE_HEADERS) $(srcdir)/pprmwait.h $(srcdir)/primpl.h -includedir := $(includedir)/private +include_subdir = private include $(topsrcdir)/config/rules.mk diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index 8501c0e0..b0cd1b5b 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -144,6 +144,9 @@ typedef struct _MDThread _MDThread; typedef struct _MDThreadStack _MDThreadStack; typedef struct _MDSemaphore _MDSemaphore; typedef struct _MDDir _MDDir; +#ifdef MOZ_UNICODE +typedef struct _MDDirUTF16 _MDDirUTF16; +#endif /* MOZ_UNICODE */ typedef struct _MDFileDesc _MDFileDesc; typedef struct _MDProcess _MDProcess; typedef struct _MDFileMap _MDFileMap; @@ -216,22 +219,13 @@ typedef struct PTDebug PRUintn cvars_notified, delayed_cv_deletes; } PTDebug; -NSPR_API(void) PT_GetStats(PTDebug* here); -NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg); - -#else - -typedef PRUintn PTDebug; -#define PT_GetStats(_p) -#define PT_FPrintStats(_fd, _msg) - #endif /* defined(DEBUG) */ +NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg); + #else /* defined(_PR_PTHREADS) */ -typedef PRUintn PTDebug; -#define PT_GetStats(_p) -#define PT_FPrintStats(_fd, _msg) +NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg); /* ** This section is contains those parts needed to implement NSPR on @@ -310,7 +304,7 @@ typedef struct _PRInterruptTable { #define _PR_CPU_PTR(_qp) \ ((_PRCPU*) ((char*) (_qp) - offsetof(_PRCPU,links))) -#if !defined(IRIX) && !defined(WIN32) +#if !defined(IRIX) && !defined(WIN32) && !defined(XP_OS2) #define _MD_GET_ATTACHED_THREAD() (_PR_MD_CURRENT_THREAD()) #endif @@ -1022,6 +1016,12 @@ extern PRStatus _PR_MD_CREATE_THREAD( PRUint32 stackSize); #define _PR_MD_CREATE_THREAD _MD_CREATE_THREAD +extern void _PR_MD_JOIN_THREAD(_MDThread *md); +#define _PR_MD_JOIN_THREAD _MD_JOIN_THREAD + +extern void _PR_MD_END_THREAD(void); +#define _PR_MD_END_THREAD _MD_END_THREAD + extern void _PR_MD_YIELD(void); #define _PR_MD_YIELD _MD_YIELD @@ -1138,6 +1138,24 @@ extern PRInt32 _PR_MD_MAKE_DIR(const char *name, PRIntn mode); extern PRInt32 _PR_MD_RMDIR(const char *name); #define _PR_MD_RMDIR _MD_RMDIR +#ifdef MOZ_UNICODE +/* UTF16 File I/O related */ +extern PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *md, const PRUnichar *name); +#define _PR_MD_OPEN_DIR_UTF16 _MD_OPEN_DIR_UTF16 + +extern PRInt32 _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, PRIntn mode); +#define _PR_MD_OPEN_FILE_UTF16 _MD_OPEN_FILE_UTF16 + +extern PRUnichar * _PR_MD_READ_DIR_UTF16(_MDDirUTF16 *md, PRIntn flags); +#define _PR_MD_READ_DIR_UTF16 _MD_READ_DIR_UTF16 + +extern PRInt32 _PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16 *md); +#define _PR_MD_CLOSE_DIR_UTF16 _MD_CLOSE_DIR_UTF16 + +extern PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *info); +#define _PR_MD_GETFILEINFO64_UTF16 _MD_GETFILEINFO64_UTF16 +#endif /* MOZ_UNICODE */ + /* Socket I/O related */ extern void _PR_MD_INIT_IO(void); #define _PR_MD_INIT_IO _MD_INIT_IO @@ -1716,6 +1734,13 @@ struct PRFilePrivate { PRBool appendMode; #endif _MDFileDesc md; +#ifdef _PR_STRICT_ADDR_LEN + PRUint16 af; /* If the platform requires passing the exact + * length of the sockaddr structure for the + * address family of the socket to socket + * functions like accept(), we need to save + * the address family of the socket. */ +#endif }; struct PRDir { @@ -1723,6 +1748,13 @@ struct PRDir { _MDDir md; }; +#ifdef MOZ_UNICODE +struct PRDirUTF16 { + PRDirEntry d; + _MDDirUTF16 md; +}; +#endif /* MOZ_UNICODE */ + extern void _PR_InitSegs(void); extern void _PR_InitStacks(void); extern void _PR_InitTPD(void); @@ -1741,10 +1773,18 @@ extern void _PR_InitMW(void); extern void _PR_InitRWLocks(void); extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me); extern void _PR_CleanupThread(PRThread *thread); +extern void _PR_CleanupCallOnce(void); +extern void _PR_CleanupMW(void); +extern void _PR_CleanupDtoa(void); +extern void _PR_ShutdownLinker(void); extern void _PR_CleanupEnv(void); extern void _PR_CleanupIO(void); +extern void _PR_CleanupNet(void); extern void _PR_CleanupLayerCache(void); extern void _PR_CleanupStacks(void); +#ifdef WINNT +extern void _PR_CleanupCPUs(void); +#endif extern void _PR_CleanupThreads(void); extern void _PR_CleanupTPD(void); extern void _PR_Cleanup(void); @@ -1800,7 +1840,7 @@ extern PRFileDesc *_pr_stderr; ** and functions with macros that expand to the native thread ** types and functions on each platform. */ -#if defined(_PR_PTHREADS) +#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) #define _PR_ZONE_ALLOCATOR #endif diff --git a/pr/include/prlink.h b/pr/include/prlink.h index 3787a369..5ccd25f1 100644 --- a/pr/include/prlink.h +++ b/pr/include/prlink.h @@ -239,6 +239,14 @@ NSPR_API(PRFuncPtr) PR_FindFunctionSymbolAndLibrary(const char *name, NSPR_API(PRLibrary*) PR_LoadStaticLibrary( const char *name, const PRStaticLinkTable *table); +/* +** Return the pathname of the file that the library "name" was loaded +** from. "addr" is the address of a function defined in the library. +** +** The caller is responsible for freeing the result with PR_Free. +*/ +NSPR_API(char *) PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr); + PR_END_EXTERN_C #endif /* prlink_h___ */ diff --git a/pr/include/prlong.h b/pr/include/prlong.h index 898b2f6d..b72471e9 100644 --- a/pr/include/prlong.h +++ b/pr/include/prlong.h @@ -51,6 +51,7 @@ PR_BEGIN_EXTERN_C ** DEFINES: LL_MaxInt ** LL_MinInt ** LL_Zero +** LL_MaxUint ** DESCRIPTION: ** Various interesting constants and static variable ** initializer @@ -62,15 +63,19 @@ PRInt64 __pascal __loadds __export LL_MinInt(void); PRInt64 __pascal __loadds __export LL_Zero(void); +PRUint64 __pascal __loadds __export + LL_MaxUint(void); #else NSPR_API(PRInt64) LL_MaxInt(void); NSPR_API(PRInt64) LL_MinInt(void); NSPR_API(PRInt64) LL_Zero(void); +NSPR_API(PRUint64) LL_MaxUint(void); #endif #define LL_MAXINT LL_MaxInt() #define LL_MININT LL_MinInt() #define LL_ZERO LL_Zero() +#define LL_MAXUINT LL_MaxUint() #if defined(HAVE_LONG_LONG) diff --git a/pr/include/prolock.h b/pr/include/prolock.h index 80b92e17..d0bdbe61 100644 --- a/pr/include/prolock.h +++ b/pr/include/prolock.h @@ -39,8 +39,6 @@ PR_BEGIN_EXTERN_C -#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) - /* ** A locking mechanism, built on the existing PRLock definiion, ** is provided that will permit applications to define a Lock @@ -80,7 +78,18 @@ PR_BEGIN_EXTERN_C ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) typedef void * PROrderedLock; +#else +/* +** Map PROrderedLock and methods onto PRLock when ordered locking +** is not compiled in. +** +*/ +#include "prlock.h" + +typedef PRLock PROrderedLock; +#endif /* ----------------------------------------------------------------------- ** FUNCTION: PR_CreateOrderedLock() -- Create an Ordered Lock @@ -98,8 +107,12 @@ typedef void * PROrderedLock; ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) #define PR_CREATE_ORDERED_LOCK(order,name)\ PR_CreateOrderedLock((order),(name)) +#else +#define PR_CREATE_ORDERED_LOCK(order) PR_NewLock() +#endif NSPR_API(PROrderedLock *) PR_CreateOrderedLock( @@ -122,7 +135,11 @@ NSPR_API(PROrderedLock *) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) #define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyOrderedLock((lock)) +#else +#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyLock((lock)) +#endif NSPR_API(void) PR_DestroyOrderedLock( @@ -146,7 +163,11 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) #define PR_LOCK_ORDERED_LOCK(lock) PR_LockOrderedLock((lock)) +#else +#define PR_LOCK_ORDERED_LOCK(lock) PR_Lock((lock)) +#endif NSPR_API(void) PR_LockOrderedLock( @@ -170,43 +191,17 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS) #define PR_UNLOCK_ORDERED_LOCK(lock) PR_UnlockOrderedLock((lock)) +#else +#define PR_UNLOCK_ORDERED_LOCK(lock) PR_Unlock((lock)) +#endif NSPR_API(PRStatus) PR_UnlockOrderedLock( PROrderedLock *lock ); -#else /* !(defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)) */ -/* -** Map PROrderedLock and methods onto PRLock when ordered locking -** is not compiled in. -** -*/ -#include - -typedef PRLock PROrderedLock; - -#define PR_CREATE_ORDERED_LOCK(order) PR_NewLock() -#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyLock((lock)) -#define PR_LOCK_ORDERED_LOCK(lock) PR_Lock((lock)) -#define PR_UNLOCK_ORDERED_LOCK(lock) PR_Unlock((lock)) - -#endif /* !(defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)) */ - PR_END_EXTERN_C #endif /* prolock_h___ */ - - - - - - - - - - - - - diff --git a/pr/include/prsystem.h b/pr/include/prsystem.h index 9484148a..73404920 100644 --- a/pr/include/prsystem.h +++ b/pr/include/prsystem.h @@ -57,6 +57,13 @@ NSPR_API(char) PR_GetDirectorySeparator(void); NSPR_API(char) PR_GetDirectorySepartor(void); +/* +** Get the host' path separator. +** Paths are assumed to be of the form: +** []* +*/ + +NSPR_API(char) PR_GetPathSeparator(void); /* Types of information available via PR_GetSystemInfo(...) */ typedef enum { diff --git a/pr/include/prthread.h b/pr/include/prthread.h index a987202a..334116ce 100644 --- a/pr/include/prthread.h +++ b/pr/include/prthread.h @@ -159,7 +159,9 @@ NSPR_API(PRStatus) PR_JoinThread(PRThread *thread); ** Never returns NULL. */ NSPR_API(PRThread*) PR_GetCurrentThread(void); +#ifndef NO_NSPR_10_SUPPORT #define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */ +#endif /* NO_NSPR_10_SUPPORT */ /* ** Get the priority of "thread". diff --git a/pr/include/prtrace.h b/pr/include/prtrace.h index 9b0b0bb8..ebfe1baf 100644 --- a/pr/include/prtrace.h +++ b/pr/include/prtrace.h @@ -103,7 +103,6 @@ PR_BEGIN_EXTERN_C */ typedef void * PRTraceHandle; -#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) /* ** PRTraceEntry -- A trace entry in the in-memory trace buffer ** looks like this. @@ -153,8 +152,12 @@ typedef enum PRTraceOption ** to value. e.g. PR_INIT_TRACE_HANDLE( myHandle, NULL ); ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_INIT_TRACE_HANDLE(handle,value)\ (handle) = (PRCounterHandle)(value) +#else +#define PR_INIT_TRACE_HANDLE(handle,value) +#endif /* ----------------------------------------------------------------------- @@ -192,8 +195,12 @@ typedef enum PRTraceOption #define PRTRACE_NAME_MAX 31 #define PRTRACE_DESC_MAX 255 +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_CREATE_TRACE(handle,qName,rName,description)\ (handle) = PR_CreateTrace((qName),(rName),(description)) +#else +#define PR_CREATE_TRACE(handle,qName,rName,description) +#endif NSPR_API(PRTraceHandle) PR_CreateTrace( @@ -222,8 +229,12 @@ NSPR_API(PRTraceHandle) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_DESTROY_TRACE(handle)\ PR_DestroyTrace((handle)) +#else +#define PR_DESTROY_TRACE(handle) +#endif NSPR_API(void) PR_DestroyTrace( @@ -259,8 +270,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\ PR_Trace((handle),(ud0),(ud1),(ud2),(ud3),(ud4),(ud5),(ud6),(ud7)) +#else +#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7) +#endif NSPR_API(void) PR_Trace( @@ -342,8 +357,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_SET_TRACE_OPTION(command,value)\ PR_SetTraceOption((command),(value)) +#else +#define PR_SET_TRACE_OPTION(command,value) +#endif NSPR_API(void) PR_SetTraceOption( @@ -376,8 +395,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_GET_TRACE_OPTION(command,value)\ PR_GetTraceOption((command),(value)) +#else +#define PR_GET_TRACE_OPTION(command,value) +#endif NSPR_API(void) PR_GetTraceOption( @@ -408,8 +431,12 @@ NSPR_API(void) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\ (handle) = PR_GetTraceHandleFromName((qName),(rName)) +#else +#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName) +#endif NSPR_API(PRTraceHandle) PR_GetTraceHandleFromName( @@ -436,8 +463,12 @@ NSPR_API(PRTraceHandle) ** RESTRICTIONS: ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\ PR_GetTraceNameFromHandle((handle),(qName),(rName),(description)) +#else +#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description) +#endif NSPR_API(void) PR_GetTraceNameFromHandle( @@ -474,8 +505,12 @@ NSPR_API(void) ** See: PR_SetTraceOption( PRLockTraceHandles ). ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_FIND_NEXT_TRACE_QNAME(next,handle)\ (next) = PR_FindNextTraceQname((handle)) +#else +#define PR_FIND_NEXT_TRACE_QNAME(next,handle) +#endif NSPR_API(PRTraceHandle) PR_FindNextTraceQname( @@ -512,8 +547,12 @@ NSPR_API(PRTraceHandle) ** PR_SetTraceOption( PRLockTraceHandles ). ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\ (next) = PR_FindNextTraceRname((rhandle),(qhandle)) +#else +#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle) +#endif NSPR_API(PRTraceHandle) PR_FindNextTraceRname( @@ -564,8 +603,12 @@ NSPR_API(PRTraceHandle) ** On error, PR_RecordTraceEntries() may return prematurely. ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_RECORD_TRACE_ENTRIES()\ PR_RecordTraceEntries() +#else +#define PR_RECORD_TRACE_ENTRIES() +#endif NSPR_API(void) PR_RecordTraceEntries( @@ -612,9 +655,12 @@ NSPR_API(void) ** application may be realized. ... YMMV. ** */ +#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #define PR_GET_TRACE_ENTRIES(buffer,count,found)\ PR_GetTraceEntries((buffer),(count),(found)) - +#else +#define PR_GET_TRACE_ENTRIES(buffer,count,found) +#endif NSPR_API(PRIntn) PR_GetTraceEntries( @@ -623,28 +669,6 @@ NSPR_API(PRIntn) PRInt32 *found /* number you got */ ); -#else /* !(defined (DEBUG) || defined (FORCE_NSPR_TRACE)) */ -/* -** Define the Trace Facility macros as No-Ops for when the trace -** facility is to be compiled-out of the application. -** -*/ -#define PR_DEFINE_TRACE(name) PRTraceHandle name -#define PR_INIT_TRACE_HANDLE(handle,value) -#define PR_CREATE_TRACE(handle,qName,rName,description) -#define PR_DESTROY_TRACE(handle) -#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7) -#define PR_SET_TRACE_OPTION(command,value) -#define PR_GET_TRACE_OPTION(command,value) -#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName) -#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description) -#define PR_FIND_NEXT_TRACE_QNAME(next,handle) -#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle) -#define PR_GET_TRACE_ENTRIES(buffer,count,found) -#define PR_RECORD_TRACE_ENTRIES() - -#endif /* !(defined (DEBUG) || defined (FORCE_NSPR_TRACE)) */ - PR_END_EXTERN_C #endif /* prtrace_h___ */ diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index b01673d0..b7ee24f4 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -79,20 +79,15 @@ ***********************************************************************/ #if defined(WIN32) -#if defined(__GNUC__) -#undef _declspec -#define _declspec(x) __declspec(x) -#endif - -#define PR_EXPORT(__type) extern _declspec(dllexport) __type -#define PR_EXPORT_DATA(__type) extern _declspec(dllexport) __type -#define PR_IMPORT(__type) _declspec(dllimport) __type -#define PR_IMPORT_DATA(__type) _declspec(dllimport) __type +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) __declspec(dllimport) __type +#define PR_IMPORT_DATA(__type) __declspec(dllimport) __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_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 @@ -239,13 +234,15 @@ /*********************************************************************** ** MACROS: PR_ROUNDUP ** PR_MIN -** PR_MAX +** PR_MAX +** PR_ABS ** DESCRIPTION: ** Commonly used macros for operations on compatible types. ***********************************************************************/ #define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y)) #define PR_MIN(x,y) ((x)<(y)?(x):(y)) #define PR_MAX(x,y) ((x)>(y)?(x):(y)) +#define PR_ABS(x) ((x)<0?-(x):(x)) PR_BEGIN_EXTERN_C @@ -277,6 +274,18 @@ typedef signed char PRInt8; #error No suitable type for PRInt8/PRUint8 #endif +/************************************************************************ + * MACROS: PR_INT8_MAX + * PR_INT8_MIN + * PR_UINT8_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt8 or PRUint8. +************************************************************************/ + +#define PR_INT8_MAX 127 +#define PR_INT8_MIN (-128) +#define PR_UINT8_MAX 255U + /************************************************************************ ** TYPES: PRUint16 ** PRInt16 @@ -290,6 +299,18 @@ typedef short PRInt16; #error No suitable type for PRInt16/PRUint16 #endif +/************************************************************************ + * MACROS: PR_INT16_MAX + * PR_INT16_MIN + * PR_UINT16_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt16 or PRUint16. +************************************************************************/ + +#define PR_INT16_MAX 32767 +#define PR_INT16_MIN (-32768) +#define PR_UINT16_MAX 65535U + /************************************************************************ ** TYPES: PRUint32 ** PRInt32 @@ -310,6 +331,18 @@ typedef long PRInt32; #error No suitable type for PRInt32/PRUint32 #endif +/************************************************************************ + * MACROS: PR_INT32_MAX + * PR_INT32_MIN + * PR_UINT32_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt32 or PRUint32. +************************************************************************/ + +#define PR_INT32_MAX PR_INT32(2147483647) +#define PR_INT32_MIN (-PR_INT32_MAX - 1) +#define PR_UINT32_MAX PR_UINT32(4294967295) + /************************************************************************ ** TYPES: PRUint64 ** PRInt64 @@ -426,6 +459,20 @@ typedef PRUint8 PRPackedBool; */ typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; +#ifdef MOZ_UNICODE +/* + * EXPERIMENTAL: This type may be removed in a future release. + */ +#ifndef __PRUNICHAR__ +#define __PRUNICHAR__ +#if defined(WIN32) || defined(XP_MAC) +typedef wchar_t PRUnichar; +#else +typedef PRUint16 PRUnichar; +#endif +#endif +#endif /* MOZ_UNICODE */ + /* ** WARNING: The undocumented data types PRWord and PRUword are ** only used in the garbage collection and arena code. Do not diff --git a/pr/include/prwin16.h b/pr/include/prwin16.h index 68e8dc8b..7a561d35 100644 --- a/pr/include/prwin16.h +++ b/pr/include/prwin16.h @@ -108,7 +108,7 @@ struct PRMethodCallbackStr { void (PR_CALLBACK *free)( void *ptr ); void * (PR_CALLBACK *getenv)( const char *name); int (PR_CALLBACK *putenv)( const char *assoc); -// void * (PR_CALLBACK *perror)( const char *prefix ); +/* void * (PR_CALLBACK *perror)( const char *prefix ); */ }; NSPR_API(void) PR_MDRegisterCallbacks(struct PRMethodCallbackStr *); diff --git a/pr/src/Makefile.in b/pr/src/Makefile.in index d4af5676..fdf10cf1 100644 --- a/pr/src/Makefile.in +++ b/pr/src/Makefile.in @@ -69,7 +69,17 @@ ifeq ($(OS_ARCH),SunOS) ifeq ($(OS_RELEASE),4.1.3_U1) OS_LIBS = -lm else # 4.1.3_U1 - +MAPFILE = $(OBJDIR)/nsprmap.sun +GARBAGE += $(MAPFILE) +ifdef NS_USE_GCC +ifdef GCC_USE_GNU_LD +MKSHLIB += -Wl,--version-script,$(MAPFILE) +else +MKSHLIB += -Wl,-M,$(MAPFILE) +endif +else +MKSHLIB += -M $(MAPFILE) +endif # # In Solaris 2.6 or earlier, -lrt is called -lposix4. # @@ -81,14 +91,19 @@ LIBRT=-lposix4 endif ifdef USE_PTHREADS -OS_LIBS = -lpthread -lthread ${LIBRT} -lsocket -lnsl -ldl +OS_LIBS = -lpthread -lthread ${LIBRT} -lsocket -lnsl -ldl -lc else ifdef LOCAL_THREADS_ONLY -OS_LIBS = -lsocket -lnsl -ldl +OS_LIBS = -lsocket -lnsl -ldl -lc else -OS_LIBS = -lthread ${LIBRT} -lsocket -lnsl -ldl +OS_LIBS = -lthread ${LIBRT} -lsocket -lnsl -ldl -lc endif # LOCAL_THREADS_ONLY endif # USE_PTHREADS +ifeq ($(OS_TEST),sun4u) +ifndef USE_64 +DSO_LDOPTS += -Wl,-f,\$$ORIGIN/cpu/\$$ISALIST/lib$(ULTRASPARC_LIBRARY)$(LIBRARY_VERSION).so +endif +endif # sun4u endif # 4.1.3_U1 endif # SunOS @@ -126,6 +141,12 @@ endif endif endif +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + ifeq ($(OS_ARCH),OSF1) ifeq ($(USE_PTHREADS), 1) OS_LIBS = -lpthread -lrt @@ -137,9 +158,9 @@ endif ifeq ($(OS_ARCH),Linux) ifeq ($(USE_PTHREADS), 1) -OS_LIBS = -lpthread -ldl -lc +OS_LIBS = -lpthread -ldl else -OS_LIBS = -ldl -lc +OS_LIBS = -ldl endif endif @@ -170,8 +191,16 @@ OS_LIBS = -lsocket -lnsl -lgen -lresolv endif ifeq ($(OS_ARCH),WINNT) +ifdef NS_USE_GCC +OS_LIBS = -ladvapi32 -lws2_32 +else OS_LIBS = advapi32.lib wsock32.lib endif +endif + +ifeq ($(OS_TARGET),MacOSX) +OS_LIBS = -framework CoreServices -framework CoreFoundation +endif ifdef GC_LEAK_DETECTOR EXTRA_LIBS = -L$(dist_libdir) -lboehm @@ -281,7 +310,11 @@ OBJS += memory/$(OBJDIR)/prgcleak.$(OBJ_SUFFIX) endif ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC +DLLBASE=-Wl,--image-base -Wl,0x30000000 +else DLLBASE=/BASE:0x30000000 +endif # GCC RES=$(OBJDIR)/nspr.res RESNAME=nspr.rc endif # WINNT @@ -320,7 +353,7 @@ NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now SH_DATE = $(shell date "+%Y-%m-%d %T") SH_NOW = $(shell $(NOW)) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) SUF = i64 else SUF = LL @@ -342,7 +375,7 @@ $(TINC): $(OBJDIR)/prvrsion.$(OBJ_SUFFIX): prvrsion.c $(TINC) -ifeq ($(OS_ARCH), WINNT) +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $< else ifeq ($(MOZ_OS2_TOOLS), VACPP) diff --git a/pr/src/io/Makefile.in b/pr/src/io/Makefile.in index 179656aa..e7316b38 100644 --- a/pr/src/io/Makefile.in +++ b/pr/src/io/Makefile.in @@ -81,5 +81,13 @@ DEFINES += -D_NSPR_BUILD_ include $(topsrcdir)/config/rules.mk +# An OS/2 Optimization bug causes PR_snprintf() to produce wrong result. +# This suppresses optimization for this single compilation unit. +ifeq ($(MOZ_OS2_TOOLS),VACPP) +$(OBJDIR)/prprf.obj: prprf.c + @$(MAKE_OBJDIR) + $(CC) -Fo$@ -c $(filter-out /O+, $(CFLAGS)) $< +endif + export:: $(TARGETS) diff --git a/pr/src/io/prdir.c b/pr/src/io/prdir.c index d0f469e9..8aa66435 100644 --- a/pr/src/io/prdir.c +++ b/pr/src/io/prdir.c @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): + * Roy Yokoyama * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the @@ -109,3 +110,52 @@ PRInt32 rv; return PR_SUCCESS; } +#ifdef MOZ_UNICODE +/* + * UTF16 Interface + */ +PR_IMPLEMENT(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar *name) +{ + PRDirUTF16 *dir; + PRStatus sts; + + dir = PR_NEW(PRDirUTF16); + if (dir) { + sts = _PR_MD_OPEN_DIR_UTF16(&dir->md,name); + if (sts != PR_SUCCESS) { + PR_DELETE(dir); + return NULL; + } + } else { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + } + return dir; +} + +PR_IMPLEMENT(PRDirEntryUTF16*) PR_ReadDirUTF16(PRDirUTF16 *dir, PRDirFlags flags) +{ + /* + * _MD_READ_DIR_UTF16 return a PRUnichar* to the name; allocation in + * machine-dependent code + */ + PRUnichar* name = _PR_MD_READ_DIR_UTF16(&dir->md, flags); + dir->d.name = name; + return name ? &dir->d : NULL; +} + +PR_IMPLEMENT(PRStatus) PR_CloseDirUTF16(PRDirUTF16 *dir) +{ + PRInt32 rv; + + if (dir) { + rv = _PR_MD_CLOSE_DIR_UTF16(&dir->md); + PR_DELETE(dir); + if (rv < 0) + return PR_FAILURE; + else + return PR_SUCCESS; + } + return PR_SUCCESS; +} + +#endif /* MOZ_UNICODE */ diff --git a/pr/src/io/prfdcach.c b/pr/src/io/prfdcach.c index 8803a419..82cbf058 100644 --- a/pr/src/io/prfdcach.c +++ b/pr/src/io/prfdcach.c @@ -73,7 +73,7 @@ static PRFileDesc **stack2fd = &(((PRFileDesc*)NULL)->higher); ** Get a FileDescriptor from the cache if one exists. If not allocate ** a new one from the heap. */ -PRFileDesc *_PR_Getfd() +PRFileDesc *_PR_Getfd(void) { PRFileDesc *fd; /* @@ -248,7 +248,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high) return PR_SUCCESS; } /* PR_SetFDCacheSize */ -void _PR_InitFdCache() +void _PR_InitFdCache(void) { /* ** The fd caching is enabled by default for DEBUG builds, diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c index e19705c7..25354453 100644 --- a/pr/src/io/prfile.c +++ b/pr/src/io/prfile.c @@ -203,7 +203,7 @@ static PRStatus PR_CALLBACK PipeSync(PRFileDesc *fd) return PR_SUCCESS; } -static PRStatus PR_CALLBACK FileInfo(PRFileDesc *fd, PRFileInfo *info) +static PRStatus PR_CALLBACK FileGetInfo(PRFileDesc *fd, PRFileInfo *info) { PRInt32 rv; @@ -214,7 +214,7 @@ static PRStatus PR_CALLBACK FileInfo(PRFileDesc *fd, PRFileInfo *info) return PR_SUCCESS; } -static PRStatus PR_CALLBACK FileInfo64(PRFileDesc *fd, PRFileInfo64 *info) +static PRStatus PR_CALLBACK FileGetInfo64(PRFileDesc *fd, PRFileInfo64 *info) { #ifdef XP_MAC #pragma unused( fd, info ) @@ -276,8 +276,8 @@ static PRIOMethods _pr_fileMethods = { FileSync, FileSeek, FileSeek64, - FileInfo, - FileInfo64, + FileGetInfo, + FileGetInfo64, (PRWritevFN)_PR_InvalidInt, (PRConnectFN)_PR_InvalidStatus, (PRAcceptFN)_PR_InvalidDesc, @@ -422,14 +422,18 @@ PRInt32 PR_GetSysfdTableMax(void) return rlim.rlim_max; #elif defined(AIX) || defined(NEXTSTEP) || defined(QNX) return sysconf(_SC_OPEN_MAX); -#elif defined(WIN32) || defined(OS2) +#elif defined(WIN32) /* * There is a systemwide limit of 65536 user handles. - * Not sure on OS/2, but sounds good. */ return 16384; #elif defined (WIN16) return FOPEN_MAX; +#elif defined(XP_OS2) + ULONG ulReqCount = 0; + ULONG ulCurMaxFH = 0; + DosSetRelMaxFH(&ulReqCount, &ulCurMaxFH); + return ulCurMaxFH; #elif defined (XP_MAC) || defined(XP_BEOS) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; @@ -464,9 +468,19 @@ PRInt32 PR_SetSysfdTableSize(int table_size) } return rlim.rlim_cur; +#elif defined(XP_OS2) + PRInt32 tableMax = PR_GetSysfdTableMax(); + if (table_size > tableMax) { + APIRET rc = NO_ERROR; + rc = DosSetMaxFH(table_size); + if (rc == NO_ERROR) + return table_size; + else + return -1; + } + return tableMax; #elif defined(AIX) || defined(NEXTSTEP) || defined(QNX) \ - || defined(WIN32) || defined(WIN16) || defined(OS2) \ - || defined(XP_BEOS) + || defined(WIN32) || defined(WIN16) || defined(XP_BEOS) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; #elif defined (XP_MAC) @@ -735,7 +749,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) +#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) #ifdef XP_OS2 HFILE pipefd[2]; #else @@ -765,9 +779,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe( close(pipefd[1]); return PR_FAILURE; } - _MD_MakeNonblock(*readPipe); +#ifndef XP_BEOS /* Pipes are nonblocking on BeOS */ + _PR_MD_MAKE_NONBLOCK(*readPipe); +#endif _PR_MD_INIT_FD_INHERITABLE(*readPipe, PR_FALSE); - _MD_MakeNonblock(*writePipe); +#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 @@ -775,3 +793,51 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe( return PR_FAILURE; #endif } + +#ifdef MOZ_UNICODE +/* ================ UTF16 Interfaces ================================ */ +PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16( + const PRUnichar *name, PRIntn flags, PRIntn mode) +{ + PRInt32 osfd; + PRFileDesc *fd = 0; +#if !defined(XP_UNIX) /* BugZilla: 4090 */ + PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE; +#endif + + if (!_pr_initialized) _PR_ImplicitInitialization(); + + /* Map pr open flags and mode to os specific flags */ + osfd = _PR_MD_OPEN_FILE_UTF16(name, flags, mode); + if (osfd != -1) { + fd = PR_AllocFileDesc(osfd, &_pr_fileMethods); + if (!fd) { + (void) _PR_MD_CLOSE_FILE(osfd); + } else { +#if !defined(XP_UNIX) /* BugZilla: 4090 */ + fd->secret->appendMode = appendMode; +#endif + _PR_MD_INIT_FD_INHERITABLE(fd, PR_FALSE); + } + } + return fd; +} + +PR_IMPLEMENT(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info) +{ +#ifdef XP_MAC +#pragma unused (fn, info) +#endif + PRInt32 rv; + + if (!_pr_initialized) _PR_ImplicitInitialization(); + rv = _PR_MD_GETFILEINFO64_UTF16(fn, info); + if (rv < 0) { + return PR_FAILURE; + } else { + return PR_SUCCESS; + } +} + +/* ================ UTF16 Interfaces ================================ */ +#endif /* MOZ_UNICODE */ diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c index 250d9b6f..66ecd7cc 100644 --- a/pr/src/io/prio.c +++ b/pr/src/io/prio.c @@ -164,7 +164,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable( PRFileDesc *fd, PRBool inheritable) { -#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2) +#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2) || defined(XP_BEOS) /* * Only a non-layered, NSPR file descriptor can be inherited * by a child process. @@ -188,3 +188,12 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable( return PR_FAILURE; #endif } + +/* +** This function only has a useful implementation in the debug build of +** the pthreads version. +*/ +PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg) +{ + /* do nothing */ +} /* PT_FPrintStats */ diff --git a/pr/src/io/priometh.c b/pr/src/io/priometh.c index a2b8e9c8..251d46a9 100644 --- a/pr/src/io/priometh.c +++ b/pr/src/io/priometh.c @@ -34,6 +34,8 @@ */ #include "primpl.h" +#include + /*****************************************************************************/ /************************** Invalid I/O method object ************************/ /*****************************************************************************/ @@ -76,21 +78,21 @@ PRIOMethods _pr_faulty_methods = { (PRReservedFN)_PR_InvalidInt }; -PRIntn _PR_InvalidInt() +PRIntn _PR_InvalidInt(void) { PR_ASSERT(!"I/O method is invalid"); PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; } /* _PR_InvalidInt */ -PRInt16 _PR_InvalidInt16() +PRInt16 _PR_InvalidInt16(void) { PR_ASSERT(!"I/O method is invalid"); PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; } /* _PR_InvalidInt */ -PRInt64 _PR_InvalidInt64() +PRInt64 _PR_InvalidInt64(void) { PRInt64 rv; LL_I2L(rv, -1); @@ -103,7 +105,7 @@ PRInt64 _PR_InvalidInt64() * An invalid method that returns PRStatus */ -PRStatus _PR_InvalidStatus() +PRStatus _PR_InvalidStatus(void) { PR_ASSERT(!"I/O method is invalid"); PR_SetError(PR_INVALID_METHOD_ERROR, 0); @@ -114,7 +116,7 @@ PRStatus _PR_InvalidStatus() * An invalid method that returns a pointer */ -PRFileDesc *_PR_InvalidDesc() +PRFileDesc *_PR_InvalidDesc(void) { PR_ASSERT(!"I/O method is invalid"); PR_SetError(PR_INVALID_METHOD_ERROR, 0); diff --git a/pr/src/io/prlayer.c b/pr/src/io/prlayer.c index d74fa8be..d377f546 100644 --- a/pr/src/io/prlayer.c +++ b/pr/src/io/prlayer.c @@ -459,7 +459,7 @@ static PRIOMethods pl_methods = { (PRReservedFN)_PR_InvalidInt }; -PR_IMPLEMENT(const PRIOMethods*) PR_GetDefaultIOMethods() +PR_IMPLEMENT(const PRIOMethods*) PR_GetDefaultIOMethods(void) { return &pl_methods; } /* PR_GetDefaultIOMethods */ @@ -736,7 +736,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity i return NULL; } /* PR_GetIdentitiesLayer */ -void _PR_InitLayerCache() +void _PR_InitLayerCache(void) { memset(&identity_cache, 0, sizeof(identity_cache)); identity_cache.ml = PR_NewLock(); diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c index 16f68823..ac1c5492 100644 --- a/pr/src/io/prlog.c +++ b/pr/src/io/prlog.c @@ -194,13 +194,16 @@ void _PR_InitLog(void) ev = PR_GetEnv("NSPR_LOG_MODULES"); if (ev && ev[0]) { - char module[64]; + char module[64]; /* Security-Critical: If you change this + * size, you must also change the sscanf + * format string to be size-1. + */ PRBool isSync = PR_FALSE; PRIntn evlen = strlen(ev), pos = 0; PRInt32 bufSize = DEFAULT_BUF_SIZE; while (pos < evlen) { PRIntn level = 1, count = 0, delta = 0; - count = sscanf(&ev[pos], "%64[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]%n:%d%n", + count = sscanf(&ev[pos], "%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]%n:%d%n", module, &delta, &level, &delta); pos += delta; if (count == 0) break; @@ -232,7 +235,7 @@ void _PR_InitLog(void) /*found:*/ count = sscanf(&ev[pos], " , %n", &delta); pos += delta; - if (count == -1) break; + if (count == EOF) break; } PR_SetLogBuffering(isSync ? bufSize : 0); @@ -277,11 +280,16 @@ void _PR_LogCleanup(void) while (lm != NULL) { PRLogModuleInfo *next = lm->next; - PR_Free((/*const*/ char *)lm->name); + free((/*const*/ char *)lm->name); PR_Free(lm); lm = next; } logModules = NULL; + + if (_pr_logLock) { + PR_DestroyLock(_pr_logLock); + _pr_logLock = NULL; + } } static void _PR_SetLogModuleLevel( PRLogModuleInfo *lm ) @@ -290,12 +298,15 @@ static void _PR_SetLogModuleLevel( PRLogModuleInfo *lm ) ev = PR_GetEnv("NSPR_LOG_MODULES"); if (ev && ev[0]) { - char module[64]; + char module[64]; /* Security-Critical: If you change this + * size, you must also change the sscanf + * format string to be size-1. + */ PRIntn evlen = strlen(ev), pos = 0; while (pos < evlen) { PRIntn level = 1, count = 0, delta = 0; - count = sscanf(&ev[pos], "%64[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]%n:%d%n", + count = sscanf(&ev[pos], "%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789]%n:%d%n", module, &delta, &level, &delta); pos += delta; if (count == 0) break; @@ -314,7 +325,7 @@ static void _PR_SetLogModuleLevel( PRLogModuleInfo *lm ) } count = sscanf(&ev[pos], " , %n", &delta); pos += delta; - if (count == -1) break; + if (count == EOF) break; } } } /* end _PR_SetLogModuleLevel() */ @@ -361,7 +372,7 @@ PR_IMPLEMENT(PRBool) PR_SetLogFile(const char *file) #else PRFileDesc *newLogFile; - newLogFile = PR_Open(file, PR_WRONLY|PR_CREATE_FILE, 0666); + newLogFile = PR_Open(file, PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE, 0666); if (newLogFile) { if (logFile && logFile != _pr_stdout && logFile != _pr_stderr) { PR_Close(logFile); diff --git a/pr/src/io/prmapopt.c b/pr/src/io/prmapopt.c index f017c36a..d8570ccb 100644 --- a/pr/src/io/prmapopt.c +++ b/pr/src/io/prmapopt.c @@ -46,9 +46,14 @@ * includes winsock.h, with _WIN32_WINNT undefined. */ -#ifdef WINNT +#ifdef WIN32 +#ifdef __MINGW32__ +#include +#include +#elif defined(WINNT) #include #endif +#endif #include "primpl.h" @@ -57,7 +62,7 @@ #include /* n_short, n_long, n_time */ #endif -#if defined(XP_UNIX) || defined(OS2) +#if defined(XP_UNIX) || defined(OS2) || (defined(XP_BEOS) && defined(BONE_VERSION)) #include /* TCP_NODELAY, TCP_MAXSEG */ #endif @@ -86,7 +91,7 @@ PRStatus PR_CALLBACK _PR_SocketGetSocketOption(PRFileDesc *fd, PRSocketOptionDat { case PR_SockOpt_Linger: { -#if !defined(XP_BEOS) +#if !defined(XP_BEOS) || defined(BONE_VERSION) struct linger linger; length = sizeof(linger); rv = _PR_MD_GETSOCKOPT( @@ -244,7 +249,7 @@ PRStatus PR_CALLBACK _PR_SocketSetSocketOption(PRFileDesc *fd, const PRSocketOpt { case PR_SockOpt_Linger: { -#if !defined(XP_BEOS) +#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); diff --git a/pr/src/io/prmwait.c b/pr/src/io/prmwait.c index a48fbc19..65ea1cd6 100644 --- a/pr/src/io/prmwait.c +++ b/pr/src/io/prmwait.c @@ -58,19 +58,8 @@ typedef struct TimerEvent { struct { PRLock *ml; PRCondVar *new_timer; - PRCondVar *cancel_timer; /* The cancel_timer condition variable is - * used to cancel a timer (i.e., remove a - * timer event from the timer queue). At - * startup I'm borrowing this condition - * variable for a different purpose (to - * tell the primordial thread that the - * timer manager thread has started) so - * that I don't need to create a new - * condition variable just for this one - * time use. - */ + PRCondVar *cancel_timer; PRThread *manager_thread; - PRBool manager_started; PRCList timer_queue; } tm_vars; @@ -88,11 +77,6 @@ static void TimerManager(void *arg) TimerEvent *timer; PR_Lock(tm_vars.ml); - /* tell the primordial thread that we have started */ - tm_vars.manager_started = PR_TRUE; - if (!_native_threads_only) { - PR_NotifyCondVar(tm_vars.cancel_timer); - } while (1) { if (PR_CLIST_IS_EMPTY(&tm_vars.timer_queue)) @@ -216,16 +200,6 @@ static PRStatus TimerInit(void) { goto failed; } - /* - * Need to wait until the timer manager thread starts - * if the timer manager thread is a local thread. - */ - if (!_native_threads_only) { - PR_Lock(tm_vars.ml); - while (!tm_vars.manager_started) - PR_WaitCondVar(tm_vars.cancel_timer, PR_INTERVAL_NO_TIMEOUT); - PR_Unlock(tm_vars.ml); - } return PR_SUCCESS; failed: @@ -269,6 +243,17 @@ void _PR_InitMW(void) max_polling_interval = PR_MillisecondsToInterval(MAX_POLLING_INTERVAL); } /* _PR_InitMW */ +void _PR_CleanupMW(void) +{ + PR_DestroyLock(mw_lock); + mw_lock = NULL; + if (mw_state->group) { + PR_DestroyWaitGroup(mw_state->group); + /* mw_state->group is set to NULL as a side effect. */ + } + PR_DELETE(mw_state); +} /* _PR_CleanupMW */ + static PRWaitGroup *MW_Init2(void) { PRWaitGroup *group = mw_state->group; /* it's the null group */ diff --git a/pr/src/io/prprf.c b/pr/src/io/prprf.c index 2d6a78d8..4fa197c1 100644 --- a/pr/src/io/prprf.c +++ b/pr/src/io/prprf.c @@ -51,8 +51,10 @@ ** Note: on some platforms va_list is defined as an array, ** and requires array notation. */ -#if (defined(LINUX) && defined(__powerpc__)) || defined(WIN16) || \ - defined(QNX) || \ +#if (defined(LINUX) && defined(__powerpc__)) || \ + (defined(LINUX) && defined(__s390__)) || \ + (defined(LINUX) && defined(__s390x__)) || \ + defined(WIN16) || defined(QNX) || \ (defined(__NetBSD__) && defined(__powerpc__) && \ __NetBSD_Version__ < 105000000) #define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0] @@ -89,9 +91,6 @@ struct NumArgState{ va_list ap; /* point to the corresponding position on ap */ }; -static PRBool l10n_debug_init = PR_FALSE; -static PRBool l10n_debug = PR_FALSE; - #define NAS_DEFAULT_NUM 20 /* default number of NumberedArgumentState array */ @@ -108,11 +107,11 @@ static PRBool l10n_debug = PR_FALSE; #define TYPE_INTSTR 10 #define TYPE_UNKNOWN 20 -#define _LEFT 0x1 -#define _SIGNED 0x2 -#define _SPACED 0x4 -#define _ZEROS 0x8 -#define _NEG 0x10 +#define FLAG_LEFT 0x1 +#define FLAG_SIGNED 0x2 +#define FLAG_SPACED 0x4 +#define FLAG_ZEROS 0x8 +#define FLAG_NEG 0x10 /* ** Fill into the buffer using the data in src @@ -124,8 +123,8 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width, int rv; width -= srclen; - if ((width > 0) && ((flags & _LEFT) == 0)) { /* Right adjusting */ - if (flags & _ZEROS) { + if ((width > 0) && ((flags & FLAG_LEFT) == 0)) { /* Right adjusting */ + if (flags & FLAG_ZEROS) { space = '0'; } while (--width >= 0) { @@ -142,7 +141,7 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width, return rv; } - if ((width > 0) && ((flags & _LEFT) != 0)) { /* Left adjusting */ + if ((width > 0) && ((flags & FLAG_LEFT) != 0)) { /* Left adjusting */ while (--width >= 0) { rv = (*ss->stuff)(ss, &space, 1); if (rv < 0) { @@ -169,13 +168,13 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width, char sign; if ((type & 1) == 0) { - if (flags & _NEG) { + if (flags & FLAG_NEG) { sign = '-'; signwidth = 1; - } else if (flags & _SIGNED) { + } else if (flags & FLAG_SIGNED) { sign = '+'; signwidth = 1; - } else if (flags & _SPACED) { + } else if (flags & FLAG_SPACED) { sign = ' '; signwidth = 1; } @@ -189,14 +188,14 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width, } } - if ((flags & _ZEROS) && (prec < 0)) { + if ((flags & FLAG_ZEROS) && (prec < 0)) { if (width > cvtwidth) { zerowidth = width - cvtwidth; /* Zero filling */ cvtwidth += zerowidth; } } - if (flags & _LEFT) { + if (flags & FLAG_LEFT) { if (width > cvtwidth) { /* Space filling on the right (i.e. left adjusting) */ rightspaces = width - cvtwidth; @@ -411,20 +410,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, struct NumArgState* nas; - /* - ** set the l10n_debug flag - ** this routine should be executed only once - ** 'cause getenv does take time - */ - if( !l10n_debug_init ){ - l10n_debug_init = PR_TRUE; - p = getenv( "NETSCAPE_LOCALIZATION_DEBUG" ); - if( ( p != NULL ) && ( *p == '1' ) ){ - l10n_debug = PR_TRUE; - } - } - - /* ** first pass: ** detemine how many legal % I have got, then allocate space @@ -444,23 +429,17 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, if( c == '$' ){ /* numbered argument csae */ if( i > 0 ){ *rv = -1; - if( l10n_debug ) - printf( "either no *OR* all arguments are numbered \"%s\"\n", fmt ); return NULL; } number++; - break; - } else{ /* non-numbered argument case */ if( number > 0 ){ - if( l10n_debug ) - printf( "either no *OR* all arguments are numbered \"%s\"\n", fmt ); *rv = -1; return NULL; } i = 1; - break; } + break; } c = *p++; @@ -476,8 +455,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, nas = (struct NumArgState*)PR_MALLOC( number * sizeof( struct NumArgState ) ); if( !nas ){ *rv = -1; - if( l10n_debug ) - printf( "PR_MALLOC() error for \"%s\"\n", fmt ); return NULL; } } else { @@ -508,8 +485,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, if( !c || cn < 1 || cn > number ){ *rv = -1; - if( l10n_debug ) - printf( "invalid argument number (valid range [1, %d]), \"%s\"\n", number, fmt ); break; } @@ -524,13 +499,11 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, if (c == '*') { /* not supported feature, for the argument is not numbered */ *rv = -1; - if( l10n_debug ) - printf( "* width specifier not support for numbered arguments \"%s\"\n", fmt ); break; - } else { - while ((c >= '0') && (c <= '9')) { - c = *p++; - } + } + + while ((c >= '0') && (c <= '9')) { + c = *p++; } /* precision */ @@ -538,14 +511,12 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, c = *p++; if (c == '*') { /* not supported feature, for the argument is not numbered */ - if( l10n_debug ) - printf( "* precision specifier not support for numbered arguments \"%s\"\n", fmt ); *rv = -1; break; - } else { - while ((c >= '0') && (c <= '9')) { - c = *p++; - } + } + + while ((c >= '0') && (c <= '9')) { + c = *p++; } } @@ -622,8 +593,6 @@ static struct NumArgState* BuildArgArray( const char *fmt, va_list ap, int* rv, /* get a legal para. */ if( nas[ cn ].type == TYPE_UNKNOWN ){ - if( l10n_debug ) - printf( "unknown type \"%s\"\n", fmt ); *rv = -1; break; } @@ -757,8 +726,6 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) } if( nas[i-1].type == TYPE_UNKNOWN ){ - if( l10n_debug ) - printf( "numbered argument type unknown\n" ); if( nas && ( nas != nasArray ) ) PR_DELETE( nas ); return -1; @@ -777,14 +744,14 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) * on this feature. */ while ((c == '-') || (c == '+') || (c == ' ') || (c == '0')) { - if (c == '-') flags |= _LEFT; - if (c == '+') flags |= _SIGNED; - if (c == ' ') flags |= _SPACED; - if (c == '0') flags |= _ZEROS; + if (c == '-') flags |= FLAG_LEFT; + if (c == '+') flags |= FLAG_SIGNED; + if (c == ' ') flags |= FLAG_SPACED; + if (c == '0') flags |= FLAG_ZEROS; c = *fmt++; } - if (flags & _SIGNED) flags &= ~_SPACED; - if (flags & _LEFT) flags &= ~_ZEROS; + if (flags & FLAG_SIGNED) flags &= ~FLAG_SPACED; + if (flags & FLAG_LEFT) flags &= ~FLAG_ZEROS; /* width */ if (c == '*') { @@ -866,7 +833,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) u.l = va_arg(ap, int); if (u.l < 0) { u.l = -u.l; - flags |= _NEG; + flags |= FLAG_NEG; } goto do_long; case TYPE_UINT16: @@ -876,7 +843,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) u.l = va_arg(ap, int); if (u.l < 0) { u.l = -u.l; - flags |= _NEG; + flags |= FLAG_NEG; } goto do_long; case TYPE_UINTN: @@ -887,7 +854,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) u.l = va_arg(ap, PRInt32); if (u.l < 0) { u.l = -u.l; - flags |= _NEG; + flags |= FLAG_NEG; } goto do_long; case TYPE_UINT32: @@ -903,7 +870,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) u.ll = va_arg(ap, PRInt64); if (!LL_GE_ZERO(u.ll)) { LL_NEG(u.ll, u.ll); - flags |= _NEG; + flags |= FLAG_NEG; } goto do_longlong; case TYPE_UINT64: @@ -939,7 +906,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) case 'c': u.ch = va_arg(ap, int); - if ((flags & _LEFT) == 0) { + if ((flags & FLAG_LEFT) == 0) { while (width-- > 1) { rv = (*ss->stuff)(ss, " ", 1); if (rv < 0) { @@ -951,7 +918,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap) if (rv < 0) { return rv; } - if (flags & _LEFT) { + if (flags & FLAG_LEFT) { while (width-- > 1) { rv = (*ss->stuff)(ss, " ", 1); if (rv < 0) { diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index 2483f963..652632fc 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -338,27 +338,16 @@ static PRStatus PR_CALLBACK SocketConnectContinue( #elif defined(XP_OS2) - if (out_flags & PR_POLL_EXCEPT) { - int len = sizeof(err); - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &len) - < 0) { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return PR_FAILURE; - } - if (err != 0) { - _PR_MD_MAP_CONNECT_ERROR(err); - } else { - PR_SetError(PR_UNKNOWN_ERROR, 0); - } + err = _MD_os2_get_nonblocking_connect_error(osfd); + if (err != 0) { + _PR_MD_MAP_CONNECT_ERROR(err); return PR_FAILURE; } - - PR_ASSERT(out_flags & PR_POLL_WRITE); return PR_SUCCESS; #elif defined(XP_MAC) - err = _MD_mac_get_nonblocking_connect_error(osfd); + err = _MD_mac_get_nonblocking_connect_error(fd); if (err == -1) return PR_FAILURE; else @@ -366,13 +355,23 @@ static PRStatus PR_CALLBACK SocketConnectContinue( #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; + _PR_MD_MAP_CONNECT_ERROR(err); + return PR_FAILURE; } else - return PR_SUCCESS; + return PR_SUCCESS; +#endif /* BONE_VERSION */ #else PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); @@ -1396,7 +1395,7 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *f[]) */ SOCKET listenSock; SOCKET osfd[2]; - struct sockaddr_in selfAddr; + struct sockaddr_in selfAddr, peerAddr; int addrLen; if (!_pr_initialized) _PR_ImplicitInitialization(); @@ -1440,10 +1439,24 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *f[]) addrLen) == SOCKET_ERROR) { goto failed; } - osfd[1] = accept(listenSock, NULL, NULL); + /* + * A malicious local process may connect to the listening + * socket, so we need to verify that the accepted connection + * is made from our own socket osfd[0]. + */ + if (getsockname(osfd[0], (struct sockaddr *) &selfAddr, + &addrLen) == SOCKET_ERROR) { + goto failed; + } + osfd[1] = accept(listenSock, (struct sockaddr *) &peerAddr, &addrLen); if (osfd[1] == INVALID_SOCKET) { goto failed; } + if (peerAddr.sin_port != selfAddr.sin_port) { + /* the connection we accepted is not from osfd[0] */ + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0); + goto failed; + } closesocket(listenSock); f[0] = PR_AllocFileDesc(osfd[0], PR_GetTCPMethods()); @@ -1480,7 +1493,7 @@ failed: * default implementation */ PRFileDesc *listenSock; - PRNetAddr selfAddr; + PRNetAddr selfAddr, peerAddr; PRUint16 port; f[0] = f[1] = NULL; @@ -1503,6 +1516,17 @@ failed: if (f[0] == NULL) { goto failed; } +#ifdef _PR_CONNECT_DOES_NOT_BIND + /* + * If connect does not implicitly bind the socket (e.g., on + * BeOS), we have to bind the socket so that we can get its + * port with getsockname later. + */ + PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); + if (PR_Bind(f[0], &selfAddr) == PR_FAILURE) { + goto failed; + } +#endif PR_InitializeNetAddr(PR_IpAddrLoopback, port, &selfAddr); /* @@ -1518,10 +1542,23 @@ failed: == PR_FAILURE) { goto failed; } - f[1] = PR_Accept(listenSock, NULL, PR_INTERVAL_NO_TIMEOUT); + /* + * A malicious local process may connect to the listening + * socket, so we need to verify that the accepted connection + * is made from our own socket f[0]. + */ + if (PR_GetSockName(f[0], &selfAddr) == PR_FAILURE) { + goto failed; + } + f[1] = PR_Accept(listenSock, &peerAddr, PR_INTERVAL_NO_TIMEOUT); if (f[1] == NULL) { goto failed; } + if (peerAddr.inet.port != selfAddr.inet.port) { + /* the connection we accepted is not from f[0] */ + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0); + goto failed; + } PR_Close(listenSock); return PR_SUCCESS; @@ -1532,6 +1569,9 @@ failed: if (f[0]) { PR_Close(f[0]); } + if (f[1]) { + PR_Close(f[1]); + } return PR_FAILURE; #endif } @@ -1539,20 +1579,14 @@ failed: PR_IMPLEMENT(PRInt32) PR_FileDesc2NativeHandle(PRFileDesc *fd) { - if (fd) { - /* - * The fd may be layered. Chase the links to the - * bottom layer to get the osfd. - */ - PRFileDesc *bottom = fd; - while (bottom->lower != NULL) { - bottom = bottom->lower; - } - return bottom->secret->md.osfd; - } else { - PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); - return -1; - } + if (fd) { + fd = PR_GetIdentitiesLayer(fd, PR_NSPR_IO_LAYER); + } + if (!fd) { + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; + } + return fd->secret->md.osfd; } PR_IMPLEMENT(void) diff --git a/pr/src/io/prstdio.c b/pr/src/io/prstdio.c index 4ae2f267..de4c39de 100644 --- a/pr/src/io/prstdio.c +++ b/pr/src/io/prstdio.c @@ -56,7 +56,45 @@ PR_IMPLEMENT(PRUint32) PR_vfprintf(PRFileDesc* fd, const char *fmt, va_list ap) PRUint32 rv, len; char* msg = PR_vsmprintf(fmt, ap); len = strlen(msg); +#ifdef XP_OS2 + /* + * OS/2 really needs a \r for every \n. + * In the future we should try to use scatter-gather instead of a + * succession of PR_Write. + */ + if (isatty(PR_FileDesc2NativeHandle(fd))) { + PRUint32 last = 0, idx; + PRInt32 tmp; + rv = 0; + for (idx = 0; idx < len+1; idx++) { + if ((idx - last > 0) && (('\n' == msg[idx]) || (idx == len))) { + tmp = PR_Write(fd, msg + last, idx - last); + if (tmp >= 0) { + rv += tmp; + } + last = idx; + } + /* + * if current character is \n, and + * previous character isn't \r, and + * next character isn't \r + */ + if (('\n' == msg[idx]) && + ((0 == idx) || ('\r' != msg[idx-1])) && + ('\r' != msg[idx+1])) { + /* add extra \r */ + tmp = PR_Write(fd, "\r", 1); + if (tmp >= 0) { + rv += tmp; + } + } + } + } else { + rv = PR_Write(fd, msg, len); + } +#else rv = PR_Write(fd, msg, len); +#endif PR_DELETE(msg); return rv; } diff --git a/pr/src/linking/Makefile.in b/pr/src/linking/Makefile.in index 1c5de3c1..d997ccba 100644 --- a/pr/src/linking/Makefile.in +++ b/pr/src/linking/Makefile.in @@ -58,6 +58,16 @@ TARGETS = $(OBJS) INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private +# For Dl_info and dladdr. +ifeq ($(OS_TARGET),Linux) +DEFINES += -D_GNU_SOURCE +endif + +# On Mac OS X use flat #includes. +ifeq ($(OS_TARGET),MacOSX) +INCLUDES += -I/Developer/Headers/FlatCarbon +endif + DEFINES += -D_NSPR_BUILD_ include $(topsrcdir)/config/rules.mk diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index b3802055..d42ad219 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -17,7 +17,7 @@ * Copyright (C) 1998-2000 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): Steve Streeter (Hewlett-Packard Company) * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the @@ -40,21 +40,26 @@ #include #endif -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #include #include #include -#include #include #if TARGET_CARBON #include #include #include +#include +#include #endif +#if defined(XP_MACOSX) +#define PStrFromCStr(src, dst) c2pstrcpy(dst, src) +#else #include "macdll.h" #include "mdmac.h" +#endif /* XP_MACOSX */ #endif #ifdef XP_UNIX @@ -73,6 +78,13 @@ #ifndef RTLD_LOCAL #define RTLD_LOCAL 0 #endif +#ifdef AIX +#include +#endif +#ifdef OSF1 +#include +#include +#endif #elif defined(USE_HPSHL) #include #elif defined(USE_MACH_DYLD) @@ -82,6 +94,70 @@ #define _PR_DEFAULT_LD_FLAGS PR_LD_LAZY +#ifdef VMS +/* These are all require for the PR_GetLibraryFilePathname implementation */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma __nostandard +#pragma __member_alignment __save +#pragma __nomember_alignment +#ifdef __INITIAL_POINTER_SIZE +#pragma __required_pointer_size __save +#pragma __required_pointer_size __short +#endif + +typedef struct _imcb { + struct _imcb *imcb$l_flink; + struct _imcb *imcb$l_blink; + unsigned short int imcb$w_size; + unsigned char imcb$b_type; + char imcb$b_resv_1; + unsigned char imcb$b_access_mode; + unsigned char imcb$b_act_code; + unsigned short int imcb$w_chan; + unsigned int imcb$l_flags; + char imcb$t_image_name [40]; + unsigned int imcb$l_symvec_size; + unsigned __int64 imcb$q_ident; + void *imcb$l_starting_address; + void *imcb$l_end_address; +} IMCB; + +#pragma __member_alignment __restore +#ifdef __INITIAL_POINTER_SIZE +#pragma __required_pointer_size __restore +#endif +#pragma __standard + +typedef struct { + short buflen; + short itmcode; + void *buffer; + void *retlen; +} ITMLST; + +typedef struct { + short cond; + short count; + int rest; +} IOSB; + +typedef unsigned long int ulong_t; + +struct _imcb *IAC$GL_IMAGE_LIST = NULL; + +#define MAX_DEVNAM 64 +#define MAX_FILNAM 255 +#endif /* VMS */ + /* * On these platforms, symbols have a leading '_'. */ @@ -111,14 +187,19 @@ struct PRLibrary { #endif #endif -#ifdef XP_MAC - CFragConnectionID dlh; +#if defined(XP_MAC) || defined(XP_MACOSX) + CFragConnectionID connection; #if TARGET_CARBON CFBundleRef bundle; #endif Ptr main; + +#if defined(XP_MACOSX) + CFMutableDictionaryRef wrappers; + const struct mach_header* image; +#endif /* XP_MACOSX */ #endif #ifdef XP_UNIX @@ -262,6 +343,10 @@ void _PR_InitLinker(void) } #if defined(WIN16) +/* + * _PR_ShutdownLinker unloads all dlls loaded by the application via + * calls to PR_LoadLibrary + */ void _PR_ShutdownLinker(void) { PR_EnterMonitor(pr_linker_lock); @@ -282,6 +367,32 @@ void _PR_ShutdownLinker(void) PR_DestroyMonitor(pr_linker_lock); pr_linker_lock = NULL; } +#else +/* + * _PR_ShutdownLinker was originally only used on WIN16 (see above), + * but I think it should also be used on other platforms. However, + * I disagree with the original implementation's unloading the dlls + * for the application. Any dlls that still remain on the pr_loadmap + * list when NSPR shuts down are application programming errors. The + * only exception is pr_exe_loadmap, which was added to the list by + * NSPR and hence should be cleaned up by NSPR. + */ +void _PR_ShutdownLinker(void) +{ + /* FIXME: pr_exe_loadmap should be destroyed. */ + + PR_DestroyMonitor(pr_linker_lock); + pr_linker_lock = NULL; + + if (_pr_currentLibPath) { + free(_pr_currentLibPath); + _pr_currentLibPath = NULL; + } + +#if !defined(USE_DLFCN) && !defined(HAVE_STRERROR) + PR_DELETE(errStrBuf); +#endif +} #endif /******************************************************************************/ @@ -292,7 +403,9 @@ PR_IMPLEMENT(PRStatus) PR_SetLibraryPath(const char *path) if (!_pr_initialized) _PR_ImplicitInitialization(); PR_EnterMonitor(pr_linker_lock); - PR_FREEIF(_pr_currentLibPath); + if (_pr_currentLibPath) { + free(_pr_currentLibPath); + } if (path) { _pr_currentLibPath = strdup(path); if (!_pr_currentLibPath) { @@ -310,7 +423,7 @@ PR_IMPLEMENT(PRStatus) PR_SetLibraryPath(const char *path) ** Return the library path for finding shared libraries. */ PR_IMPLEMENT(char *) -PR_GetLibraryPath() +PR_GetLibraryPath(void) { char *ev; char *copy = NULL; /* a copy of _pr_currentLibPath */ @@ -342,7 +455,7 @@ PR_GetLibraryPath() ev = ""; len = strlen(ev) + 1; /* +1 for the null */ - p = (char*) PR_MALLOC(len); + p = (char*) malloc(len); if (p) { strcpy(p, ev); } @@ -369,7 +482,7 @@ PR_GetLibraryPath() #endif len = strlen(ev) + 1; /* +1 for the null */ - p = (char*) PR_MALLOC(len); + p = (char*) malloc(len); if (p) { strcpy(p, ev); } /* if (p) */ @@ -410,20 +523,40 @@ PR_GetLibraryName(const char *path, const char *lib) #ifdef XP_PC if (strstr(lib, PR_DLL_SUFFIX) == NULL) { - fullname = PR_smprintf("%s\\%s%s", path, lib, PR_DLL_SUFFIX); + if (path) { + fullname = PR_smprintf("%s\\%s%s", path, lib, PR_DLL_SUFFIX); + } else { + fullname = PR_smprintf("%s%s", lib, PR_DLL_SUFFIX); + } } else { - fullname = PR_smprintf("%s\\%s", path, lib); + if (path) { + fullname = PR_smprintf("%s\\%s", path, lib); + } else { + fullname = PR_smprintf("%s", lib); + } } #endif /* XP_PC */ #ifdef XP_MAC - fullname = PR_smprintf("%s%s", path, lib); + if (path) { + fullname = PR_smprintf("%s%s", path, lib); + } else { + fullname = PR_smprintf("%s", lib); + } #endif #if defined(XP_UNIX) || defined(XP_BEOS) if (strstr(lib, PR_DLL_SUFFIX) == NULL) { - fullname = PR_smprintf("%s/lib%s%s", path, lib, PR_DLL_SUFFIX); + if (path) { + fullname = PR_smprintf("%s/lib%s%s", path, lib, PR_DLL_SUFFIX); + } else { + fullname = PR_smprintf("lib%s%s", lib, PR_DLL_SUFFIX); + } } else { - fullname = PR_smprintf("%s/%s", path, lib); + if (path) { + fullname = PR_smprintf("%s/%s", path, lib); + } else { + fullname = PR_smprintf("%s", lib); + } } #endif /* XP_UNIX || XP_BEOS */ return fullname; @@ -447,9 +580,11 @@ pr_UnlockedFindLibrary(const char *name) while (lm) { const char* cp = strrchr(lm->name, PR_DIRECTORY_SEPARATOR); cp = cp ? cp + 1 : lm->name; -#ifdef XP_PC +#ifdef WIN32 /* Windows DLL names are case insensitive... */ if (strcmpi(np, cp) == 0) +#elif defined(XP_OS2) + if (stricmp(np, cp) == 0) #else if (strcmp(np, cp) == 0) #endif @@ -501,37 +636,277 @@ PR_LoadLibrary(const char *name) return PR_LoadLibraryWithFlags(libSpec, 0); } +#if defined(USE_MACH_DYLD) +static NSModule +pr_LoadMachDyldModule(const char *name) +{ + NSObjectFileImage ofi; + NSModule h = NULL; + if (NSCreateObjectFileImageFromFile(name, &ofi) + == NSObjectFileImageSuccess) { + h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE + | NSLINKMODULE_OPTION_RETURN_ON_ERROR); + /* + * TODO: If NSLinkModule fails, use NSLinkEditError to retrieve + * error information. + */ + if (NSDestroyObjectFileImage(ofi) == FALSE) { + if (h) { + (void)NSUnLinkModule(h, NSUNLINKMODULE_OPTION_NONE); + h = NULL; + } + } + } + return h; +} +#endif + +#if defined(XP_MAC) || defined(XP_MACOSX) + +#ifdef XP_MACOSX +static void* TV2FP(CFMutableDictionaryRef dict, const char* name, void *tvp) +{ + static uint32 glue[6] = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 }; + uint32* newGlue = NULL; + + if (tvp != NULL) { + CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII); + if (nameRef) { + CFMutableDataRef glueData = (CFMutableDataRef) CFDictionaryGetValue(dict, nameRef); + if (glueData == NULL) { + glueData = CFDataCreateMutable(NULL, sizeof(glue)); + if (glueData != NULL) { + newGlue = (uint32*) CFDataGetMutableBytePtr(glueData); + memcpy(newGlue, glue, sizeof(glue)); + newGlue[0] |= ((UInt32)tvp >> 16); + newGlue[1] |= ((UInt32)tvp & 0xFFFF); + MakeDataExecutable(newGlue, sizeof(glue)); + CFDictionaryAddValue(dict, nameRef, glueData); + CFRelease(glueData); + + PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("TV2FP: created wrapper for CFM function %s().", name)); + } + } else { + PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("TV2FP: found wrapper for CFM function %s().", name)); + + newGlue = (uint32*) CFDataGetMutableBytePtr(glueData); + } + CFRelease(nameRef); + } + } + + return newGlue; +} +#endif + +/* +** macLibraryLoadProc is a function definition for a Mac shared library +** loading method. The "name" param is the same full or partial pathname +** that was passed to pr_LoadLibraryByPathName. The function must fill +** in the fields of "lm" which apply to its library type. Returns +** PR_SUCCESS if successful. +*/ + +typedef PRStatus (*macLibraryLoadProc)(const char *name, PRLibrary *lm); + +static PRStatus +pr_LoadViaCFM(const char *name, PRLibrary *lm) +{ + OSErr err; + char cName[64]; + Str255 errName; + +#if !defined(XP_MACOSX) + Str255 pName; + /* + * Algorithm: The "name" passed in could be either a shared + * library name that we should look for in the normal library + * search paths, or a full path name to a specific library on + * disk. Since the full path will always contain a ":" + * (shortest possible path is "Volume:File"), and since a + * library name can not contain a ":", we can test for the + * presence of a ":" to see which type of library we should load. + * or its a full UNIX path which we for now assume is Java + * enumerating all the paths (see below) + */ + if (strchr(name, PR_PATH_SEPARATOR) == NULL) { + if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) { + /* + * The name did not contain a ":", so it must be a + * library name. Convert the name to a Pascal string + * and try to find the library. + */ + } else { + /* + * name contained a "/" which means we need to suck off + * the last part of the path and pass that on the + * NSGetSharedLibrary. this may not be what we really + * want to do .. because Java could be iterating through + * the whole LD path, and we'll find it if it's anywhere + * on that path -- it appears that's what UNIX and the + * PC do too...so we'll emulate but it could be wrong. + */ + name = strrchr(name, PR_DIRECTORY_SEPARATOR) + 1; + } + + PStrFromCStr(name, pName); + + /* + * beard: NSGetSharedLibrary was so broken that I just decided to + * use GetSharedLibrary for now. This will need to change for + * plugins, but those should go in the Extensions folder anyhow. + */ + err = GetSharedLibrary(pName, kCompiledCFragArch, kReferenceCFrag, + &lm->connection, &lm->main, errName); + if (err != noErr) + return PR_FAILURE; + } + else +#endif + { + /* + * The name did contain a ":", so it must be a full path name. + * Now we have to do a lot of work to convert the path name to + * an FSSpec (silly, since we were probably just called from the + * MacFE plug-in code that already knew the FSSpec and converted + * it to a full path just to pass to us). Make an FSSpec from + * the full path and call GetDiskFragment. + */ + FSSpec fileSpec; + Boolean tempUnusedBool; + +#if defined(XP_MACOSX) + { + /* Use direct conversion of POSIX path to FSRef to FSSpec. */ + FSRef ref; + err = FSPathMakeRef((const UInt8*)name, &ref, NULL); + if (err == noErr) + err = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, + &fileSpec, NULL); + } +#else + PStrFromCStr(name, pName); + err = FSMakeFSSpec(0, 0, pName, &fileSpec); +#endif + if (err != noErr) + return PR_FAILURE; + + /* Resolve an alias if this was one */ + err = ResolveAliasFile(&fileSpec, true, &tempUnusedBool, + &tempUnusedBool); + if (err != noErr) + return PR_FAILURE; + + /* Finally, try to load the library */ + err = GetDiskFragment(&fileSpec, 0, kCFragGoesToEOF, fileSpec.name, + kLoadCFrag, &lm->connection, &lm->main, errName); + #if TARGET_CARBON + p2cstrcpy(cName, fileSpec.name); +#else + memcpy(cName, fileSpec.name + 1, fileSpec.name[0]); + cName[fileSpec.name[0]] = '\0'; +#endif + +#ifdef XP_MACOSX + if (err == noErr && lm->connection) { + /* + * if we're a mach-o binary, need to wrap all CFM function + * pointers. need a hash-table of already seen function + * pointers, etc. + */ + lm->wrappers = CFDictionaryCreateMutable(NULL, 16, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + if (lm->wrappers) { + lm->main = TV2FP(lm->wrappers, "main", lm->main); + } else + err = memFullErr; + } +#endif + } + return (err == noErr) ? PR_SUCCESS : PR_FAILURE; +} /* -** Returns a CFBundleRef if the FSSpec refers to a Mac OS X bundle directory. -** The caller is responsible for calling CFRelease() to deallocate. +** Creates a CFBundleRef if the pathname refers to a Mac OS X bundle +** directory. The caller is responsible for calling CFRelease() to +** deallocate. */ -static CFBundleRef getLibraryBundle(const FSSpec* spec) + +#if TARGET_CARBON +static PRStatus +pr_LoadCFBundle(const char *name, PRLibrary *lm) { + CFURLRef bundleURL; CFBundleRef bundle = NULL; - FSRef ref; - OSErr err = FSpMakeFSRef(spec, &ref); - char path[512]; - if (err == noErr && ((UInt32)(FSRefMakePath) != kUnresolvedCFragSymbolAddress)) { - err = FSRefMakePath(&ref, (UInt8*)path, sizeof(path) - 1); - if (err == noErr) { - CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8); - if (pathRef) { - CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, pathRef, kCFURLPOSIXPathStyle, true); - if (bundleURL != NULL) { - bundle = CFBundleCreate(NULL, bundleURL); - CFRelease(bundleURL); - } - CFRelease(pathRef); - } + +#ifdef XP_MACOSX + char pathBuf[PATH_MAX]; + const char *resolvedPath; + CFStringRef pathRef; + + /* Takes care of relative paths and symlinks */ + resolvedPath = realpath(name, pathBuf); + if (!resolvedPath) + return PR_FAILURE; + + pathRef = CFStringCreateWithCString(NULL, pathBuf, kCFStringEncodingUTF8); + if (pathRef) { + bundleURL = CFURLCreateWithFileSystemPath(NULL, pathRef, + kCFURLPOSIXPathStyle, true); + if (bundleURL) { + bundle = CFBundleCreate(NULL, bundleURL); + CFRelease(bundleURL); } + CFRelease(pathRef); } - return bundle; +#else + OSErr err; + Str255 pName; + FSSpec fsSpec; + FSRef fsRef; + + if ((UInt32)(CFURLCreateFromFSRef) == kUnresolvedCFragSymbolAddress) + return PR_FAILURE; + PStrFromCStr(name, pName); + err = FSMakeFSSpec(0, 0, pName, &fsSpec); + if (err != noErr) + return PR_FAILURE; + err = FSpMakeFSRef(&fsSpec, &fsRef); + if (err != noErr) + return PR_FAILURE; + bundleURL = CFURLCreateFromFSRef(NULL, &fsRef); + if (bundleURL) { + bundle = CFBundleCreate(NULL, bundleURL); + CFRelease(bundleURL); + } +#endif + + lm->bundle = bundle; + return (bundle != NULL) ? PR_SUCCESS : PR_FAILURE; } +#endif +#ifdef XP_MACOSX +static PRStatus +pr_LoadViaDyld(const char *name, PRLibrary *lm) +{ + lm->dlh = pr_LoadMachDyldModule(name); + if (lm->dlh == NULL) { + lm->image = NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ON_ERROR + | NSADDIMAGE_OPTION_WITH_SEARCHING); + /* + * TODO: If NSAddImage fails, use NSLinkEditError to retrieve + * error information. + */ + } + return (lm->dlh != NULL || lm->image != NULL) ? PR_SUCCESS : PR_FAILURE; +} #endif +#endif /* defined(XP_MAC) || defined(XP_MACOSX) */ + /* ** Dynamically load a library. Only load libraries once, so scan the load ** map first. @@ -594,157 +969,48 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) lm->next = pr_loadmap; pr_loadmap = lm; - /* - ** Try to load a table of "static functions" provided by the DLL - */ + /* + ** Try to load a table of "static functions" provided by the DLL + */ - pfn = (NODL_PROC *)GetProcAddress(h, "NODL_TABLE"); - if (pfn != NULL) { - lm->staticTable = (*pfn)(); - } + pfn = (NODL_PROC *)GetProcAddress(h, "NODL_TABLE"); + if (pfn != NULL) { + lm->staticTable = (*pfn)(); + } } #endif /* WIN32 || WIN16 */ -#if defined(XP_MAC) && TARGET_RT_MAC_CFM - { - OSErr err; - CFragConnectionID connectionID; - Str255 errName; - Str255 pName; - char cName[64]; - const char* libName; - - /* - * Algorithm: The "name" passed in could be either a shared - * library name that we should look for in the normal library - * search paths, or a full path name to a specific library on - * disk. Since the full path will always contain a ":" - * (shortest possible path is "Volume:File"), and since a - * library name can not contain a ":", we can test for the - * presence of a ":" to see which type of library we should load. - * or its a full UNIX path which we for now assume is Java - * enumerating all the paths (see below) - */ - if (strchr(name, PR_PATH_SEPARATOR) == NULL) +#if defined(XP_MAC) || defined(XP_MACOSX) { - if (strchr(name, PR_DIRECTORY_SEPARATOR) == NULL) - { - /* - * The name did not contain a ":", so it must be a - * library name. Convert the name to a Pascal string - * and try to find the library. - */ - } - else - { - /* name contained a "/" which means we need to suck off the last part */ - /* of the path and pass that on the NSGetSharedLibrary */ - /* this may not be what we really want to do .. because Java could */ - /* be iterating through the whole LD path, and we'll find it if it's */ - /* anywhere on that path -- it appears that's what UNIX and the PC do */ - /* too...so we'll emulate but it could be wrong. */ - name = strrchr(name, PR_DIRECTORY_SEPARATOR) + 1; - } - - PStrFromCStr(name, pName); - - /* - * beard: NSGetSharedLibrary was so broken that I just decided to - * use GetSharedLibrary for now. This will need to change for - * plugins, but those should go in the Extensions folder anyhow. - */ -#if 0 - err = NSGetSharedLibrary(pName, &connectionID, &lm->main); + int i; + PRStatus status; + + static const macLibraryLoadProc loadProcs[] = { +#if defined(XP_MACOSX) + pr_LoadViaDyld, pr_LoadCFBundle, pr_LoadViaCFM +#elif TARGET_CARBON + pr_LoadViaCFM, pr_LoadCFBundle #else - err = GetSharedLibrary(pName, kCompiledCFragArch, kReferenceCFrag, - &connectionID, &lm->main, errName); + pr_LoadViaCFM #endif - if (err != noErr) - { - oserr = err; - PR_DELETE(lm); - goto unlock; - } - - libName = name; - } - else - { - /* - * The name did contain a ":", so it must be a full path name. - * Now we have to do a lot of work to convert the path name to - * an FSSpec (silly, since we were probably just called from the - * MacFE plug-in code that already knew the FSSpec and converted - * it to a full path just to pass to us). First we copy out the - * volume name (the text leading up to the first ":"); then we - * separate the file name (the text following the last ":") from - * rest of the path. After converting the strings to Pascal - * format we can call GetCatInfo to get the parent directory ID - * of the file, and then (finally) make an FSSpec and call - * GetDiskFragment. - */ - FSSpec fileSpec; - Boolean tempUnusedBool; - - PStrFromCStr(name, pName); - err = FSMakeFSSpec(0, 0, pName, &fileSpec); - if (err != noErr) { - oserr = _MD_ERRNO(); - PR_DELETE(lm); - goto unlock; - } - - /* Resolve an alias if this was one */ - err = ResolveAliasFile(&fileSpec, true, &tempUnusedBool, &tempUnusedBool); - if (err != noErr) - { - oserr = err; - PR_DELETE(lm); - goto unlock; - } - - /* Finally, try to load the library */ - err = GetDiskFragment(&fileSpec, 0, kCFragGoesToEOF, fileSpec.name, - kLoadCFrag, &connectionID, &lm->main, errName); + }; - memcpy(cName, fileSpec.name + 1, fileSpec.name[0]); - cName[fileSpec.name[0]] = '\0'; - libName = cName; - - if (err != noErr) - { -#if TARGET_CARBON - /* If not a CFM library, perhaps it's a CFBundle. */ - lm->bundle = getLibraryBundle(&fileSpec); -#ifdef DEBUG - fprintf(stderr, "*** loading bundle for library '%s' [%s]. ***\n", - libName, lm->bundle ? "SUCCEEDED" : "FAILED"); -#endif - if (lm->bundle == NULL) { - oserr = err; - PR_DELETE(lm); - goto unlock; - } -#else - oserr = err; - PR_DELETE(lm); - goto unlock; -#endif - } + for (i = 0; i < sizeof(loadProcs) / sizeof(loadProcs[0]); i++) { + if ((status = loadProcs[i](name, lm)) == PR_SUCCESS) + break; } - - lm->name = strdup(libName); - lm->dlh = connectionID; + if (status != PR_SUCCESS) { + oserr = cfragNoLibraryErr; + PR_DELETE(lm); + goto unlock; + } + lm->name = strdup(name); lm->next = pr_loadmap; pr_loadmap = lm; - } -#elif defined(XP_MAC) && !TARGET_RT_MAC_CFM - { - } #endif -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) #ifdef HAVE_DLL { #if defined(USE_DLFCN) @@ -790,12 +1056,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) /* No equivalent of PR_LD_GLOBAL and PR_LD_LOCAL. */ h = shl_load(name, shl_flags, 0L); #elif defined(USE_MACH_DYLD) - NSObjectFileImage ofi; - NSModule h = NULL; - if (NSCreateObjectFileImageFromFile(name, &ofi) - == NSObjectFileImageSuccess) { - h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE); - } + NSModule h = pr_LoadMachDyldModule(name); #else #error Configuration error #endif @@ -971,7 +1232,7 @@ pr_Mac_LoadNamedFragment(const FSSpec *fileSpec, const char* fragmentName) goto unlock; newLib->name = strdup(fragmentName); - newLib->dlh = connectionID; + newLib->connection = connectionID; newLib->next = pr_loadmap; pr_loadmap = newLib; @@ -1037,7 +1298,7 @@ pr_Mac_LoadIndexedFragment(const FSSpec *fileSpec, PRUint32 fragIndex) } newLib->name = fragmentName; /* was malloced in NSLoadIndexedFragment */ - newLib->dlh = connectionID; + newLib->connection = connectionID; newLib->next = pr_loadmap; pr_loadmap = newLib; @@ -1094,7 +1355,7 @@ PR_UnloadLibrary(PRLibrary *lib) #elif defined(USE_HPSHL) result = shl_unload(lib->dlh); #elif defined(USE_MACH_DYLD) - result = NSUnLinkModule(lib->dlh, FALSE); + result = NSUnLinkModule(lib->dlh, NSUNLINKMODULE_OPTION_NONE) ? 0 : -1; #else #error Configuration error #endif @@ -1107,14 +1368,19 @@ PR_UnloadLibrary(PRLibrary *lib) } #endif /* XP_PC */ -#if defined(XP_MAC) && TARGET_RT_MAC_CFM +#if defined(XP_MAC) || defined(XP_MACOSX) /* Close the connection */ + if (lib->connection) + CloseConnection(&(lib->connection)); #if TARGET_CARBON if (lib->bundle) CFRelease(lib->bundle); - else #endif - CloseConnection(&(lib->dlh)); +#if defined(XP_MACOSX) + if (lib->wrappers) + CFRelease(lib->wrappers); + /* No way to unload an image (lib->image) */ +#endif #endif /* unlink from library search list */ @@ -1148,9 +1414,10 @@ PR_UnloadLibrary(PRLibrary *lib) freeLib: PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Unloaded library %s", lib->name)); - PR_DELETE(lib->name); + free(lib->name); + lib->name = NULL; PR_DELETE(lib); - if (result == -1) { + if (result != 0) { PR_SetError(PR_UNLOAD_LIBRARY_ERROR, _MD_ERRNO()); DLLErrorInternal(_MD_ERRNO()); status = PR_FAILURE; @@ -1167,12 +1434,12 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) void *f = NULL; if (lm->staticTable != NULL) { - const PRStaticLinkTable* tp; - for (tp = lm->staticTable; tp->name; tp++) { - if (strcmp(name, tp->name) == 0) { - return (void*) tp->fp; + const PRStaticLinkTable* tp; + for (tp = lm->staticTable; tp->name; tp++) { + if (strcmp(name, tp->name) == 0) { + return (void*) tp->fp; + } } - } /* ** If the symbol was not found in the static table then check if ** the symbol was exported in the DLL... Win16 only!! @@ -1191,29 +1458,58 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) f = GetProcAddress(lm->dlh, name); #endif /* WIN32 || WIN16 */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) +#if defined(NEED_LEADING_UNDERSCORE) +#define SYM_OFFSET 1 +#else +#define SYM_OFFSET 0 +#endif #if TARGET_CARBON - if (lm->bundle) - { - CFStringRef nameRef = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII); + if (lm->bundle) { + CFStringRef nameRef = CFStringCreateWithCString(NULL, name + SYM_OFFSET, kCFStringEncodingASCII); if (nameRef) { f = CFBundleGetFunctionPointerForName(lm->bundle, nameRef); CFRelease(nameRef); } } - else #endif - { + if (lm->connection) { Ptr symAddr; CFragSymbolClass symClass; Str255 pName; - - PStrFromCStr(name, pName); - f = (NSFindSymbol(lm->dlh, pName, &symAddr, &symClass) == noErr) ? symAddr : NULL; + PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Looking up symbol: %s", name + SYM_OFFSET)); + + PStrFromCStr(name + SYM_OFFSET, pName); + +#if defined(XP_MACOSX) + f = (FindSymbol(lm->connection, pName, &symAddr, &symClass) == noErr) ? symAddr : NULL; +#else + f = (NSFindSymbol(lm->connection, pName, &symAddr, &symClass) == noErr) ? symAddr : NULL; +#endif + +#if defined(XP_MACOSX) + /* callers expect mach-o function pointers, so must wrap tvectors with glue. */ + if (f && symClass == kTVectorCFragSymbol) { + f = TV2FP(lm->wrappers, name + SYM_OFFSET, f); + } +#endif - if (f == NULL && strcmp(name, "main") == 0) f = lm->main; + if (f == NULL && strcmp(name + SYM_OFFSET, "main") == 0) f = lm->main; } +#if defined(XP_MACOSX) + if (lm->image) { + NSSymbol symbol; + symbol = NSLookupSymbolInImage(lm->image, name, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND + | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + if (symbol != NULL) + f = NSAddressOfSymbol(symbol); + else + f = NULL; + } +#endif +#undef SYM_OFFSET #endif /* XP_MAC */ #ifdef XP_BEOS @@ -1231,7 +1527,7 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) f = NULL; } #elif defined(USE_MACH_DYLD) - { + if (lm->dlh) { NSSymbol symbol; symbol = NSLookupSymbolInModule(lm->dlh, name); if (symbol != NULL) @@ -1385,7 +1681,11 @@ PR_LoadStaticLibrary(const char *name, const PRStaticLinkTable *slt) lm->name = strdup(name); lm->refCount = 1; +#if defined(XP_MAC) + lm->connection = pr_exe_loadmap ? pr_exe_loadmap->connection : 0; +#else lm->dlh = pr_exe_loadmap ? pr_exe_loadmap->dlh : 0; +#endif lm->staticTable = slt; lm->next = pr_loadmap; pr_loadmap = lm; @@ -1397,3 +1697,342 @@ PR_LoadStaticLibrary(const char *name, const PRStaticLinkTable *slt) PR_ExitMonitor(pr_linker_lock); return result; } + +PR_IMPLEMENT(char *) +PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr) +{ +#if defined(SOLARIS) || defined(LINUX) + Dl_info dli; + char *result; + + if (dladdr((void *)addr, &dli) == 0) { + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO()); + DLLErrorInternal(_MD_ERRNO()); + return NULL; + } + result = PR_Malloc(strlen(dli.dli_fname)+1); + if (result != NULL) { + strcpy(result, dli.dli_fname); + } + return result; +#elif defined(USE_MACH_DYLD) + char *result; + char *image_name; + int i, count = _dyld_image_count(); + + for (i = 0; i < count; i++) { + image_name = _dyld_get_image_name(i); + if (strstr(image_name, name) != NULL) { + result = PR_Malloc(strlen(image_name)+1); + if (result != NULL) { + strcpy(result, image_name); + } + return result; + } + } + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0); + return NULL; +#elif defined(AIX) + char *result; +#define LD_INFO_INCREMENT 64 + struct ld_info *info; + unsigned int info_length = LD_INFO_INCREMENT * sizeof(struct ld_info); + struct ld_info *infop; + + for (;;) { + info = PR_Malloc(info_length); + if (info == NULL) { + return NULL; + } + /* If buffer is too small, loadquery fails with ENOMEM. */ + if (loadquery(L_GETINFO, info, info_length) != -1) { + break; + } + PR_Free(info); + if (errno != ENOMEM) { + /* should not happen */ + _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO()); + return NULL; + } + /* retry with a larger buffer */ + info_length += LD_INFO_INCREMENT * sizeof(struct ld_info); + } + + for (infop = info; + ; + infop = (struct ld_info *)((char *)infop + infop->ldinfo_next)) { + if (strstr(infop->ldinfo_filename, name) != NULL) { + result = PR_Malloc(strlen(infop->ldinfo_filename)+1); + if (result != NULL) { + strcpy(result, infop->ldinfo_filename); + } + break; + } + if (!infop->ldinfo_next) { + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0); + result = NULL; + break; + } + } + PR_Free(info); + return result; +#elif defined(OSF1) + /* Contributed by Steve Streeter of HP */ + ldr_process_t process, ldr_my_process(); + ldr_module_t mod_id; + ldr_module_info_t info; + ldr_region_t regno; + ldr_region_info_t reginfo; + size_t retsize; + int rv; + char *result; + + /* Get process for which dynamic modules will be listed */ + + process = ldr_my_process(); + + /* Attach to process */ + + rv = ldr_xattach(process); + if (rv) { + /* should not happen */ + _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO()); + return NULL; + } + + /* Print information for list of modules */ + + mod_id = LDR_NULL_MODULE; + + for (;;) { + + /* Get information for the next module in the module list. */ + + ldr_next_module(process, &mod_id); + if (ldr_inq_module(process, mod_id, &info, sizeof(info), + &retsize) != 0) { + /* No more modules */ + break; + } + if (retsize < sizeof(info)) { + continue; + } + + /* + * Get information for each region in the module and check if any + * contain the address of this function. + */ + + for (regno = 0; ; regno++) { + if (ldr_inq_region(process, mod_id, regno, ®info, + sizeof(reginfo), &retsize) != 0) { + /* No more regions */ + break; + } + if (((unsigned long)reginfo.lri_mapaddr <= + (unsigned long)addr) && + (((unsigned long)reginfo.lri_mapaddr + reginfo.lri_size) > + (unsigned long)addr)) { + /* Found it. */ + result = PR_Malloc(strlen(info.lmi_name)+1); + if (result != NULL) { + strcpy(result, info.lmi_name); + } + return result; + } + } + } + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0); + return NULL; +#elif defined(VMS) + /* Contributed by Colin Blake of HP */ + struct _imcb *icb; + ulong_t status; + char device_name[MAX_DEVNAM]; + int device_name_len; + $DESCRIPTOR (device_name_desc, device_name); + struct fibdef fib; + struct dsc$descriptor_s fib_desc = + { sizeof(struct fibdef), DSC$K_DTYPE_Z, DSC$K_CLASS_S, (char *)&fib } ; + IOSB iosb; + ITMLST devlst[2] = { + {MAX_DEVNAM, DVI$_ALLDEVNAM, device_name, &device_name_len}, + {0,0,0,0}}; + short file_name_len; + char file_name[MAX_FILNAM+1]; + char *result = NULL; + struct dsc$descriptor_s file_name_desc = + { MAX_FILNAM, DSC$K_DTYPE_T, DSC$K_CLASS_S, (char *) &file_name[0] } ; + + /* + ** The address for the process image list could change in future versions + ** of the operating system. 7FFD0688 is valid for V7.2 and V7.3 releases, + ** so we use that for the default, but allow an environment variable + ** (logical name) to override. + */ + if (IAC$GL_IMAGE_LIST == NULL) { + char *p = getenv("MOZILLA_IAC_GL_IMAGE_LIST"); + if (p) + IAC$GL_IMAGE_LIST = (struct _imcb *) strtol(p,NULL,0); + else + IAC$GL_IMAGE_LIST = (struct _imcb *) 0x7FFD0688; + } + + for (icb = IAC$GL_IMAGE_LIST->imcb$l_flink; + icb != IAC$GL_IMAGE_LIST; + icb = icb->imcb$l_flink) { + if (((void *)addr >= icb->imcb$l_starting_address) && + ((void *)addr <= icb->imcb$l_end_address)) { + /* + ** This is the correct image. + ** Get the device name. + */ + status = sys$getdviw(0,icb->imcb$w_chan,0,&devlst,0,0,0,0); + if ($VMS_STATUS_SUCCESS(status)) + device_name_desc.dsc$w_length = device_name_len; + + /* + ** Get the FID. + */ + memset(&fib,0,sizeof(struct fibdef)); + status = sys$qiow(0,icb->imcb$w_chan,IO$_ACCESS,&iosb, + 0,0,&fib_desc,0,0,0,0,0); + + /* + ** If we got the FID, now look up its name (if for some reason + ** we didn't get the device name, this call will fail). + */ + if (($VMS_STATUS_SUCCESS(status)) && ($VMS_STATUS_SUCCESS(iosb.cond))) { + status = lib$fid_to_name ( + &device_name_desc, + &fib.fib$w_fid, + &file_name_desc, + &file_name_len, + 0, 0); + + /* + ** If we succeeded then remove the version number and + ** return a copy of the UNIX format version of the file name. + */ + if ($VMS_STATUS_SUCCESS(status)) { + char *p, *result; + file_name[file_name_len] = 0; + p = strrchr(file_name,';'); + if (p) *p = 0; + p = decc$translate_vms(&file_name[0]); + result = PR_Malloc(strlen(p)+1); + if (result != NULL) { + strcpy(result, p); + } + return result; + } + } + } + } + + /* Didn't find it */ + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0); + return NULL; + +#elif defined(HPUX) && defined(USE_HPSHL) + int index; + struct shl_descriptor desc; + char *result; + + for (index = 0; shl_get_r(index, &desc) == 0; index++) { + if (strstr(desc.filename, name) != NULL) { + result = PR_Malloc(strlen(desc.filename)+1); + if (result != NULL) { + strcpy(result, desc.filename); + } + return result; + } + } + /* + * Since the index value of a library is decremented if + * a library preceding it in the shared library search + * list was unloaded, it is possible that we missed some + * libraries as we went up the list. So we should go + * down the list to be sure that we not miss anything. + */ + for (index--; index >= 0; index--) { + if ((shl_get_r(index, &desc) == 0) + && (strstr(desc.filename, name) != NULL)) { + result = PR_Malloc(strlen(desc.filename)+1); + if (result != NULL) { + strcpy(result, desc.filename); + } + return result; + } + } + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, 0); + return NULL; +#elif defined(HPUX) && defined(USE_DLFCN) + struct load_module_desc desc; + char *result; + const char *module_name; + + if (dlmodinfo((unsigned long)addr, &desc, sizeof desc, NULL, 0, 0) == 0) { + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO()); + DLLErrorInternal(_MD_ERRNO()); + return NULL; + } + module_name = dlgetname(&desc, sizeof desc, NULL, 0, 0); + if (module_name == NULL) { + /* should not happen */ + _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO()); + DLLErrorInternal(_MD_ERRNO()); + return NULL; + } + result = PR_Malloc(strlen(module_name)+1); + if (result != NULL) { + strcpy(result, module_name); + } + return result; +#elif defined(WIN32) + HMODULE handle; + char module_name[MAX_PATH]; + char *result; + + handle = GetModuleHandle(name); + if (handle == NULL) { + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO()); + DLLErrorInternal(_MD_ERRNO()); + return NULL; + } + if (GetModuleFileName(handle, module_name, sizeof module_name) == 0) { + /* should not happen */ + _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO()); + return NULL; + } + result = PR_Malloc(strlen(module_name)+1); + if (result != NULL) { + strcpy(result, module_name); + } + return result; +#elif defined(XP_OS2) + HMODULE module = NULL; + char module_name[_MAX_PATH]; + char *result; + APIRET ulrc = DosQueryModFromEIP(&module, NULL, 0, NULL, NULL, (ULONG) addr); + if ((NO_ERROR != ulrc) || (NULL == module) ) { + PR_SetError(PR_LIBRARY_NOT_LOADED_ERROR, _MD_ERRNO()); + DLLErrorInternal(_MD_ERRNO()); + return NULL; + } + ulrc = DosQueryModuleName(module, sizeof module_name, module_name); + if (NO_ERROR != ulrc) { + /* should not happen */ + _PR_MD_MAP_DEFAULT_ERROR(_MD_ERRNO()); + return NULL; + } + result = PR_Malloc(strlen(module_name)+1); + if (result != NULL) { + strcpy(result, module_name); + } + return result; +#else + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +#endif +} diff --git a/pr/src/malloc/prmem.c b/pr/src/malloc/prmem.c index 0a70b439..ef8fdc74 100644 --- a/pr/src/malloc/prmem.c +++ b/pr/src/malloc/prmem.c @@ -97,20 +97,79 @@ _PR_DestroyZones(void) while (mz->head) { MemBlockHdr *hdr = mz->head; mz->head = hdr->s.next; /* unlink it */ - pr_ZoneFree(hdr); + free(hdr); mz->elements--; } } } + use_zone_allocator = PR_FALSE; } +/* +** pr_FindSymbolInProg +** +** Find the specified data symbol in the program and return +** its address. +*/ + +#ifdef USE_DLFCN + +#include + +static void * +pr_FindSymbolInProg(const char *name) +{ + void *h; + void *sym; + + h = dlopen(0, RTLD_LAZY); + if (h == NULL) + return NULL; + sym = dlsym(h, name); + (void)dlclose(h); + return sym; +} + +#elif defined(USE_HPSHL) + +#include + +static void * +pr_FindSymbolInProg(const char *name) +{ + shl_t h = NULL; + void *sym; + + if (shl_findsym(&h, name, TYPE_DATA, &sym) == -1) + return NULL; + return sym; +} + +#elif defined(USE_MACH_DYLD) + +static void * +pr_FindSymbolInProg(const char *name) +{ + /* FIXME: not implemented */ + return NULL; +} + +#else + +#error "The zone allocator is not supported on this platform" + +#endif + void _PR_InitZones(void) { int i, j; char *envp; + PRBool *sym; - if (envp = getenv("NSPR_USE_ZONE_ALLOCATOR")) { + if ((sym = (PRBool *)pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) { + use_zone_allocator = *sym; + } else if ((envp = getenv("NSPR_USE_ZONE_ALLOCATOR")) != NULL) { use_zone_allocator = (atoi(envp) == 1); } @@ -174,7 +233,7 @@ pr_ZoneMalloc(PRUint32 size) } if (zone < MEM_ZONES) { pthread_t me = pthread_self(); - unsigned int pool = (ptrdiff_t)me % THREAD_POOLS; + unsigned int pool = (PRUptrdiff)me % THREAD_POOLS; PRUint32 wasLocked; mz = &zones[zone][pool]; wasLocked = mz->locked; @@ -275,6 +334,11 @@ pr_ZoneRealloc(void *oldptr, PRUint32 bytes) PR_ASSERT(mb->s.magic == ZONE_MAGIC); if (mb->s.magic != ZONE_MAGIC) { /* Maybe this just came from ordinary malloc */ +#ifdef DEBUG + fprintf(stderr, + "Warning: reallocing memory block %p from ordinary malloc\n", + oldptr); +#endif /* We don't know how big it is. But we can fix that. */ oldptr = realloc(oldptr, bytes); if (!oldptr) { @@ -329,6 +393,10 @@ pr_ZoneFree(void *ptr) if (mb->s.magic != ZONE_MAGIC) { /* maybe this came from ordinary malloc */ +#ifdef DEBUG + fprintf(stderr, + "Warning: freeing memory block %p from ordinary malloc\n", ptr); +#endif free(ptr); return; } @@ -342,7 +410,7 @@ pr_ZoneFree(void *ptr) if (!mz) { PR_ASSERT(blockSize > 65536); /* This block was not in any zone. Just free it. */ - free(ptr); + free(mb); return; } PR_ASSERT(mz->blockSize == blockSize); diff --git a/pr/src/md/beos/bfile.c b/pr/src/md/beos/bfile.c index e80181cc..6fd6cce9 100644 --- a/pr/src/md/beos/bfile.c +++ b/pr/src/md/beos/bfile.c @@ -118,18 +118,45 @@ _MD_make_nonblock (PRFileDesc *fd) } +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) { - /* XXX this function needs to be implemented */ - fd->secret->inheritable = _PR_TRI_UNKNOWN; + 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) { - /* XXX this function needs to be implemented */ - PR_ASSERT(0); + 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 @@ -223,12 +250,14 @@ _MD_write (PRFileDesc *fd, const void *buf, PRInt32 amount) return( rv ); } +#ifndef BONE_VERSION /* Writev moves to bnet.c with BONE */ PRInt32 -_MD_writev (PRFileDesc *fd, struct PRIOVec *iov, PRInt32 iov_size, +_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) @@ -524,191 +553,281 @@ int rv, err; } PRInt32 -_MD_pr_poll (PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) +_MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) { - PRInt32 rc = 0; - fd_set rd, wr; - struct timeval tv, *tvp = NULL; + 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; - int i = 0, j = 0; - int maxfd = -1; - PRInt32 osfd; - PRInt16 in_flags; - PRFileDesc *bottom; + PRInt32 maxfd = -1, ready, err; + PRIntervalTime remaining, elapsed, start; - /*printf("POLL: entering _MD_pr_poll\n");*/ - - /* - * Is it an empty set? If so, just sleep for the timeout and return - */ - if (npds < 1) - { - /*printf("POLL: empty set. exiting _MD_pr_poll\n");*/ - PR_Sleep(timeout); - return rc; - } + 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(&wr); + FD_ZERO(&rd); + FD_ZERO(&wt); + FD_ZERO(&ex); - /* - * first, sort out the new connects, the reads, and the writes - */ - epd = pds + npds; - for(pd = pds; pd < epd; pd++) + ready = 0; + for (pd = pds, epd = pd + npds; pd < epd; pd++) { - in_flags = pd->in_flags; - bottom = pd->fd; + PRInt16 in_flags_read = 0, in_flags_write = 0; + PRInt16 out_flags_read = 0, out_flags_write = 0; - if(bottom != 0 && in_flags != 0) + if ((NULL != pd->fd) && (0 != pd->in_flags)) { - while(bottom->lower != 0) + if (pd->in_flags & PR_POLL_READ) { - bottom = bottom->lower; + in_flags_read = (pd->fd->methods->poll)(pd->fd, pd->in_flags & ~PR_POLL_WRITE, &out_flags_read); } - osfd = bottom->secret->md.osfd; - - if(in_flags & PR_POLL_WRITE || in_flags & PR_POLL_EXCEPT) + if (pd->in_flags & PR_POLL_WRITE) { - /*printf("POLL: adding to write\n");*/ - FD_SET(osfd, &wr); - if( osfd > maxfd ) maxfd = osfd; + 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; } - if(in_flags & PR_POLL_READ || in_flags & PR_POLL_EXCEPT) + else { - /*printf("POLL: adding to read\n");*/ - FD_SET(osfd, &rd); - if( osfd > maxfd ) maxfd = osfd; + 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 */ - if(maxfd >= 0) + remaining = timeout; + start = PR_IntervalNow(); + + retry: + if (timeout != PR_INTERVAL_NO_TIMEOUT) + { + PRInt32 ticksPerSecond = PR_TicksPerSecond(); + tv.tv_sec = remaining / ticksPerSecond; + tv.tv_usec = remaining - (ticksPerSecond * tv.tv_sec); + tv.tv_usec = (PR_USEC_PER_SEC * tv.tv_usec) / ticksPerSecond; + tvp = &tv; + } + + ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp); + + if (ready == -1 && errno == EINTR) { - PRInt32 n; - do { - PRIntervalTime start = PR_IntervalNow(); - if (timeout != PR_INTERVAL_NO_TIMEOUT) + if (timeout == PR_INTERVAL_NO_TIMEOUT) goto retry; + else + { + elapsed = (PRIntervalTime) (PR_IntervalNow() - start); + if (elapsed > timeout) ready = 0; /* timed out */ + else { - /*printf("POLL: timeout = %ld\n", (long) PR_IntervalToMicroseconds(timeout));*/ - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds(timeout) % PR_USEC_PER_SEC; - tvp = &tv; + remaining = timeout - elapsed; + goto retry; } + } + } - - n = select(maxfd + 1, &rd, &wr, 0, tvp); - /*printf("POLL: maxfd = %d, select returns %d, errno = %d %s\n", maxfd, n, errno, strerror(errno));*/ - if (n == 0 || (n < 0 && errno == EINTR)) + /* + ** 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)) { - if (timeout != PR_INTERVAL_NO_TIMEOUT) - { - timeout -= PR_IntervalNow() - start; - if(timeout <= 0) + 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)) { - /* timed out */ - n = 0; + 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; } - } - } - - } while(n < 0 && errno == EINTR); - - if(n > 0) - { - epd = pds + npds; - for(pd = pds; pd < epd; pd++) - { - int selected; - in_flags = pd->in_flags; - bottom = pd->fd; - selected = 0; - - if(bottom != 0 && in_flags != 0) + if (FD_ISSET(osfd, &wt)) { - while(bottom->lower != 0) - { - bottom = bottom->lower; - } - osfd = bottom->secret->md.osfd; - if (FD_ISSET(osfd, &rd)) - { - pd->out_flags |= PR_POLL_READ; - selected++; - } - if (FD_ISSET(osfd, &wr)) - { - pd->out_flags |= PR_POLL_WRITE; - selected++; - } - - if(selected > 0) + 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++ ) { - rc++; - /* - * check if it is a pending connect - */ - PR_Lock( _connectLock ); - for( i = 0; i < connectCount; i++ ) + if(connectList[i].osfd == osfd) { - 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 ) { - 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) { - if(connectError == EINTR || connectError == EWOULDBLOCK - || connectError == EINPROGRESS || connectError == EALREADY) - { - break; - } + break; } - - if(i == (connectCount - 1)) + } + + if(i == (connectCount - 1)) + { + connectList[i].osfd = -1; + } else { + for(j = i; j < connectCount; j++ ) { - connectList[i].osfd = -1; - } else { - for(j = i; j < connectCount; j++ ) - { - memcpy( &connectList[j], &connectList[j+1], - sizeof(connectList[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; } + connectCount--; + + bottom->secret->md.connectReturnValue = connectResult; + bottom->secret->md.connectReturnError = connectError; + bottom->secret->md.connectValueValid = PR_TRUE; + break; } - - - PR_Unlock( _connectLock ); } - } else { - pd->out_flags = 0; - continue; + PR_Unlock( _connectLock ); } - +#endif } - } else if (n < 0) { - /* hit error that's not EINTR. */ - rc = -1; + pd->out_flags = out_flags; + if (out_flags) ready++; } + PR_ASSERT(ready > 0); } - - /*printf("POLL: exiting _MD_pr_poll with %d\n", rc);*/ - return rc; -} + 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. diff --git a/pr/src/md/beos/bmisc.c b/pr/src/md/beos/bmisc.c index 634bea11..056d26a9 100644 --- a/pr/src/md/beos/bmisc.c +++ b/pr/src/md/beos/bmisc.c @@ -37,8 +37,12 @@ #include 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) @@ -63,7 +67,10 @@ _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 diff --git a/pr/src/md/beos/bmmap.c b/pr/src/md/beos/bmmap.c index 2af102cc..27759693 100644 --- a/pr/src/md/beos/bmmap.c +++ b/pr/src/md/beos/bmmap.c @@ -37,6 +37,7 @@ PR_EXTERN(PRStatus) _PR_MD_CREATE_FILE_MAP(PRFileMap *fmap, PRInt64 size) { + PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); return PR_FAILURE; } @@ -57,11 +58,13 @@ _PR_MD_MEM_MAP(PRFileMap *fmap, PRInt64 offset, PRUint32 len) 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 index 86943b3b..2aa0194f 100644 --- a/pr/src/md/beos/bnet.c +++ b/pr/src/md/beos/bnet.c @@ -1,5 +1,5 @@ /* -*- Mode: C++; c-basic-offset: 4 -*- */ -/* +/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of @@ -49,6 +49,7 @@ */ #define _PRSockLen_t int + /* ** Global lock variable used to bracket calls into rusty libraries that ** aren't thread safe (like libc, libX, etc). @@ -56,135 +57,154 @@ 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) */ -#define READ_FD 1 -#define WRITE_FD 2 + +/* + * socket_io_wait -- + * + * wait for socket i/o, periodically checking for interrupt + * + */ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, - PRIntervalTime timeout) + PRIntervalTime timeout) { - PRInt32 rv = -1; - struct timeval tv, *tvp; - PRThread *me = _PR_MD_CURRENT_THREAD(); - PRIntervalTime epoch, now, elapsed, 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; - tvp = &tv; - FD_ZERO(&rd_wr); - do { - FD_SET(osfd, &rd_wr); - if (fd_type == READ_FD) - rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, tvp); - else - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, tvp); - if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) { - if (syserror == EBADF) { - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF); - } else { - PR_SetError(PR_UNKNOWN_ERROR, syserror); - } - if( _PR_PENDING_INTERRUPT(me)) { - me->flags &= ~_PR_INTERRUPT; - PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0); - rv = -1; - break; - } - break; - } - } while (rv == 0 || (rv == -1 && syserror == EINTR)); - break; - default: - now = epoch = PR_IntervalNow(); - remaining = timeout; - tvp = &tv; - 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. - */ - tv.tv_sec = PR_IntervalToSeconds(remaining); - if (tv.tv_sec > _PR_INTERRUPT_CHECK_INTERVAL_SECS) { - 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, tvp); - else - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, tvp); - /* - * we don't consider EINTR a real error - */ - if (rv == -1 && (syserror = _MD_ERRNO()) != EINTR) { - if (syserror == EBADF) { - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, EBADF); - } else { - PR_SetError(PR_UNKNOWN_ERROR, syserror); - } - 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) { - 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 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) @@ -193,33 +213,44 @@ _MD_recv (PRFileDesc *fd, void *buf, PRInt32 amount, PRInt32 flags, 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; + _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(); + 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; + 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; - } + } else + break; } if (rv < 0) { - _PR_MD_MAP_RECV_ERROR(err); + _PR_MD_MAP_RECV_ERROR(err); } done: @@ -235,31 +266,38 @@ _MD_recvfrom (PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, 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; - } + ((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; - } + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { + continue; + } else { + break; + } } if (rv < 0) { - _PR_MD_MAP_RECVFROM_ERROR(err); + _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); } @@ -271,46 +309,56 @@ _MD_send (PRFileDesc *fd, const void *buf, PRInt32 amount, PRInt32 flags, 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; + _PR_MD_MAP_SEND_ERROR(EPIPE); + return -1; } +#endif while ((rv = send(osfd, buf, amount, flags)) == -1) { - err = _MD_ERRNO(); + err = _MD_ERRNO(); - if ((err == EAGAIN) || (err == EWOULDBLOCK)) { - if (fd->secret->nonblocking) { - break; - } + if ((err == EAGAIN) || (err == EWOULDBLOCK)) { + if (fd->secret->nonblocking) { + break; + } - if( _PR_PENDING_INTERRUPT(me)) { +#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 if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { - continue; + /* 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; - } + } else { + break; + } } if (rv < 0) { - _PR_MD_MAP_SEND_ERROR(err); + _PR_MD_MAP_SEND_ERROR(err); } +#ifdef BONE_VERSION +done: +#endif return(rv); } @@ -321,32 +369,97 @@ _MD_sendto (PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, 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 *) addr, addrlen)) == -1) { - err = _MD_ERRNO(); + (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; - } + if ((err == EAGAIN) || (err == EWOULDBLOCK)) { + if (fd->secret->nonblocking) { + break; + } - printf( "This should be a blocking sendto call!!!\n" ); - } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))) { - continue; +#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; - } + } else { + break; + } } if (rv < 0) { - _PR_MD_MAP_SENDTO_ERROR(err); + _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; + + /* + * 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; indexsecret->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; + } + } + + 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) @@ -356,42 +469,39 @@ _MD_accept (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, 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 (addr) addr->raw.family = AF_INET; + (_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); + _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) { - *((unsigned char *) addr) = 0; -#ifdef IS_LITTLE_ENDIAN - addr->raw.family = ntohs(addr->raw.family); -#endif - } + /* 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); @@ -401,62 +511,118 @@ PRInt32 _MD_connect (PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; 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(); - fd->secret->md.connectReturnValue = rv; - fd->secret->md.connectReturnError = err; - fd->secret->md.connectValueValid = PR_TRUE; - - if( err == EINTR ) { +#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)) { + if( _PR_PENDING_INTERRUPT(me)) { - me->flags &= ~_PR_INTERRUPT; + me->flags &= ~_PR_INTERRUPT; PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); return -1; } - snooze( 100000L ); +#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. - */ + /* + ** 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)) { + if( _PR_PENDING_INTERRUPT(me)) { me->flags &= ~_PR_INTERRUPT; PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); return -1; - } + } + + goto retry; + } - 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; + } - if( fd->secret->nonblocking && ((err == EAGAIN) || (err == EINPROGRESS))) { - PR_Lock(_connectLock); - 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); - return rv; - } + 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); + _PR_MD_MAP_CONNECT_ERROR(err); } return rv; @@ -466,9 +632,16 @@ 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); @@ -482,12 +655,14 @@ _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(); @@ -502,15 +677,24 @@ _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; + fd->secret->md.sock_state = BE_SOCK_SHUTDOWN_WRITE; else if (how == PR_SHUTDOWN_RCV) - fd->secret->md.sock_state = BE_SOCK_SHUTDOWN_READ; + 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); + 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 @@ -522,7 +706,11 @@ _MD_socketpair (int af, int type, int flags, PRInt32 *osfd) PRInt32 _MD_close_socket (PRInt32 osfd) { +#ifdef BONE_VERSION + close( osfd ); +#else closesocket( osfd ); +#endif } PRStatus @@ -532,7 +720,14 @@ _MD_getsockname (PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen) 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); @@ -560,9 +755,6 @@ PRStatus _MD_getsockopt (PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen) { - return PR_NOT_IMPLEMENTED_ERROR; - -#if 0 PRInt32 rv, err; rv = getsockopt(fd->secret->md.osfd, level, optname, @@ -573,7 +765,6 @@ _MD_getsockopt (PRFileDesc *fd, PRInt32 level, } return rv==0?PR_SUCCESS:PR_FAILURE; -#endif } PRStatus @@ -597,6 +788,7 @@ _MD_accept_read (PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, return PR_NOT_IMPLEMENTED_ERROR; } +#ifndef BONE_VERSION PRInt32 _MD_socket (int af, int type, int flags) { @@ -606,17 +798,43 @@ _MD_socket (int af, int type, int flags) if( -1 == osfd ) { - err = _MD_ERRNO(); - _PR_MD_MAP_SOCKET_ERROR( err ); + 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 @@ -628,32 +846,25 @@ _MD_get_socket_error (void) PRStatus _MD_gethostname (char *name, PRUint32 namelen) { -PRInt32 rv, err; + PRInt32 rv, err; rv = gethostname(name, namelen); if (rv == 0) { - err = _MD_ERRNO(); - _PR_MD_MAP_GETHOSTNAME_ERROR(err); - return PR_FAILURE; + 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; - if( fd->secret->md.connectValueValid == PR_TRUE ) - - if( fd->secret->md.connectReturnValue == -1 ) - - return fd->secret->md.connectReturnError; - else - return 0; /* No error */ - rv = recv(fd->secret->md.osfd, NULL, 0, flags); PR_ASSERT(-1 == rv || 0 == rv); if (-1 == rv && errno != EAGAIN && errno != EWOULDBLOCK) { @@ -661,3 +872,17 @@ _MD_beos_get_nonblocking_connect_error(PRFileDesc *fd) } 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 index 5d9ac0a5..54ccaa0f 100644 --- a/pr/src/md/beos/bproc.c +++ b/pr/src/md/beos/bproc.c @@ -1,4 +1,4 @@ -/* -*- Mode: C++; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 8; c-basic-offset: 8 -*- */ /* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file @@ -33,28 +33,202 @@ */ #include "primpl.h" +#include +#include + +#define _PR_SIGNALED_EXITSTATUS 256 PRProcess* _MD_create_process (const char *path, char *const *argv, char *const *envp, const PRProcessAttr *attr) { - return NULL; + PRProcess *process; + int nEnv, idx; + char *const *childEnvp; + char **newEnvp = NULL; + int flags; + + 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]; + } + 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) { - return PR_NOT_IMPLEMENTED_ERROR; + /* 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) { - return PR_NOT_IMPLEMENTED_ERROR; + 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) { - return PR_NOT_IMPLEMENTED_ERROR; + 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/mac/macdll.c b/pr/src/md/mac/macdll.c index 2cfe79db..23b32759 100644 --- a/pr/src/md/mac/macdll.c +++ b/pr/src/md/mac/macdll.c @@ -218,7 +218,7 @@ GetSharedLibraryFilterProc(const CInfoPBRec* const inCpb, Boolean* inWantQuit, v // see if this symbol is in this fragment if (LibInPefContainer(&fragSpec, pFilterData->inName, &codeOffset, &codeLength)) - tempErr = GetDiskFragment(&fragSpec, codeOffset, codeLength, pFilterData->inName, kLoadCFrag, &pFilterData->outID, &pFilterData->outAddress, errName); + tempErr = GetDiskFragment(&fragSpec, codeOffset, codeLength, fragSpec.name, kLoadCFrag, &pFilterData->outID, &pFilterData->outAddress, errName); else return; @@ -503,19 +503,30 @@ done: OSErr NSLoadNamedFragment(const FSSpec *fileSpec, const char* fragmentName, CFragConnectionID *outConnectionID) { - UInt32 fragOffset, fragLength; - Ptr main; - Str255 fragName = "\p"; - Str255 errName; - OSErr err; - - err = GetNamedFragmentOffsets(fileSpec, fragmentName, &fragOffset, &fragLength); - if (err != noErr) return err; - - err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName, - kLoadCFrag, outConnectionID, &main, errName); - - return err; + UInt32 fragOffset, fragLength; + short fragNameLength; + Ptr main; + Str255 fragName; + Str255 errName; + OSErr err; + + err = GetNamedFragmentOffsets(fileSpec, fragmentName, &fragOffset, &fragLength); + if (err != noErr) return err; + + // convert fragment name to pascal string + fragNameLength = strlen(fragmentName); + if (fragNameLength > 255) + fragNameLength = 255; + BlockMoveData(fragmentName, &fragName[1], fragNameLength); + fragName[0] = fragNameLength; + + // Note that we pass the fragment name as the 4th param to GetDiskFragment. + // This value affects the ability of debuggers, and the Talkback system, + // to match code fragments with symbol files + err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName, + kLoadCFrag, outConnectionID, &main, errName); + + return err; } @@ -532,39 +543,42 @@ OSErr NSLoadNamedFragment(const FSSpec *fileSpec, const char* fragmentName, CFra -----------------------------------------------------------------*/ OSErr NSLoadIndexedFragment(const FSSpec *fileSpec, PRUint32 fragmentIndex, - char** outFragName, CFragConnectionID *outConnectionID) + char** outFragName, CFragConnectionID *outConnectionID) { - UInt32 fragOffset, fragLength; - char *fragNameBlock = NULL; - Ptr main; - Str255 fragName = "\p"; - Str255 errName; - OSErr err; - - *outFragName = NULL; - - err = GetIndexedFragmentOffsets(fileSpec, fragmentIndex, &fragOffset, &fragLength, &fragNameBlock); - if (err != noErr) return err; - - if (fragNameBlock) - { - UInt32 nameLen = strlen(fragNameBlock); - if (nameLen > 63) - nameLen = 63; - BlockMoveData(fragNameBlock, &fragName[1], nameLen); - fragName[0] = nameLen; - } - - err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName, - kLoadCFrag, outConnectionID, &main, errName); - if (err != noErr) - { - free(fragNameBlock); - return err; - } - - *outFragName = fragNameBlock; - return noErr; + UInt32 fragOffset, fragLength; + char *fragNameBlock = NULL; + Ptr main; + Str255 fragName = "\p"; + Str255 errName; + OSErr err; + + *outFragName = NULL; + + err = GetIndexedFragmentOffsets(fileSpec, fragmentIndex, &fragOffset, &fragLength, &fragNameBlock); + if (err != noErr) return err; + + if (fragNameBlock) + { + UInt32 nameLen = strlen(fragNameBlock); + if (nameLen > 63) + nameLen = 63; + BlockMoveData(fragNameBlock, &fragName[1], nameLen); + fragName[0] = nameLen; + } + + // Note that we pass the fragment name as the 4th param to GetDiskFragment. + // This value affects the ability of debuggers, and the Talkback system, + // to match code fragments with symbol files + err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName, + kLoadCFrag, outConnectionID, &main, errName); + if (err != noErr) + { + free(fragNameBlock); + return err; + } + + *outFragName = fragNameBlock; + return noErr; } diff --git a/pr/src/md/mac/macio.c b/pr/src/md/mac/macio.c index 0a546635..f4bb60a4 100644 --- a/pr/src/md/mac/macio.c +++ b/pr/src/md/mac/macio.c @@ -81,15 +81,16 @@ static void AsyncIOCompletion (ExtendedParamBlock *pbAsyncPtr) if (_PR_MD_GET_INTSOFF()) { thread->md.missedIONotify = PR_TRUE; cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - return; - } + } else { + _PR_INTSOFF(is); - _PR_INTSOFF(is); + thread->md.osErrCode = noErr; + DoneWaitingOnThisThread(thread); - thread->md.osErrCode = noErr; - DoneWaitingOnThisThread(thread); + _PR_FAST_INTSON(is); + } - _PR_FAST_INTSON(is); + SignalIdleSemaphore(); } void _MD_SetError(OSErr oserror) @@ -266,7 +267,7 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op) a 32 byte Ptr in the heap, so only do this once */ if (!sCompletionUPP) - sCompletionUPP = NewIOCompletionProc((IOCompletionProcPtr)&AsyncIOCompletion); + sCompletionUPP = NewIOCompletionUPP((IOCompletionProcPtr)&AsyncIOCompletion); /* grab the thread so we know which one to post to at completion */ pbAsync.thread = me; @@ -1295,7 +1296,9 @@ ConvertUnixPathToMacPath(const char *unixPath, char **macPath) FSSpec foundSpec; short pathBufferSize; +#if DEBUG char *temp; +#endif int tempLen; // Are we dealing with the temp folder? @@ -1905,14 +1908,12 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size) { #pragma unused (fmap, size) - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } PRInt32 _MD_GetMemMapAlignment(void) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; } @@ -1924,7 +1925,6 @@ void * _MD_MemMap( { #pragma unused (fmap, offset, len) - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return NULL; } @@ -1933,7 +1933,6 @@ PRStatus _MD_MemUnmap(void *addr, PRUint32 len) { #pragma unused (addr, len) - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } @@ -1942,7 +1941,6 @@ PRStatus _MD_CloseFileMap(PRFileMap *fmap) { #pragma unused (fmap) - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } diff --git a/pr/src/md/mac/macsocket.h b/pr/src/md/mac/macsocket.h index b1045e36..b9194c52 100644 --- a/pr/src/md/mac/macsocket.h +++ b/pr/src/md/mac/macsocket.h @@ -39,6 +39,7 @@ // Interface visible to xp code // C socket type definitions and routines // from sys/socket.h +#include #include // All the internet typedefs #include // For timeval /* diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c index ef15a56b..6c54de4c 100644 --- a/pr/src/md/mac/macsockotpt.c +++ b/pr/src/md/mac/macsockotpt.c @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -173,9 +174,9 @@ static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode otEvent, O if (_PR_MD_GET_INTSOFF()) { dnsContext.thread->md.missedIONotify = PR_TRUE; cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - return; + } else { + DoneWaitingOnThisThread(dnsContext.thread); } - DoneWaitingOnThisThread(dnsContext.thread); break; case kOTProviderWillClose: @@ -189,9 +190,9 @@ static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode otEvent, O if (_PR_MD_GET_INTSOFF()) { dnsContext.thread->md.missedIONotify = PR_TRUE; cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - return; + } else { + DoneWaitingOnThisThread(dnsContext.thread); } - DoneWaitingOnThisThread(dnsContext.thread); break; default: // or else we don't handle the event @@ -199,6 +200,8 @@ static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode otEvent, O } // or else we don't handle the event + + SignalIdleSemaphore(); } @@ -296,10 +299,12 @@ WakeUpNotifiedThread(PRThread *thread, OTResult result) if (_PR_MD_GET_INTSOFF()) { thread->md.missedIONotify = PR_TRUE; cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - return; + } else { + DoneWaitingOnThisThread(thread); } - DoneWaitingOnThisThread(thread); } + + SignalIdleSemaphore(); } // Notification routine @@ -369,6 +374,8 @@ static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResul PR_ASSERT(err == kOTNoError); secret->md.exceptReady = PR_TRUE; // XXX Check this + md->disconnectError = discon.reason; // save for _MD_mac_get_nonblocking_connect_error + // wake up waiting threads, if any result = -3199 - discon.reason; // obtain the negative error code if ((readThread = secret->md.read.thread) != NULL) { @@ -1080,12 +1087,12 @@ typedef struct RawEndpointAndThread // A5 is OK. Cannot allocate memory here static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) { - RawEndpointAndThread *endthr = (RawEndpointAndThread *) contextPtr; + RawEndpointAndThread *endthr = (RawEndpointAndThread *) contextPtr; PRThread * thread = endthr->thread; EndpointRef * endpoint = endthr->endpoint; _PRCPU * cpu = _PR_MD_CURRENT_CPU(); - OSStatus err; - OTResult resultOT; + OSStatus err; + OTResult resultOT; switch (code) { @@ -1169,10 +1176,12 @@ static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode co if (_PR_MD_GET_INTSOFF()) { thread->md.asyncNotifyPending = PR_TRUE; cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - return; + } else { + DoneWaitingOnThisThread(thread); } - DoneWaitingOnThisThread(thread); } + + SignalIdleSemaphore(); } PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout) @@ -1309,7 +1318,7 @@ PRInt32 _MD_connect(PRFileDesc *fd, PRNetAddr *addr, PRUint32 addrlen, PRInterva err = kEFAULTErr; goto ErrorExit; } - + // Bind to a local port; let the system assign it. bindAddr.inet.family = AF_INET; @@ -1320,19 +1329,19 @@ PRInt32 _MD_connect(PRFileDesc *fd, PRNetAddr *addr, PRUint32 addrlen, PRInterva bindReq.addr.buf = (UInt8*) &bindAddr; bindReq.qlen = 0; - PR_Lock(fd->secret->md.miscLock); + PR_Lock(fd->secret->md.miscLock); PrepareForAsyncCompletion(me, fd->secret->md.osfd); - fd->secret->md.misc.thread = me; + fd->secret->md.misc.thread = me; err = OTBind(endpoint, &bindReq, NULL); if (err != kOTNoError) { - me->io_pending = PR_FALSE; - PR_Unlock(fd->secret->md.miscLock); - goto ErrorExit; - } + me->io_pending = PR_FALSE; + PR_Unlock(fd->secret->md.miscLock); + goto ErrorExit; + } WaitOnThisThread(me, PR_INTERVAL_NO_TIMEOUT); - PR_Unlock(fd->secret->md.miscLock); + PR_Unlock(fd->secret->md.miscLock); err = me->md.osErrCode; if (err != kOTNoError) @@ -1344,26 +1353,26 @@ PRInt32 _MD_connect(PRFileDesc *fd, PRNetAddr *addr, PRUint32 addrlen, PRInterva sndCall.addr.len = addrlen; sndCall.addr.buf = (UInt8*) addr; - if (!fd->secret->nonblocking) { - PrepareForAsyncCompletion(me, fd->secret->md.osfd); - PR_ASSERT(fd->secret->md.write.thread == NULL); - fd->secret->md.write.thread = me; + if (!fd->secret->nonblocking) { + PrepareForAsyncCompletion(me, fd->secret->md.osfd); + PR_ASSERT(fd->secret->md.write.thread == NULL); + fd->secret->md.write.thread = me; } - + err = OTConnect (endpoint, &sndCall, NULL); - if (err == kOTNoError) { - PR_ASSERT(!"OTConnect returned kOTNoError in async mode!?!"); - } - if (fd->secret->nonblocking) { - if (err == kOTNoDataErr) - err = EINPROGRESS; - goto ErrorExit; - } else { - if (err != kOTNoError && err != kOTNoDataErr) { - me->io_pending = PR_FALSE; - goto ErrorExit; - } - } + if (err == kOTNoError) { + PR_ASSERT(!"OTConnect returned kOTNoError in async mode!?!"); + } + if (fd->secret->nonblocking) { + if (err == kOTNoDataErr) + err = EINPROGRESS; + goto ErrorExit; + } else { + if (err != kOTNoError && err != kOTNoDataErr) { + me->io_pending = PR_FALSE; + goto ErrorExit; + } + } WaitOnThisThread(me, timeout); @@ -1583,7 +1592,6 @@ static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, PRThread *me = _PR_MD_CURRENT_THREAD(); PRInt32 bytesLeft = amount; TUnitData dgram; - OTResult result; PR_ASSERT(flags == 0); @@ -1618,13 +1626,13 @@ static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, fd->secret->md.write.thread = me; fd->secret->md.writeReady = PR_FALSE; // expect the worst err = OTSndUData(endpoint, &dgram); - if (result != kOTFlowErr) // hope for the best + if (err != kOTFlowErr) // hope for the best fd->secret->md.writeReady = PR_TRUE; } else { fd->secret->md.read.thread = me; fd->secret->md.readReady = PR_FALSE; // expect the worst err = OTRcvUData(endpoint, &dgram, NULL); - if (result != kOTNoDataErr) // hope for the best + if (err != kOTNoDataErr) // hope for the best fd->secret->md.readReady = PR_TRUE; } @@ -1754,83 +1762,131 @@ static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PR } // check to see if any of the poll descriptors have data available +// for reading or writing, by calling their poll methods (layered IO). +static PRInt32 CheckPollDescMethods(PRPollDesc *pds, PRIntn npds, PRInt16 *outReadFlags, PRInt16 *outWriteFlags) +{ + PRInt32 ready = 0; + PRPollDesc *pd, *epd; + PRInt16 *readFlag, *writeFlag; + + for (pd = pds, epd = pd + npds, readFlag = outReadFlags, writeFlag = outWriteFlags; + pd < epd; + pd++, readFlag++, writeFlag++) + { + PRInt16 in_flags_read = 0, in_flags_write = 0; + PRInt16 out_flags_read = 0, out_flags_write = 0; + + pd->out_flags = 0; + + if (NULL == pd->fd || pd->in_flags == 0) continue; + + 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))) + { + ready += 1; /* some layer has buffer input */ + pd->out_flags = out_flags_read | out_flags_write; + } + + *readFlag = in_flags_read; + *writeFlag = in_flags_write; + } + + return ready; +} + +// check to see if any of OT endpoints of the poll descriptors have data available // for reading or writing. -static PRInt32 CheckPollDescs(PRPollDesc *pds, PRIntn npds) +static PRInt32 CheckPollDescEndpoints(PRPollDesc *pds, PRIntn npds, const PRInt16 *inReadFlags, const PRInt16 *inWriteFlags) { PRInt32 ready = 0; PRPollDesc *pd, *epd; + const PRInt16 *readFlag, *writeFlag; - 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; + for (pd = pds, epd = pd + npds, readFlag = inReadFlags, writeFlag = inWriteFlags; + pd < epd; + pd++, readFlag++, writeFlag++) + { + PRFileDesc *bottomFD; + PRBool readReady, writeReady, exceptReady; + PRInt16 in_flags_read = *readFlag; + PRInt16 in_flags_write = *writeFlag; - if (NULL == pd->fd || pd->in_flags == 0) continue; + if (NULL == pd->fd || pd->in_flags == 0) continue; - 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))) - { - ready += 1; /* some layer has buffer input */ - pd->out_flags = out_flags_read | out_flags_write; - } - else - { - PRFileDesc *bottomFD; - PRBool readReady, writeReady, exceptReady; + if ((pd->in_flags & ~pd->out_flags) == 0) { + ready++; + continue; + } - pd->out_flags = 0; /* pre-condition */ - bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER); - /* bottomFD can be NULL for pollable sockets */ - if (bottomFD) + bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER); + /* bottomFD can be NULL for pollable sockets */ + if (bottomFD) + { + if (_PR_FILEDESC_OPEN == bottomFD->secret->state) + { + if (GetState(bottomFD, &readReady, &writeReady, &exceptReady)) { - if (_PR_FILEDESC_OPEN == bottomFD->secret->state) + if (readReady) + { + if (in_flags_read & PR_POLL_READ) + pd->out_flags |= PR_POLL_READ; + if (in_flags_write & PR_POLL_READ) + pd->out_flags |= PR_POLL_WRITE; + } + if (writeReady) { - if (GetState(bottomFD, &readReady, &writeReady, &exceptReady)) - { - if (readReady) - { - if (in_flags_read & PR_POLL_READ) - pd->out_flags |= PR_POLL_READ; - if (in_flags_write & PR_POLL_READ) - pd->out_flags |= PR_POLL_WRITE; - } - if (writeReady) - { - if (in_flags_read & PR_POLL_WRITE) - pd->out_flags |= PR_POLL_READ; - if (in_flags_write & PR_POLL_WRITE) - pd->out_flags |= PR_POLL_WRITE; - } - if (exceptReady && (pd->in_flags & PR_POLL_EXCEPT)) - { - pd->out_flags |= PR_POLL_EXCEPT; - } - if (0 != pd->out_flags) ready++; - } + if (in_flags_read & PR_POLL_WRITE) + pd->out_flags |= PR_POLL_READ; + if (in_flags_write & PR_POLL_WRITE) + pd->out_flags |= PR_POLL_WRITE; } - else /* bad state */ + if (exceptReady && (pd->in_flags & PR_POLL_EXCEPT)) { - ready += 1; /* this will cause an abrupt return */ - pd->out_flags = PR_POLL_NVAL; /* bogii */ + pd->out_flags |= PR_POLL_EXCEPT; } } + if (0 != pd->out_flags) ready++; + } + else /* bad state */ + { + ready += 1; /* this will cause an abrupt return */ + pd->out_flags = PR_POLL_NVAL; /* bogii */ } } + } return ready; } -// set or clear md.poll.thread on the poll descriptors + +// see how many of the poll descriptors are ready +static PRInt32 CountReadyPollDescs(PRPollDesc *pds, PRIntn npds) +{ + PRInt32 ready = 0; + PRPollDesc *pd, *epd; + + for (pd = pds, epd = pd + npds; pd < epd; pd++) + { + if (pd->out_flags) + ready ++; + } + + return ready; +} + +// set or clear the poll thread on the poll descriptors static void SetDescPollThread(PRPollDesc *pds, PRIntn npds, PRThread* thread) { PRInt32 ready = 0; @@ -1862,43 +1918,82 @@ static void SetDescPollThread(PRPollDesc *pds, PRIntn npds, PRThread* thread) bottomFD->secret->md.write.thread = thread; } } - } + } } } + +#define DESCRIPTOR_FLAGS_ARRAY_SIZE 32 + PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) { + PRInt16 readFlagsArray[DESCRIPTOR_FLAGS_ARRAY_SIZE]; + PRInt16 writeFlagsArray[DESCRIPTOR_FLAGS_ARRAY_SIZE]; + + PRInt16 *readFlags = readFlagsArray; + PRInt16 *writeFlags = writeFlagsArray; + + PRInt16 *ioFlags = NULL; + PRThread *thread = _PR_MD_CURRENT_THREAD(); - intn is; - PRInt32 ready; + PRInt32 ready; - if (timeout == PR_INTERVAL_NO_WAIT) { - return CheckPollDescs(pds, npds); + if (npds > DESCRIPTOR_FLAGS_ARRAY_SIZE) + { + // we allocate a single double-size array. The first half is used + // for read flags, and the second half for write flags. + ioFlags = (PRInt16*)PR_Malloc(sizeof(PRInt16) * npds * 2); + if (!ioFlags) + { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return -1; + } + + readFlags = ioFlags; + writeFlags = &ioFlags[npds]; } - - _PR_INTSOFF(is); - PR_Lock(thread->md.asyncIOLock); - // ensure that we don't miss the firing of the notifier while checking socket status - // need to set up the thread - PrepareForAsyncCompletion(thread, 0); + // we have to be outside the lock when calling this, since + // it can call arbitrary user code (including other socket + // entry points) + ready = CheckPollDescMethods(pds, npds, readFlags, writeFlags); - SetDescPollThread(pds, npds, thread); - ready = CheckPollDescs(pds, npds); + if (!ready && timeout != PR_INTERVAL_NO_WAIT) { + intn is; + - PR_Unlock(thread->md.asyncIOLock); - _PR_FAST_INTSON(is); + _PR_INTSOFF(is); + PR_Lock(thread->md.asyncIOLock); + PrepareForAsyncCompletion(thread, 0); - if (ready == 0) { - WaitOnThisThread(thread, timeout); - ready = CheckPollDescs(pds, npds); + SetDescPollThread(pds, npds, thread); - } else { + (void)CheckPollDescEndpoints(pds, npds, readFlags, writeFlags); + + PR_Unlock(thread->md.asyncIOLock); + _PR_FAST_INTSON(is); + + ready = CountReadyPollDescs(pds, npds); + + if (ready == 0) { + WaitOnThisThread(thread, timeout); + + // since we may have been woken by a pollable event firing, + // we have to check both poll methods and endpoints. + (void)CheckPollDescMethods(pds, npds, readFlags, writeFlags); + ready = CheckPollDescEndpoints(pds, npds, readFlags, writeFlags); + } + thread->io_pending = PR_FALSE; + SetDescPollThread(pds, npds, NULL); + } + else { + ready = CheckPollDescEndpoints(pds, npds, readFlags, writeFlags); } - SetDescPollThread(pds, npds, NULL); - + if (readFlags != readFlagsArray) + PR_Free(ioFlags); + return ready; } @@ -2192,25 +2287,32 @@ ErrorExit: } -int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd) +int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd) { - OTResult resultOT; - EndpointRef endpoint = (EndpointRef) osfd; + EndpointRef endpoint = (EndpointRef)fd->secret->md.osfd; + OTResult resultOT = OTGetEndpointState(endpoint); - resultOT = OTGetEndpointState(endpoint); switch (resultOT) { case T_OUTCON: macsock_map_error(EINPROGRESS); return -1; + case T_DATAXFER: return 0; + case T_IDLE: + macsock_map_error(fd->secret->md.disconnectError); + fd->secret->md.disconnectError = 0; return -1; + case T_INREL: macsock_map_error(ENOTCONN); return -1; + default: PR_ASSERT(0); return -1; } + + return -1; // not reached } diff --git a/pr/src/md/mac/macthr.c b/pr/src/md/mac/macthr.c index 0df8a590..fd3b489d 100644 --- a/pr/src/md/mac/macthr.c +++ b/pr/src/md/mac/macthr.c @@ -39,7 +39,7 @@ #include #include #include - +#include #include #include #include @@ -49,6 +49,8 @@ TimerUPP gTimerCallbackUPP = NULL; PRThread * gPrimaryThread = NULL; +ProcessSerialNumber gApplicationProcess; + PR_IMPLEMENT(PRThread *) PR_GetPrimaryThread() { return gPrimaryThread; @@ -159,7 +161,21 @@ extern void _MD_ClearStack(PRThreadStack *ts) #pragma mark - #pragma mark TIME MANAGER-BASED CLOCK -TMTask gTimeManagerTaskElem; +// On Mac OS X, it's possible for the application to spend lots of time +// in WaitNextEvent, yielding to other applications. Since NSPR threads are +// cooperative here, this means that NSPR threads will also get very little +// time to run. To kick ourselves out of a WaitNextEvent call when we have +// determined that it's time to schedule another thread, the Timer Task +// (which fires every 8ms, even when other apps have the CPU) calls WakeUpProcess. +// We only want to do this on Mac OS X; the gTimeManagerTaskDoesWUP variable +// indicates when we're running on that OS. +// +// Note that the TimerCallback makes use of gApplicationProcess. We need to +// have set this up before the first possible run of the timer task; we do +// so in _MD_EarlyInit(). +static Boolean gTimeManagerTaskDoesWUP; + +static TMTask gTimeManagerTaskElem; extern void _MD_IOInterrupt(void); _PRInterruptTable _pr_interruptTable[] = { @@ -168,6 +184,8 @@ _PRInterruptTable _pr_interruptTable[] = { { 0 } }; +#define kMacTimerInMiliSecs 8L + pascal void TimerCallback(TMTaskPtr tmTaskPtr) { _PRCPU *cpu = _PR_MD_CURRENT_CPU(); @@ -184,8 +202,20 @@ pascal void TimerCallback(TMTaskPtr tmTaskPtr) // And tell nspr that a clock interrupt occured. _PR_ClockInterrupt(); - if ((_PR_RUNQREADYMASK(cpu)) >> ((_PR_MD_CURRENT_THREAD()->priority))) + if ((_PR_RUNQREADYMASK(cpu)) >> ((_PR_MD_CURRENT_THREAD()->priority))) { + if (gTimeManagerTaskDoesWUP) { + // We only want to call WakeUpProcess if we know that NSPR has managed to switch threads + // since the last call, otherwise we end up spewing out WakeUpProcess() calls while the + // application is blocking somewhere. This can interfere with events loops other than + // our own (see bug 158927). + if (UnsignedWideToUInt64(cpu->md.lastThreadSwitch) > UnsignedWideToUInt64(cpu->md.lastWakeUpProcess)) + { + WakeUpProcess(&gApplicationProcess); + cpu->md.lastWakeUpProcess = UpTime(); + } + } _PR_SET_RESCHED_FLAG(); + } _PR_FAST_INTSON(is); @@ -198,8 +228,10 @@ void _MD_StartInterrupts(void) { gPrimaryThread = _PR_MD_CURRENT_THREAD(); + gTimeManagerTaskDoesWUP = RunningOnOSX(); + if ( !gTimerCallbackUPP ) - gTimerCallbackUPP = NewTimerProc(TimerCallback); + gTimerCallbackUPP = NewTimerUPP(TimerCallback); // Fill in the Time Manager queue element @@ -222,26 +254,36 @@ void _MD_StopInterrupts(void) } } + +#define MAX_PAUSE_TIMEOUT_MS 500 + void _MD_PauseCPU(PRIntervalTime timeout) { if (timeout != PR_INTERVAL_NO_WAIT) { - EventRecord theEvent; - - /* - ** Calling WaitNextEvent() here is suboptimal. This routine should - ** pause the process until IO or the timeout occur, yielding time to - ** other processes on operating systems that require this (Mac OS classic). - ** WaitNextEvent() may incur too much latency, and has other problems, - ** such as the potential to drop suspend/resume events, and to handle - ** AppleEvents at a time at which we're not prepared to handle them. - */ - (void) WaitNextEvent(nullEvent, &theEvent, 1, NULL); - + // There is a race condition entering the critical section + // in AsyncIOCompletion (and probably elsewhere) that can + // causes deadlock for the duration of this timeout. To + // work around this, use a max 500ms timeout for now. + // See bug 99561 for details. + if (PR_IntervalToMilliseconds(timeout) > MAX_PAUSE_TIMEOUT_MS) + timeout = PR_MillisecondsToInterval(MAX_PAUSE_TIMEOUT_MS); + + WaitOnIdleSemaphore(timeout); (void) _MD_IOInterrupt(); } } +void _MD_InitRunningCPU(_PRCPU* cpu) +{ + cpu->md.trackScheduling = RunningOnOSX(); + if (cpu->md.trackScheduling) { + AbsoluteTime zeroTime = {0, 0}; + cpu->md.lastThreadSwitch = UpTime(); + cpu->md.lastWakeUpProcess = zeroTime; + } +} + //############################################################################## //############################################################################## @@ -528,19 +570,25 @@ void _MD_SetIntsOff(PRInt32 ints) #pragma mark - #pragma mark CRITICAL REGION SUPPORT + +static PRBool RunningOnOSX() +{ + long systemVersion; + OSErr err = Gestalt(gestaltSystemVersion, &systemVersion); + return (err == noErr) && (systemVersion >= 0x00001000); +} + + #if MAC_CRITICAL_REGIONS MDCriticalRegionID gCriticalRegion; void InitCriticalRegion() { - long systemVersion; OSStatus err; // we only need to do critical region stuff on Mac OS X - err = Gestalt(gestaltSystemVersion, &systemVersion); - gUseCriticalRegions = (err == noErr) && (systemVersion >= 0x00001000); - + gUseCriticalRegions = RunningOnOSX(); if (!gUseCriticalRegions) return; err = MD_CriticalRegionCreate(&gCriticalRegion); @@ -586,3 +634,85 @@ void LeaveCritialRegion() #endif // MAC_CRITICAL_REGIONS +//############################################################################## +//############################################################################## +#pragma mark - +#pragma mark IDLE SEMAPHORE SUPPORT + +/* + Since the WaitNextEvent() in _MD_PauseCPU() is causing all sorts of + headache under Mac OS X we're going to switch to MPWaitOnSemaphore() + which should do what we want +*/ + +#if TARGET_CARBON +PRBool gUseIdleSemaphore = PR_FALSE; +MPSemaphoreID gIdleSemaphore = NULL; +#endif + +void InitIdleSemaphore() +{ + // we only need to do idle semaphore stuff on Mac OS X +#if TARGET_CARBON + gUseIdleSemaphore = RunningOnOSX(); + if (gUseIdleSemaphore) + { + OSStatus err = MPCreateSemaphore(1 /* max value */, 0 /* initial value */, &gIdleSemaphore); + PR_ASSERT(err == noErr); + } +#endif +} + +void TermIdleSemaphore() +{ +#if TARGET_CARBON + if (gUseIdleSemaphore) + { + OSStatus err = MPDeleteSemaphore(gIdleSemaphore); + PR_ASSERT(err == noErr); + gUseIdleSemaphore = NULL; + } +#endif +} + + +void WaitOnIdleSemaphore(PRIntervalTime timeout) +{ +#if TARGET_CARBON + if (gUseIdleSemaphore) + { + OSStatus err = MPWaitOnSemaphore(gIdleSemaphore, kDurationMillisecond * PR_IntervalToMilliseconds(timeout)); + PR_ASSERT(err == noErr); + } + else +#endif + { + EventRecord theEvent; + /* + ** Calling WaitNextEvent() here is suboptimal. This routine should + ** pause the process until IO or the timeout occur, yielding time to + ** other processes on operating systems that require this (Mac OS classic). + ** WaitNextEvent() may incur too much latency, and has other problems, + ** such as the potential to drop suspend/resume events. + */ + (void)WaitNextEvent(nullEvent, &theEvent, 1, NULL); + } +} + + +void SignalIdleSemaphore() +{ +#if TARGET_CARBON + if (gUseIdleSemaphore) + { + // often we won't be waiting on the semaphore here, so ignore any errors + (void)MPSignalSemaphore(gIdleSemaphore); + } + else +#endif + { + WakeUpProcess(&gApplicationProcess); + } +} + + diff --git a/pr/src/md/mac/mdcriticalregion.c b/pr/src/md/mac/mdcriticalregion.c index 927b9246..ff035d0d 100644 --- a/pr/src/md/mac/mdcriticalregion.c +++ b/pr/src/md/mac/mdcriticalregion.c @@ -35,6 +35,7 @@ */ #include "mdcriticalregion.h" +#include /* This code is a replacement for MPEnterCriticalRegion/MPLeaveCriticalRegion, diff --git a/pr/src/md/mac/mdmac.c b/pr/src/md/mac/mdmac.c index f7e9a4fa..6d65e578 100644 --- a/pr/src/md/mac/mdmac.c +++ b/pr/src/md/mac/mdmac.c @@ -70,6 +70,7 @@ unsigned char GarbageCollectorCacheFlusher(PRUint32 size); extern PRThread *gPrimaryThread; +extern ProcessSerialNumber gApplicationProcess; // in macthr.c //############################################################################## @@ -288,7 +289,10 @@ void _MD_EarlyInit() { Handle environmentVariables; + GetCurrentProcess(&gApplicationProcess); + INIT_CRITICAL_REGION(); + InitIdleSemaphore(); #if !defined(MAC_NSPR_STANDALONE) // MacintoshInitializeMemory(); Moved to mdmacmem.c: AllocateRawMemory(Size blockSize) @@ -376,6 +380,7 @@ void CleanupTermProc(void) _MD_StopInterrupts(); // deactive Time Manager task CLOSE_OPEN_TRANSPORT(); + TermIdleSemaphore(); TERM_CRITICAL_REGION(); __NSTerminate(); diff --git a/pr/src/md/os2/Makefile.in b/pr/src/md/os2/Makefile.in index 9898c88f..7db0b44b 100644 --- a/pr/src/md/os2/Makefile.in +++ b/pr/src/md/os2/Makefile.in @@ -62,6 +62,10 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP) ASFILES = os2vacpp.asm endif +ifeq ($(MOZ_OS2_TOOLS),EMX) +ASFILES = os2emx.s +endif + TARGETS = $(OBJS) INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private diff --git a/pr/src/md/os2/objs.mk b/pr/src/md/os2/objs.mk index 7c0bb943..3339a538 100644 --- a/pr/src/md/os2/objs.mk +++ b/pr/src/md/os2/objs.mk @@ -52,6 +52,10 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP) ASFILES = os2vacpp.asm endif +ifeq ($(MOZ_OS2_TOOLS),EMX) +ASFILES = os2emx.s +endif + OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ - $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.asm=.$(OBJ_SUFFIX))) + $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))) diff --git a/pr/src/md/os2/os2_errors.c b/pr/src/md/os2/os2_errors.c index f5be8391..5efd2c16 100644 --- a/pr/src/md/os2/os2_errors.c +++ b/pr/src/md/os2/os2_errors.c @@ -35,6 +35,44 @@ #include "prerror.h" #include "primpl.h" +void _MD_os2_map_default_error(PRInt32 err) +{ + switch (err) { + case EWOULDBLOCK: + PR_SetError(PR_WOULD_BLOCK_ERROR, err); + break; + case EBADF: + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); + break; + case ENOTSOCK: + PR_SetError(PR_NOT_SOCKET_ERROR, err); + break; + case EMSGSIZE: + case EINVAL: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); + break; + case ENOBUFS: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case ECONNREFUSED: + PR_SetError(PR_CONNECT_REFUSED_ERROR, err); + break; + case EISCONN: + PR_SetError(PR_IS_CONNECTED_ERROR, err); + break; +#ifdef SOCEFAULT + case SOCEFAULT: + PR_SetError(PR_ACCESS_FAULT_ERROR, err); + break; +#endif + case ERROR_NETNAME_DELETED: + PR_SetError(PR_CONNECT_RESET_ERROR, err); + break; + default: + PR_SetError(PR_UNKNOWN_ERROR, err); + break; + } +} void _MD_os2_map_opendir_error(PRInt32 err) { switch (err) { @@ -92,7 +130,7 @@ void _MD_os2_map_closedir_error(PRInt32 err) } } -void _MD_unix_readdir_error(PRInt32 err) +void _MD_os2_readdir_error(PRInt32 err) { switch (err) { @@ -671,73 +709,17 @@ void _MD_os2_map_send_error(PRInt32 err) void _MD_os2_map_sendto_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EMSGSIZE: - case EINVAL: - PR_SetError(PR_INVALID_ARGUMENT_ERROR, err); - break; - case ENOBUFS: - PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); - break; - case ECONNREFUSED: - PR_SetError(PR_CONNECT_REFUSED_ERROR, err); - break; - case EISCONN: - PR_SetError(PR_IS_CONNECTED_ERROR, err); - break; -#ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; -#endif - case ERROR_NETNAME_DELETED: - PR_SetError(PR_CONNECT_RESET_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + _MD_os2_map_default_error(err); +} + +void _MD_os2_map_writev_error(int err) +{ + _MD_os2_map_default_error(err); } void _MD_os2_map_accept_error(PRInt32 err) { - switch (err) { - case EWOULDBLOCK: - PR_SetError(PR_WOULD_BLOCK_ERROR, err); - break; - case EBADF: - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, err); - break; - case ENOTSOCK: - PR_SetError(PR_NOT_SOCKET_ERROR, err); - break; - case EOPNOTSUPP: - PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); - break; -#ifdef SOCEFAULT - case SOCEFAULT: - PR_SetError(PR_ACCESS_FAULT_ERROR, err); - break; -#endif - case EMFILE: - PR_SetError(PR_PROC_DESC_TABLE_FULL_ERROR, err); - break; - case ENOBUFS: - PR_SetError(PR_OUT_OF_MEMORY_ERROR, err); - break; - default: - PR_SetError(PR_UNKNOWN_ERROR, err); - break; - } + _MD_os2_map_default_error(err); } void _MD_os2_map_acceptex_error(PRInt32 err) @@ -759,6 +741,21 @@ void _MD_os2_map_acceptex_error(PRInt32 err) } } +/* + * An error code of 0 means that the nonblocking connect succeeded. + */ + +int _MD_os2_get_nonblocking_connect_error(int osfd) +{ + int err; + int len = sizeof(err); + if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &len) == -1) { + return sock_errno(); + } else { + return err; + } +} + void _MD_os2_map_connect_error(PRInt32 err) { switch (err) { diff --git a/pr/src/md/os2/os2cv.c b/pr/src/md/os2/os2cv.c index 1a2d9399..44e1e68b 100644 --- a/pr/src/md/os2/os2cv.c +++ b/pr/src/md/os2/os2cv.c @@ -48,6 +48,42 @@ #include "primpl.h" +#ifdef USE_RAMSEM +ULONG _Far16 _Pascal Dos16GetInfoSeg(PSEL pselGlobal, PSEL pselLocal); + +#ifdef XP_OS2_EMX +typedef unsigned short BOOL16; +#endif + +typedef struct _LINFOSEG +{ + USHORT pidCurrent; + USHORT pidParent; + USHORT prtyCurrent; + USHORT tidCurrent; + USHORT sgCurrent; + UCHAR rfProcStatus; + UCHAR dummy1; + BOOL16 fForeground; + UCHAR typProcess; + UCHAR dummy2; + SEL selEnvironment; + USHORT offCmdLine; + USHORT cbDataSegment; + USHORT cbStack; + USHORT cbHeap; + USHORT hmod; + SEL selDS; + SEL selPack; + SEL selPackShr; + SEL selPackPck; + ULONG ulReserved; +} LINFOSEG; +typedef LINFOSEG FAR *PLINFOSEG; + +PLINFOSEG plisCurrent = NULL; +#endif + /* * AddThreadToCVWaitQueueInternal -- * @@ -82,7 +118,7 @@ AddThreadToCVWaitQueueInternal(PRThread *thred, struct _MDCVar *cv) * This function is called by _PR_MD_WAIT_CV and _PR_MD_UNLOCK, * the two places where a lock is unlocked. */ -static void +void md_UnlockAndPostNotifies( _MDLock *lock, PRThread *waitThred, @@ -163,7 +199,11 @@ md_UnlockAndPostNotifies( } /* Release the lock before notifying */ - DosReleaseMutexSem(lock->mutex); +#ifdef USE_RAMSEM + SemReleasex86(&lock->mutex, 0); +#else + DosReleaseMutexSem(lock->mutex); +#endif notified = &post; /* this is where we start */ do { @@ -270,7 +310,11 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout ) md_UnlockAndPostNotifies(lock, thred, cv); } else { AddThreadToCVWaitQueueInternal(thred, cv); +#ifdef USE_RAMSEM + SemReleasex86( &lock->mutex, 0 ); +#else DosReleaseMutexSem(lock->mutex); +#endif } /* Wait for notification or timeout; don't really care which */ @@ -279,7 +323,11 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout ) DosResetEventSem(thred->md.blocked_sema, &count); } +#ifdef USE_RAMSEM + SemRequest486(&(lock->mutex), -1); +#else DosRequestMutexSem((lock->mutex), SEM_INDEFINITE_WAIT); +#endif PR_ASSERT(rv == NO_ERROR || rv == ERROR_TIMEOUT); @@ -336,28 +384,41 @@ _PR_MD_NOTIFY_CV(_MDCVar *cv, _MDLock *lock) PRStatus _PR_MD_NEW_LOCK(_MDLock *lock) { +#ifdef USE_RAMSEM + // It's better if this API traps when pCriticalSect is not a valid + // pointer, because we can't return an error code and if we just return + // the API caller will have nasty bugs that are hard to find. + + PRAMSEM pramsem = (PRAMSEM)(&(lock->mutex)); + /* First time, set up addresses of processor specific functions + */ + if (plisCurrent == NULL) + { + SEL selGlobal = 0, selLocal = 0; + + /* Convert 16 bit global information segment to 32 bit address + * by performing CRMA on the 16 bit address: "shift" operation + * to convert sel to flat, "and" operation to mask the address + * to 32-bit + */ + Dos16GetInfoSeg(&selGlobal, &selLocal); + plisCurrent = (PLINFOSEG)(((ULONG)selLocal << 13) & + (ULONG)0x1fff0000); + + } + + memset(pramsem, 0, sizeof(pramsem)); + DosCreateEventSem(0, &pramsem->hevSem, DC_SEM_SHARED, 0); + + lock->notified.length=0; + lock->notified.link=NULL; + return PR_SUCCESS; +#else DosCreateMutexSem(0, &(lock->mutex), 0, 0); (lock)->notified.length=0; (lock)->notified.link=NULL; return PR_SUCCESS; -} - -void -_PR_MD_FREE_LOCK(_MDLock *lock) -{ - DosCloseMutexSem(lock->mutex); -} - -void _PR_MD_LOCK(_MDLock *lock) -{ - DosRequestMutexSem(lock->mutex, SEM_INDEFINITE_WAIT); -} - -PRIntn -_PR_MD_TEST_AND_LOCK(_MDLock *lock) -{ - DosRequestMutexSem(lock->mutex, SEM_INDEFINITE_WAIT); - return 0; +#endif } void @@ -366,14 +427,3 @@ _PR_MD_NOTIFYALL_CV(_MDCVar *cv, _MDLock *lock) md_PostNotifyToCvar(cv, lock, PR_TRUE); return; } - -void -_PR_MD_UNLOCK(_MDLock *lock) -{ - if (0 != lock->notified.length) { - md_UnlockAndPostNotifies(lock, NULL, NULL); - } else { - DosReleaseMutexSem(lock->mutex); - } - return; -} diff --git a/pr/src/md/os2/os2emx.s b/pr/src/md/os2/os2emx.s new file mode 100644 index 00000000..4dd81e39 --- /dev/null +++ b/pr/src/md/os2/os2emx.s @@ -0,0 +1,111 @@ +/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/ +/ The contents of this file are subject to the Mozilla Public +/ License Version 1.1 (the "License"); you may not use this file +/ except in compliance with the License. You may obtain a copy of +/ the License at http://www.mozilla.org/MPL/ +/ +/ Software distributed under the License is distributed on an "AS +/ IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +/ implied. See the License for the specific language governing +/ rights and limitations under the License. +/ +/ The Original Code is the Netscape Portable Runtime (NSPR). +/ +/ The Initial Developer of the Original Code is Netscape +/ Communications Corporation. Portions created by Netscape are +/ Copyright (C) 2000 Netscape Communications Corporation. All +/ Rights Reserved. +/ +/ Contributor(s): +/ +/ Alternatively, the contents of this file may be used under the +/ terms of the GNU General Public License Version 2 or later (the +/ "GPL"), in which case the provisions of the GPL are applicable +/ instead of those above. If you wish to allow use of your +/ version of this file only under the terms of the GPL and not to +/ allow others to use your version of this file under the MPL, +/ indicate your decision by deleting the provisions above and +/ replace them with the notice and other provisions required by +/ the GPL. If you do not delete the provisions above, a recipient +/ may use your version of this file under either the MPL or the +/ GPL. +/ + +/ PRInt32 __PR_MD_ATOMIC_INCREMENT(PRInt32 *val) +/ +/ Atomically increment the integer pointed to by 'val' and return +/ the result of the increment. +/ + .text + .globl __PR_MD_ATOMIC_INCREMENT + .align 4 +__PR_MD_ATOMIC_INCREMENT: + movl 4(%esp), %ecx + movl $1, %eax + lock + xaddl %eax, (%ecx) + incl %eax + ret + +/ PRInt32 __PR_MD_ATOMIC_DECREMENT(PRInt32 *val) +/ +/ Atomically decrement the integer pointed to by 'val' and return +/ the result of the decrement. +/ + .text + .globl __PR_MD_ATOMIC_DECREMENT + .align 4 +__PR_MD_ATOMIC_DECREMENT: + movl 4(%esp), %ecx + movl $-1, %eax + lock + xaddl %eax, (%ecx) + decl %eax + ret + +/ PRInt32 __PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) +/ +/ Atomically set the integer pointed to by 'val' to the new +/ value 'newval' and return the old value. +/ +/ An alternative implementation: +/ .text +/ .globl __PR_MD_ATOMIC_SET +/ .align 4 +/__PR_MD_ATOMIC_SET: +/ movl 4(%esp), %ecx +/ movl 8(%esp), %edx +/ movl (%ecx), %eax +/retry: +/ lock +/ cmpxchgl %edx, (%ecx) +/ jne retry +/ ret +/ + .text + .globl __PR_MD_ATOMIC_SET + .align 4 +__PR_MD_ATOMIC_SET: + movl 4(%esp), %ecx + movl 8(%esp), %eax + lock + xchgl %eax, (%ecx) + ret + +/ PRInt32 __PR_MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val) +/ +/ Atomically add 'val' to the integer pointed to by 'ptr' +/ and return the result of the addition. +/ + .text + .globl __PR_MD_ATOMIC_ADD + .align 4 +__PR_MD_ATOMIC_ADD: + movl 4(%esp), %ecx + movl 8(%esp), %eax + movl %eax, %edx + lock + xaddl %eax, (%ecx) + addl %edx, %eax + ret diff --git a/pr/src/md/os2/os2inrval.c b/pr/src/md/os2/os2inrval.c index 469da314..d4c90073 100644 --- a/pr/src/md/os2/os2inrval.c +++ b/pr/src/md/os2/os2inrval.c @@ -39,57 +39,62 @@ #include "primpl.h" -ULONG _os2_ticksPerSec = -1; +static PRBool useHighResTimer = PR_FALSE; +PRIntervalTime _os2_ticksPerSec = -1; PRIntn _os2_bitShift = 0; PRInt32 _os2_highMask = 0; - - void _PR_MD_INTERVAL_INIT() { - if (DosTmrQueryFreq(&_os2_ticksPerSec) == NO_ERROR) - { - while(_os2_ticksPerSec > PR_INTERVAL_MAX) { - _os2_ticksPerSec >>= 1; - _os2_bitShift++; - _os2_highMask = (_os2_highMask << 1)+1; - } - } - else - _os2_ticksPerSec = -1; + ULONG timerFreq = 0; /* OS/2 high-resolution timer frequency in Hz */ + APIRET rc = DosTmrQueryFreq(&timerFreq); + if (NO_ERROR == rc) { + useHighResTimer = PR_TRUE; + PR_ASSERT(timerFreq != 0); + while (timerFreq > PR_INTERVAL_MAX) { + timerFreq >>= 1; + _os2_bitShift++; + _os2_highMask = (_os2_highMask << 1)+1; + } - PR_ASSERT(_os2_ticksPerSec > PR_INTERVAL_MIN && _os2_ticksPerSec < PR_INTERVAL_MAX); + _os2_ticksPerSec = timerFreq; + PR_ASSERT(_os2_ticksPerSec > PR_INTERVAL_MIN); + } } PRIntervalTime _PR_MD_GET_INTERVAL() { - QWORD count; - - /* Sadly; nspr requires the interval to range from 1000 ticks per second - * to only 100000 ticks per second; Counter is too high - * resolution... - */ - if (DosTmrQueryTime(&count) == NO_ERROR) { - PRInt32 top = count.ulHi & _os2_highMask; + if (useHighResTimer) { + QWORD timestamp; + PRInt32 top; + APIRET rc = DosTmrQueryTime(×tamp); + if (NO_ERROR != rc) { + return -1; + } + /* Sadly, nspr requires the interval to range from 1000 ticks per + * second to only 100000 ticks per second. DosTmrQueryTime is too + * high resolution... + */ + top = timestamp.ulHi & _os2_highMask; top = top << (32 - _os2_bitShift); - count.ulLo = count.ulLo >> _os2_bitShift; - count.ulHi = count.ulLo + top; - return (PRUint32)count.ulLo; - } - else{ - ULONG msCount = PR_FAILURE; - DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &msCount, sizeof(msCount)); - return msCount; + timestamp.ulLo = timestamp.ulLo >> _os2_bitShift; + timestamp.ulLo = timestamp.ulLo + top; + return (PRUint32)timestamp.ulLo; + } else { + ULONG msCount = -1; + DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &msCount, sizeof(msCount)); + return msCount; } } PRIntervalTime _PR_MD_INTERVAL_PER_SEC() { - if(_os2_ticksPerSec != -1) - return _os2_ticksPerSec; - else - return 1000; + if (useHighResTimer) { + return _os2_ticksPerSec; + } else { + return 1000; + } } diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index 12e2f2a2..acccf6a6 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -253,6 +253,12 @@ _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) return -1; } + if (len != bytes) { + rv = ERROR_DISK_FULL; + _PR_MD_MAP_WRITE_ERROR(rv); + return -1; + } + return bytes; } /* --- end _PR_MD_WRITE() --- */ diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c index be597fcd..d14972c6 100644 --- a/pr/src/md/os2/os2misc.c +++ b/pr/src/md/os2/os2misc.c @@ -118,107 +118,28 @@ PR_Now(void) static int assembleCmdLine(char *const *argv, char **cmdLine) { char *const *arg; - char *p, *q; int cmdLineSize; - int numBackslashes; - int i; - int argNeedQuotes; /* * Find out how large the command line buffer should be. */ - cmdLineSize = 0; - for (arg = argv; *arg; arg++) { - /* - * \ and " need to be escaped by a \. In the worst case, - * every character is a \ or ", so the string of length - * may double. If we quote an argument, that needs two ". - * Finally, we need a space between arguments, a null between - * the EXE name and the arguments, and 2 nulls at the end - * of command line. - */ - cmdLineSize += 2 * strlen(*arg) /* \ and " need to be escaped */ - + 2 /* we quote every argument */ - + 4; /* space in between, or final nulls */ - } - p = *cmdLine = PR_MALLOC(cmdLineSize); - if (p == NULL) { + cmdLineSize = 1; /* final null */ + for (arg = argv+1; *arg; arg++) { + cmdLineSize += strlen(*arg) + 1; /* space in between */ + } + *cmdLine = PR_MALLOC(cmdLineSize); + if (*cmdLine == NULL) { return -1; } - for (arg = argv; *arg; arg++) { - /* Add a space to separates the arguments */ - if (arg > argv + 1) { - *p++ = ' '; - } - q = *arg; - numBackslashes = 0; - argNeedQuotes = 0; - - /* If the argument contains white space, it needs to be quoted. */ - if (strpbrk(*arg, " \f\n\r\t\v")) { - argNeedQuotes = 1; - } + (*cmdLine)[0] = '\0'; - if (argNeedQuotes) { - *p++ = '"'; + for (arg = argv+1; *arg; arg++) { + if (arg > argv +1) { + strcat(*cmdLine, " "); } - while (*q) { - if (*q == '\\') { - numBackslashes++; - q++; - } else if (*q == '"') { - if (numBackslashes) { - /* - * Double the backslashes since they are followed - * by a quote - */ - for (i = 0; i < 2 * numBackslashes; i++) { - *p++ = '\\'; - } - numBackslashes = 0; - } - /* To escape the quote */ - *p++ = '\\'; - *p++ = *q++; - } else { - if (numBackslashes) { - /* - * Backslashes are not followed by a quote, so - * don't need to double the backslashes. - */ - for (i = 0; i < numBackslashes; i++) { - *p++ = '\\'; - } - numBackslashes = 0; - } - *p++ = *q++; - } - } - - /* Now we are at the end of this argument */ - if (numBackslashes) { - /* - * Double the backslashes if we have a quote string - * delimiter at the end. - */ - if (argNeedQuotes) { - numBackslashes *= 2; - } - for (i = 0; i < numBackslashes; i++) { - *p++ = '\\'; - } - } - if (argNeedQuotes) { - *p++ = '"'; - } - if(arg == argv) - *p++ = '\0'; + strcat(*cmdLine, *arg); } - - /* Add 2 nulls at the end */ - *p++ = '\0'; - *p = '\0'; return 0; } @@ -308,129 +229,154 @@ static int compare(const void *arg1, const void *arg2) { return stricmp(* (char**)arg1, * (char**)arg2); } + PRProcess * _PR_CreateOS2Process( const char *path, char *const *argv, char *const *envp, const PRProcessAttr *attr) { - char szFailed[CCHMAXPATH]; - RESULTCODES procInfo; - APIRET retVal; - char *cmdLine = NULL; - char *envBlock = NULL; - char **newEnvp; - PRProcess *proc = NULL; - HFILE hStdIn = 0, - hStdOut = 0, - hStdErr = 0; - HFILE hStdInSave = -1, - hStdOutSave = -1, - hStdErrSave = -1; - - proc = PR_NEW(PRProcess); - if (!proc) { - PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); - goto errorExit; - } - - if (assembleCmdLine(argv, &cmdLine) == -1) { - PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); - goto errorExit; - } - - if (envp == NULL) { - newEnvp = NULL; - } else { - int i; - int numEnv = 0; - while (envp[numEnv]) { - numEnv++; - } - newEnvp = (char **) PR_MALLOC((numEnv+1) * sizeof(char *)); - for (i = 0; i <= numEnv; i++) { - newEnvp[i] = envp[i]; - } - qsort((void *) newEnvp, (size_t) numEnv, sizeof(char *), compare); - } - if (assembleEnvBlock(newEnvp, &envBlock) == -1) { - PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); - goto errorExit; - } - - if (attr) { - /* On OS/2, there is really no way to pass file handles for stdin, stdout, - * and stderr to a new process. Instead, we can make it a child process - * and make the given file handles a copy of our stdin, stdout, and stderr. - * The child process then inherits ours, and we set ours back. Twisted - * and gross I know. If you know a better way, please use it. - */ - if (attr->stdinFd) { - hStdIn = 0; - DosDupHandle(hStdIn, &hStdInSave); - DosDupHandle((HFILE) attr->stdinFd->secret->md.osfd, &hStdIn); - } - if (attr->stdoutFd) { - hStdOut = 1; - DosDupHandle(hStdOut, &hStdOutSave); - DosDupHandle((HFILE) attr->stdoutFd->secret->md.osfd, &hStdOut); + PRProcess *proc = NULL; + char *cmdLine = NULL; + char **newEnvp = NULL; + char *envBlock = NULL; + + STARTDATA startData = {0}; + APIRET rc; + ULONG ulAppType = 0; + PID pid = 0; + char *pEnvWPS = NULL; + char *pszComSpec; + char pszEXEName[CCHMAXPATH] = ""; + char pszFormatString[CCHMAXPATH]; + char pszObjectBuffer[CCHMAXPATH]; + char *pszFormatResult = NULL; + + proc = PR_NEW(PRProcess); + if (!proc) { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + goto errorExit; + } + + if (assembleCmdLine(argv, &cmdLine) == -1) { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + goto errorExit; + } + + if (envp == NULL) { + newEnvp = NULL; + } else { + int i; + int numEnv = 0; + while (envp[numEnv]) { + numEnv++; } - if (attr->stderrFd) { - hStdErr = 2; - DosDupHandle(hStdErr, &hStdErrSave); - DosDupHandle((HFILE) attr->stderrFd->secret->md.osfd, &hStdErr); + newEnvp = (char **) PR_MALLOC((numEnv+1) * sizeof(char *)); + for (i = 0; i <= numEnv; i++) { + newEnvp[i] = envp[i]; } - } - - retVal = DosExecPgm(szFailed, - CCHMAXPATH, - EXEC_ASYNCRESULT, - cmdLine, - envBlock, - &procInfo, - argv[0]); - - /* Restore our old values. Hope this works */ - if(hStdInSave != -1){ - DosDupHandle(hStdInSave, &hStdIn); - DosClose(hStdInSave); - } - if(hStdOutSave != -1){ - DosDupHandle(hStdOutSave, &hStdOut); - DosClose(hStdOutSave); - } - if(hStdErrSave != -1){ - DosDupHandle(hStdErrSave, &hStdErr); - DosClose(hStdErrSave); - } + qsort((void *) newEnvp, (size_t) numEnv, sizeof(char *), compare); + } + if (assembleEnvBlock(newEnvp, &envBlock) == -1) { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + goto errorExit; + } + + if (attr) { + PR_ASSERT(!"Not implemented"); + } - if (retVal != NO_ERROR) { - /* XXX what error code? */ - PR_SetError(PR_UNKNOWN_ERROR, retVal); + rc = DosQueryAppType(path, &ulAppType); + if (rc != NO_ERROR) { + char *pszDot = strrchr(path, '.'); + if (pszDot) { + /* If it is a CMD file, launch the users command processor */ + if (!stricmp(pszDot, ".cmd")) { + rc = DosScanEnv("COMSPEC", &pszComSpec); + if (!rc) { + strcpy(pszFormatString, "/C %s %s"); + strcpy(pszEXEName, pszComSpec); + ulAppType = FAPPTYP_WINDOWCOMPAT; + } + } + } + } + if (ulAppType == 0) { + PR_SetError(PR_UNKNOWN_ERROR, 0); goto errorExit; - } - - proc->md.pid = procInfo.codeTerminate; + } + + if ((ulAppType & FAPPTYP_WINDOWAPI) == FAPPTYP_WINDOWAPI) { + startData.SessionType = SSF_TYPE_PM; + } + else if (ulAppType & FAPPTYP_WINDOWCOMPAT) { + startData.SessionType = SSF_TYPE_WINDOWABLEVIO; + } + else { + startData.SessionType = SSF_TYPE_DEFAULT; + } + + if (ulAppType & (FAPPTYP_WINDOWSPROT31 | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSREAL)) + { + strcpy(pszEXEName, "WINOS2.COM"); + startData.SessionType = PROG_31_STDSEAMLESSVDM; + strcpy(pszFormatString, "/3 %s %s"); + } + + startData.InheritOpt = SSF_INHERTOPT_SHELL; + + if (pszEXEName[0]) { + pszFormatResult = PR_MALLOC(strlen(pszFormatString)+strlen(path)+strlen(cmdLine)); + sprintf(pszFormatResult, pszFormatString, path, cmdLine); + startData.PgmInputs = pszFormatResult; + } else { + strcpy(pszEXEName, path); + startData.PgmInputs = cmdLine; + } + startData.PgmName = pszEXEName; + + startData.Length = sizeof(startData); + startData.Related = SSF_RELATED_INDEPENDENT; + startData.ObjectBuffer = pszObjectBuffer; + startData.ObjectBuffLen = CCHMAXPATH; + startData.Environment = envBlock; + + rc = DosStartSession(&startData, &ulAppType, &pid); + + if ((rc != NO_ERROR) && (rc != ERROR_SMG_START_IN_BACKGROUND)) { + PR_SetError(PR_UNKNOWN_ERROR, 0); + } + + proc->md.pid = pid; - PR_DELETE(cmdLine); - if (envBlock) { - PR_DELETE(envBlock); - } - return proc; + if (pszFormatResult) { + PR_DELETE(pszFormatResult); + } + + PR_DELETE(cmdLine); + if (newEnvp) { + PR_DELETE(newEnvp); + } + if (envBlock) { + PR_DELETE(envBlock); + } + return proc; errorExit: - if (cmdLine) { - PR_DELETE(cmdLine); - } - if (envBlock) { - PR_DELETE(envBlock); - } - if (proc) { - PR_DELETE(proc); - } - return NULL; - -} /* _PR_CreateWindowsProcess */ + if (cmdLine) { + PR_DELETE(cmdLine); + } + if (newEnvp) { + PR_DELETE(newEnvp); + } + if (envBlock) { + PR_DELETE(envBlock); + } + if (proc) { + PR_DELETE(proc); + } + return NULL; +} /* _PR_CreateOS2Process */ PRStatus _PR_DetachOS2Process(PRProcess *process) { @@ -506,14 +452,12 @@ _PR_MD_WAKEUP_CPUS( void ) PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } PRInt32 _MD_GetMemMapAlignment(void) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; } @@ -523,21 +467,18 @@ void * _MD_MemMap( PROffset64 offset, PRUint32 len) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return NULL; } PRStatus _MD_MemUnmap(void *addr, PRUint32 len) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } PRStatus _MD_CloseFileMap(PRFileMap *fmap) { - PR_ASSERT(!"Not implemented"); PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } @@ -577,43 +518,3 @@ unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long fla return rc; } -#ifndef XP_OS2_VACPP - -PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *intp, PRInt32 val) -{ - PRInt32 result; - asm volatile ("lock ; xchg %0, %1" - : "=r"(result), "=m"(intp) - : "0"(val), "m"(intp)); - return result; -} - -PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *intp, PRInt32 val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(intp) - : "0"(val), "m"(intp)); - return result + val; -} - -PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(*val) - : "0"(1), "m"(*val)); - return result + 1; -} - -PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(*val) - : "0"(1), "m"(*val)); - return result - 1; -} - -#endif - diff --git a/pr/src/md/os2/os2poll.c b/pr/src/md/os2/os2poll.c index 12f199f6..3b087e11 100644 --- a/pr/src/md/os2/os2poll.c +++ b/pr/src/md/os2/os2poll.c @@ -37,54 +37,64 @@ */ #ifdef XP_OS2_EMX - #include /* For timeval. */ + #include /* For timeval. */ #endif #include "primpl.h" -PRInt32 _PR_MD_PR_POLL( - PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) +#ifndef BSD_SELECT +/* Utility functions called when using OS/2 select */ + +PRBool IsSocketSet( PRInt32 osfd, int* socks, int start, int count ) +{ + int i; + PRBool isSet = PR_FALSE; + + for( i = start; i < start+count; i++ ) + { + if( socks[i] == osfd ) + isSet = PR_TRUE; + } + + return isSet; +} +#endif + +PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) { - PRInt32 osfd; - int maxfd = -1; +#ifdef BSD_SELECT fd_set rd, wt, ex; +#else + int rd, wt, ex; + int* socks; + unsigned long msecs; + int i, j; +#endif PRFileDesc *bottom; PRPollDesc *pd, *epd; - PRInt32 ready, err; - PRThread *me = _PR_MD_CURRENT_THREAD(); - struct timeval tv, *tvp = NULL; + PRInt32 maxfd = -1, ready, err; + PRIntervalTime remaining, elapsed, start; - /* - * For restarting _MD_SELECT() if it is interrupted by a signal. - * We use these variables to figure out how much time has elapsed - * and how much of the timeout still remains. - */ - PRIntervalTime start, elapsed, remaining; +#ifdef BSD_SELECT + struct timeval tv, *tvp = NULL; - if (_PR_PENDING_INTERRUPT(me)) + FD_ZERO(&rd); + FD_ZERO(&wt); + FD_ZERO(&ex); +#else + rd = 0; + wt = 0; + ex = 0; + socks = (int) PR_MALLOC( npds * 3 * sizeof(int) ); + + if (!socks) { - me->flags &= ~_PR_INTERRUPT; - PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0); + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); return -1; } +#endif - /* - ** Is it an empty set? If so, just sleep for the timeout and return - */ - if (0 == npds) - { - PR_Sleep(timeout); - return 0; - } - - remaining = timeout; - start = PR_IntervalNow(); - - FD_ZERO(&rd); - FD_ZERO(&wt); - FD_ZERO(&ex); - - ready = 0; + ready = 0; for (pd = pds, epd = pd + npds; pd < epd; pd++) { PRInt16 in_flags_read = 0, in_flags_write = 0; @@ -95,19 +105,17 @@ PRInt32 _PR_MD_PR_POLL( if (pd->in_flags & PR_POLL_READ) { in_flags_read = (pd->fd->methods->poll)( - pd->fd, (PRInt16)(pd->in_flags & ~PR_POLL_WRITE), - &out_flags_read); + 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, (PRInt16)(pd->in_flags & ~PR_POLL_READ), - &out_flags_write); + 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))) + if ((0 != (in_flags_read & out_flags_read)) || + (0 != (in_flags_write & out_flags_write))) { - /* this one's ready right now (buffered input) */ + /* this one's ready right now */ if (0 == ready) { /* @@ -128,37 +136,67 @@ PRInt32 _PR_MD_PR_POLL( 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 ((NULL != bottom) && + (_PR_FILEDESC_OPEN == bottom->secret->state)) { if (0 == ready) { - osfd = bottom->secret->md.osfd; - if (osfd > maxfd) maxfd = osfd; + 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; +#ifdef BSD_SELECT FD_SET(osfd, &rd); +#else + socks[rd] = osfd; + rd++; +#endif } if (in_flags_read & PR_POLL_WRITE) { pd->out_flags |= _PR_POLL_READ_SYS_WRITE; +#ifdef BSD_SELECT FD_SET(osfd, &wt); +#else + socks[npds+wt] = osfd; + wt++; +#endif } if (in_flags_write & PR_POLL_READ) { pd->out_flags |= _PR_POLL_WRITE_SYS_READ; +#ifdef BSD_SELECT FD_SET(osfd, &rd); +#else + socks[rd] = osfd; + rd++; +#endif } if (in_flags_write & PR_POLL_WRITE) { pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE; +#ifdef BSD_SELECT FD_SET(osfd, &wt); +#else + socks[npds+wt] = osfd; + wt++; +#endif + } + if (pd->in_flags & PR_POLL_EXCEPT) + { +#ifdef BSD_SELECT + FD_SET(osfd, &ex); +#else + socks[npds*2+ex] = osfd; + ex++; +#endif } - if (pd->in_flags & PR_POLL_EXCEPT) FD_SET(osfd, &ex); } } else @@ -176,11 +214,25 @@ PRInt32 _PR_MD_PR_POLL( } } } + else + { + pd->out_flags = 0; + } } - if (0 != ready) return ready; /* no need to block */ + if (0 != ready) + { +#ifndef BSD_SELECT + free(socks); +#endif + return ready; /* no need to block */ + } + + remaining = timeout; + start = PR_IntervalNow(); retry: +#ifdef BSD_SELECT if (timeout != PR_INTERVAL_NO_TIMEOUT) { PRInt32 ticksPerSecond = PR_TicksPerSecond(); @@ -191,21 +243,50 @@ retry: } ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp); +#else + switch (timeout) + { + case PR_INTERVAL_NO_WAIT: + msecs = 0; + break; + case PR_INTERVAL_NO_TIMEOUT: + msecs = -1; + break; + default: + msecs = PR_IntervalToMilliseconds(remaining); + } + + /* compact array */ + for( i = rd, j = npds; j < npds+wt; i++,j++ ) + socks[i] = socks[j]; + for( i = rd+wt, j = npds*2; j < npds*2+ex; i++,j++ ) + socks[i] = socks[j]; + + ready = _MD_SELECT(socks, rd, wt, ex, msecs); +#endif + if (ready == -1 && errno == EINTR) { - if (timeout == PR_INTERVAL_NO_TIMEOUT) goto retry; - else + if (timeout == PR_INTERVAL_NO_TIMEOUT) + goto retry; + else { - elapsed = (PRIntervalTime) (PR_IntervalNow() - start); - if (elapsed > timeout) ready = 0; /* timed out */ - else + elapsed = (PRIntervalTime) (PR_IntervalNow() - start); + if (elapsed > timeout) + ready = 0; /* timed out */ + else { - remaining = timeout - elapsed; - goto retry; + 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; @@ -214,26 +295,44 @@ retry: 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; +#ifdef BSD_SELECT if (FD_ISSET(osfd, &rd)) +#else + if( IsSocketSet(osfd, socks, 0, rd) ) +#endif { 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; - } + } + +#ifdef BSD_SELECT if (FD_ISSET(osfd, &wt)) +#else + if( IsSocketSet(osfd, socks, rd, wt) ) +#endif { 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; + } + +#ifdef BSD_SELECT + if (FD_ISSET(osfd, &ex)) +#else + if( IsSocketSet(osfd, socks, rd+wt, ex) ) +#endif + { + out_flags |= PR_POLL_EXCEPT; } - if (FD_ISSET(osfd, &ex)) out_flags |= PR_POLL_EXCEPT; } pd->out_flags = out_flags; if (out_flags) ready++; @@ -242,39 +341,42 @@ retry: } else if (ready < 0) { - err = _MD_ERRNO(); - if (err == EBADF) + err = _MD_ERRNO(); + if (err == EBADF) { - /* Find the bad fds */ - ready = 0; - for (pd = pds, epd = pd + npds; pd < epd; pd++) + /* Find the bad fds */ + int optval; + int optlen = sizeof(optval); + ready = 0; + for (pd = pds, epd = pd + npds; pd < epd; pd++) { - int optval; - int optlen = sizeof(optval); - pd->out_flags = 0; - if ((NULL == pd->fd) || (pd->in_flags == 0)) continue; - bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER); - if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, - SO_TYPE, (char *) &optval, &optlen) == -1) + pd->out_flags = 0; + if ((NULL != pd->fd) && (0 != pd->in_flags)) { - PR_ASSERT(_MD_ERRNO() == ENOTSOCK); - if (_MD_ERRNO() == ENOTSOCK) + bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER); + if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, + SO_TYPE, (char *) &optval, &optlen) == -1) { - pd->out_flags = PR_POLL_NVAL; - ready++; + PR_ASSERT(sock_errno() == ENOTSOCK); + if (sock_errno() == ENOTSOCK) + { + pd->out_flags = PR_POLL_NVAL; + ready++; + } } } - } - PR_ASSERT(ready > 0); - } - else - { - PR_ASSERT(err != EINTR); /* should have been handled above */ - _PR_MD_MAP_SELECT_ERROR(err); + } + PR_ASSERT(ready > 0); } - } - return ready; - } + else + _PR_MD_MAP_SELECT_ERROR(err); + } + +#ifndef BSD_SELECT + free(socks); +#endif + return ready; +} #ifdef XP_OS2_EMX HMTX thread_select_mutex = 0; /* because EMX's select is not thread safe - duh! */ diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c index 529e0e5a..b9c812ba 100644 --- a/pr/src/md/os2/os2sock.c +++ b/pr/src/md/os2/os2sock.c @@ -46,9 +46,13 @@ #include "primpl.h" #ifdef XP_OS2_EMX - #include /* For timeval. */ + #include /* For timeval. */ #endif +#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5 +#define READ_FD 1 +#define WRITE_FD 2 + void _PR_MD_INIT_IO() { @@ -59,34 +63,19 @@ _PR_MD_INIT_IO() PRInt32 -_PR_MD_SOCKET(int af, int type, int flags) +_PR_MD_SOCKET(int domain, int type, int flags) { - int sock; - PRUint32 one = 1; - PRInt32 rv; - PRInt32 err; + PRInt32 osfd, err; - sock = socket(af, type, flags); - - if (sock == -1 ) - { - int rv = sock_errno(); - soclose(sock); - _PR_MD_MAP_SOCKET_ERROR(rv); - return (PRInt32) -1; - } + osfd = socket(domain, type, flags); - /* - ** Make the socket Non-Blocking - */ - rv = ioctl( sock, FIONBIO, (char *) &one, sizeof(one)); - if ( rv != 0 ) + if (osfd == -1) { err = sock_errno(); - return -1; + _PR_MD_MAP_SOCKET_ERROR(err); } - return (PRInt32)sock; + return(osfd); } /* @@ -96,12 +85,13 @@ _PR_MD_SOCKET(int af, int type, int flags) PRInt32 _MD_CloseSocket(PRInt32 osfd) { - PRInt32 rv = -1; - - rv = soclose((int) osfd ); - if (rv < 0) - _PR_MD_MAP_SOCKET_ERROR(sock_errno()); + PRInt32 rv, err; + rv = soclose(osfd); + if (rv == -1) { + err = sock_errno(); + _PR_MD_MAP_CLOSE_ERROR(err); + } return rv; } @@ -117,256 +107,276 @@ _MD_SocketAvailable(PRFileDesc *fd) return result; } -PRInt32 -_MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, - PRIntervalTime timeout ) +static PRInt32 +socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) { - PRInt32 osfd = fd->secret->md.osfd; - PRInt32 rv, err; + PRInt32 rv = -1; + PRThread *me = _PR_MD_CURRENT_THREAD(); + PRIntervalTime epoch, now, elapsed, remaining; + PRBool wait_for_remaining; + PRInt32 syserror; #ifdef BSD_SELECT - fd_set rd; - struct timeval tv, *tvp; - - FD_ZERO(&rd); - FD_SET(osfd, &rd); + struct timeval tv; + fd_set rd_wr; #else int socks[1]; - socks[0] = osfd; + long lTimeout; #endif - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - while ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1) - { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { + + 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. + */ #ifdef BSD_SELECT - if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL,NULL)) == -1) { + 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); #else - if ((rv = _MD_SELECT(socks, 1, 0, 0, -1)) == -1) { -#endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; + do { + socks[0] = osfd; + if (fd_type == READ_FD) + rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); + else + rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); +#endif + if (rv == -1 && (syserror = sock_errno()) != EINTR) { + _PR_MD_MAP_SELECT_ERROR(syserror); break; - } - } - else { - _PR_MD_MAP_ACCEPT_ERROR(err); - break; - } - } - return(rv); - } - else if (timeout == PR_INTERVAL_NO_WAIT) - { - if ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1) - { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - } - else - { - _PR_MD_MAP_ACCEPT_ERROR(err); - } - } - return(rv); - } - else - { -retry: - if ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1) - { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { + } + 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; #ifdef BSD_SELECT - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp); + FD_ZERO(&rd_wr); +#endif + 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. + */ +#ifdef BSD_SELECT + 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); #else - long lTimeout = PR_IntervalToMilliseconds(timeout); - rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); + wait_for_remaining = PR_TRUE; + lTimeout = PR_IntervalToMilliseconds(remaining); + if (lTimeout > _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000) { + wait_for_remaining = PR_FALSE; + lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; + } + socks[0] = osfd; + if (fd_type == READ_FD) + rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); + else + rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); #endif - if (rv > 0) { - goto retry; - } - else if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + /* + * we don't consider EINTR a real error + */ + if (rv == -1 && (syserror = sock_errno()) != EINTR) { + _PR_MD_MAP_SELECT_ERROR(syserror); + break; + } + if (_PR_PENDING_INTERRUPT(me)) { + me->flags &= ~_PR_INTERRUPT; + PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0); rv = -1; - } else { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + break; } - } else { - _PR_MD_MAP_ACCEPT_ERROR(err); - } + /* + * 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 { +#ifdef BSD_SELECT + now += PR_SecondsToInterval(tv.tv_sec) + + PR_MicrosecondsToInterval(tv.tv_usec); +#else + now += PR_MillisecondsToInterval(lTimeout); +#endif + } + } 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); -} /* end _MD_Accept() */ +} +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, (int*)addrlen)) == -1) + { + err = sock_errno(); + if ((err == EWOULDBLOCK) || (err == ECONNABORTED)) + { + 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_ACCEPT_ERROR(err); + } +done: + return(rv); +} PRInt32 _PR_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; - PRInt32 rv; - int err, len; -#ifdef BSD_SELECT -#ifdef XP_OS2//_VACPP - fd_set wd; -#else - fd_set wd, ex; -#endif #vacpp - struct timeval tv, *tvp; -#else - int socks[1]; - long lTimeout = -1; -#endif - if ((rv = connect(osfd, (struct sockaddr *) addr, addrlen)) == -1) + /* + * 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: + if ((rv = connect(osfd, (struct sockaddr *)addr, addrlen)) == -1) { err = sock_errno(); - if ((!fd->secret->nonblocking) && ((err == EINPROGRESS) || (err == EWOULDBLOCK))) - { -#ifdef BSD_SELECT - if (timeout == PR_INTERVAL_NO_TIMEOUT) - tvp = NULL; - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; + + if (err == EINTR) { + if (_PR_PENDING_INTERRUPT(me)) { + me->flags &= ~_PR_INTERRUPT; + PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); + return -1; } + goto retry; + } - FD_ZERO(&wd); - FD_SET(osfd, &wd); -#ifdef XP_OS2//_VACPP - rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp); -#else - FD_ZERO(&ex); - FD_SET(osfd, &ex); - rv = _MD_SELECT(osfd + 1, NULL, &wd, &ex, tvp); -#endif #vacpp -#else #!bsd_select - if (timeout == PR_INTERVAL_NO_TIMEOUT) - lTimeout = -1; - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); + if (!fd->secret->nonblocking && (err == EINPROGRESS)) + { + /* + * socket_io_wait() may return -1 or 1. + */ + + rv = socket_io_wait(osfd, WRITE_FD, timeout); + if (rv == -1) { + return -1; } - - socks[0] = osfd; -#ifdef XP_OS2//_VACPP - rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); -#else - rv = _MD_SELECT(socks, 0, 1, 1, lTimeout); -#endif #vacpp -#endif - if (rv > 0) - { -#ifdef BSD_SELECT -#ifdef XP_OS2//_VACPP - if (FD_ISSET(osfd, &wd)) - { - //DosSleep(0); - len = sizeof(err); - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, - (char *) &err, &len) < 0) - { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return -1; - } - if (err != 0) - { - _PR_MD_MAP_CONNECT_ERROR(err); - return -1; - } - else - return 0; /* it's connected */ - } - else - return -1; -#else - if (FD_ISSET(osfd, &ex)) - { - DosSleep(0); - len = sizeof(err); - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, - (char *) &err, &len) < 0) - { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return -1; - } - if (err != 0) - _PR_MD_MAP_CONNECT_ERROR(err); - else - PR_SetError(PR_UNKNOWN_ERROR, 0); - return -1; - } - if (FD_ISSET(osfd, &wd)) - { - /* it's connected */ - return 0; - } -#endif #vacpp -#else #!bsd_select - if (socks[0] == osfd) - { - len = sizeof(err); - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, - (char *) &err, &len) < 0) - { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return -1; - } - - if (err != 0) - { - _PR_MD_MAP_CONNECT_ERROR(err); - return -1; - } - else - return 0; /* it's connected */ - } - else - return -1; -#endif + PR_ASSERT(rv == 1); + if (_PR_PENDING_INTERRUPT(me)) { + me->flags &= ~_PR_INTERRUPT; + PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); + return -1; } - else if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return(-1); - } else if (rv < 0) - { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - return(-1); + err = _MD_os2_get_nonblocking_connect_error(osfd); + if (err != 0) { + _PR_MD_MAP_CONNECT_ERROR(err); + return -1; } - } + return 0; + } + _PR_MD_MAP_CONNECT_ERROR(err); } - return rv; -} + return rv; +} /* _MD_connect */ PRInt32 _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen) { - PRInt32 rv; - - rv = bind(fd->secret->md.osfd, (struct sockaddr*) &(addr->inet), addrlen); + PRInt32 rv, err; + rv = bind(fd->secret->md.osfd, (struct sockaddr *) addr, (int )addrlen); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_BIND_ERROR(err); + } + return(rv); +} - if (rv == -1) { - _PR_MD_MAP_BIND_ERROR(sock_errno()); - return -1; - } - return 0; +PRInt32 +_PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog) +{ + PRInt32 rv, err; + rv = listen(fd->secret->md.osfd, backlog); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_DEFAULT_ERROR(err); + } + return(rv); } @@ -376,70 +386,27 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, { PRInt32 osfd = fd->secret->md.osfd; PRInt32 rv, err; -#ifdef BSD_SELECT - struct timeval tv, *tvp; - fd_set rd; -#else - int socks[1]; - long lTimeout = -1; -#endif - int osflags; + PRThread *me = _PR_MD_CURRENT_THREAD(); - if (0 == flags) { - osflags = 0; - } else { - PR_ASSERT(PR_MSG_PEEK == flags); - osflags = MSG_PEEK; - } - while ((rv = recv( osfd, buf, amount, osflags)) == -1) + while ((rv = recv(osfd,buf,amount,flags)) == -1) { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { -#ifdef BSD_SELECT - FD_ZERO(&rd); - FD_SET(osfd, &rd); - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1) -#else - socks[0] = osfd; - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1) -#endif - { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - return -1; - } - else if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - rv = -1; + err = sock_errno(); + if ((err == EWOULDBLOCK)) { + if (fd->secret->nonblocking) { break; } - } - else - { - _PR_MD_MAP_RECV_ERROR(err); + if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) + goto done; + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + continue; + } else { break; } - } /* end while() */ + } + if (rv < 0) { + _PR_MD_MAP_RECV_ERROR(err); + } +done: return(rv); } @@ -449,108 +416,42 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, { PRInt32 osfd = fd->secret->md.osfd; PRInt32 rv, err; -#ifdef BSD_SELECT - struct timeval tv, *tvp; - fd_set wd; -#else - int socks[1]; - long lTimeout = -1; -#endif - PRInt32 bytesSent = 0; + PRThread *me = _PR_MD_CURRENT_THREAD(); - while(bytesSent < amount ) + while ((rv = send(osfd,buf,amount,flags)) == -1) { - while ((rv = send( osfd, (char *) buf, amount, 0 )) == -1) - { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { -#ifdef BSD_SELECT - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&wd); - FD_SET(osfd, &wd); - if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL,tvp)) == -1) { -#else - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - socks[0] = osfd; - if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) { -#endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - break; - } - if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; - } - } - else { - _PR_MD_MAP_SEND_ERROR(err); - return -1; + err = sock_errno(); + if ((err == EWOULDBLOCK)) { + if (fd->secret->nonblocking) { + break; } - } - bytesSent += rv; - if (fd->secret->nonblocking) - { + if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) + goto done; + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + continue; + } else { break; } - if ((rv >= 0) && (bytesSent < amount )) - { -#ifdef BSD_SELECT - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&wd); - FD_SET(osfd, &wd); - if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL,tvp)) == -1) { -#else - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - socks[0] = osfd; - if ((rv = _MD_SELECT(socks, 0, 1, 0,lTimeout)) == -1) { -#endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - break; - } - if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; - } + } + + /* + * optimization; if bytes sent is less than "amount" call + * select before returning. This is because it is likely that + * the next send() 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; } } - return bytesSent; + if (rv < 0) { + _PR_MD_MAP_SEND_ERROR(err); + } +done: + return(rv); } PRInt32 @@ -559,109 +460,29 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, { PRInt32 osfd = fd->secret->md.osfd; PRInt32 rv, err; - PRInt32 bytesSent = 0; -#ifdef BSD_SELECT - struct timeval tv, *tvp; - fd_set wd; -#else - int socks[1]; - long lTimeout = -1; -#endif - - while(bytesSent < amount) + PRThread *me = _PR_MD_CURRENT_THREAD(); + while ((rv = sendto(osfd, buf, amount, flags, + (struct sockaddr *) addr, addrlen)) == -1) { - while ((rv = sendto( osfd, (char *) buf, amount, 0, (struct sockaddr *) addr, - addrlen)) == -1) - { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { -#ifdef BSD_SELECT - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&wd); - FD_SET(osfd, &wd); - if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp)) == -1) { -#else - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - socks[0] = osfd; - if ((rv = _MD_SELECT(socks, 0, 1, 0, lTimeout)) == -1) { -#endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - break; - } - if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; - } - } - else { - _PR_MD_MAP_SENDTO_ERROR(err); - return -1; - } - } - bytesSent += rv; - if (fd->secret->nonblocking) - { - break; - } - if ((rv >= 0) && (bytesSent < amount )) + err = sock_errno(); + if ((err == EWOULDBLOCK)) { -#ifdef BSD_SELECT - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&wd); - FD_SET(osfd, &wd); - if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL, tvp)) == -1) { -#else - if ( timeout == PR_INTERVAL_NO_TIMEOUT ) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - socks[0] = osfd; - if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) { -#endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + if (fd->secret->nonblocking) { break; } - if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; - } + if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) + goto done; + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ + continue; + } else { + break; } } - return bytesSent; + if (rv < 0) { + _PR_MD_MAP_SENDTO_ERROR(err); + } +done: + return(rv); } PRInt32 @@ -670,103 +491,86 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, { PRInt32 osfd = fd->secret->md.osfd; PRInt32 rv, err; - PRUint32 addrlen_temp = *addrlen; -#ifdef BSD_SELECT - struct timeval tv, *tvp; - fd_set rd; -#else - int socks[1]; - long lTimeout = -1; -#endif + PRThread *me = _PR_MD_CURRENT_THREAD(); - while ((rv = recvfrom( osfd, (char *) buf, amount, 0, (struct sockaddr *) addr, - (int *) addrlen)) == -1) + while( (*addrlen = PR_NETADDR_SIZE(addr)), + ((rv = recvfrom(osfd, buf, amount, flags, + (struct sockaddr *) addr, (int *)addrlen)) == -1)) { - if (((err = sock_errno()) == EWOULDBLOCK) - && (!fd->secret->nonblocking)) - { -#ifdef BSD_SELECT - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&rd); - FD_SET(osfd, &rd); - if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1) -#else - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - lTimeout = -1; - } - else - { - lTimeout = PR_IntervalToMilliseconds(timeout); - } - socks[0] = osfd; - if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1) -#endif - { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); - return -1; - } else if (rv == 0) - { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - rv = -1; + err = sock_errno(); + if ((err == EWOULDBLOCK)) { + if (fd->secret->nonblocking) { break; } - - /* recvfrom blows this value away if it fails first time */ - *addrlen = addrlen_temp; - } - else - { - _PR_MD_MAP_RECVFROM_ERROR(err); + 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: return(rv); } PRInt32 -_PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout) +_PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, + PRIntervalTime timeout) { - int index; - int sent = 0; - int rv; + PRInt32 rv, err; + PRThread *me = _PR_MD_CURRENT_THREAD(); + PRInt32 index, amount = 0; + PRInt32 osfd = fd->secret->md.osfd; - for (index=0; index < iov_size; index++) - { - rv = _PR_MD_SEND(fd, iov[index].iov_base, iov[index].iov_len, 0, timeout); - if (rv > 0) - sent += rv; - if ( rv != iov[index].iov_len ) - { - if (rv < 0) - { - if (fd->secret->nonblocking - && (PR_GetError() == PR_WOULD_BLOCK_ERROR) - && (sent > 0)) - { - return sent; - } - else - { - return -1; - } + /* + * 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; indexsecret->nonblocking) { + break; } - /* Only a nonblocking socket can have partial sends */ - PR_ASSERT(fd->secret->nonblocking); - return sent; + 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; } } - return sent; + if (rv < 0) { + _PR_MD_MAP_WRITEV_ERROR(err); + } +done: + return(rv); } PRInt32 @@ -781,63 +585,77 @@ _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how) } PRStatus -_PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len) +_PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen) { - PRInt32 rv; + PRInt32 rv, err; - rv = getsockname((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len); - if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETSOCKNAME_ERROR(sock_errno()); - return PR_FAILURE; + rv = getsockname(fd->secret->md.osfd, + (struct sockaddr *) addr, (int *)addrlen); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_GETSOCKNAME_ERROR(err); } + return rv==0?PR_SUCCESS:PR_FAILURE; } PRStatus -_PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len) +_PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen) { - PRInt32 rv; + PRInt32 rv, err; - rv = getpeername((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len); - if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETPEERNAME_ERROR(sock_errno()); - return PR_FAILURE; + rv = getpeername(fd->secret->md.osfd, + (struct sockaddr *) addr, (int *)addrlen); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_GETPEERNAME_ERROR(err); } + return rv==0?PR_SUCCESS:PR_FAILURE; } PRStatus -_PR_MD_GETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen) +_PR_MD_GETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, + char* optval, PRInt32* optlen) { - PRInt32 rv; + PRInt32 rv, err; - rv = getsockopt((int)fd->secret->md.osfd, level, optname, optval, optlen); - if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return PR_FAILURE; + rv = getsockopt(fd->secret->md.osfd, level, optname, optval, (int *)optlen); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_GETSOCKOPT_ERROR(err); } + return rv==0?PR_SUCCESS:PR_FAILURE; } PRStatus -_PR_MD_SETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen) +_PR_MD_SETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, + const char* optval, PRInt32 optlen) { - PRInt32 rv; + PRInt32 rv, err; - rv = setsockopt((int)fd->secret->md.osfd, level, optname, (char *) optval, optlen); - if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_SETSOCKOPT_ERROR(sock_errno()); - return PR_FAILURE; + rv = setsockopt(fd->secret->md.osfd, level, optname, optval, optlen); + if (rv < 0) { + err = sock_errno(); + _PR_MD_MAP_SETSOCKOPT_ERROR(err); } + return rv==0?PR_SUCCESS:PR_FAILURE; } void -_MD_MakeNonblock(PRFileDesc *f) +_MD_MakeNonblock(PRFileDesc *fd) { - return; /* do nothing! */ + PRInt32 osfd = fd->secret->md.osfd; + PRInt32 err; + PRUint32 one = 1; + + if (osfd <= 2) { + /* Don't mess around with stdin, stdout or stderr */ + return; + } + + err = ioctl( osfd, FIONBIO, (char *) &one, sizeof(one)); + if ( err != 0 ) + { + err = sock_errno(); + _PR_MD_MAP_SOCKET_ERROR(err); + } } diff --git a/pr/src/md/os2/os2thred.c b/pr/src/md/os2/os2thred.c index d64ae0b9..735856bd 100644 --- a/pr/src/md/os2/os2thred.c +++ b/pr/src/md/os2/os2thred.c @@ -93,14 +93,6 @@ PRStatus _PR_MD_INIT_THREAD(PRThread *thread) { APIRET rv; -#ifdef XP_OS2_EMX - /* disable SIGPIPE */ - struct sigaction sa; - sa.sa_handler = SIG_IGN; - sa.sa_flags = 0; - sigemptyset( &sa.sa_mask); - sigaction( SIGPIPE, &sa, NULL); -#endif if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { _pr_SetThreadMDHandle(thread); @@ -127,7 +119,15 @@ _PR_MD_CREATE_THREAD(PRThread *thread, if(thread->md.handle == -1) { return PR_FAILURE; } - _PR_MD_SET_PRIORITY(&(thread->md), priority); + + /* + * On OS/2, a thread is created with a thread priority of + * THREAD_PRIORITY_NORMAL + */ + + if (priority != PR_PRIORITY_NORMAL) { + _PR_MD_SET_PRIORITY(&(thread->md), priority); + } return PR_SUCCESS; } @@ -270,3 +270,19 @@ _PR_MD_RESUME_THREAD(PRThread *thread) } } + +PRThread* +_MD_CURRENT_THREAD(void) +{ + PRThread *thread; + + thread = _MD_GET_ATTACHED_THREAD(); + + if (NULL == thread) { + thread = _PRI_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0); + } + + PR_ASSERT(thread != NULL); + return thread; +} + diff --git a/pr/src/md/os2/os2vacpp.asm b/pr/src/md/os2/os2vacpp.asm index 2581323b..6b49e407 100644 --- a/pr/src/md/os2/os2vacpp.asm +++ b/pr/src/md/os2/os2vacpp.asm @@ -30,59 +30,230 @@ COMMENT | -*- Mode: asm; tab-width: 8; c-basic-offset: 4 -*- GPL. Windows uses inline assembly for their atomic functions, so we have - created an assembly file for VACPP on OS/2 + created an assembly file for VACPP on OS/2. + + This assembly file also contains an implementation of RAM semaphores. + + Notes: + The ulTIDPID element of the RAMSEM structure is overloaded in the 386 + implementation to hold the TID:PID in the lower 31 bits and the lock + bit in the high bit | + page ,132 .486P - .MODEL FLAT, OPTLINK - .STACK + ASSUME CS:FLAT, DS:FLAT, SS:FLAT, ES:FLAT, FS:FLAT + + EXTRN Dos32PostEventSem:PROC + EXTRN Dos32WaitEventSem:PROC + EXTRN Dos32ResetEventSem:PROC + +ramsem STRUC + ramsem_ulTIDPID DD ? + ramsem_hevSem DD ? + ramsem_cLocks DD ? + ramsem_cWaiting DW ? + ramsem_cPosts DW ? +ramsem ENDS + +ERROR_SEM_TIMEOUT equ 121 +ERROR_NOT_OWNER equ 288 +SEM_RELEASE_UNOWNED equ 1 +SEM_RELEASE_ALL equ 2 +TS_LOCKBIT equ 31 + + +DATA SEGMENT DWORD USE32 PUBLIC 'DATA' + + EXTRN plisCurrent:DWORD + +DATA ENDS + +CODE32 SEGMENT USE32 PUBLIC 'CODE' + + PUBLIC SemRequest486 + PUBLIC SemReleasex86 + + PUBLIC _PR_MD_ATOMIC_SET + PUBLIC _PR_MD_ATOMIC_ADD + PUBLIC _PR_MD_ATOMIC_INCREMENT + PUBLIC _PR_MD_ATOMIC_DECREMENT + +;;;--------------------------------------------------------------------------- +;;; APIRET _Optlink SemRequest(PRAMSEM pramsem, ULONG ulTimeout); +;;; +;;; Registers: +;;; EAX - packed TID:PID word +;;; ECX - address of RAMSEM structure +;;; EDX - length of timeout in milli-seconds +;;;--------------------------------------------------------------------------- + + ALIGN 10H +SemRequest486 PROC + push ebx ; Save ebx (volatile) + mov ecx, eax ; PRAMSEM must be in ecx, + ; not eax, for cmpxchg + + mov ebx, dword ptr [plisCurrent] + mov eax, dword ptr [ebx+4] ; Place thread id in high + ; word, process id in low + mov ax, word ptr [ebx] ; word + mov ebx,eax + +req486_test: + xor eax,eax + cmp (ramsem PTR [ecx]).ramsem_ulTIDPID, ebx ; If we own the sem, just + jz short req486_inc_exit ; increment the use count + + lock inc (ramsem PTR [ecx]).ramsem_cWaiting ; inc waiting flag + +; lock ; Uncomment for SMP + DB 0F0h +; cmpxchg (ramsem PTR [ecx]).ramsem_ulTIDPID, ebx +; (byte 3 is the offset of ulProcessThread into the RAMSEM structure) + DB 00Fh + DB 0B1h + DB 019h + jnz short req486_sleep + +req486_inc_exit: + lock inc (ramsem PTR [ecx]).ramsem_cLocks + +req486_exit: + pop ebx ; Restore ebx + ret + +req486_sleep: + push ecx ; Save ecx (volatile) + push edx ; Save edx (volatile) + push edx ; timeout + push (ramsem PTR [ecx]).ramsem_hevSem + call Dos32WaitEventSem + add esp, 8 + pop edx ; restore edx + pop ecx ; restore ecx + or eax, eax + jne req486_exit ; Exit, if error - .CODE + push ecx ; Save ecx (volatile) + push edx ; Save edx (volatile) + sub esp, 4 ; Use stack space for + push esp ; dummy pulPostCt + push (ramsem PTR [ecx]).ramsem_hevSem + call Dos32ResetEventSem + add esp, 12 + pop edx ; restore edx + pop ecx ; restore ecx + jmp req486_test ; Retry the semaphore + +SemRequest486 ENDP + +;;;--------------------------------------------------------------------- +;;; APIRET _Optlink SemReleasex86(PRAMSEM pramsem, ULONG flFlags); +;;; +;;; Registers: +;;; EAX - address of RAMSEM structure +;;; ECX - temporary variable +;;; EDX - flags +;;;--------------------------------------------------------------------- + + ALIGN 10H +SemReleasex86 PROC + test edx, SEM_RELEASE_UNOWNED ; If set, don't bother + jnz short rel_ownerok ; getting/checking PID/TID + + push ebx ; Save ebx (volatile) + mov ebx, dword ptr [plisCurrent] + mov ecx, dword ptr [ebx+4] ; Place thread id in high + ; word, process id in low + mov cx, word ptr [ebx] ; word + pop ebx ; Restore ebx + + sub ecx, (ramsem PTR [eax]).ramsem_ulTIDPID ; This thread the owner? + shl ecx,1 ; Don't compare top bit + jnz short rel_notowner + +rel_ownerok: + test edx, SEM_RELEASE_ALL + jnz short rel_clear + + lock dec (ramsem PTR [eax]).ramsem_cLocks + jnz short rel_exit + +rel_disown: + mov (ramsem PTR [eax]).ramsem_ulTIDPID, 0 + + lock inc (ramsem PTR [eax]).ramsem_cPosts + mov cx, (ramsem PTR [eax]).ramsem_cWaiting + cmp (ramsem PTR [eax]).ramsem_cPosts, cx + jne short rel_post + +rel_exit: + xor eax, eax + ret + +rel_clear: + lock mov (ramsem PTR [eax]).ramsem_cLocks,0 + jmp rel_disown + +rel_notowner: + mov eax, ERROR_NOT_OWNER + ret + +rel_post: + mov (ramsem PTR [eax]).ramsem_cPosts, cx + push (ramsem PTR [eax]).ramsem_hevSem + call Dos32PostEventSem + add esp,4 + xor eax,eax + ret +SemReleasex86 ENDP ;;;--------------------------------------------------------------------- ;;; PRInt32 _Optlink _PR_MD_ATOMIC_SET(PRInt32* val, PRInt32 newval) ;;;--------------------------------------------------------------------- -_PR_MD_ATOMIC_SET PROC OPTLINK EXPORT - lock xchg dword ptr [eax],edx + ALIGN 10H +_PR_MD_ATOMIC_SET proc + lock xchg dword ptr [eax],edx mov eax, edx; - ret _PR_MD_ATOMIC_SET endp ;;;--------------------------------------------------------------------- ;;; PRInt32 _Optlink _PR_MD_ATOMIC_ADD(PRInt32* ptr, PRInt32 val) ;;;--------------------------------------------------------------------- -_PR_MD_ATOMIC_ADD PROC OPTLINK EXPORT + ALIGN 10H +_PR_MD_ATOMIC_ADD proc mov ecx, edx lock xadd dword ptr [eax], edx mov eax, edx add eax, ecx - ret _PR_MD_ATOMIC_ADD endp ;;;--------------------------------------------------------------------- ;;; PRInt32 _Optlink _PR_MD_ATOMIC_INCREMENT(PRInt32* val) ;;;--------------------------------------------------------------------- -_PR_MD_ATOMIC_INCREMENT PROC OPTLINK EXPORT + ALIGN 10H +_PR_MD_ATOMIC_INCREMENT proc mov edx, 1 lock xadd dword ptr [eax], edx mov eax, edx inc eax - ret _PR_MD_ATOMIC_INCREMENT endp ;;;--------------------------------------------------------------------- ;;; PRInt32 _Optlink _PR_MD_ATOMIC_DECREMENT(PRInt32* val) ;;;--------------------------------------------------------------------- -_PR_MD_ATOMIC_DECREMENT PROC OPTLINK EXPORT + ALIGN 10H +_PR_MD_ATOMIC_DECREMENT proc mov edx, 0ffffffffh lock xadd dword ptr [eax], edx mov eax, edx dec eax - ret _PR_MD_ATOMIC_DECREMENT endp - END +CODE32 ENDS +END diff --git a/pr/src/md/unix/Makefile.in b/pr/src/md/unix/Makefile.in index aa78f21b..8c5dfe80 100644 --- a/pr/src/md/unix/Makefile.in +++ b/pr/src/md/unix/Makefile.in @@ -76,6 +76,8 @@ ifeq ($(OS_ARCH),SunOS) ULTRASPARC_ASOBJS = $(addprefix $(OBJDIR)/,$(ULTRASPARC_ASFILES:.s=.$(OBJ_SUFFIX))) TARGETS += $(ULTRASPARC_ASOBJS) $(SHARED_LIBRARY) RELEASE_LIBS = $(SHARED_LIBRARY) + RELEASE_LIBS_DEST = $(RELEASE_LIB_DIR)/cpu/sparcv8plus + lib_subdir = cpu/sparcv8plus endif endif endif @@ -98,8 +100,24 @@ $(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES) /usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v9 $< else $(SHARED_LIBRARY): $(ULTRASPARC_ASOBJS) - $(LD) -G -z text -o $@ $(ULTRASPARC_ASOBJS) - $(INSTALL) -m 444 $@ $(dist_libdir) + $(LD) -G -z text -z endfiltee -o $@ $(ULTRASPARC_ASOBJS) + $(INSTALL) -m 444 $@ $(dist_libdir)/cpu/sparcv8plus + $(INSTALL) -m 444 $@ $(dist_bindir)/cpu/sparcv8plus +# +# The -f $(ORIGIN)/... linker flag uses the real file, after symbolic links +# are resolved, as the origin. If NSDISTMODE is not "copy", libnspr4.so +# will be installed as a symbolic link in $(dist_libdir), pointing to the +# real libnspr4.so file in pr/src. Therefore we need to install an +# additional copy of libnspr_flt4.so in pr/src/cpu/sparcv8plus. +# +ifneq ($(NSDISTMODE),copy) + $(INSTALL) -m 444 $@ ../../cpu/sparcv8plus +endif + +ifneq ($(NSDISTMODE),copy) +clobber realclean clobber_all distclean:: + rm -rf ../../cpu +endif $(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES) /usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v8plus $< diff --git a/pr/src/md/unix/darwin.c b/pr/src/md/unix/darwin.c index 43988b8d..82208c61 100644 --- a/pr/src/md/unix/darwin.c +++ b/pr/src/md/unix/darwin.c @@ -82,11 +82,11 @@ _MD_WAKEUP_WAITER(PRThread *thread) return PR_SUCCESS; } -/* These functions should not be called for Rhapsody */ +/* These functions should not be called for Darwin */ void _MD_YIELD(void) { - PR_NOT_REACHED("_MD_YIELD should not be called for Rhapsody."); + PR_NOT_REACHED("_MD_YIELD should not be called for Darwin."); } PRStatus @@ -98,37 +98,10 @@ _MD_CREATE_THREAD( PRThreadState state, PRUint32 stackSize) { - PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Rhapsody."); + PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin."); return PR_FAILURE; } #endif /* ! _PR_PTHREADS */ -#if defined(_PR_PTHREADS) - -/* -** Stubs for unimplemented functions -*/ - -int pthread_condattr_init(pthread_condattr_t *attr) -{ - return 0; -} - -int pthread_kill(pthread_t thread, int sig) -{ - return ENOSYS; -} - -typedef struct siginfo_t siginfo_t; - -int sigtimedwait(const sigset_t *set, siginfo_t *info, - const struct timespec *timeout) -{ - errno = ENOSYS; - return -1; -} - -#endif /* _PR_PTHREADS */ - /* darwin.c */ diff --git a/pr/src/md/unix/irix.c b/pr/src/md/unix/irix.c index 7ba079f8..f3d52f01 100644 --- a/pr/src/md/unix/irix.c +++ b/pr/src/md/unix/irix.c @@ -1451,7 +1451,7 @@ void _MD_EarlyInit(void) _MD_IrixIntervalInit(); } /* _MD_EarlyInit */ -void _MD_IrixInit() +void _MD_IrixInit(void) { #if !defined(_PR_PTHREADS) struct sigaction sigact; @@ -1567,7 +1567,7 @@ static PRUint32 pr_ticks_per_second = 0; extern PRIntervalTime _PR_UNIX_GetInterval(void); extern PRIntervalTime _PR_UNIX_TicksPerSecond(void); -static void _MD_IrixIntervalInit() +static void _MD_IrixIntervalInit(void) { /* * As much as I would like, the service available through this @@ -1634,12 +1634,12 @@ static void _MD_IrixIntervalInit() } } /* _MD_IrixIntervalInit */ -PRIntervalTime _MD_IrixIntervalPerSec() +PRIntervalTime _MD_IrixIntervalPerSec(void) { return pr_ticks_per_second; } -PRIntervalTime _MD_IrixGetInterval() +PRIntervalTime _MD_IrixGetInterval(void) { if (mmem_fd != -1) { diff --git a/pr/src/md/unix/openvms.c b/pr/src/md/unix/openvms.c index 72c20432..73d52314 100644 --- a/pr/src/md/unix/openvms.c +++ b/pr/src/md/unix/openvms.c @@ -204,4 +204,80 @@ int thread_resume(PRThread *thr_id) { return 0; } +/* +** Stubs for nspr_symvec.opt +** +** PR_ResumeSet, PR_ResumeTest, and PR_SuspendAllSuspended +** (defined in ptthread.c) used to be exported by mistake +** (because they look like public functions). They have been +** converted into static functions. +** +** There is an existing third-party binary that uses NSPR: the +** Java plugin for Mozilla. Because it is part of the Java +** SDK, we have no control over its releases. So we need these +** stub functions to occupy the slots that used to be occupied +** by PR_ResumeSet, PR_ResumeTest, and PR_SuspendAllSuspended +** in the symbol vector so that LIBNSPR4 is backward compatible. +** +** The Java plugin was also using PR_CreateThread which we didn't +** realise and hadn't "nailed down". So we now need to nail it down +** to its Mozilla 1.1 position and have to insert 51 additional stubs +** in order to achive this (stubs 4-54). +** +** Over time some of these stubs will get reused by new symbols. +** - Stub54 is replaced by LL_MaxUint +*/ +void PR_VMS_Stub1(void) { } +void PR_VMS_Stub2(void) { } +void PR_VMS_Stub3(void) { } +void PR_VMS_Stub4(void) { } +void PR_VMS_Stub5(void) { } +void PR_VMS_Stub6(void) { } +void PR_VMS_Stub7(void) { } +void PR_VMS_Stub8(void) { } +void PR_VMS_Stub9(void) { } +void PR_VMS_Stub10(void) { } +void PR_VMS_Stub11(void) { } +void PR_VMS_Stub12(void) { } +void PR_VMS_Stub13(void) { } +void PR_VMS_Stub14(void) { } +void PR_VMS_Stub15(void) { } +void PR_VMS_Stub16(void) { } +void PR_VMS_Stub17(void) { } +void PR_VMS_Stub18(void) { } +void PR_VMS_Stub19(void) { } +void PR_VMS_Stub20(void) { } +void PR_VMS_Stub21(void) { } +void PR_VMS_Stub22(void) { } +void PR_VMS_Stub23(void) { } +void PR_VMS_Stub24(void) { } +void PR_VMS_Stub25(void) { } +void PR_VMS_Stub26(void) { } +void PR_VMS_Stub27(void) { } +void PR_VMS_Stub28(void) { } +void PR_VMS_Stub29(void) { } +void PR_VMS_Stub30(void) { } +void PR_VMS_Stub31(void) { } +void PR_VMS_Stub32(void) { } +void PR_VMS_Stub33(void) { } +void PR_VMS_Stub34(void) { } +void PR_VMS_Stub35(void) { } +void PR_VMS_Stub36(void) { } +void PR_VMS_Stub37(void) { } +void PR_VMS_Stub38(void) { } +void PR_VMS_Stub39(void) { } +void PR_VMS_Stub40(void) { } +void PR_VMS_Stub41(void) { } +void PR_VMS_Stub42(void) { } +void PR_VMS_Stub43(void) { } +void PR_VMS_Stub44(void) { } +void PR_VMS_Stub45(void) { } +void PR_VMS_Stub46(void) { } +void PR_VMS_Stub47(void) { } +void PR_VMS_Stub48(void) { } +void PR_VMS_Stub49(void) { } +void PR_VMS_Stub50(void) { } +void PR_VMS_Stub51(void) { } +void PR_VMS_Stub52(void) { } +void PR_VMS_Stub53(void) { } diff --git a/pr/src/md/unix/os_Darwin_ppc.s b/pr/src/md/unix/os_Darwin_ppc.s new file mode 100644 index 00000000..f38ac644 --- /dev/null +++ b/pr/src/md/unix/os_Darwin_ppc.s @@ -0,0 +1,92 @@ +# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 2003 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +# +# Based on the programming examples in The PowerPC Architecture: +# A Specification for A New Family of RISC Processors, 2nd Ed., +# Book I, Section E.1, "Synchronization," pp. 249-256, May 1994. +# + +.text + +# +# PRInt32 __PR_DarwinPPC_AtomicIncrement(PRInt32 *val); +# + .align 2 + .globl __PR_DarwinPPC_AtomicIncrement +__PR_DarwinPPC_AtomicIncrement: + lwarx r4,0,r3 + addi r0,r4,1 + stwcx. r0,0,r3 + bne- __PR_DarwinPPC_AtomicIncrement + mr r3,r0 + blr + +# +# PRInt32 __PR_DarwinPPC_AtomicDecrement(PRInt32 *val); +# + .align 2 + .globl __PR_DarwinPPC_AtomicDecrement +__PR_DarwinPPC_AtomicDecrement: + lwarx r4,0,r3 + addi r0,r4,-1 + stwcx. r0,0,r3 + bne- __PR_DarwinPPC_AtomicDecrement + mr r3,r0 + blr + +# +# PRInt32 __PR_DarwinPPC_AtomicSet(PRInt32 *val, PRInt32 newval); +# + .align 2 + .globl __PR_DarwinPPC_AtomicSet +__PR_DarwinPPC_AtomicSet: + lwarx r5,0,r3 + stwcx. r4,0,r3 + bne- __PR_DarwinPPC_AtomicSet + mr r3,r5 + blr + +# +# PRInt32 __PR_DarwinPPC_AtomicAdd(PRInt32 *ptr, PRInt32 val); +# + .align 2 + .globl __PR_DarwinPPC_AtomicAdd +__PR_DarwinPPC_AtomicAdd: + lwarx r5,0,r3 + add r0,r4,r5 + stwcx. r0,0,r3 + bne- __PR_DarwinPPC_AtomicAdd + mr r3,r0 + blr diff --git a/pr/src/md/unix/unix.c b/pr/src/md/unix/unix.c index 69153f27..c69a233a 100644 --- a/pr/src/md/unix/unix.c +++ b/pr/src/md/unix/unix.c @@ -64,7 +64,8 @@ * Make sure _PRSockLen_t is 32-bit, because we will cast a PRUint32* or * PRInt32* pointer to a _PRSockLen_t* pointer. */ -#if defined(HAVE_SOCKLEN_T) +#if defined(HAVE_SOCKLEN_T) \ + || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2) #define _PRSockLen_t socklen_t #elif defined(IRIX) || defined(HPUX) || defined(OSF1) || defined(SOLARIS) \ || defined(AIX4_1) || defined(LINUX) || defined(SONY) \ @@ -514,6 +515,7 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, struct timeval tv; PRThread *me = _PR_MD_CURRENT_THREAD(); PRIntervalTime epoch, now, elapsed, remaining; + PRBool wait_for_remaining; PRInt32 syserror; fd_set rd_wr; @@ -558,8 +560,10 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, * 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 { @@ -596,8 +600,12 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, * PR_IntervalNow() call. */ if (rv == 0) { - now += PR_SecondsToInterval(tv.tv_sec) - + PR_MicrosecondsToInterval(tv.tv_usec); + if (wait_for_remaining) { + now += remaining; + } else { + now += PR_SecondsToInterval(tv.tv_sec) + + PR_MicrosecondsToInterval(tv.tv_usec); + } } else { now = PR_IntervalNow(); } @@ -625,6 +633,7 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, int msecs; PRThread *me = _PR_MD_CURRENT_THREAD(); PRIntervalTime epoch, now, elapsed, remaining; + PRBool wait_for_remaining; PRInt32 syserror; struct pollfd pfd; @@ -682,8 +691,10 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, * so that there is an upper limit on the delay * before the interrupt bit is checked. */ + wait_for_remaining = PR_TRUE; msecs = PR_IntervalToMilliseconds(remaining); if (msecs > _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000) { + wait_for_remaining = PR_FALSE; msecs = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; } rv = _MD_POLL(&pfd, 1, msecs); @@ -719,7 +730,11 @@ static PRInt32 socket_io_wait(PRInt32 osfd, PRInt32 fd_type, * PR_IntervalNow() call. */ if (rv == 0) { - now += PR_MillisecondsToInterval(msecs); + if (wait_for_remaining) { + now += remaining; + } else { + now += PR_MillisecondsToInterval(msecs); + } } else { now = PR_IntervalNow(); } @@ -2713,6 +2728,28 @@ static void* _MD_Unix_mmap64( } /* _MD_Unix_mmap64 */ #endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */ +#if defined(OSF1) && defined(__GNUC__) + +/* + * On OSF1 V5.0A, defines stat and fstat as + * macros when compiled under gcc, so it is rather tricky to + * take the addresses of the real functions the macros expend + * to. A simple solution is to define forwarder functions + * and take the addresses of the forwarder functions instead. + */ + +static int stat_forwarder(const char *path, struct stat *buffer) +{ + return stat(path, buffer); +} + +static int fstat_forwarder(int filedes, struct stat *buffer) +{ + return fstat(filedes, buffer); +} + +#endif + static void _PR_InitIOV(void) { #if defined(SOLARIS2_5) @@ -2757,8 +2794,13 @@ static void _PR_InitIOV(void) #elif defined(_PR_HAVE_LARGE_OFF_T) _md_iovector._open64 = open; _md_iovector._mmap64 = mmap; +#if defined(OSF1) && defined(__GNUC__) + _md_iovector._fstat64 = fstat_forwarder; + _md_iovector._stat64 = stat_forwarder; +#else _md_iovector._fstat64 = fstat; _md_iovector._stat64 = stat; +#endif _md_iovector._lseek64 = lseek; #else #error "I don't know yet" @@ -3221,9 +3263,6 @@ int _MD_unix_get_nonblocking_connect_error(int osfd) int err; _PRSockLen_t optlen = sizeof(err); - printf("_MD_unix_get_nonblocking_connect_error: " - "Assuming Large TCP/IP Stack -REVISIT- Never Tested!\n"); - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &optlen) == -1) { return errno; diff --git a/pr/src/md/unix/unix_errors.c b/pr/src/md/unix/unix_errors.c index 1ce52e68..055961ee 100644 --- a/pr/src/md/unix/unix_errors.c +++ b/pr/src/md/unix/unix_errors.c @@ -108,6 +108,9 @@ void _MD_unix_map_default_error(int err) case EFBIG: prError = PR_FILE_TOO_BIG_ERROR; break; + case EHOSTUNREACH: + prError = PR_HOST_UNREACHABLE_ERROR; + break; case EINPROGRESS: prError = PR_IN_PROGRESS_ERROR; break; @@ -847,3 +850,10 @@ void _MD_solaris_map_sendfile_error(int err) _MD_unix_map_default_error(err) ; } #endif /* SOLARIS */ + +#ifdef LINUX +void _MD_linux_map_sendfile_error(int err) +{ + _MD_unix_map_default_error(err) ; +} +#endif /* LINUX */ diff --git a/pr/src/md/unix/uxpoll.c b/pr/src/md/unix/uxpoll.c index 56a0d3dc..a95e4558 100644 --- a/pr/src/md/unix/uxpoll.c +++ b/pr/src/md/unix/uxpoll.c @@ -173,6 +173,8 @@ static PRInt32 NativeThreadPoll( { /* make poll() ignore this entry */ syspoll[index].fd = -1; + syspoll[index].events = 0; + pds[index].out_flags = 0; } } @@ -384,6 +386,10 @@ static PRInt32 NativeThreadSelect( } } } + else + { + pd->out_flags = 0; + } } if (0 != ready) return ready; /* no need to block */ diff --git a/pr/src/md/unix/uxproces.c b/pr/src/md/unix/uxproces.c index 58b5ab8a..d469f1c4 100644 --- a/pr/src/md/unix/uxproces.c +++ b/pr/src/md/unix/uxproces.c @@ -802,7 +802,7 @@ static void pr_InstallSigchldHandler() #endif /* !defined(_PR_NATIVE_THREADS) */ -static PRStatus _MD_InitProcesses() +static PRStatus _MD_InitProcesses(void) { #if !defined(_PR_NATIVE_THREADS) int rv; diff --git a/pr/src/md/unix/uxrng.c b/pr/src/md/unix/uxrng.c index 64358289..6add3bf1 100644 --- a/pr/src/md/unix/uxrng.c +++ b/pr/src/md/unix/uxrng.c @@ -64,6 +64,18 @@ GetHighResClock(void *buf, size_t maxbytes) #elif defined(HPUX) +#ifdef __ia64 +#include + +static size_t +GetHighResClock(void *buf, size_t maxbytes) +{ + PRUint64 t; + + t = _Asm_mov_from_ar(_AREG44); + return _pr_CopyLowBits(buf, maxbytes, &t, sizeof(t)); +} +#else static size_t GetHighResClock(void *buf, size_t maxbytes) { @@ -73,6 +85,7 @@ GetHighResClock(void *buf, size_t maxbytes) cr16val = ret_cr16(); return(_pr_CopyLowBits(buf, maxbytes, &cr16val, sizeof(cr16val))); } +#endif #elif defined(OSF1) @@ -88,7 +101,11 @@ GetHighResClock(void *buf, size_t maxbytes) { unsigned long t; +#ifdef __GNUC__ + __asm__("rpcc %0" : "=r" (t)); +#else t = asm("rpcc %v0"); +#endif return _pr_CopyLowBits(buf, maxbytes, &t, sizeof(t)); } @@ -210,7 +227,7 @@ static size_t GetHighResClock(void *buf, size_t maxbuf) } iotimer_addr = (unsigned *) mmap(0, pgoffmask, PROT_READ, MAP_PRIVATE, mfd, (int)raddr); - if (iotimer_addr == (void*)-1) { + if (iotimer_addr == (unsigned*)-1) { close(mfd); iotimer_addr = NULL; return 0; diff --git a/pr/src/md/unix/uxshm.c b/pr/src/md/unix/uxshm.c index 888cbe04..1dc98386 100644 --- a/pr/src/md/unix/uxshm.c +++ b/pr/src/md/unix/uxshm.c @@ -94,7 +94,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory( return( NULL ); } - shm->ipcname = PR_MALLOC( strlen( ipcname ) + 1 ); + shm->ipcname = (char*)PR_MALLOC( strlen( ipcname ) + 1 ); if ( NULL == shm->ipcname ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); @@ -118,7 +118,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory( PR_DELETE( shm ); return( NULL ); } - if ( close(osfd == -1 )) { + if ( close(osfd) == -1 ) { _PR_MD_MAP_CLOSE_ERROR( errno ); PR_FREEIF( shm->ipcname ); PR_DELETE( shm ); @@ -243,7 +243,7 @@ extern PRStatus _MD_DeleteSharedMemory( const char *name ) _PR_MD_MAP_OPEN_ERROR( errno ); return( PR_FAILURE ); } - if ( close(osfd == -1 )) { + if ( close(osfd) == -1 ) { _PR_MD_MAP_CLOSE_ERROR( errno ); return( PR_FAILURE ); } @@ -311,7 +311,6 @@ extern PRSharedMemory * _MD_OpenSharedMemory( ) { PRStatus rc = PR_SUCCESS; - PRIntn id; PRInt32 end; PRSharedMemory *shm; char ipcname[PR_IPC_NAME_SIZE]; diff --git a/pr/src/md/windows/Makefile.in b/pr/src/md/windows/Makefile.in index 283fa4a4..dd5a613b 100644 --- a/pr/src/md/windows/Makefile.in +++ b/pr/src/md/windows/Makefile.in @@ -105,3 +105,13 @@ include $(topsrcdir)/config/rules.mk export:: $(TARGETS) +# Bug 122433 workaround: disable global optimization (-Og-) on ntio.c. +ifdef BUILD_OPT +ifeq ($(OS_TARGET), WINNT) +ifndef NS_USE_GCC +$(OBJDIR)/ntio.$(OBJ_SUFFIX): ntio.c + @$(MAKE_OBJDIR) + $(CC) -Fo$@ -c $(CFLAGS) -Og- $< +endif +endif +endif diff --git a/pr/src/md/windows/ntinrval.c b/pr/src/md/windows/ntinrval.c index d6a3fe6f..857ada6a 100644 --- a/pr/src/md/windows/ntinrval.c +++ b/pr/src/md/windows/ntinrval.c @@ -45,9 +45,8 @@ #define QueryPerformanceCounter(x) FALSE #endif -PRIntn _nt_bitShift = 0; -PRInt32 _nt_highMask = 0; -PRInt32 _nt_ticksPerSec = -1; +static PRIntn _nt_bitShift = 0; +static PRInt32 _nt_ticksPerSec = -1; void _PR_MD_INTERVAL_INIT() @@ -55,16 +54,33 @@ _PR_MD_INTERVAL_INIT() LARGE_INTEGER count; if (QueryPerformanceFrequency(&count)) { + /* + * HighPart is signed (LONG). Assert that its sign bit is 0 + * because we will be right shifting it. LowPart is unsigned + * (DWORD). + */ + PR_ASSERT(count.HighPart >= 0); + while(count.HighPart) { + count.LowPart = (count.HighPart << 31) + (count.LowPart >> 1); + count.HighPart >>= 1; + _nt_bitShift++; + } while(count.LowPart > PR_INTERVAL_MAX) { count.LowPart >>= 1; _nt_bitShift++; - _nt_highMask = (_nt_highMask << 1)+1; } - _nt_ticksPerSec = count.LowPart; - PR_ASSERT(_nt_ticksPerSec > PR_INTERVAL_MIN); - } else - _nt_ticksPerSec = -1; + /* + * We can't use the performance counter if after + * normalization we are left with fewer than 32 bits. + */ + if (_nt_bitShift <= 32) { + _nt_ticksPerSec = count.LowPart; + PR_ASSERT(_nt_ticksPerSec > PR_INTERVAL_MIN); + return; + } + } + _nt_ticksPerSec = -1; } PRIntervalTime @@ -76,12 +92,15 @@ _PR_MD_GET_INTERVAL() * to only 100000 ticks per second; QueryPerformanceCounter is too high * resolution... */ - if (QueryPerformanceCounter(&count)) { - PRInt32 top = count.HighPart & _nt_highMask; - top = top << (32 - _nt_bitShift); - count.LowPart = count.LowPart >> _nt_bitShift; - count.LowPart = count.LowPart + top; - return (PRUint32)count.LowPart; + if (_nt_ticksPerSec != -1) { + (void)QueryPerformanceCounter(&count); + PR_ASSERT(_nt_bitShift <= 32); + if (_nt_bitShift == 32) { + return (PRUint32)count.HighPart; + } else { + return (PRUint32)((count.HighPart << (32 - _nt_bitShift)) + + (count.LowPart >> _nt_bitShift)); + } } else #if defined(__MINGW32__) return time(); diff --git a/pr/src/md/windows/ntio.c b/pr/src/md/windows/ntio.c index 299033cc..e206f787 100644 --- a/pr/src/md/windows/ntio.c +++ b/pr/src/md/windows/ntio.c @@ -99,7 +99,11 @@ static DWORD dirAccessTable[] = { * We store the value in a PRTime variable for convenience. * This constant is used by _PR_FileTimeToPRTime(). */ +#ifdef __GNUC__ +static const PRTime _pr_filetime_offset = 116444736000000000LL; +#else static const PRTime _pr_filetime_offset = 116444736000000000i64; +#endif #define _NEED_351_FILE_LOCKING_HACK #ifdef _NEED_351_FILE_LOCKING_HACK @@ -2322,7 +2326,7 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) } PRInt32 -_PR_MD_WRITE(PRFileDesc *fd, void *buf, PRInt32 len) +_PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { PRInt32 f = fd->secret->md.osfd; PRInt32 bytes; @@ -2488,7 +2492,7 @@ _PR_MD_PIPEAVAILABLE(PRFileDesc *fd) } PROffset32 -_PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, int whence) +_PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence) { DWORD moveMethod; PROffset32 rv; @@ -2521,7 +2525,7 @@ _PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, int whence) } PROffset64 -_PR_MD_LSEEK64(PRFileDesc *fd, PROffset64 offset, int whence) +_PR_MD_LSEEK64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence) { DWORD moveMethod; LARGE_INTEGER li; @@ -2815,12 +2819,16 @@ _PR_MD_DELETE(const char *name) } } -static void +void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm) { PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime)); CopyMemory(prtm, filetime, sizeof(PRTime)); +#ifdef __GNUC__ + *prtm = (*prtm - _pr_filetime_offset) / 10LL; +#else *prtm = (*prtm - _pr_filetime_offset) / 10i64; +#endif #ifdef DEBUG /* Doublecheck our calculation. */ @@ -3168,7 +3176,7 @@ _PR_MD_RENAME(const char *from, const char *to) } PRInt32 -_PR_MD_ACCESS(const char *name, PRIntn how) +_PR_MD_ACCESS(const char *name, PRAccessHow how) { PRInt32 rv; diff --git a/pr/src/md/windows/ntmisc.c b/pr/src/md/windows/ntmisc.c index c4bb8511..32a199ce 100644 --- a/pr/src/md/windows/ntmisc.c +++ b/pr/src/md/windows/ntmisc.c @@ -84,18 +84,12 @@ PRIntn _PR_MD_PUT_ENV(const char *name) PR_IMPLEMENT(PRTime) PR_Now(void) { - PRInt64 s, ms, ms2us, s2us; - struct timeb b; - - ftime(&b); - LL_I2L(ms2us, PR_USEC_PER_MSEC); - LL_I2L(s2us, PR_USEC_PER_SEC); - LL_I2L(s, b.time); - LL_I2L(ms, b.millitm); - LL_MUL(ms, ms, ms2us); - LL_MUL(s, s, s2us); - LL_ADD(s, s, ms); - return s; + PRTime prt; + FILETIME ft; + + GetSystemTimeAsFileTime(&ft); + _PR_FileTimeToPRTime(&ft, &prt); + return prt; } /* @@ -792,7 +786,7 @@ PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *val) PRInt32 result; asm volatile ("lock ; xadd %0, %1" : "=r"(result), "=m"(*val) - : "0"(1), "m"(*val)); + : "0"(-1), "m"(*val)); //asm volatile("lock ; xadd %0, %1" : "=m" (val), "=a" (result) : "-1" (1)); return result - 1; #else @@ -814,8 +808,8 @@ PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *intp, PRInt32 val) PRInt32 result; //asm volatile("lock ; xadd %1, %0" : "=m" (intp), "=a" (result) : "1" (val)); asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(intp) - : "0"(val), "m"(intp)); + : "=r"(result), "=m"(*intp) + : "0"(val), "m"(*intp)); return result + val; #else __asm diff --git a/pr/src/md/windows/ntthread.c b/pr/src/md/windows/ntthread.c index 9c3e2baf..a414e5c7 100644 --- a/pr/src/md/windows/ntthread.c +++ b/pr/src/md/windows/ntthread.c @@ -238,6 +238,13 @@ _PR_MD_CREATE_THREAD(PRThread *thread, } thread->md.id = thread->id; + /* + * On windows, a thread is created with a thread priority of + * THREAD_PRIORITY_NORMAL. + */ + if (priority != PR_PRIORITY_NORMAL) { + _PR_MD_SET_PRIORITY(&(thread->md), priority); + } /* Activate the thread */ if ( ResumeThread( thread->md.handle ) != -1) @@ -247,6 +254,21 @@ _PR_MD_CREATE_THREAD(PRThread *thread, return PR_FAILURE; } +void +_PR_MD_JOIN_THREAD(_MDThread *md) +{ + DWORD rv; + + rv = WaitForSingleObject(md->handle, INFINITE); + PR_ASSERT(WAIT_OBJECT_0 == rv); +} + +void +_PR_MD_END_THREAD(void) +{ + _endthreadex(0); +} + void _PR_MD_YIELD(void) { diff --git a/pr/src/md/windows/w32poll.c b/pr/src/md/windows/w32poll.c index 2747a040..93a9a2d3 100644 --- a/pr/src/md/windows/w32poll.c +++ b/pr/src/md/windows/w32poll.c @@ -36,6 +36,9 @@ * This file implements _PR_MD_PR_POLL for Win32. */ +/* The default value of FD_SETSIZE is 64. */ +#define FD_SETSIZE 1024 + #include "primpl.h" #if !defined(_PR_GLOBAL_THREADS_ONLY) @@ -105,6 +108,8 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) { int ready, err; fd_set rd, wt, ex; + fd_set *rdp, *wtp, *exp; + int nrd, nwt, nex; PRFileDesc *bottom; PRPollDesc *pd, *epd; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -127,6 +132,7 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) return 0; } + nrd = nwt = nex = 0; FD_ZERO(&rd); FD_ZERO(&wt); FD_ZERO(&ex); @@ -189,23 +195,30 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) { pd->out_flags |= _PR_POLL_READ_SYS_READ; FD_SET(osfd, &rd); + nrd++; } if (in_flags_read & PR_POLL_WRITE) { pd->out_flags |= _PR_POLL_READ_SYS_WRITE; FD_SET(osfd, &wt); + nwt++; } if (in_flags_write & PR_POLL_READ) { pd->out_flags |= _PR_POLL_WRITE_SYS_READ; FD_SET(osfd, &rd); + nrd++; } if (in_flags_write & PR_POLL_WRITE) { pd->out_flags |= _PR_POLL_WRITE_SYS_WRITE; FD_SET(osfd, &wt); + nwt++; + } + if (pd->in_flags & PR_POLL_EXCEPT) { + FD_SET(osfd, &ex); + nex++; } - if (pd->in_flags & PR_POLL_EXCEPT) FD_SET(osfd, &ex); } } else @@ -223,10 +236,28 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) } } } + else + { + pd->out_flags = 0; + } } if (0 != ready) return ready; /* no need to block */ + if ((nrd > FD_SETSIZE) || (nwt > FD_SETSIZE) || (nex > FD_SETSIZE)) { + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; + } + + rdp = (0 == nrd) ? NULL : &rd; + wtp = (0 == nwt) ? NULL : &wt; + exp = (0 == nex) ? NULL : &ex; + + if ((NULL == rdp) && (NULL == wtp) && (NULL == exp)) { + PR_Sleep(timeout); + return 0; + } + if (timeout != PR_INTERVAL_NO_TIMEOUT) { PRInt32 ticksPerSecond = PR_TicksPerSecond(); @@ -237,9 +268,9 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout) } #if defined(_PR_GLOBAL_THREADS_ONLY) - ready = _MD_SELECT(0, &rd, &wt, &ex, tvp); + ready = _MD_SELECT(0, rdp, wtp, exp, tvp); #else - ready = _PR_NTFiberSafeSelect(0, &rd, &wt, &ex, tvp); + ready = _PR_NTFiberSafeSelect(0, rdp, wtp, exp, tvp); #endif /* diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c index 89669e6e..6ccdf410 100644 --- a/pr/src/md/windows/w95io.c +++ b/pr/src/md/windows/w95io.c @@ -41,6 +41,9 @@ #include "primpl.h" #include #include +#ifdef MOZ_UNICODE +#include +#endif /* MOZ_UNICODE */ struct _MDLock _pr_ioq_lock; @@ -74,6 +77,10 @@ static const PRTime _pr_filetime_offset = 116444736000000000LL; static const PRTime _pr_filetime_offset = 116444736000000000i64; #endif +#ifdef MOZ_UNICODE +static void InitUnicodeSupport(void); +#endif + void _PR_MD_INIT_IO() { @@ -110,6 +117,10 @@ _PR_MD_INIT_IO() #endif /* DEBUG */ _PR_NT_InitSids(); + +#ifdef MOZ_UNICODE + InitUnicodeSupport(); +#endif } PRStatus @@ -568,7 +579,7 @@ _PR_MD_DELETE(const char *name) } } -static void +void _PR_FileTimeToPRTime(const FILETIME *filetime, PRTime *prtm) { PR_ASSERT(sizeof(FILETIME) == sizeof(PRTime)); @@ -1088,3 +1099,410 @@ _PR_MD_PIPEAVAILABLE(PRFileDesc *fd) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return -1; } + +#ifdef MOZ_UNICODE + +typedef HANDLE (WINAPI *CreateFileWFn) (LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); +static CreateFileWFn createFileW = NULL; +typedef HANDLE (WINAPI *FindFirstFileWFn) (LPCWSTR, LPWIN32_FIND_DATAW); +static FindFirstFileWFn findFirstFileW = NULL; +typedef BOOL (WINAPI *FindNextFileWFn) (HANDLE, LPWIN32_FIND_DATAW); +static FindNextFileWFn findNextFileW = NULL; +typedef DWORD (WINAPI *GetFullPathNameWFn) (LPCWSTR, DWORD, LPWSTR, LPWSTR *); +static GetFullPathNameWFn getFullPathNameW = NULL; +typedef UINT (WINAPI *GetDriveTypeWFn) (LPCWSTR); +static GetDriveTypeWFn getDriveTypeW = NULL; + +static void InitUnicodeSupport(void) +{ + HMODULE module; + + /* + * The W functions do not exist on Win9x. NSPR won't run on Win9x + * if we call the W functions directly. Use GetProcAddress() to + * look up their addresses at run time. + */ + + module = GetModuleHandle("Kernel32.dll"); + if (!module) { + return; + } + + createFileW = (CreateFileWFn)GetProcAddress(module, "CreateFileW"); + findFirstFileW = (FindFirstFileWFn)GetProcAddress(module, "FindFirstFileW"); + findNextFileW = (FindNextFileWFn)GetProcAddress(module, "FindNextFileW"); + getDriveTypeW = (GetDriveTypeWFn)GetProcAddress(module, "GetDriveTypeW"); + getFullPathNameW = (GetFullPathNameWFn)GetProcAddress(module, "GetFullPathNameW"); +} + +/* ================ UTF16 Interfaces ================================ */ +void FlipSlashesW(PRUnichar *cp, int len) +{ + while (--len >= 0) { + if (cp[0] == L'/') { + cp[0] = L'\\'; + } + cp++; + } +} /* end FlipSlashesW() */ + +PRInt32 +_PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, int mode) +{ + HANDLE file; + PRInt32 access = 0; + PRInt32 flags = 0; + PRInt32 flag6 = 0; + SECURITY_ATTRIBUTES sa; + LPSECURITY_ATTRIBUTES lpSA = NULL; + PSECURITY_DESCRIPTOR pSD = NULL; + PACL pACL = NULL; + + if (!createFileW) { + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return -1; + } + + if (osflags & PR_CREATE_FILE) { + if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable, + &pSD, &pACL) == PR_SUCCESS) { + sa.nLength = sizeof(sa); + sa.lpSecurityDescriptor = pSD; + sa.bInheritHandle = FALSE; + lpSA = &sa; + } + } + + if (osflags & PR_SYNC) flag6 = FILE_FLAG_WRITE_THROUGH; + + if (osflags & PR_RDONLY || osflags & PR_RDWR) + access |= GENERIC_READ; + if (osflags & PR_WRONLY || osflags & PR_RDWR) + access |= GENERIC_WRITE; + + if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL ) + flags = CREATE_NEW; + else if (osflags & PR_CREATE_FILE) { + if (osflags & PR_TRUNCATE) + flags = CREATE_ALWAYS; + else + flags = OPEN_ALWAYS; + } else { + if (osflags & PR_TRUNCATE) + flags = TRUNCATE_EXISTING; + else + flags = OPEN_EXISTING; + } + + file = createFileW(name, + access, + FILE_SHARE_READ|FILE_SHARE_WRITE, + lpSA, + flags, + flag6, + NULL); + if (lpSA != NULL) { + _PR_NT_FreeSecurityDescriptorACL(pSD, pACL); + } + if (file == INVALID_HANDLE_VALUE) { + _PR_MD_MAP_OPEN_ERROR(GetLastError()); + return -1; + } + + return (PRInt32)file; +} + +PRStatus +_PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *d, const PRUnichar *name) +{ + PRUnichar filename[ MAX_PATH ]; + int len; + + if (!findFirstFileW) { + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; + } + + len = wcslen(name); + /* Need 5 bytes for \*.* and the trailing null byte. */ + if (len + 5 > MAX_PATH) { + PR_SetError(PR_NAME_TOO_LONG_ERROR, 0); + return PR_FAILURE; + } + wcscpy(filename, name); + + /* + * If 'name' ends in a slash or backslash, do not append + * another backslash. + */ + if (filename[len - 1] == L'/' || filename[len - 1] == L'\\') { + len--; + } + wcscpy(&filename[len], L"\\*.*"); + FlipSlashesW( filename, wcslen(filename) ); + + d->d_hdl = findFirstFileW( filename, &(d->d_entry) ); + if ( d->d_hdl == INVALID_HANDLE_VALUE ) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return PR_FAILURE; + } + d->firstEntry = PR_TRUE; + d->magic = _MD_MAGIC_DIR; + return PR_SUCCESS; +} + +PRUnichar * +_PR_MD_READ_DIR_UTF16(_MDDirUTF16 *d, PRIntn flags) +{ + PRInt32 err; + BOOL rv; + PRUnichar *fileName; + + if (!findNextFileW) { + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; + } + + if ( d ) { + while (1) { + if (d->firstEntry) { + d->firstEntry = PR_FALSE; + rv = 1; + } else { + rv = findNextFileW(d->d_hdl, &(d->d_entry)); + } + if (rv == 0) { + break; + } + fileName = GetFileFromDIR(d); + if ( (flags & PR_SKIP_DOT) && + (fileName[0] == L'.') && (fileName[1] == L'\0')) + continue; + if ( (flags & PR_SKIP_DOT_DOT) && + (fileName[0] == L'.') && (fileName[1] == L'.') && + (fileName[2] == L'\0')) + continue; + if ( (flags & PR_SKIP_HIDDEN) && FileIsHidden(d)) + continue; + return fileName; + } + err = GetLastError(); + PR_ASSERT(NO_ERROR != err); + _PR_MD_MAP_READDIR_ERROR(err); + return NULL; + } + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return NULL; +} + +PRStatus +_PR_MD_CLOSE_DIR_UTF16(_MDDirUTF16 *d) +{ + if ( d ) { + if (FindClose(d->d_hdl)) { + d->magic = (PRUint32)-1; + return PR_SUCCESS; + } else { + _PR_MD_MAP_CLOSEDIR_ERROR(GetLastError()); + return PR_FAILURE; + } + } + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return PR_FAILURE; +} + +#define _PR_IS_W_SLASH(ch) ((ch) == L'/' || (ch) == L'\\') + +/* + * IsRootDirectoryW -- + * + * Return PR_TRUE if the pathname 'fn' is a valid root directory, + * else return PR_FALSE. The PRUnichar buffer pointed to by 'fn' must + * be writable. During the execution of this function, the contents + * of the buffer pointed to by 'fn' may be modified, but on return + * the original contents will be restored. 'buflen' is the size of + * the buffer pointed to by 'fn', in PRUnichars. + * + * Root directories come in three formats: + * 1. / or \, meaning the root directory of the current drive. + * 2. C:/ or C:\, where C is a drive letter. + * 3. \\\\ or + * \\\, meaning the root directory + * of a UNC (Universal Naming Convention) name. + */ + +static PRBool +IsRootDirectoryW(PRUnichar *fn, size_t buflen) +{ + PRUnichar *p; + PRBool slashAdded = PR_FALSE; + PRBool rv = PR_FALSE; + + if (_PR_IS_W_SLASH(fn[0]) && fn[1] == L'\0') { + return PR_TRUE; + } + + if (iswalpha(fn[0]) && fn[1] == L':' && _PR_IS_W_SLASH(fn[2]) + && fn[3] == L'\0') { + rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE; + return rv; + } + + /* The UNC root directory */ + + if (_PR_IS_W_SLASH(fn[0]) && _PR_IS_W_SLASH(fn[1])) { + /* The 'server' part should have at least one character. */ + p = &fn[2]; + if (*p == L'\0' || _PR_IS_W_SLASH(*p)) { + return PR_FALSE; + } + + /* look for the next slash */ + do { + p++; + } while (*p != L'\0' && !_PR_IS_W_SLASH(*p)); + if (*p == L'\0') { + return PR_FALSE; + } + + /* The 'share' part should have at least one character. */ + p++; + if (*p == L'\0' || _PR_IS_W_SLASH(*p)) { + return PR_FALSE; + } + + /* look for the final slash */ + do { + p++; + } while (*p != L'\0' && !_PR_IS_W_SLASH(*p)); + if (_PR_IS_W_SLASH(*p) && p[1] != L'\0') { + return PR_FALSE; + } + if (*p == L'\0') { + /* + * GetDriveType() doesn't work correctly if the + * path is of the form \\server\share, so we add + * a final slash temporarily. + */ + if ((p + 1) < (fn + buflen)) { + *p++ = L'\\'; + *p = L'\0'; + slashAdded = PR_TRUE; + } else { + return PR_FALSE; /* name too long */ + } + } + rv = getDriveTypeW(fn) > 1 ? PR_TRUE : PR_FALSE; + /* restore the 'fn' buffer */ + if (slashAdded) { + *--p = L'\0'; + } + } + return rv; +} + +PRInt32 +_PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *info) +{ + HANDLE hFindFile; + WIN32_FIND_DATAW findFileData; + PRUnichar pathbuf[MAX_PATH + 1]; + + if (!findFirstFileW || !getFullPathNameW || !getDriveTypeW) { + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return -1; + } + + if (NULL == fn || L'\0' == *fn) { + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; + } + + /* + * FindFirstFile() expands wildcard characters. So + * we make sure the pathname contains no wildcard. + */ + if (NULL != wcspbrk(fn, L"?*")) { + PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0); + return -1; + } + + hFindFile = findFirstFileW(fn, &findFileData); + if (INVALID_HANDLE_VALUE == hFindFile) { + DWORD len; + PRUnichar *filePart; + + /* + * FindFirstFile() does not work correctly on root directories. + * It also doesn't work correctly on a pathname that ends in a + * slash. So we first check to see if the pathname specifies a + * root directory. If not, and if the pathname ends in a slash, + * we remove the final slash and try again. + */ + + /* + * If the pathname does not contain ., \, and /, it cannot be + * a root directory or a pathname that ends in a slash. + */ + if (NULL == wcspbrk(fn, L".\\/")) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } + len = getFullPathNameW(fn, sizeof(pathbuf)/sizeof(pathbuf[0]), pathbuf, + &filePart); + if (0 == len) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } + if (len > sizeof(pathbuf)/sizeof(pathbuf[0])) { + PR_SetError(PR_NAME_TOO_LONG_ERROR, 0); + return -1; + } + if (IsRootDirectoryW(pathbuf, sizeof(pathbuf)/sizeof(pathbuf[0]))) { + info->type = PR_FILE_DIRECTORY; + info->size = 0; + /* + * These timestamps don't make sense for root directories. + */ + info->modifyTime = 0; + info->creationTime = 0; + return 0; + } + if (!_PR_IS_W_SLASH(pathbuf[len - 1])) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } else { + pathbuf[len - 1] = L'\0'; + hFindFile = findFirstFileW(pathbuf, &findFileData); + if (INVALID_HANDLE_VALUE == hFindFile) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } + } + } + + FindClose(hFindFile); + + if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + info->type = PR_FILE_DIRECTORY; + } else { + info->type = PR_FILE_FILE; + } + + info->size = findFileData.nFileSizeHigh; + info->size = (info->size << 32) + findFileData.nFileSizeLow; + + _PR_FileTimeToPRTime(&findFileData.ftLastWriteTime, &info->modifyTime); + + if (0 == findFileData.ftCreationTime.dwLowDateTime && + 0 == findFileData.ftCreationTime.dwHighDateTime) { + info->creationTime = info->modifyTime; + } else { + _PR_FileTimeToPRTime(&findFileData.ftCreationTime, + &info->creationTime); + } + + return 0; +} +/* ================ end of UTF16 Interfaces ================================ */ +#endif /* MOZ_UNICODE */ diff --git a/pr/src/md/windows/w95sock.c b/pr/src/md/windows/w95sock.c index d36ffdcd..58944703 100644 --- a/pr/src/md/windows/w95sock.c +++ b/pr/src/md/windows/w95sock.c @@ -168,7 +168,6 @@ PRInt32 _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen) { PRInt32 rv; - int one = 1; rv = bind(fd->secret->md.osfd, (const struct sockaddr *)&(addr->inet), addrlen); @@ -180,6 +179,20 @@ _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen) return 0; } +PRInt32 +_PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog) +{ + PRInt32 rv; + + rv = listen(fd->secret->md.osfd, backlog); + + if (rv == SOCKET_ERROR) { + _PR_MD_MAP_DEFAULT_ERROR(WSAGetLastError()); + return -1; + } + + return 0; +} PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, @@ -461,6 +474,7 @@ static PRInt32 socket_io_wait( struct timeval tv; PRThread *me = _PR_MD_CURRENT_THREAD(); PRIntervalTime elapsed, remaining; + PRBool wait_for_remaining; fd_set rd_wr, ex; int err, len; @@ -547,8 +561,10 @@ static PRInt32 socket_io_wait( * 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 { @@ -618,8 +634,12 @@ static PRInt32 socket_io_wait( */ if (rv == 0 ) { - elapsed = PR_SecondsToInterval(tv.tv_sec) - + PR_MicrosecondsToInterval(tv.tv_usec); + if (wait_for_remaining) { + elapsed = remaining; + } else { + elapsed = PR_SecondsToInterval(tv.tv_sec) + + PR_MicrosecondsToInterval(tv.tv_usec); + } if (elapsed >= remaining) { PR_SetError(PR_IO_TIMEOUT_ERROR, 0); rv = -1; diff --git a/pr/src/md/windows/w95thred.c b/pr/src/md/windows/w95thred.c index a70f1620..f8a70043 100644 --- a/pr/src/md/windows/w95thred.c +++ b/pr/src/md/windows/w95thred.c @@ -131,7 +131,13 @@ _PR_MD_CREATE_THREAD(PRThread *thread, } thread->md.id = thread->id; - _PR_MD_SET_PRIORITY(&(thread->md), priority); + /* + * On windows, a thread is created with a thread priority of + * THREAD_PRIORITY_NORMAL. + */ + if (priority != PR_PRIORITY_NORMAL) { + _PR_MD_SET_PRIORITY(&(thread->md), priority); + } /* Activate the thread */ if ( ResumeThread( thread->md.handle ) != -1) diff --git a/pr/src/misc/Makefile.in b/pr/src/misc/Makefile.in index 114e110b..afc4b631 100644 --- a/pr/src/misc/Makefile.in +++ b/pr/src/misc/Makefile.in @@ -82,12 +82,14 @@ RELEASE_BINS = $(srcdir)/compile-et.pl $(srcdir)/prerr.properties include $(topsrcdir)/config/rules.mk -# An AIX Optimization bug causes PR_dtoa() to produce wrong result. -# This suppresses optimization for this single compilation unit. -ifeq ($(OS_ARCH), AIX) -$(OBJDIR)/prdtoa.o: prdtoa.c +# Prevent floating point errors caused by MSVC 6.0 Processor Pack +# optimizations (bug 207421). This disables optimizations that +# could change the precision of floating-point calculations for +# this single compilation unit. +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) +$(OBJDIR)/prdtoa.$(OBJ_SUFFIX): prdtoa.c @$(MAKE_OBJDIR) - $(CC) -o $@ -c $(filter-out -O, $(CFLAGS)) $< + $(CC) -Fo$@ -c $(CFLAGS) -Op $(call abspath,$<) endif # diff --git a/pr/src/misc/compile-et.pl b/pr/src/misc/compile-et.pl index c1c55dd7..8fafcb7b 100644 --- a/pr/src/misc/compile-et.pl +++ b/pr/src/misc/compile-et.pl @@ -129,7 +129,7 @@ print C "};\n\n"; printf C "static const struct PRErrorTable et = { text, \"%s\", %dL, %d };\n", $base, $table_base, $table_item_count; print C "\n"; -print C "void ", $table_name, "_InitializePRErrorTable", "() {\n"; +print C "void ", $table_name, "_InitializePRErrorTable", "(void) {\n"; print C " PR_ErrorInstallTable(&et);\n"; print C "}\n"; diff --git a/pr/src/misc/pralarm.c b/pr/src/misc/pralarm.c index 488ce5a4..81b251d9 100644 --- a/pr/src/misc/pralarm.c +++ b/pr/src/misc/pralarm.c @@ -116,7 +116,7 @@ static PRIntervalTime pr_PredictNextNotifyTime(PRAlarmID *id) id->lastNotify = id->nextNotify; /* just keeping track of things */ id->nextNotify = (PRIntervalTime)(offsetFromEpoch + 0.5); - delta = id->nextNotify - id->nextNotify; + delta = id->nextNotify - id->lastNotify; return delta; } /* pr_PredictNextNotifyTime */ @@ -180,7 +180,7 @@ static void PR_CALLBACK pr_alarmNotifier(void *arg) } /* pr_alarm_notifier */ -PR_IMPLEMENT(PRAlarm*) PR_CreateAlarm() +PR_IMPLEMENT(PRAlarm*) PR_CreateAlarm(void) { PRAlarm *alarm = PR_NEWZAP(PRAlarm); if (alarm != NULL) diff --git a/pr/src/misc/prcountr.c b/pr/src/misc/prcountr.c index 850f7bcd..b5f6ae23 100644 --- a/pr/src/misc/prcountr.c +++ b/pr/src/misc/prcountr.c @@ -68,7 +68,6 @@ ** */ -#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #include "prcountr.h" #include "prclist.h" #include "prlock.h" @@ -502,14 +501,3 @@ PR_IMPLEMENT(PRCounterHandle) return((PRCounterHandle)rnp); } /* end PR_FindNextCounterRname() */ - - -#else /* !(defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)) */ -/* -** NSPR Counters are not defined in this case -** -** -*/ -/* Some compilers don't like an empty compilation unit. */ -static int dummy = 0; -#endif /* defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) */ diff --git a/pr/src/misc/prdtoa.c b/pr/src/misc/prdtoa.c index e2e715fe..ee552229 100644 --- a/pr/src/misc/prdtoa.c +++ b/pr/src/misc/prdtoa.c @@ -123,6 +123,11 @@ * if memory is available and otherwise does something you deem * appropriate. If MALLOC is undefined, malloc will be invoked * directly -- and assumed always to succeed. + * #define YES_ALIAS to permit aliasing certain double values with + * arrays of unsigned Longs. This leads to slightly better code with + * some compilers and was always used prior to 19990916, but it + * is not strictly legal and can cause trouble with aggressively + * optimizing compilers (e.g., gcc 2.95.1 under -O2). */ #if defined(IS_LITTLE_ENDIAN) #define IEEE_8087 @@ -197,6 +202,16 @@ extern void *MALLOC(size_t); #endif #else #include "float.h" +/* + * MacOS 10.2 defines the macro FLT_ROUNDS to an internal function + * which does not exist on 10.1. We can safely #define it to 1 here + * to allow 10.2 builds to run on 10.1, since we can't use fesetround() + * (which does not exist on 10.1 either). + */ +#if defined(MACOS_DEPLOYMENT_TARGET) && (MACOS_DEPLOYMENT_TARGET < 100200) +#undef FLT_ROUNDS +#define FLT_ROUNDS 1 +#endif #endif #ifndef __MATH_H__ #include "math.h" @@ -216,6 +231,10 @@ extern void *MALLOC(size_t); Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. #endif +typedef union { double d; unsigned Long L[2]; } U; + +#ifdef YES_ALIAS +#define dval(x) x #ifdef IEEE_8087 #define word0(x) ((unsigned Long *)&x)[1] #define word1(x) ((unsigned Long *)&x)[0] @@ -223,6 +242,16 @@ Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. #define word0(x) ((unsigned Long *)&x)[0] #define word1(x) ((unsigned Long *)&x)[1] #endif +#else +#ifdef IEEE_8087 +#define word0(x) ((U*)&x)->L[1] +#define word1(x) ((U*)&x)->L[0] +#else +#define word0(x) ((U*)&x)->L[0] +#define word1(x) ((U*)&x)->L[1] +#endif +#define dval(x) ((U*)&x)->d +#endif /* The following definition of Storeinc is appropriate for MIPS processors. * An alternative that might be better on some machines is @@ -904,7 +933,7 @@ static double ulp(double x) } } #endif - return a; + return dval(a); } static double @@ -974,7 +1003,7 @@ ret_d: #undef d0 #undef d1 #endif - return d; + return dval(d); } static Bigint * @@ -1117,8 +1146,8 @@ ratio double da, db; PRInt32 k, ka, kb; - da = b2d(a, &ka); - db = b2d(b, &kb); + dval(da) = b2d(a, &ka); + dval(db) = b2d(b, &kb); #ifdef Pack_32 k = ka - kb + 32*(a->wds - b->wds); #else @@ -1128,13 +1157,13 @@ ratio if (k > 0) { word0(da) += (k >> 2)*Exp_msk1; if (k &= 3) - da *= 1 << k; + dval(da) *= 1 << k; } else { k = -k; word0(db) += (k >> 2)*Exp_msk1; if (k &= 3) - db *= 1 << k; + dval(db) *= 1 << k; } #else if (k > 0) @@ -1144,7 +1173,7 @@ ratio word0(db) += k*Exp_msk1; } #endif - return da / db; + return dval(da) / dval(db); } static CONST double @@ -1180,6 +1209,16 @@ void _PR_InitDtoa(void) p5s_lock = PR_NewLock(); } +void _PR_CleanupDtoa(void) +{ + PR_DestroyLock(freelist_lock); + freelist_lock = NULL; + PR_DestroyLock(p5s_lock); + p5s_lock = NULL; + + /* FIXME: deal with freelist and p5s. */ +} + #if defined(HAVE_WATCOM_BUG_1) PRFloat64 __pascal __loadds __export #else @@ -1199,7 +1238,7 @@ PR_strtod(CONST char *s00, char **se) if (!_pr_initialized) _PR_ImplicitInitialization(); sign = nz0 = nz = 0; - rv = 0.; + dval(rv) = 0.; for(s = s00;;s++) switch(*s) { case '-': sign = 1; @@ -1321,9 +1360,9 @@ dig_done: if (!nd0) nd0 = nd; k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; - rv = y; + dval(rv) = y; if (k > 9) - rv = tens[k - 9] * rv + z; + dval(rv) = tens[k - 9] * dval(rv) + z; bd0 = 0; if (nd <= DBL_DIG #ifndef RND_PRODQUOT @@ -1337,7 +1376,7 @@ dig_done: #ifdef VAX goto vax_ovfl_check; #else - /* rv = */ rounded_product(rv, tens[e]); + /* rv = */ rounded_product(dval(rv), tens[e]); goto ret; #endif } @@ -1347,27 +1386,27 @@ dig_done: * this for larger i values. */ e -= i; - rv *= tens[i]; + dval(rv) *= tens[i]; #ifdef VAX /* VAX exponent range is so narrow we must * worry about overflow here... */ vax_ovfl_check: word0(rv) -= P*Exp_msk1; - /* rv = */ rounded_product(rv, tens[e]); + /* rv = */ rounded_product(dval(rv), tens[e]); if ((word0(rv) & Exp_mask) > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) goto ovfl; word0(rv) += P*Exp_msk1; #else - /* rv = */ rounded_product(rv, tens[e]); + /* rv = */ rounded_product(dval(rv), tens[e]); #endif goto ret; } } #ifndef Inaccurate_Divide else if (e >= -Ten_pmax) { - /* rv = */ rounded_quotient(rv, tens[-e]); + /* rv = */ rounded_quotient(dval(rv), tens[-e]); goto ret; } #endif @@ -1378,13 +1417,13 @@ dig_done: if (e1 > 0) { if ((i = e1 & 15) != 0) - rv *= tens[i]; + dval(rv) *= tens[i]; if (e1 &= ~15) { if (e1 > DBL_MAX_10_EXP) { ovfl: PR_SetError(PR_RANGE_ERROR, 0); #ifdef __STDC__ - rv = HUGE_VAL; + dval(rv) = HUGE_VAL; #else /* Can't trust HUGE_VAL */ #ifdef IEEE_Arith @@ -1402,10 +1441,10 @@ dig_done: if (e1 >>= 4) { for(j = 0; e1 > 1; j++, e1 >>= 1) if (e1 & 1) - rv *= bigtens[j]; + dval(rv) *= bigtens[j]; /* The last multiplication could overflow. */ word0(rv) -= P*Exp_msk1; - rv *= bigtens[j]; + dval(rv) *= bigtens[j]; if ((z = word0(rv) & Exp_mask) > Exp_msk1*(DBL_MAX_EXP+Bias-P)) goto ovfl; @@ -1424,23 +1463,23 @@ dig_done: else if (e1 < 0) { e1 = -e1; if ((i = e1 & 15) != 0) - rv /= tens[i]; + dval(rv) /= tens[i]; if (e1 &= ~15) { e1 >>= 4; if (e1 >= 1 << n_bigtens) goto undfl; for(j = 0; e1 > 1; j++, e1 >>= 1) if (e1 & 1) - rv *= tinytens[j]; + dval(rv) *= tinytens[j]; /* The last multiplication could underflow. */ - rv0 = rv; - rv *= tinytens[j]; - if (!rv) { - rv = 2.*rv0; - rv *= tinytens[j]; - if (!rv) { + dval(rv0) = dval(rv); + dval(rv) *= tinytens[j]; + if (!dval(rv)) { + dval(rv) = 2.*dval(rv0); + dval(rv) *= tinytens[j]; + if (!dval(rv)) { undfl: - rv = 0.; + dval(rv) = 0.; PR_SetError(PR_RANGE_ERROR, 0); if (bd0) goto retfree; @@ -1464,7 +1503,7 @@ dig_done: for(;;) { bd = Balloc(bd0->k); Bcopy(bd, bd0); - bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ + bb = d2b(dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ bs = i2b(1); if (e >= 0) { @@ -1576,12 +1615,12 @@ dig_done: break; #endif if (dsign) - rv += ulp(rv); + dval(rv) += ulp(dval(rv)); #ifndef ROUND_BIASED else { - rv -= ulp(rv); + dval(rv) -= ulp(dval(rv)); #ifndef Sudden_Underflow - if (!rv) + if (!dval(rv)) goto undfl; #endif } @@ -1632,10 +1671,10 @@ dig_done: /* Check for overflow */ if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { - rv0 = rv; + dval(rv0) = dval(rv); word0(rv) -= P*Exp_msk1; - adj = aadj1 * ulp(rv); - rv += adj; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; if ((word0(rv) & Exp_mask) >= Exp_msk1*(DBL_MAX_EXP+Bias-P)) { if (word0(rv0) == Big0 && word1(rv0) == Big1) @@ -1650,10 +1689,10 @@ dig_done: else { #ifdef Sudden_Underflow if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { - rv0 = rv; + dval(rv0) = dval(rv); word0(rv) += P*Exp_msk1; - adj = aadj1 * ulp(rv); - rv += adj; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; #ifdef IBM if ((word0(rv) & Exp_mask) < P*Exp_msk1) #else @@ -1671,8 +1710,8 @@ dig_done: word0(rv) -= P*Exp_msk1; } else { - adj = aadj1 * ulp(rv); - rv += adj; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; } #else /* Compute adj so that the IEEE rounding rules will @@ -1687,8 +1726,8 @@ dig_done: if (!dsign) aadj1 = -aadj1; } - adj = aadj1 * ulp(rv); - rv += adj; + adj = aadj1 * ulp(dval(rv)); + dval(rv) += adj; #endif } z = word0(rv) & Exp_mask; @@ -1719,7 +1758,7 @@ retfree: ret: if (se) *se = (char *)s; - return sign ? -rv : rv; + return sign ? -dval(rv) : dval(rv); } static PRInt32 @@ -1952,9 +1991,9 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, } #endif #ifdef IBM - d += 0; /* normalize */ + dval(d) += 0; /* normalize */ #endif - if (!d) { + if (!dval(d)) { *decpt = 1; if (bufsize < 2) { PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0); @@ -1968,18 +2007,18 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, return PR_SUCCESS; } - b = d2b(d, &be, &bbits); + b = d2b(dval(d), &be, &bbits); #ifdef Sudden_Underflow i = (PRInt32)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); #else if ((i = (PRInt32)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) { #endif - d2 = d; + dval(d2) = dval(d); word0(d2) &= Frac_mask1; word0(d2) |= Exp_11; #ifdef IBM if (j = 11 - hi0bits(word0(d2) & Frac_mask)) - d2 /= 1 << j; + dval(d2) /= 1 << j; #endif /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 @@ -2018,19 +2057,19 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, i = bbits + be + (Bias + (P-1) - 1); x = i > 32 ? word0(d) << (64 - i) | word1(d) >> (i - 32) : word1(d) << (32 - i); - d2 = x; + dval(d2) = x; word0(d2) -= 31*Exp_msk1; /* adjust exponent */ i -= (Bias + (P-1) - 1) + 1; denorm = 1; } #endif - ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + ds = (dval(d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; k = (PRInt32)ds; if (ds < 0. && ds != k) k--; /* want k = floor(ds) */ k_check = 1; if (k >= 0 && k <= Ten_pmax) { - if (d < tens[k]) + if (dval(d) < tens[k]) k--; k_check = 0; } @@ -2097,7 +2136,7 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, /* Try to get by with floating-point arithmetic. */ i = 0; - d2 = d; + dval(d2) = dval(d); k0 = k; ilim0 = ilim; ieps = 2; /* conservative */ @@ -2107,7 +2146,7 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, if (j & Bletch) { /* prevent overflows */ j &= Bletch - 1; - d /= bigtens[n_bigtens-1]; + dval(d) /= bigtens[n_bigtens-1]; ieps++; } for(; j; j >>= 1, i++) @@ -2115,32 +2154,32 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, ieps++; ds *= bigtens[i]; } - d /= ds; + dval(d) /= ds; } else if ((j1 = -k) != 0) { - d *= tens[j1 & 0xf]; + dval(d) *= tens[j1 & 0xf]; for(j = j1 >> 4; j; j >>= 1, i++) if (j & 1) { ieps++; - d *= bigtens[i]; + dval(d) *= bigtens[i]; } } - if (k_check && d < 1. && ilim > 0) { + if (k_check && dval(d) < 1. && ilim > 0) { if (ilim1 <= 0) goto fast_failed; ilim = ilim1; k--; - d *= 10.; + dval(d) *= 10.; ieps++; } - eps = ieps*d + 7.; + dval(eps) = ieps*dval(d) + 7.; word0(eps) -= (P-1)*Exp_msk1; if (ilim == 0) { S = mhi = 0; - d -= 5.; - if (d > eps) + dval(d) -= 5.; + if (dval(d) > dval(eps)) goto one_digit; - if (d < -eps) + if (dval(d) < -dval(eps)) goto no_digits; goto fast_failed; } @@ -2149,33 +2188,33 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, /* Use Steele & White method of only * generating digits needed. */ - eps = 0.5/tens[ilim-1] - eps; + dval(eps) = 0.5/tens[ilim-1] - dval(eps); for(i = 0;;) { - L = (Long) d; - d -= L; + L = (Long) (dval(d)); + dval(d) -= L; *s++ = '0' + (PRInt32)L; - if (d < eps) + if (dval(d) < dval(eps)) goto ret1; - if (1. - d < eps) + if (1. - dval(d) < dval(eps)) goto bump_up; if (++i >= ilim) break; - eps *= 10.; - d *= 10.; + dval(eps) *= 10.; + dval(d) *= 10.; } } else { #endif /* Generate ilim digits, then fix them up. */ - eps *= tens[ilim-1]; - for(i = 1;; i++, d *= 10.) { - L = (Long) d; - d -= L; + dval(eps) *= tens[ilim-1]; + for(i = 1;; i++, dval(d) *= 10.) { + L = (Long) (dval(d)); + dval(d) -= L; *s++ = '0' + (PRInt32)L; if (i == ilim) { - if (d > 0.5 + eps) + if (dval(d) > 0.5 + dval(eps)) goto bump_up; - else if (d < 0.5 - eps) { + else if (dval(d) < 0.5 - dval(eps)) { while(*--s == '0'){} /* just count -- nothing to execute */ s++; goto ret1; @@ -2188,7 +2227,7 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, #endif fast_failed: s = s0; - d = d2; + dval(d) = dval(d2); k = k0; ilim = ilim0; } @@ -2200,24 +2239,24 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, ds = tens[k]; if (ndigits < 0 && ilim <= 0) { S = mhi = 0; - if (ilim < 0 || d <= 5*ds) + if (ilim < 0 || dval(d) <= 5*ds) goto no_digits; goto one_digit; } for(i = 1;; i++) { - L = (Long) (d / ds); - d -= L*ds; + L = (Long) (dval(d) / ds); + dval(d) -= L*ds; #ifdef Check_FLT_ROUNDS /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (d < 0) { + if (dval(d) < 0) { L--; - d += ds; + dval(d) += ds; } #endif *s++ = '0' + (PRInt32)L; if (i == ilim) { - d += d; - if ((d > ds) || (d == ds && L & 1)) { + dval(d) += dval(d); + if ((dval(d) > ds) || (dval(d) == ds && L & 1)) { bump_up: while(*--s == '9') if (s == s0) { @@ -2229,7 +2268,7 @@ PR_dtoa(PRFloat64 d, int mode, int ndigits, } break; } - if (!(d *= 10.)) + if (!(dval(d) *= 10.)) break; } goto ret1; @@ -2514,7 +2553,7 @@ PR_cnvtf(char *buf,int bufsz, int prcsn,double fval) return; } /* XXX Why use mode 1? */ - if (PR_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz) + if (PR_dtoa(dval(fval),1,prcsn,&decpt,&sign,&endnum,num,bufsz) == PR_FAILURE) { buf[0] = '\0'; goto done; diff --git a/pr/src/misc/prenv.c b/pr/src/misc/prenv.c index 75af10fb..fdcfb017 100644 --- a/pr/src/misc/prenv.c +++ b/pr/src/misc/prenv.c @@ -59,7 +59,7 @@ static PRLock *_pr_envLock = NULL; /************************************************************************/ -void _PR_InitEnv() +void _PR_InitEnv(void) { _PR_NEW_LOCK_ENV(); } diff --git a/pr/src/misc/prerr.c b/pr/src/misc/prerr.c index 68bcc6ce..aaa1c38b 100644 --- a/pr/src/misc/prerr.c +++ b/pr/src/misc/prerr.c @@ -113,12 +113,13 @@ static const struct PRErrorMessage text[] = { {"PR_SOCKET_SHUTDOWN_ERROR", "Socket shutdown"}, {"PR_CONNECT_ABORTED_ERROR", "Connection aborted"}, {"PR_HOST_UNREACHABLE_ERROR", "Host is unreachable"}, + {"PR_LIBRARY_NOT_LOADED_ERROR", "The library is not loaded"}, {"PR_MAX_ERROR", "Placeholder for the end of the list"}, {0, 0} }; -static const struct PRErrorTable et = { text, "prerr", -6000L, 75 }; +static const struct PRErrorTable et = { text, "prerr", -6000L, 76 }; -void nspr_InitializePRErrorTable() { +void nspr_InitializePRErrorTable(void) { PR_ErrorInstallTable(&et); } diff --git a/pr/src/misc/prerr.et b/pr/src/misc/prerr.et index e7e21305..9281ee6e 100644 --- a/pr/src/misc/prerr.et +++ b/pr/src/misc/prerr.et @@ -128,6 +128,7 @@ ec PR_NETWORK_DOWN_ERROR, "Network is down" ec PR_SOCKET_SHUTDOWN_ERROR, "Socket shutdown" ec PR_CONNECT_ABORTED_ERROR, "Connection aborted" ec PR_HOST_UNREACHABLE_ERROR, "Host is unreachable" +ec PR_LIBRARY_NOT_LOADED_ERROR, "The library is not loaded" ec PR_MAX_ERROR, "Placeholder for the end of the list" diff --git a/pr/src/misc/prerr.properties b/pr/src/misc/prerr.properties index 652545e0..f6f0db26 100644 --- a/pr/src/misc/prerr.properties +++ b/pr/src/misc/prerr.properties @@ -31,7 +31,6 @@ # GPL. # -# # # prerr.properties # This file is automatically generated; please do not edit it. @@ -109,4 +108,5 @@ PR_NETWORK_DOWN_ERROR=Network is down PR_SOCKET_SHUTDOWN_ERROR=Socket shutdown PR_CONNECT_ABORTED_ERROR=Connection aborted PR_HOST_UNREACHABLE_ERROR=Host is unreachable +PR_LIBRARY_NOT_LOADED_ERROR=The library is not loaded PR_MAX_ERROR=Placeholder for the end of the list diff --git a/pr/src/misc/prerror.c b/pr/src/misc/prerror.c index 8456d9d2..6e0d5f19 100644 --- a/pr/src/misc/prerror.c +++ b/pr/src/misc/prerror.c @@ -37,13 +37,13 @@ #include #include -PR_IMPLEMENT(PRErrorCode) PR_GetError() +PR_IMPLEMENT(PRErrorCode) PR_GetError(void) { PRThread *thread = PR_GetCurrentThread(); return thread->errorCode; } -PR_IMPLEMENT(PRInt32) PR_GetOSError() +PR_IMPLEMENT(PRInt32) PR_GetOSError(void) { PRThread *thread = PR_GetCurrentThread(); return thread->osErrorCode; diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c index 6da27fa0..04c92226 100644 --- a/pr/src/misc/prinit.c +++ b/pr/src/misc/prinit.c @@ -161,7 +161,7 @@ static void _pr_SetNativeThreadsOnlyMode(void) #endif #if !defined(_PR_INET6) || defined(_PR_INET6_PROBE) -extern PRStatus _pr_init_ipv6(); +extern PRStatus _pr_init_ipv6(void); #endif static void _PR_InitStuff(void) @@ -169,6 +169,9 @@ static void _PR_InitStuff(void) if (_pr_initialized) return; _pr_initialized = PR_TRUE; +#ifdef _PR_ZONE_ALLOCATOR + _PR_InitZones(); +#endif #ifdef WINNT _pr_SetNativeThreadsOnlyMode(); #endif @@ -220,10 +223,6 @@ static void _PR_InitStuff(void) _PR_InitCPUs(); #endif -#ifdef _PR_ZONE_ALLOCATOR - _PR_InitZones(); -#endif - /* * XXX: call _PR_InitMem only on those platforms for which nspr implements * malloc, for now. @@ -251,7 +250,7 @@ static void _PR_InitStuff(void) _PR_MD_FINAL_INIT(); } -void _PR_ImplicitInitialization() +void _PR_ImplicitInitialization(void) { _PR_InitStuff(); @@ -417,9 +416,10 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup() PR_ASSERT((_PR_IS_NATIVE_THREAD(me)) || (me->cpu->id == 0)); #endif -#if defined(WIN16) + _PR_CleanupMW(); + _PR_CleanupDtoa(); + _PR_CleanupCallOnce(); _PR_ShutdownLinker(); -#endif /* Release the primordial thread's private data, etc. */ _PR_CleanupThread(me); @@ -449,7 +449,11 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup() * Ideally, for each _PR_InitXXX(), there should be a corresponding * _PR_XXXCleanup() that we can call here. */ + _PR_CleanupNet(); _PR_CleanupIO(); +#ifdef WINNT + _PR_CleanupCPUs(); +#endif _PR_CleanupThreads(); PR_DestroyLock(_pr_sleeplock); _pr_sleeplock = NULL; @@ -561,7 +565,7 @@ PR_ProcessAttrSetCurrentDirectory( const char *dir) { PR_FREEIF(attr->currentDirectory); - attr->currentDirectory = PR_MALLOC(strlen(dir) + 1); + attr->currentDirectory = (char *) PR_MALLOC(strlen(dir) + 1); if (!attr->currentDirectory) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); return PR_FAILURE; @@ -776,13 +780,20 @@ static struct { PRCondVar *cv; } mod_init; -static void _PR_InitCallOnce() { +static void _PR_InitCallOnce(void) { mod_init.ml = PR_NewLock(); PR_ASSERT(NULL != mod_init.ml); mod_init.cv = PR_NewCondVar(mod_init.ml); PR_ASSERT(NULL != mod_init.cv); } +void _PR_CleanupCallOnce() +{ + PR_DestroyLock(mod_init.ml); + mod_init.ml = NULL; + PR_DestroyCondVar(mod_init.cv); + mod_init.cv = NULL; +} PR_IMPLEMENT(PRStatus) PR_CallOnce( PRCallOnceType *once, @@ -808,6 +819,31 @@ PR_IMPLEMENT(PRStatus) PR_CallOnce( return once->status; } +PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( + PRCallOnceType *once, + PRCallOnceWithArgFN func, + void *arg) +{ + if (!_pr_initialized) _PR_ImplicitInitialization(); + + if (!once->initialized) { + if (PR_AtomicSet(&once->inProgress, 1) == 0) { + once->status = (*func)(arg); + PR_Lock(mod_init.ml); + once->initialized = 1; + PR_NotifyAllCondVar(mod_init.cv); + PR_Unlock(mod_init.ml); + } else { + PR_Lock(mod_init.ml); + while (!once->initialized) { + PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); + } + PR_Unlock(mod_init.ml); + } + } + return once->status; +} + PRBool _PR_Obsolete(const char *obsolete, const char *preferred) { #if defined(DEBUG) diff --git a/pr/src/misc/prinrval.c b/pr/src/misc/prinrval.c index d0af3977..a319e8cb 100644 --- a/pr/src/misc/prinrval.c +++ b/pr/src/misc/prinrval.c @@ -68,13 +68,13 @@ void _PR_InitClock(void) * 2) The units here are milliseconds. That's not appropriate for our use. */ -PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow() +PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) { if (!_pr_initialized) _PR_ImplicitInitialization(); return _PR_MD_GET_INTERVAL(); } /* PR_IntervalNow */ -PR_EXTERN(PRUint32) PR_TicksPerSecond() +PR_EXTERN(PRUint32) PR_TicksPerSecond(void) { if (!_pr_initialized) _PR_ImplicitInitialization(); return _PR_MD_INTERVAL_PER_SEC(); diff --git a/pr/src/misc/prlong.c b/pr/src/misc/prlong.c index df8d9e2e..31153293 100644 --- a/pr/src/misc/prlong.c +++ b/pr/src/misc/prlong.c @@ -37,6 +37,7 @@ static PRInt64 ll_zero = LL_INIT( 0x00000000,0x00000000 ); static PRInt64 ll_maxint = LL_INIT( 0x7fffffff, 0xffffffff ); static PRInt64 ll_minint = LL_INIT( 0x80000000, 0x00000000 ); +static PRUint64 ll_maxuint = LL_INIT( 0xffffffff, 0xffffffff ); #if defined(HAVE_WATCOM_BUG_2) PRInt64 __pascal __loadds __export @@ -45,10 +46,13 @@ PRInt64 __pascal __loadds __export LL_MaxInt(void) { return ll_maxint; } PRInt64 __pascal __loadds __export LL_MinInt(void) { return ll_minint; } +PRUint64 __pascal __loadds __export + LL_MaxUint(void) { return ll_maxuint; } #else PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; } PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; } PR_IMPLEMENT(PRInt64) LL_MinInt(void) { return ll_minint; } +PR_IMPLEMENT(PRUint64) LL_MaxUint(void) { return ll_maxuint; } #endif #ifndef HAVE_LONG_LONG diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c index b40ca804..dc89b891 100644 --- a/pr/src/misc/prnetdb.c +++ b/pr/src/misc/prnetdb.c @@ -83,6 +83,12 @@ PRLock *_pr_dnsLock = NULL; * Some return a pointer to struct protoent, others return * an int. */ +#if defined(XP_BEOS) && defined(BONE_VERSION) +#include /* pick up define for inet_addr */ +#include +#define _PR_HAVE_GETPROTO_R +#define _PR_HAVE_GETPROTO_R_POINTER +#endif #if defined(SOLARIS) || (defined(BSDI) && defined(_REENTRANT)) \ || (defined(LINUX) && defined(_REENTRANT) \ @@ -92,7 +98,7 @@ PRLock *_pr_dnsLock = NULL; #endif #if defined(OSF1) \ - || defined(AIX4_3) || (defined(AIX) && defined(_THREAD_SAFE)) \ + || defined(AIX4_3_PLUS) || (defined(AIX) && defined(_THREAD_SAFE)) \ || (defined(HPUX10_10) && defined(_REENTRANT)) \ || (defined(HPUX10_20) && defined(_REENTRANT)) #define _PR_HAVE_GETPROTO_R @@ -157,6 +163,250 @@ const PRIPv6Addr _pr_in6addr_loopback = {{{ 0, 0, 0, 0, #define _PR_IN6_V4MAPPED_TO_IPADDR(a) ((a)->pr_s6_addr32[3]) +#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2) + +/* + * The _pr_QueryNetIfs() function finds out if the system has + * IPv4 or IPv6 source addresses configured and sets _pr_have_inet_if + * and _pr_have_inet6_if accordingly. + * + * We have an implementation using SIOCGIFCONF ioctl and a + * default implementation that simply sets _pr_have_inet_if + * and _pr_have_inet6_if to true. A better implementation + * would be to use the routing sockets (see Chapter 17 of + * W. Richard Stevens' Unix Network Programming, Vol. 1, 2nd. Ed.) + */ + +static PRLock *_pr_query_ifs_lock = NULL; +static PRBool _pr_have_inet_if = PR_FALSE; +static PRBool _pr_have_inet6_if = PR_FALSE; + +#undef DEBUG_QUERY_IFS + +#if defined(AIX) \ + || (defined(DARWIN) && (!defined(HAVE_GETIFADDRS) \ + || (defined(MACOS_DEPLOYMENT_TARGET) \ + && MACOS_DEPLOYMENT_TARGET < 100200))) + +/* + * Use SIOCGIFCONF ioctl on platforms that don't have routing + * sockets. Warning: whether SIOCGIFCONF ioctl returns AF_INET6 + * network interfaces is not portable. + * + * The _pr_QueryNetIfs() function is derived from the code in + * src/lib/libc/net/getifaddrs.c in BSD Unix and the code in + * Section 16.6 of W. Richard Stevens' Unix Network Programming, + * Vol. 1, 2nd. Ed. + */ + +#include +#include +#include +#include + +#ifdef DEBUG_QUERY_IFS +static void +_pr_PrintIfreq(struct ifreq *ifr) +{ + PRNetAddr addr; + struct sockaddr *sa; + const char* family; + char addrstr[64]; + + sa = &ifr->ifr_addr; + if (sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + family = "inet"; + memcpy(&addr.inet.ip, &sin->sin_addr, sizeof(sin->sin_addr)); + } else if (sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + family = "inet6"; + memcpy(&addr.ipv6.ip, &sin6->sin6_addr, sizeof(sin6->sin6_addr)); + } else { + return; /* skip if not AF_INET or AF_INET6 */ + } + addr.raw.family = sa->sa_family; + PR_NetAddrToString(&addr, addrstr, sizeof(addrstr)); + printf("%s: %s %s\n", ifr->ifr_name, family, addrstr); +} +#endif + +static void +_pr_QueryNetIfs(void) +{ + int sock; + int rv; + struct ifconf ifc; + struct ifreq *ifr; + struct ifreq *lifr; + PRUint32 len, lastlen; + char *buf; + + if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + return; + } + + /* Issue SIOCGIFCONF request in a loop. */ + lastlen = 0; + len = 100 * sizeof(struct ifreq); /* initial buffer size guess */ + for (;;) { + buf = (char *)PR_Malloc(len); + if (NULL == buf) { + close(sock); + return; + } + ifc.ifc_buf = buf; + ifc.ifc_len = len; + rv = ioctl(sock, SIOCGIFCONF, &ifc); + if (rv < 0) { + if (errno != EINVAL || lastlen != 0) { + close(sock); + PR_Free(buf); + return; + } + } else { + if (ifc.ifc_len == lastlen) + break; /* success, len has not changed */ + lastlen = ifc.ifc_len; + } + len += 10 * sizeof(struct ifreq); /* increment */ + PR_Free(buf); + } + close(sock); + + ifr = ifc.ifc_req; + lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len]; + + while (ifr < lifr) { + struct sockaddr *sa; + int sa_len; + +#ifdef DEBUG_QUERY_IFS + _pr_PrintIfreq(ifr); +#endif + sa = &ifr->ifr_addr; + if (sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *) sa; + if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { + _pr_have_inet_if = PR_TRUE; + } + } else if (sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; + if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) + && !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + _pr_have_inet6_if = PR_TRUE; + } + } + +#ifdef _PR_HAVE_SOCKADDR_LEN + sa_len = PR_MAX(sa->sa_len, sizeof(struct sockaddr)); +#else + switch (sa->sa_family) { +#ifdef AF_LINK + case AF_LINK: + sa_len = sizeof(struct sockaddr_dl); + break; +#endif + case AF_INET6: + sa_len = sizeof(struct sockaddr_in6); + break; + default: + sa_len = sizeof(struct sockaddr); + break; + } +#endif + ifr = (struct ifreq *)(((char *)sa) + sa_len); + } + PR_Free(buf); +} + +#elif (defined(DARWIN) && defined(HAVE_GETIFADDRS)) || defined(FREEBSD) \ + || defined(NETBSD) + +/* + * Use the BSD getifaddrs function. + */ + +#include +#include +#include +#include + +#ifdef DEBUG_QUERY_IFS +static void +_pr_PrintIfaddrs(struct ifaddrs *ifa) +{ + struct sockaddr *sa; + const char* family; + void *addrp; + char addrstr[64]; + + sa = ifa->ifa_addr; + if (sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + family = "inet"; + addrp = &sin->sin_addr; + } else if (sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + family = "inet6"; + addrp = &sin6->sin6_addr; + } else { + return; /* skip if not AF_INET or AF_INET6 */ + } + inet_ntop(sa->sa_family, addrp, addrstr, sizeof(addrstr)); + printf("%s: %s %s\n", ifa->ifa_name, family, addrstr); +} +#endif + +static void +_pr_QueryNetIfs(void) +{ + struct ifaddrs *ifp; + struct ifaddrs *ifa; + + if (getifaddrs(&ifp) == -1) { + return; + } + for (ifa = ifp; ifa; ifa = ifa->ifa_next) { + struct sockaddr *sa; + +#ifdef DEBUG_QUERY_IFS + _pr_PrintIfaddrs(ifa); +#endif + sa = ifa->ifa_addr; + if (sa->sa_family == AF_INET) { + struct sockaddr_in *sin = (struct sockaddr_in *) sa; + if (sin->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) { + _pr_have_inet_if = 1; + } + } else if (sa->sa_family == AF_INET6) { + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; + if (!IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) + && !IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + _pr_have_inet6_if = 1; + } + } + } + freeifaddrs(ifp); +} + +#else /* default */ + +/* + * Emulate the code in NSPR 4.2 or older. PR_GetIPNodeByName behaves + * as if the system had both IPv4 and IPv6 source addresses configured. + */ +static void +_pr_QueryNetIfs(void) +{ + _pr_have_inet_if = PR_TRUE; + _pr_have_inet6_if = PR_TRUE; +} + +#endif + +#endif /* _PR_INET6 && _PR_HAVE_GETHOSTBYNAME2 */ + void _PR_InitNet(void) { #if defined(XP_UNIX) @@ -174,6 +424,31 @@ void _PR_InitNet(void) #if !defined(_PR_HAVE_GETPROTO_R) _getproto_lock = PR_NewLock(); #endif +#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2) + _pr_query_ifs_lock = PR_NewLock(); +#endif +} + +void _PR_CleanupNet(void) +{ +#if !defined(_PR_NO_DNS_LOCK) + if (_pr_dnsLock) { + PR_DestroyLock(_pr_dnsLock); + _pr_dnsLock = NULL; + } +#endif +#if !defined(_PR_HAVE_GETPROTO_R) + if (_getproto_lock) { + PR_DestroyLock(_getproto_lock); + _getproto_lock = NULL; + } +#endif +#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2) + if (_pr_query_ifs_lock) { + PR_DestroyLock(_pr_query_ifs_lock); + _pr_query_ifs_lock = NULL; + } +#endif } /* @@ -215,7 +490,6 @@ static void MakeIPv4MappedAddr(const char *v4, char *v6) memset(v6, 0, 10); memset(v6 + 10, 0xff, 2); memcpy(v6 + 12, v4, 4); - PR_ASSERT(_PR_IN6_IS_ADDR_V4MAPPED(((PRIPv6Addr *) v6))); } /* @@ -225,7 +499,6 @@ static void MakeIPv4CompatAddr(const char *v4, char *v6) { memset(v6, 0, 12); memcpy(v6 + 12, v4, 4); - PR_ASSERT(_PR_IN6_IS_ADDR_V4COMPAT(((PRIPv6Addr *) v6))); } /* @@ -406,7 +679,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByName( tmpbuf = localbuf; if (bufsize > sizeof(localbuf)) { - tmpbuf = PR_Malloc(bufsize); + tmpbuf = (char *)PR_Malloc(bufsize); if (NULL == tmpbuf) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); @@ -521,6 +794,25 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( return PR_FAILURE; } +#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2) + PR_Lock(_pr_query_ifs_lock); + /* + * Keep querying the presence of IPv4 and IPv6 interfaces until + * at least one is up. This allows us to detect the local + * machine going from offline to online. + */ + if (!_pr_have_inet_if && !_pr_have_inet6_if) { + _pr_QueryNetIfs(); +#ifdef DEBUG_QUERY_IFS + if (_pr_have_inet_if) + printf("Have IPv4 source address\n"); + if (_pr_have_inet6_if) + printf("Have IPv6 source address\n"); +#endif + } + PR_Unlock(_pr_query_ifs_lock); +#endif + #if defined(_PR_HAVE_GETIPNODEBYNAME) if (flags & PR_AI_V4MAPPED) tmp_flags |= AI_V4MAPPED; @@ -538,7 +830,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( tmpbuf = localbuf; if (bufsize > sizeof(localbuf)) { - tmpbuf = PR_Malloc(bufsize); + tmpbuf = (char *)PR_Malloc(bufsize); if (NULL == tmpbuf) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); @@ -553,11 +845,15 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( LOCK_DNS(); if (af == PR_AF_INET6) { + if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet6_if) + { #ifdef _PR_INET6_PROBE - if (_pr_ipv6_is_present == PR_TRUE) + if (_pr_ipv6_is_present == PR_TRUE) #endif - h = GETHOSTBYNAME2(name, AF_INET6); - if ((NULL == h) && (flags & PR_AI_V4MAPPED)) + h = GETHOSTBYNAME2(name, AF_INET6); + } + if ((NULL == h) && (flags & PR_AI_V4MAPPED) + && ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if)) { did_af_inet = PR_TRUE; h = GETHOSTBYNAME2(name, AF_INET); @@ -565,8 +861,11 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( } else { - did_af_inet = PR_TRUE; - h = GETHOSTBYNAME2(name, af); + if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet_if) + { + did_af_inet = PR_TRUE; + h = GETHOSTBYNAME2(name, af); + } } #elif defined(_PR_HAVE_GETIPNODEBYNAME) h = getipnodebyname(name, md_af, tmp_flags, &error_num); @@ -575,7 +874,12 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( #endif /* _PR_HAVE_GETHOSTBYNAME2 */ #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME) if (_pr_ipv6_is_present == PR_TRUE) + { +#ifdef PR_GETIPNODE_NOT_THREADSAFE + LOCK_DNS(); +#endif h = (*((_pr_getipnodebyname_t)_pr_getipnodebyname_fp))(name, md_af, tmp_flags, &error_num); + } else { LOCK_DNS(); @@ -619,7 +923,8 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( #endif #if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2) if ((PR_SUCCESS == rv) && (flags & PR_AI_V4MAPPED) - && (flags & (PR_AI_ALL|PR_AI_ADDRCONFIG)) + && ((flags & PR_AI_ALL) + || ((flags & PR_AI_ADDRCONFIG) && _pr_have_inet_if)) && !did_af_inet && (h = GETHOSTBYNAME2(name, AF_INET)) != 0) { rv = AppendV4AddrsToHostent(h, &buf, &bufsize, hp); if (PR_SUCCESS != rv) @@ -634,8 +939,12 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName( UNLOCK_DNS(); #endif /* _PR_HAVE_GETHOSTBYNAME2 */ #elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME) +#ifdef PR_GETIPNODE_NOT_THREADSAFE + UNLOCK_DNS(); +#else if (_pr_ipv6_is_present == PR_FALSE) UNLOCK_DNS(); +#endif #else /* _PR_INET6 */ UNLOCK_DNS(); #endif /* _PR_INET6 */ @@ -680,6 +989,10 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( af = AF_INET6; #else af = AF_INET; +#endif +#if defined(_PR_GHBA_DISALLOW_V4MAPPED) + if (_PR_IN6_IS_ADDR_V4MAPPED(&hostaddr->ipv6.ip)) + af = AF_INET; #endif } else @@ -717,7 +1030,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( tmpbuf = localbuf; if (bufsize > sizeof(localbuf)) { - tmpbuf = PR_Malloc(bufsize); + tmpbuf = (char *)PR_Malloc(bufsize); if (NULL == tmpbuf) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); @@ -731,8 +1044,13 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( h = getipnodebyaddr(addr, addrlen, af, &error_num); #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE) if (_pr_ipv6_is_present == PR_TRUE) + { +#ifdef PR_GETIPNODE_NOT_THREADSAFE + LOCK_DNS(); +#endif h = (*((_pr_getipnodebyaddr_t)_pr_getipnodebyaddr_fp))(addr, addrlen, af, &error_num); + } else { LOCK_DNS(); @@ -788,8 +1106,12 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr( /* Must match the convoluted logic above for LOCK_DNS() */ #if defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6) #elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE) +#ifdef PR_GETIPNODE_NOT_THREADSAFE + UNLOCK_DNS(); +#else if (_pr_ipv6_is_present == PR_FALSE) UNLOCK_DNS(); +#endif #else /* _PR_HAVE_GETIPNODEBYADDR */ UNLOCK_DNS(); #endif /* _PR_HAVE_GETIPNODEBYADDR */ @@ -1164,7 +1486,7 @@ PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val) return PR_FALSE; } -#ifndef _PR_INET6 +#ifndef _PR_HAVE_INET_NTOP #define XX 127 static const unsigned char index_hex[256] = { XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, XX,XX,XX,XX, @@ -1404,14 +1726,14 @@ static const char *V6AddrToString( #undef STUFF } -#endif /* !_PR_INET6 */ +#endif /* !_PR_HAVE_INET_NTOP */ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr) { PRStatus status = PR_SUCCESS; PRIntn rv; -#if defined(_PR_INET6) +#if defined(_PR_HAVE_INET_NTOP) rv = inet_pton(AF_INET6, string, &addr->ipv6.ip); if (1 == rv) { @@ -1434,7 +1756,7 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr) status = PR_FAILURE; } } -#else /* _PR_INET6 */ +#else /* _PR_HAVE_INET_NTOP */ rv = StringToV6Addr(string, &addr->ipv6.ip); if (1 == rv) { addr->raw.family = PR_AF_INET6; @@ -1458,7 +1780,7 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr) PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); status = PR_FAILURE; } -#endif /* _PR_INET6 */ +#endif /* _PR_HAVE_INET_NTOP */ return status; } @@ -1468,7 +1790,7 @@ PR_IMPLEMENT(PRStatus) PR_NetAddrToString( { if (PR_AF_INET6 == addr->raw.family) { -#if defined(_PR_INET6) +#if defined(_PR_HAVE_INET_NTOP) if (NULL == inet_ntop(AF_INET6, &addr->ipv6.ip, string, size)) #else if (NULL == V6AddrToString(&addr->ipv6.ip, string, size)) diff --git a/pr/src/misc/prolock.c b/pr/src/misc/prolock.c index a2a50ced..e8384879 100644 --- a/pr/src/misc/prolock.c +++ b/pr/src/misc/prolock.c @@ -38,7 +38,6 @@ ** Implement the API defined in prolock.h ** */ -#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS) #include "prolock.h" #include "prlog.h" #include "prerror.h" @@ -96,13 +95,3 @@ PR_IMPLEMENT(PRStatus) PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); return PR_FAILURE; } /* end PR_UnlockOrderedLock() */ - -#else /* ! defined(FORCE_NSPR_ORDERED_LOCK) */ -/* -** NSPR Ordered Lock is not defined when !DEBUG and !FORCE_NSPR_ORDERED_LOCK -** -*/ - -/* Some compilers don't like an empty compilation unit. */ -static int dummy = 0; -#endif /* defined(FORCE_NSPR_ORDERED_LOCK */ diff --git a/pr/src/misc/prrng.c b/pr/src/misc/prrng.c index bc6c0cd8..480b347d 100644 --- a/pr/src/misc/prrng.c +++ b/pr/src/misc/prrng.c @@ -34,6 +34,16 @@ #include "primpl.h" +/* + * We were not including in optimized builds. On AIX this + * caused libnspr4.so to export memcpy and some binaries linked with + * libnspr4.so resolved their memcpy references with libnspr4.so. To + * be backward compatible with old libnspr4.so binaries, we do not + * include in optimized builds for AIX. (bug 200561) + */ +#if !(defined(AIX) && !defined(DEBUG)) +#include +#endif PRSize _pr_CopyLowBits( void *dst, diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c index bb786766..edf5dbd0 100644 --- a/pr/src/misc/prsystem.c +++ b/pr/src/misc/prsystem.c @@ -58,7 +58,7 @@ #endif #if defined(HPUX) -#include +#include #endif #if defined(XP_UNIX) @@ -66,7 +66,7 @@ #include #endif -PR_IMPLEMENT(char) PR_GetDirectorySeparator() +PR_IMPLEMENT(char) PR_GetDirectorySeparator(void) { return PR_DIRECTORY_SEPARATOR; } /* PR_GetDirectorySeparator */ @@ -74,7 +74,7 @@ PR_IMPLEMENT(char) PR_GetDirectorySeparator() /* ** OBSOLETE -- the function name is misspelled. */ -PR_IMPLEMENT(char) PR_GetDirectorySepartor() +PR_IMPLEMENT(char) PR_GetDirectorySepartor(void) { #if defined(DEBUG) static PRBool warn = PR_TRUE; @@ -86,6 +86,11 @@ PR_IMPLEMENT(char) PR_GetDirectorySepartor() return PR_GetDirectorySeparator(); } /* PR_GetDirectorySepartor */ +PR_IMPLEMENT(char) PR_GetPathSeparator(void) +{ + return PR_PATH_SEPARATOR; +} /* PR_GetPathSeparator */ + PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 buflen) { PRUintn len = 0; @@ -97,6 +102,12 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle case PR_SI_HOSTNAME: if (PR_FAILURE == _PR_MD_GETHOSTNAME(buf, (PRUintn)buflen)) return PR_FAILURE; + /* + * On some platforms a system does not have a hostname and + * its IP address is returned instead. The following code + * should be skipped on those platforms. + */ +#ifndef _PR_GET_HOST_ADDR_AS_NAME /* Return the unqualified hostname */ while (buf[len] && (len < buflen)) { if (buf[len] == '.') { @@ -105,6 +116,7 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle } len += 1; } +#endif break; case PR_SI_SYSNAME: @@ -150,7 +162,6 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle default: PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return PR_FAILURE; - break; } return PR_SUCCESS; } diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c index 0aa6e46c..aeb7992c 100644 --- a/pr/src/misc/prtime.c +++ b/pr/src/misc/prtime.c @@ -774,7 +774,7 @@ PR_IMPLEMENT(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt) { PRTimeParameters retVal; - PRExplodedTime std; + PRExplodedTime st; /* * Based on geographic location and GMT, figure out offset of @@ -789,32 +789,32 @@ PR_USPacificTimeParameters(const PRExplodedTime *gmt) * is ignored. */ - std.tm_usec = gmt->tm_usec; - std.tm_sec = gmt->tm_sec; - std.tm_min = gmt->tm_min; - std.tm_hour = gmt->tm_hour; - std.tm_mday = gmt->tm_mday; - std.tm_month = gmt->tm_month; - std.tm_year = gmt->tm_year; - std.tm_wday = gmt->tm_wday; - std.tm_yday = gmt->tm_yday; + st.tm_usec = gmt->tm_usec; + st.tm_sec = gmt->tm_sec; + st.tm_min = gmt->tm_min; + st.tm_hour = gmt->tm_hour; + st.tm_mday = gmt->tm_mday; + st.tm_month = gmt->tm_month; + st.tm_year = gmt->tm_year; + st.tm_wday = gmt->tm_wday; + st.tm_yday = gmt->tm_yday; /* Apply the offset to GMT to obtain the local standard time */ - ApplySecOffset(&std, retVal.tp_gmt_offset); + ApplySecOffset(&st, retVal.tp_gmt_offset); /* * Apply the rules on standard time or GMT to obtain daylight saving * time offset. In this implementation, we use the US DST rule. */ - if (std.tm_month < 3) { + if (st.tm_month < 3) { retVal.tp_dst_offset = 0L; - } else if (std.tm_month == 3) { - if (std.tm_wday == 0) { + } else if (st.tm_month == 3) { + if (st.tm_wday == 0) { /* A Sunday */ - if (std.tm_mday <= 7) { + if (st.tm_mday <= 7) { /* First Sunday */ /* 01:59:59 PST -> 03:00:00 PDT */ - if (std.tm_hour < 2) { + if (st.tm_hour < 2) { retVal.tp_dst_offset = 0L; } else { retVal.tp_dst_offset = 3600L; @@ -825,7 +825,7 @@ PR_USPacificTimeParameters(const PRExplodedTime *gmt) } } else { /* Not a Sunday. See if before first Sunday or after */ - if (std.tm_wday + 1 <= std.tm_mday) { + if (st.tm_wday + 1 <= st.tm_mday) { /* After first Sunday */ retVal.tp_dst_offset = 3600L; } else { @@ -833,14 +833,14 @@ PR_USPacificTimeParameters(const PRExplodedTime *gmt) retVal.tp_dst_offset = 0L; } } - } else if (std.tm_month < 9) { + } else if (st.tm_month < 9) { retVal.tp_dst_offset = 3600L; - } else if (std.tm_month == 9) { - if (std.tm_wday == 0) { - if (31 - std.tm_mday < 7) { + } else if (st.tm_month == 9) { + if (st.tm_wday == 0) { + if (31 - st.tm_mday < 7) { /* Last Sunday */ /* 01:59:59 PDT -> 01:00:00 PST */ - if (std.tm_hour < 1) { + if (st.tm_hour < 1) { retVal.tp_dst_offset = 3600L; } else { retVal.tp_dst_offset = 0L; @@ -851,7 +851,7 @@ PR_USPacificTimeParameters(const PRExplodedTime *gmt) } } else { /* See if before or after last Sunday */ - if (7 - std.tm_wday <= 31 - std.tm_mday) { + if (7 - st.tm_wday <= 31 - st.tm_mday) { /* before last Sunday */ retVal.tp_dst_offset = 3600L; } else { @@ -1662,15 +1662,13 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm) /* * On some platforms, for example SunOS 4, struct tm has two additional - * fields: tm_zone and tm_gmtoff. The following code attempts to obtain - * values for these two fields. + * fields: tm_zone and tm_gmtoff. */ -#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) - if (mktime(&a) == -1) { - PR_snprintf(buf, buflen, "can't get timezone"); - return 0; - } +#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) \ + || defined(NETBSD) + a.tm_zone = NULL; + a.tm_gmtoff = tm->tm_params.tp_gmt_offset + tm->tm_params.tp_dst_offset; #endif return strftime(buf, buflen, fmt, &a); diff --git a/pr/src/misc/prtpool.c b/pr/src/misc/prtpool.c index 2f43c676..d0816b30 100644 --- a/pr/src/misc/prtpool.c +++ b/pr/src/misc/prtpool.c @@ -166,7 +166,7 @@ struct PRJob { PR_END_MACRO static void delete_job(PRJob *jobp); -static PRThreadPool * alloc_threadpool(); +static PRThreadPool * alloc_threadpool(void); static PRJob * alloc_job(PRBool joinable, PRThreadPool *tp); static void notify_ioq(PRThreadPool *tp); static void notify_timerq(PRThreadPool *tp); @@ -599,11 +599,11 @@ delete_threadpool(PRThreadPool *tp) } static PRThreadPool * -alloc_threadpool() +alloc_threadpool(void) { PRThreadPool *tp; - tp = PR_CALLOC(sizeof(*tp)); + tp = (PRThreadPool *) PR_CALLOC(sizeof(*tp)); if (NULL == tp) goto failed; tp->jobq.lock = PR_NewLock(); diff --git a/pr/src/misc/prtrace.c b/pr/src/misc/prtrace.c index 72b9c52d..f861557c 100644 --- a/pr/src/misc/prtrace.c +++ b/pr/src/misc/prtrace.c @@ -41,7 +41,6 @@ ** */ -#if defined (DEBUG) || defined (FORCE_NSPR_TRACE) #include #include "prtrace.h" #include "prclist.h" @@ -917,14 +916,4 @@ PR_IMPLEMENT(PRIntn) return rc; } /* end PR_GetTraceEntries() */ -#else /* !defined(FORCE_NSPR_TRACE) */ -/* -** The trace facility is not defined when !DEBUG and !FORCE_NSPR_TRACE -** -*/ - -/* Some compilers don't like an empty compilation unit. */ -static int dummy = 0; -#endif /* defined(FORCE_NSPR_TRACE) */ - /* end prtrace.c */ diff --git a/pr/src/nspr.def b/pr/src/nspr.def new file mode 100644 index 00000000..676bd21d --- /dev/null +++ b/pr/src/nspr.def @@ -0,0 +1,449 @@ +;+# +;+# The contents of this file are subject to the Mozilla Public +;+# License Version 1.1 (the "License"); you may not use this file +;+# except in compliance with the License. You may obtain a copy of +;+# the License at http://www.mozilla.org/MPL/ +;+# +;+# Software distributed under the License is distributed on an "AS +;+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +;+# implied. See the License for the specific language governing +;+# rights and limitations under the License. +;+# +;+# The Original Code is the Netscape Portable Runtime (NSPR). +;+# +;+# The Initial Developer of the Original Code is Netscape +;+# Communications Corporation. Portions created by Netscape are +;+# Copyright (C) 2002-2003 Netscape Communications Corporation. All +;+# Rights Reserved. +;+# +;+# Contributor(s): +;+# +;+# Alternatively, the contents of this file may be used under the +;+# terms of the GNU General Public License Version 2 or later (the +;+# "GPL"), in which case the provisions of the GPL are applicable +;+# instead of those above. If you wish to allow use of your +;+# version of this file only under the terms of the GPL and not to +;+# allow others to use your version of this file under the MPL, +;+# indicate your decision by deleting the provisions above and +;+# replace them with the notice and other provisions required by +;+# the GPL. If you do not delete the provisions above, a recipient +;+# may use your version of this file under either the MPL or the +;+# GPL. +;+# +;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS +;+# 1. For all unix platforms, the string ";-" means "remove this line" +;+# 2. For all unix platforms, the string " DATA " will be removed from any +;+# line on which it occurs. +;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX. +;+# On AIX, lines containing ";+" will be removed. +;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed. +;+# 5. For all unix platforms, after the above processing has taken place, +;+# all characters after the first ";" on the line will be removed. +;+# And for AIX, the first ";" will also be removed. +;+# This file is passed directly to windows. Since ';' is a comment, all UNIX +;+# directives are hidden behind ";", ";+", and ";-" +;+# +;+NSPR_4.0 { +;+ global: +LIBRARY nspr4 ;- +EXPORTS ;- + LL_MaxInt; + LL_MinInt; + LL_Zero; + PR_Abort; + PR_AddToCounter; + PR_Accept; + PR_AcceptRead; + PR_Access; + PR_AddWaitFileDesc; + PR_AllocFileDesc; + PR_Assert; + PR_AtomicAdd; + PR_AtomicDecrement; + PR_AtomicIncrement; + PR_AtomicSet; + PR_AttachSharedMemory; + PR_AttachThread; + PR_Available; + PR_Available64; + PR_Bind; + PR_BlockClockInterrupts; + PR_BlockInterrupt; + PR_CEnterMonitor; + PR_CExitMonitor; + PR_CNotify; + PR_CNotifyAll; + PR_CSetOnMonitorRecycle; + PR_CWait; + PR_CallOnce; + PR_Calloc; + PR_CancelJob; + PR_CancelWaitFileDesc; + PR_CancelWaitGroup; + PR_CeilingLog2; + PR_ChangeFileDescNativeHandle; + PR_Cleanup; + PR_ClearInterrupt; + PR_ClearThreadGCAble; + PR_Close; + PR_CloseDir; + PR_CloseFileMap; + PR_CloseSemaphore; + PR_CloseSharedMemory; + PR_Connect; + PR_CreateCounter; + PR_ConvertIPv4AddrToIPv6; + PR_CreateAlarm; + PR_CreateFileMap; + PR_CreateIOLayerStub; + PR_CreateOrderedLock; + PR_CreateMWaitEnumerator; + PR_CreatePipe; + PR_CreateProcess; + PR_CreateProcessDetached; + PR_CreateSocketPollFd; + PR_CreateStack; + PR_CreateThread; + PR_CreateThreadGCAble; + PR_CreateTrace; + PR_CreateThreadPool; + PR_DecrementCounter; + PR_CreateWaitGroup; + PR_Delete; + PR_DeleteSemaphore; + PR_DeleteSharedMemory; + PR_DestroyAlarm; + PR_DestroyCounter; + PR_DestroyCondVar; + PR_DestroyLock; + PR_DestroyMWaitEnumerator; + PR_DestroyOrderedLock; + PR_DestroyMonitor; + PR_DestroyPollableEvent; + PR_DestroyProcessAttr; + PR_DestroyRWLock; + PR_DestroySem; + PR_DestroySocketPollFd; + PR_DestroyTrace; + PR_DestroyStack; + PR_DestroyWaitGroup; + PR_DetachProcess; + PR_DetachSharedMemory; + PR_DetachThread; + PR_DisableClockInterrupts; + PR_EnableClockInterrupts; + PR_EnterMonitor; + PR_EnumerateHostEnt; + PR_EnumerateThreads; + PR_EnumerateWaitGroup; + PR_ErrorInstallCallback; + PR_ErrorInstallTable; + PR_ErrorLanguages; + PR_ErrorToName; + PR_ErrorToString; + PR_ExitMonitor; + PR_ExplodeTime; + PR_ExportFileMapAsString; + PR_FD_CLR; + PR_FD_ISSET; + PR_FD_NCLR; + PR_FD_NISSET; + PR_FD_NSET; + PR_FD_SET; + PR_FD_ZERO; + PR_FileDesc2NativeHandle; + PR_FindSymbol; + PR_FindSymbolAndLibrary; + PR_FloorLog2; + PR_FormatTime; + PR_FindNextCounterQname; + PR_FindNextCounterRname; + PR_FindNextTraceQname; + PR_FindNextTraceRname; + PR_FormatTimeUSEnglish; + PR_Free; + PR_FreeLibraryName; + PR_GMTParameters; + PR_GetConnectStatus; + PR_GetCurrentThread; + PR_GetDefaultIOMethods; + PR_GetDescType; + PR_GetDirectorySeparator; + PR_GetCounter; + PR_GetCounterHandleFromName; + PR_GetCounterNameFromHandle; + PR_GetDirectorySepartor; + PR_GetEnv; + PR_GetError; + PR_GetErrorText; + PR_GetErrorTextLength; + PR_GetFileInfo; + PR_GetFileInfo64; + PR_GetFileMethods; + PR_GetGCRegisters; + PR_GetHostByAddr; + PR_GetHostByName; + PR_GetIPNodeByName; + PR_GetIdentitiesLayer; + PR_GetInheritedFD; + PR_GetInheritedFileMap; + PR_GetLayersIdentity; + PR_GetLibraryName; + PR_GetLibraryPath; + PR_GetMonitorEntryCount; + PR_GetNameForIdentity; + PR_GetOSError; + PR_GetOpenFileInfo; + PR_GetOpenFileInfo64; + PR_GetPageShift; + PR_GetPageSize; + PR_GetPeerName; + PR_GetPipeMethods; + PR_GetProtoByName; + PR_GetProtoByNumber; + PR_GetRandomNoise; + PR_GetSP; + PR_GetSockName; + PR_GetSocketOption; + PR_GetSpecialFD; + PR_GetStackSpaceLeft; + PR_GetSysfdTableMax; + PR_GetSystemInfo; + PR_GetTCPMethods; + PR_GetThreadAffinityMask; + PR_GetThreadID; + PR_GetThreadPriority; + PR_GetThreadPrivate; + PR_GetThreadScope; + PR_GetThreadState; + PR_GetThreadType; + PR_GetUDPMethods; + PR_GetUniqueIdentity; + PR_ImplodeTime; + PR_ImportFile; + PR_ImportFileMapFromString; + PR_ImportTCPSocket; + PR_ImportUDPSocket; + PR_GetTraceEntries; + PR_GetTraceHandleFromName; + PR_GetTraceNameFromHandle; + PR_GetTraceOption; + PR_Init; + PR_Initialize; + PR_InitializeNetAddr; + PR_Initialized; + PR_Interrupt; + PR_IntervalNow; + PR_IntervalToMicroseconds; + PR_IntervalToMilliseconds; + PR_IncrementCounter; + PR_IntervalToSeconds; + PR_IsNetAddrType; + PR_JoinJob; + PR_JoinThread; + PR_JoinThreadPool; + PR_KillProcess; + PR_Listen; + PR_LoadLibrary; + PR_LoadLibraryWithFlags; + PR_LoadStaticLibrary; + PR_LocalTimeParameters; + PR_Lock; + PR_LockFile; + PR_LogFlush; + PR_LogPrint; + PR_MakeDir; + PR_Malloc; + PR_MemMap; + PR_MemUnmap; + PR_MicrosecondsToInterval; + PR_MillisecondsToInterval; + PR_LockOrderedLock; + PR_MkDir; + PR_NetAddrToString; + PR_NewCondVar; + PR_NewLock; + PR_NewLogModule; + PR_NewMonitor; + PR_NewNamedMonitor; + PR_NewPollableEvent; + PR_NewProcessAttr; + PR_NewRWLock; + PR_NewSem; + PR_NewTCPSocket; + PR_NewTCPSocketPair; + PR_NewThreadPrivateIndex; + PR_NewUDPSocket; + PR_NormalizeTime; + PR_Notify; + PR_NotifyAll; + PR_NotifyAllCondVar; + PR_NotifyCondVar; + PR_Now; + PR_Open; + PR_OpenAnonFileMap; + PR_OpenDir; + PR_OpenFile; + PR_OpenSemaphore; + PR_OpenSharedMemory; + PR_OpenTCPSocket; + PR_OpenUDPSocket; + PR_ParseTimeString; + PR_Poll; + PR_PopIOLayer; + PR_PostSem; + PR_PostSemaphore; + PR_ProcessAttrSetCurrentDirectory; + PR_ProcessAttrSetInheritableFD; + PR_ProcessAttrSetInheritableFileMap; + PR_ProcessAttrSetStdioRedirect; + PR_ProcessExit; + PR_PushIOLayer; + PR_QueueJob; + PR_QueueJob_Accept; + PR_QueueJob_Connect; + PR_QueueJob_Read; + PR_QueueJob_Timer; + PR_QueueJob_Write; + PR_RWLock_Rlock; + PR_RWLock_Unlock; + PR_RWLock_Wlock; + PR_Read; + PR_ReadDir; + PR_Realloc; + PR_Recv; + PR_RecvFrom; + PR_Rename; + PR_ResetAlarm; + PR_ResetProcessAttr; + PR_ResumeAll; + PR_RmDir; + PR_ScanStackPointers; + PR_RecordTraceEntries; + PR_SecondsToInterval; + PR_Seek; + PR_Seek64; + PR_Select; + PR_Send; + PR_SendFile; + PR_SendTo; + PR_SetAlarm; + PR_SetConcurrency; + PR_SetError; + PR_SetErrorText; + PR_SetFDCacheSize; + PR_SetFDInheritable; + PR_SetLibraryPath; + PR_SetLogBuffering; + PR_SetLogFile; + PR_SetNetAddr; + PR_SetPollableEvent; + PR_SetSocketOption; + PR_SetCounter; + PR_SetStdioRedirect; + PR_SetSysfdTableSize; + PR_SetThreadAffinityMask; + PR_SetThreadDumpProc; + PR_SetThreadGCAble; + PR_SetThreadPriority; + PR_SetThreadPrivate; + PR_SetThreadRecycleMode; + PR_Shutdown; + PR_ShutdownThreadPool; + PR_Sleep; + PR_Socket; + PR_StackPop; + PR_StackPush; + PR_Stat; + PR_StringToNetAddr; + PR_SuspendAll; + PR_Sync; + PR_TLockFile; + PR_ThreadScanStackPointers; + PR_SetTraceOption; + PR_TicksPerSecond; + PR_TransmitFile; + PR_USPacificTimeParameters; + PR_UnblockClockInterrupts; + PR_UnblockInterrupt; + PR_UnloadLibrary; + PR_SubtractFromCounter; + PR_Unlock; + PR_UnlockFile; + PR_VersionCheck; + PR_Wait; + PR_WaitCondVar; + PR_WaitForPollableEvent; + PR_Trace; + PR_WaitProcess; + PR_WaitRecvReady; + PR_WaitSem; + PR_WaitSemaphore; + PR_Write; + PR_Writev; + PR_Yield; + PR_UnlockOrderedLock; + PR_cnvtf; + PR_dtoa; + PR_fprintf; + PR_htonl; + PR_htonll; + PR_htons; + PR_ntohl; + PR_ntohll; + PR_ntohs; + PR_smprintf; + PR_smprintf_free; + PR_snprintf; + PR_sprintf_append; + PR_sscanf; + PR_strtod; + PR_sxprintf; + PR_vfprintf; + PR_vsmprintf; + PR_vsnprintf; + PR_vsprintf_append; + PR_vsxprintf; + PRP_DestroyNakedCondVar; + PRP_NakedBroadcast; + PRP_NakedNotify; + PRP_NakedWait; + PRP_NewNakedCondVar; + PRP_TryLock; + libVersionPoint; +;+ local: *; +;+}; +;+ +;+NSPRprivate { +;+ global: + GetExecutionEnvironment; + PT_FPrintStats; + SetExecutionEnvironment; +;+ local: *; +;+}; +;+ +;+NSPR_4.1 { +;+ global: + PR_ConnectContinue; + PR_CreateIOLayer; + PR_EmulateAcceptRead; + PR_EmulateSendFile; + PR_FindFunctionSymbol; + PR_FindFunctionSymbolAndLibrary; + PR_GetMemMapAlignment; + PR_GetNumberOfProcessors; + PR_ImportPipe; + PR_SetEnv; +;+} NSPR_4.0; +;+ +;+NSPR_4.3 { +;+ global: + LL_MaxUint; + PR_CallOnceWithArg; + PR_GetLibraryFilePathname; +;+} NSPR_4.1; +;+ +;+NSPR_4.4 { +;+ global: + PR_GetPathSeparator; +;+} NSPR_4.3; diff --git a/pr/src/nspr_symvec.opt b/pr/src/nspr_symvec.opt new file mode 100644 index 00000000..68e78bdb --- /dev/null +++ b/pr/src/nspr_symvec.opt @@ -0,0 +1,491 @@ +! Fixed section of symbol vector for LIBNSPR4 (non-debug) +! +GSMATCH=LEQUAL,2,5 +case_sensitive=YES +! +! -------------------------------------------------------------------------- +! Ident 2,1 introduced for Mozilla 0.9.4 +! Based on NSPR 4.1.2 +! -------------------------------------------------------------------------- +! Ident 2,2 introduced for Mozilla 1.2 +! Based on NSPR 4.2.2? +! PR_ResumeSet, PR_ResumeTest, and PR_SuspendAllSuspended has been "removed". +! Only we can't remove the entry points because OJI is linked against NSPR so +! we have to make an upwardly compatible change: +! PR_ResumeSet is now PR_VMS_Stub1 +! PR_ResumeTest is now PR_VMS_Stub2 +! PR_SuspendAllSuspended is PR_VMS_Stub3 +! These are stub functions (defined in openvms.c) solely for the purpose of +! occupying the slots in our fixed section of the symbol table. +! -------------------------------------------------------------------------- +! Ident 2,3 introduced for Mozilla 1.3 +! Previously we were missing some symbols from NSPR 4.0 and 4.1, so now we +! include everything that's specified in nspr.def. +! -------------------------------------------------------------------------- +! Ident 2,4 introduced for Mozilla 1.3 final. +! 2,3 was still missing some symbols, in particular PR_CreateThread, which +! is used by OJI. So insert stubs to force the PR_CreateThread entry down +! to its Mozilla 1.1 (and Java 1.4-0) location so that everyone can play +! together and be happy. +! -------------------------------------------------------------------------- +! Ident 2,5 introduced for post Mozilla 1.3. +! LL_MaxUint introduced. Replaces Stub54. +! -------------------------------------------------------------------------- +! +SYMBOL_VECTOR=(PR_Accept=PROCEDURE) +SYMBOL_VECTOR=(PR_AcceptRead=PROCEDURE) +SYMBOL_VECTOR=(PR_Access=PROCEDURE) +SYMBOL_VECTOR=(PR_AllocFileDesc=PROCEDURE) +SYMBOL_VECTOR=(PR_Assert=PROCEDURE) +SYMBOL_VECTOR=(PR_AtomicAdd=PROCEDURE) +SYMBOL_VECTOR=(PR_AtomicDecrement=PROCEDURE) +SYMBOL_VECTOR=(PR_AtomicSet=PROCEDURE) +SYMBOL_VECTOR=(PR_AttachSharedMemory=PROCEDURE) +SYMBOL_VECTOR=(PR_AttachThread=PROCEDURE) +SYMBOL_VECTOR=(PR_Available64=PROCEDURE) +SYMBOL_VECTOR=(PR_Available=PROCEDURE) +SYMBOL_VECTOR=(PR_Bind=PROCEDURE) +SYMBOL_VECTOR=(PR_BlockClockInterrupts=PROCEDURE) +SYMBOL_VECTOR=(PR_BlockInterrupt=PROCEDURE) +SYMBOL_VECTOR=(PR_CExitMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_CNotify=PROCEDURE) +SYMBOL_VECTOR=(PR_CNotifyAll=PROCEDURE) +SYMBOL_VECTOR=(PR_CSetOnMonitorRecycle=PROCEDURE) +SYMBOL_VECTOR=(PR_CWait=PROCEDURE) +SYMBOL_VECTOR=(PR_CallOnce=PROCEDURE) +SYMBOL_VECTOR=(PR_Calloc=PROCEDURE) +SYMBOL_VECTOR=(PR_CancelJob=PROCEDURE) +SYMBOL_VECTOR=(PR_CancelWaitFileDesc=PROCEDURE) +SYMBOL_VECTOR=(PR_CancelWaitGroup=PROCEDURE) +SYMBOL_VECTOR=(PR_ChangeFileDescNativeHandle=PROCEDURE) +SYMBOL_VECTOR=(PR_Cleanup=PROCEDURE) +SYMBOL_VECTOR=(PR_ClearInterrupt=PROCEDURE) +SYMBOL_VECTOR=(PR_ClearThreadGCAble=PROCEDURE) +SYMBOL_VECTOR=(PR_Close=PROCEDURE) +SYMBOL_VECTOR=(PR_CloseDir=PROCEDURE) +SYMBOL_VECTOR=(PR_CloseFileMap=PROCEDURE) +SYMBOL_VECTOR=(PR_CloseSemaphore=PROCEDURE) +SYMBOL_VECTOR=(PR_CloseSharedMemory=PROCEDURE) +SYMBOL_VECTOR=(PR_Connect=PROCEDURE) +SYMBOL_VECTOR=(PR_ConnectContinue=PROCEDURE) +SYMBOL_VECTOR=(PR_ConvertIPv4AddrToIPv6=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateIOLayer=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateIOLayerStub=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateMWaitEnumerator=PROCEDURE) +SYMBOL_VECTOR=(PR_CreatePipe=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateProcess=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateProcessDetached=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateSocketPollFd=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateStack=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateThreadGCAble=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateWaitGroup=PROCEDURE) +SYMBOL_VECTOR=(PR_Delete=PROCEDURE) +SYMBOL_VECTOR=(PR_DeleteSemaphore=PROCEDURE) +SYMBOL_VECTOR=(PR_DeleteSharedMemory=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyAlarm=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyCondVar=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyLock=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyMWaitEnumerator=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyPollableEvent=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyProcessAttr=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyRWLock=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroySem=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroySocketPollFd=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyStack=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyWaitGroup=PROCEDURE) +SYMBOL_VECTOR=(PR_DetachProcess=PROCEDURE) +SYMBOL_VECTOR=(PR_DetachSharedMemory=PROCEDURE) +SYMBOL_VECTOR=(PR_DetachThread=PROCEDURE) +SYMBOL_VECTOR=(PR_DisableClockInterrupts=PROCEDURE) +SYMBOL_VECTOR=(PR_EmulateAcceptRead=PROCEDURE) +SYMBOL_VECTOR=(PR_EmulateSendFile=PROCEDURE) +SYMBOL_VECTOR=(PR_EnableClockInterrupts=PROCEDURE) +SYMBOL_VECTOR=(PR_EnterMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_EnumerateHostEnt=PROCEDURE) +SYMBOL_VECTOR=(PR_EnumerateThreads=PROCEDURE) +SYMBOL_VECTOR=(PR_EnumerateWaitGroup=PROCEDURE) +SYMBOL_VECTOR=(PR_ErrorInstallCallback=PROCEDURE) +SYMBOL_VECTOR=(PR_ErrorInstallTable=PROCEDURE) +SYMBOL_VECTOR=(PR_ErrorLanguages=PROCEDURE) +SYMBOL_VECTOR=(PR_ErrorToName=PROCEDURE) +SYMBOL_VECTOR=(PR_ExitMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_ExportFileMapAsString=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_CLR=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_ISSET=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_NCLR=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_NISSET=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_NSET=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_SET=PROCEDURE) +SYMBOL_VECTOR=(PR_FD_ZERO=PROCEDURE) +SYMBOL_VECTOR=(PR_FileDesc2NativeHandle=PROCEDURE) +SYMBOL_VECTOR=(PR_FindFunctionSymbol=PROCEDURE) +SYMBOL_VECTOR=(PR_FindFunctionSymbolAndLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_FindLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_FindSymbol=PROCEDURE) +SYMBOL_VECTOR=(PR_FindSymbolAndLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_FloorLog2=PROCEDURE) +SYMBOL_VECTOR=(PR_FormatTime=PROCEDURE) +SYMBOL_VECTOR=(PR_FormatTimeUSEnglish=PROCEDURE) +SYMBOL_VECTOR=(PR_Free=PROCEDURE) +SYMBOL_VECTOR=(PR_FreeLibraryName=PROCEDURE) +SYMBOL_VECTOR=(PR_GMTParameters=PROCEDURE) +SYMBOL_VECTOR=(PR_GetConnectStatus=PROCEDURE) +SYMBOL_VECTOR=(PR_GetCurrentThread=PROCEDURE) +SYMBOL_VECTOR=(PR_GetDefaultIOMethods=PROCEDURE) +SYMBOL_VECTOR=(PR_GetDirectorySepartor=PROCEDURE) +SYMBOL_VECTOR=(PR_GetError=PROCEDURE) +SYMBOL_VECTOR=(PR_GetErrorText=PROCEDURE) +SYMBOL_VECTOR=(PR_GetErrorTextLength=PROCEDURE) +SYMBOL_VECTOR=(PR_GetFileInfo64=PROCEDURE) +SYMBOL_VECTOR=(PR_GetFileInfo=PROCEDURE) +SYMBOL_VECTOR=(PR_GetFileMethods=PROCEDURE) +SYMBOL_VECTOR=(PR_GetHostByAddr=PROCEDURE) +SYMBOL_VECTOR=(PR_GetHostByName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetIPNodeByName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetIdentitiesLayer=PROCEDURE) +SYMBOL_VECTOR=(PR_GetInheritedFD=PROCEDURE) +SYMBOL_VECTOR=(PR_GetInheritedFileMap=PROCEDURE) +SYMBOL_VECTOR=(PR_GetLayersIdentity=PROCEDURE) +SYMBOL_VECTOR=(PR_GetLibraryName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetLibraryPath=PROCEDURE) +SYMBOL_VECTOR=(PR_GetMemMapAlignment=PROCEDURE) +SYMBOL_VECTOR=(PR_GetMonitorEntryCount=PROCEDURE) +SYMBOL_VECTOR=(PR_GetNameForIdentity=PROCEDURE) +SYMBOL_VECTOR=(PR_GetNumberOfProcessors=PROCEDURE) +SYMBOL_VECTOR=(PR_GetOSError=PROCEDURE) +SYMBOL_VECTOR=(PR_GetOpenFileInfo64=PROCEDURE) +SYMBOL_VECTOR=(PR_GetOpenFileInfo=PROCEDURE) +SYMBOL_VECTOR=(PR_GetPageShift=PROCEDURE) +SYMBOL_VECTOR=(PR_GetPeerName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetPipeMethods=PROCEDURE) +SYMBOL_VECTOR=(PR_GetProtoByName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetProtoByNumber=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSP=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSockName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSocketOption=PROCEDURE) +SYMBOL_VECTOR=(PR_GetStackSpaceLeft=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSysfdTableMax=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSystemInfo=PROCEDURE) +SYMBOL_VECTOR=(PR_GetTCPMethods=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadAffinityMask=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadID=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadPriority=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadPrivate=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadScope=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadState=PROCEDURE) +SYMBOL_VECTOR=(PR_GetThreadType=PROCEDURE) +SYMBOL_VECTOR=(PR_GetUDPMethods=PROCEDURE) +SYMBOL_VECTOR=(PR_ImplodeTime=PROCEDURE) +SYMBOL_VECTOR=(PR_ImportFile=PROCEDURE) +SYMBOL_VECTOR=(PR_ImportFileMapFromString=PROCEDURE) +SYMBOL_VECTOR=(PR_ImportPipe=PROCEDURE) +SYMBOL_VECTOR=(PR_ImportTCPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_ImportUDPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_Init=PROCEDURE) +SYMBOL_VECTOR=(PR_Initialize=PROCEDURE) +SYMBOL_VECTOR=(PR_InitializeNetAddr=PROCEDURE) +SYMBOL_VECTOR=(PR_Initialized=PROCEDURE) +SYMBOL_VECTOR=(PR_Interrupt=PROCEDURE) +SYMBOL_VECTOR=(PR_IntervalToMicroseconds=PROCEDURE) +SYMBOL_VECTOR=(PR_IntervalToMilliseconds=PROCEDURE) +SYMBOL_VECTOR=(PR_IntervalToSeconds=PROCEDURE) +SYMBOL_VECTOR=(PR_IsNetAddrType=PROCEDURE) +SYMBOL_VECTOR=(PR_JoinJob=PROCEDURE) +SYMBOL_VECTOR=(PR_JoinThread=PROCEDURE) +SYMBOL_VECTOR=(PR_JoinThreadPool=PROCEDURE) +SYMBOL_VECTOR=(PR_KillProcess=PROCEDURE) +SYMBOL_VECTOR=(PR_Listen=PROCEDURE) +SYMBOL_VECTOR=(PR_LoadLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_LoadLibraryWithFlags=PROCEDURE) +SYMBOL_VECTOR=(PR_LoadStaticLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_LocalTimeParameters=PROCEDURE) +SYMBOL_VECTOR=(PR_Lock=PROCEDURE) +SYMBOL_VECTOR=(PR_LockFile=PROCEDURE) +SYMBOL_VECTOR=(PR_LogFlush=PROCEDURE) +SYMBOL_VECTOR=(PR_LogPrint=PROCEDURE) +SYMBOL_VECTOR=(PR_MakeDir=PROCEDURE) +SYMBOL_VECTOR=(PR_MemMap=PROCEDURE) +SYMBOL_VECTOR=(PR_MemUnmap=PROCEDURE) +SYMBOL_VECTOR=(PR_MicrosecondsToInterval=PROCEDURE) +SYMBOL_VECTOR=(PR_MillisecondsToInterval=PROCEDURE) +SYMBOL_VECTOR=(PR_MkDir=PROCEDURE) +SYMBOL_VECTOR=(PR_NetAddrToString=PROCEDURE) +SYMBOL_VECTOR=(PR_NewCondVar=PROCEDURE) +SYMBOL_VECTOR=(PR_NewLogModule=PROCEDURE) +SYMBOL_VECTOR=(PR_NewMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_NewNamedMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_NewProcessAttr=PROCEDURE) +SYMBOL_VECTOR=(PR_NewSem=PROCEDURE) +SYMBOL_VECTOR=(PR_NewTCPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_NewTCPSocketPair=PROCEDURE) +SYMBOL_VECTOR=(PR_NewUDPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_NormalizeTime=PROCEDURE) +SYMBOL_VECTOR=(PR_Notify=PROCEDURE) +SYMBOL_VECTOR=(PR_NotifyAll=PROCEDURE) +SYMBOL_VECTOR=(PR_NotifyAllCondVar=PROCEDURE) +SYMBOL_VECTOR=(PR_NotifyCondVar=PROCEDURE) +SYMBOL_VECTOR=(PR_Open=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenDir=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenFile=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenSemaphore=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenTCPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenUDPSocket=PROCEDURE) +SYMBOL_VECTOR=(PR_ParseTimeString=PROCEDURE) +SYMBOL_VECTOR=(PR_Poll=PROCEDURE) +SYMBOL_VECTOR=(PR_PopIOLayer=PROCEDURE) +SYMBOL_VECTOR=(PR_PostSem=PROCEDURE) +SYMBOL_VECTOR=(PR_PostSemaphore=PROCEDURE) +SYMBOL_VECTOR=(PR_ProcessAttrSetCurren1sb1r7b$=PROCEDURE) ! PR_ProcessAttrSetCurrentDirectory +SYMBOL_VECTOR=(PR_ProcessAttrSetInheri3dpg1d0$=PROCEDURE) ! PR_ProcessAttrSetInheritableFileMap +SYMBOL_VECTOR=(PR_ProcessAttrSetInheritableFD=PROCEDURE) +SYMBOL_VECTOR=(PR_ProcessAttrSetStdioRedirect=PROCEDURE) +SYMBOL_VECTOR=(PR_ProcessExit=PROCEDURE) +SYMBOL_VECTOR=(PR_PushIOLayer=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob_Accept=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob_Connect=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob_Read=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob_Timer=PROCEDURE) +SYMBOL_VECTOR=(PR_QueueJob_Write=PROCEDURE) +SYMBOL_VECTOR=(PR_RWLock_Rlock=PROCEDURE) +SYMBOL_VECTOR=(PR_RWLock_Unlock=PROCEDURE) +SYMBOL_VECTOR=(PR_RWLock_Wlock=PROCEDURE) +SYMBOL_VECTOR=(PR_Read=PROCEDURE) +SYMBOL_VECTOR=(PR_ReadDir=PROCEDURE) +SYMBOL_VECTOR=(PR_Realloc=PROCEDURE) +SYMBOL_VECTOR=(PR_Recv=PROCEDURE) +SYMBOL_VECTOR=(PR_RecvFrom=PROCEDURE) +SYMBOL_VECTOR=(PR_Rename=PROCEDURE) +SYMBOL_VECTOR=(PR_ResetAlarm=PROCEDURE) +SYMBOL_VECTOR=(PR_ResetProcessAttr=PROCEDURE) +SYMBOL_VECTOR=(PR_ResumeAll=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub1=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub2=PROCEDURE) +SYMBOL_VECTOR=(PR_RmDir=PROCEDURE) +SYMBOL_VECTOR=(PR_ScanStackPointers=PROCEDURE) +SYMBOL_VECTOR=(PR_SecondsToInterval=PROCEDURE) +SYMBOL_VECTOR=(PR_Seek64=PROCEDURE) +SYMBOL_VECTOR=(PR_Seek=PROCEDURE) +SYMBOL_VECTOR=(PR_Select=PROCEDURE) +SYMBOL_VECTOR=(PR_Send=PROCEDURE) +SYMBOL_VECTOR=(PR_SendFile=PROCEDURE) +SYMBOL_VECTOR=(PR_SendTo=PROCEDURE) +SYMBOL_VECTOR=(PR_SetAlarm=PROCEDURE) +SYMBOL_VECTOR=(PR_SetEnv=PROCEDURE) +SYMBOL_VECTOR=(PR_SetErrorText=PROCEDURE) +SYMBOL_VECTOR=(PR_SetFDInheritable=PROCEDURE) +SYMBOL_VECTOR=(PR_SetLogBuffering=PROCEDURE) +SYMBOL_VECTOR=(PR_SetLogFile=PROCEDURE) +SYMBOL_VECTOR=(PR_SetNetAddr=PROCEDURE) +SYMBOL_VECTOR=(PR_SetPollableEvent=PROCEDURE) +SYMBOL_VECTOR=(PR_SetSocketOption=PROCEDURE) +SYMBOL_VECTOR=(PR_SetStdioRedirect=PROCEDURE) +SYMBOL_VECTOR=(PR_SetSysfdTableSize=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadAffinityMask=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadDumpProc=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadGCAble=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadPriority=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadPrivate=PROCEDURE) +SYMBOL_VECTOR=(PR_SetThreadRecycleMode=PROCEDURE) +SYMBOL_VECTOR=(PR_Shutdown=PROCEDURE) +SYMBOL_VECTOR=(PR_ShutdownThreadPool=PROCEDURE) +SYMBOL_VECTOR=(PR_Sleep=PROCEDURE) +SYMBOL_VECTOR=(PR_Socket=PROCEDURE) +SYMBOL_VECTOR=(PR_StackPop=PROCEDURE) +SYMBOL_VECTOR=(PR_StackPush=PROCEDURE) +SYMBOL_VECTOR=(PR_Stat=PROCEDURE) +SYMBOL_VECTOR=(PR_SuspendAll=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub3=PROCEDURE) +SYMBOL_VECTOR=(PR_Sync=PROCEDURE) +SYMBOL_VECTOR=(PR_TLockFile=PROCEDURE) +SYMBOL_VECTOR=(PR_ThreadScanStackPointers=PROCEDURE) +SYMBOL_VECTOR=(PR_TicksPerSecond=PROCEDURE) +SYMBOL_VECTOR=(PR_TransmitFile=PROCEDURE) +SYMBOL_VECTOR=(PR_USPacificTimeParameters=PROCEDURE) +SYMBOL_VECTOR=(PR_UnblockClockInterrupts=PROCEDURE) +SYMBOL_VECTOR=(PR_UnblockInterrupt=PROCEDURE) +SYMBOL_VECTOR=(PR_UnloadLibrary=PROCEDURE) +SYMBOL_VECTOR=(PR_Unlock=PROCEDURE) +SYMBOL_VECTOR=(PR_UnlockFile=PROCEDURE) +SYMBOL_VECTOR=(PR_Wait=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitCondVar=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitForPollableEvent=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitProcess=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitRecvReady=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitSem=PROCEDURE) +SYMBOL_VECTOR=(PR_WaitSemaphore=PROCEDURE) +SYMBOL_VECTOR=(PR_Write=PROCEDURE) +SYMBOL_VECTOR=(PR_Writev=PROCEDURE) +SYMBOL_VECTOR=(PR_XIsLocked=PROCEDURE) +SYMBOL_VECTOR=(PR_XLock=PROCEDURE) +SYMBOL_VECTOR=(PR_XNotify=PROCEDURE) +SYMBOL_VECTOR=(PR_XNotifyAll=PROCEDURE) +SYMBOL_VECTOR=(PR_XUnlock=PROCEDURE) +SYMBOL_VECTOR=(PR_XWait=PROCEDURE) +SYMBOL_VECTOR=(PR_Yield=PROCEDURE) +SYMBOL_VECTOR=(PR_cnvtf=PROCEDURE) +SYMBOL_VECTOR=(PR_dtoa=PROCEDURE) +SYMBOL_VECTOR=(PR_htonl=PROCEDURE) +SYMBOL_VECTOR=(PR_htonll=PROCEDURE) +SYMBOL_VECTOR=(PR_htons=PROCEDURE) +SYMBOL_VECTOR=(PR_ntohl=PROCEDURE) +SYMBOL_VECTOR=(PR_ntohll=PROCEDURE) +SYMBOL_VECTOR=(PR_ntohs=PROCEDURE) +SYMBOL_VECTOR=(PR_smprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_smprintf_free=PROCEDURE) +SYMBOL_VECTOR=(PR_sprintf_append=PROCEDURE) +SYMBOL_VECTOR=(PR_sxprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_vfprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_vsmprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_vsnprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_vsprintf_append=PROCEDURE) +SYMBOL_VECTOR=(PR_vsxprintf=PROCEDURE) +! +! Start of 2,3 additions +! +SYMBOL_VECTOR=(LL_MaxInt=PROCEDURE) +SYMBOL_VECTOR=(LL_MinInt=PROCEDURE) +SYMBOL_VECTOR=(LL_Zero=PROCEDURE) +SYMBOL_VECTOR=(PR_Abort=PROCEDURE) +SYMBOL_VECTOR=(PR_AddToCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_AddWaitFileDesc=PROCEDURE) +SYMBOL_VECTOR=(PR_AtomicIncrement=PROCEDURE) +SYMBOL_VECTOR=(PR_CEnterMonitor=PROCEDURE) +SYMBOL_VECTOR=(PR_CeilingLog2=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateAlarm=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateFileMap=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateOrderedLock=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateTrace=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateThreadPool=PROCEDURE) +SYMBOL_VECTOR=(PR_DecrementCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyOrderedLock=PROCEDURE) +SYMBOL_VECTOR=(PR_DestroyTrace=PROCEDURE) +SYMBOL_VECTOR=(PR_ErrorToString=PROCEDURE) +SYMBOL_VECTOR=(PR_ExplodeTime=PROCEDURE) +SYMBOL_VECTOR=(PR_FindNextCounterQname=PROCEDURE) +SYMBOL_VECTOR=(PR_FindNextCounterRname=PROCEDURE) +SYMBOL_VECTOR=(PR_FindNextTraceQname=PROCEDURE) +SYMBOL_VECTOR=(PR_FindNextTraceRname=PROCEDURE) +SYMBOL_VECTOR=(PR_GetDescType=PROCEDURE) +SYMBOL_VECTOR=(PR_GetDirectorySeparator=PROCEDURE) +SYMBOL_VECTOR=(PR_GetCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_GetCounterHandleFromName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetCounterNameFromHandle=PROCEDURE) +SYMBOL_VECTOR=(PR_GetEnv=PROCEDURE) +SYMBOL_VECTOR=(PR_GetGCRegisters=PROCEDURE) +SYMBOL_VECTOR=(PR_GetPageSize=PROCEDURE) +SYMBOL_VECTOR=(PR_GetRandomNoise=PROCEDURE) +SYMBOL_VECTOR=(PR_GetSpecialFD=PROCEDURE) +SYMBOL_VECTOR=(PR_GetUniqueIdentity=PROCEDURE) +SYMBOL_VECTOR=(PR_GetTraceEntries=PROCEDURE) +SYMBOL_VECTOR=(PR_GetTraceHandleFromName=PROCEDURE) +SYMBOL_VECTOR=(PR_GetTraceNameFromHandle=PROCEDURE) +SYMBOL_VECTOR=(PR_GetTraceOption=PROCEDURE) +SYMBOL_VECTOR=(PR_IntervalNow=PROCEDURE) +SYMBOL_VECTOR=(PR_IncrementCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_Malloc=PROCEDURE) +SYMBOL_VECTOR=(PR_LockOrderedLock=PROCEDURE) +SYMBOL_VECTOR=(PR_NewLock=PROCEDURE) +SYMBOL_VECTOR=(PR_NewPollableEvent=PROCEDURE) +SYMBOL_VECTOR=(PR_NewRWLock=PROCEDURE) +SYMBOL_VECTOR=(PR_NewThreadPrivateIndex=PROCEDURE) +SYMBOL_VECTOR=(PR_Now=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenAnonFileMap=PROCEDURE) +SYMBOL_VECTOR=(PR_OpenSharedMemory=PROCEDURE) +SYMBOL_VECTOR=(PR_RecordTraceEntries=PROCEDURE) +SYMBOL_VECTOR=(PR_SetConcurrency=PROCEDURE) +SYMBOL_VECTOR=(PR_SetFDCacheSize=PROCEDURE) +SYMBOL_VECTOR=(PR_SetLibraryPath=PROCEDURE) +SYMBOL_VECTOR=(PR_SetCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_StringToNetAddr=PROCEDURE) +SYMBOL_VECTOR=(PR_SetTraceOption=PROCEDURE) +SYMBOL_VECTOR=(PR_SubtractFromCounter=PROCEDURE) +SYMBOL_VECTOR=(PR_VersionCheck=PROCEDURE) +SYMBOL_VECTOR=(PR_Trace=PROCEDURE) +SYMBOL_VECTOR=(PR_UnlockOrderedLock=PROCEDURE) +SYMBOL_VECTOR=(PR_fprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_snprintf=PROCEDURE) +SYMBOL_VECTOR=(PR_sscanf=PROCEDURE) +SYMBOL_VECTOR=(PR_strtod=PROCEDURE) +SYMBOL_VECTOR=(PRP_DestroyNakedCondVar=PROCEDURE) +SYMBOL_VECTOR=(PRP_NakedBroadcast=PROCEDURE) +SYMBOL_VECTOR=(PRP_NakedNotify=PROCEDURE) +SYMBOL_VECTOR=(PRP_NakedWait=PROCEDURE) +SYMBOL_VECTOR=(PRP_NewNakedCondVar=PROCEDURE) +SYMBOL_VECTOR=(PRP_TryLock=PROCEDURE) +SYMBOL_VECTOR=(libVersionPoint=PROCEDURE) +! +! NSPR private +! +SYMBOL_VECTOR=(GetExecutionEnvironment=PROCEDURE) +SYMBOL_VECTOR=(PT_FPrintStats=PROCEDURE) +SYMBOL_VECTOR=(SetExecutionEnvironment=PROCEDURE) +! +! Start of 2,4 additions +! 51 stubs (4 thru 54) so that PR_CreateThread ends up at 1B70. +! Over time some of these stubs will get replaced by new symbols. +! +SYMBOL_VECTOR=(PR_VMS_Stub4=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub5=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub6=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub7=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub8=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub9=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub10=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub11=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub12=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub13=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub14=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub15=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub16=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub17=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub18=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub19=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub20=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub21=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub22=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub23=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub24=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub25=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub26=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub27=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub28=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub29=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub30=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub31=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub32=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub33=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub34=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub35=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub36=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub37=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub38=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub39=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub40=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub41=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub42=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub43=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub44=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub45=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub46=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub47=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub48=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub49=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub50=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub51=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub52=PROCEDURE) +SYMBOL_VECTOR=(PR_VMS_Stub53=PROCEDURE) +SYMBOL_VECTOR=(LL_MaxUint=PROCEDURE) +! +SYMBOL_VECTOR=(PR_CallOnceWithArg=PROCEDURE) +SYMBOL_VECTOR=(PR_GetLibraryFilePathname=PROCEDURE) +SYMBOL_VECTOR=(PR_SetError=PROCEDURE) +SYMBOL_VECTOR=(PR_CreateThread=PROCEDURE) +! +! -------------------------------------------------------------------------- +! End of fixed section +! -------------------------------------------------------------------------- +! diff --git a/pr/src/pthreads/Makefile.in b/pr/src/pthreads/Makefile.in index a43fd6ac..8eb237d4 100644 --- a/pr/src/pthreads/Makefile.in +++ b/pr/src/pthreads/Makefile.in @@ -63,6 +63,11 @@ INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/incl DEFINES += -D_NSPR_BUILD_ +ifeq ($(OS_ARCH),Linux) +# for pthread_mutexattr_settype +DEFINES += -D_XOPEN_SOURCE=500 +endif + include $(topsrcdir)/config/rules.mk export:: $(TARGETS) diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index ce263217..6222b722 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -40,9 +40,11 @@ #if defined(_PR_PTHREADS) #if defined(_PR_POLL_WITH_SELECT) +#if !(defined(HPUX) && defined(_USE_BIG_FDS)) /* set fd limit for select(), before including system header files */ #define FD_SETSIZE (16 * 1024) #endif +#endif #include #include /* for memset() */ @@ -173,11 +175,26 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; #endif /* HAVE_SEND_FILE */ #endif /* AIX */ +#ifdef LINUX +#include +#endif + #include "primpl.h" -/* On Alpha Linux, these are already defined in sys/socket.h */ -#if !(defined(LINUX) && defined(__alpha)) #include /* TCP_NODELAY, TCP_MAXSEG */ +#ifdef LINUX +/* TCP_CORK is not defined in on Red Hat Linux 6.0 */ +#ifndef TCP_CORK +#define TCP_CORK 3 +#endif +#endif + +#ifdef DARWIN +static PRBool _pr_ipv6_v6only_on_by_default; +/* The IPV6_V6ONLY socket option is not defined on Mac OS X 10.1. */ +#ifndef IPV6_V6ONLY +#define IPV6_V6ONLY 27 +#endif #endif #if defined(SOLARIS) @@ -281,11 +298,9 @@ static PRBool IsValidNetAddrLen(const PRNetAddr *addr, PRInt32 addr_len) * most current systems. */ #if defined(HAVE_SOCKLEN_T) \ - || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2 \ - && !defined(__alpha)) + || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2) typedef socklen_t pt_SockLen; #elif (defined(AIX) && !defined(AIX4_1)) \ - || (defined(LINUX) && defined(__alpha)) \ || defined(VMS) typedef PRSize pt_SockLen; #else @@ -338,6 +353,15 @@ struct pt_Continuation */ int nbytes_to_send; /* size of header and file */ #endif /* SOLARIS */ + +#ifdef LINUX + /* + * For sendfile() + */ + int in_fd; /* descriptor of file to send */ + off_t offset; + size_t count; +#endif /* LINUX */ PRIntervalTime timeout; /* client (relative) timeout */ @@ -358,15 +382,13 @@ struct pt_Continuation PTDebug pt_debug; /* this is shared between several modules */ -PR_IMPLEMENT(void) PT_GetStats(PTDebug* here) { *here = pt_debug; } - PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg) { PTDebug stats; char buffer[100]; PRExplodedTime tod; PRInt64 elapsed, aMil; - PT_GetStats(&stats); /* a copy */ + stats = pt_debug; /* a copy */ PR_ExplodeTime(stats.timeStarted, PR_LocalTimeParameters, &tod); (void)PR_FormatTime(buffer, sizeof(buffer), "%T", &tod); @@ -391,6 +413,13 @@ PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg) stats.cvars_notified, stats.delayed_cv_deletes); } /* PT_FPrintStats */ +#else + +PR_IMPLEMENT(void) PT_FPrintStats(PRFileDesc *debug_out, const char *msg) +{ + /* do nothing */ +} /* PT_FPrintStats */ + #endif /* DEBUG */ #if defined(_PR_POLL_WITH_SELECT) @@ -406,6 +435,7 @@ static void pt_poll_now_with_select(pt_Continuation *op) fd_set rd, wr, *rdp, *wrp; struct timeval tv; PRIntervalTime epoch, now, elapsed, remaining; + PRBool wait_for_remaining; PRThread *self = PR_GetCurrentThread(); PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout); @@ -485,9 +515,12 @@ static void pt_poll_now_with_select(pt_Continuation *op) } else wrp = NULL; + wait_for_remaining = PR_TRUE; msecs = (PRInt32)PR_IntervalToMilliseconds(remaining); - if (msecs > PT_DEFAULT_POLL_MSEC) + if (msecs > PT_DEFAULT_POLL_MSEC) { + wait_for_remaining = PR_FALSE; msecs = PT_DEFAULT_POLL_MSEC; + } tv.tv_sec = msecs/PR_MSEC_PER_SEC; tv.tv_usec = (msecs % PR_MSEC_PER_SEC) * PR_USEC_PER_MSEC; rv = select(op->arg1.osfd + 1, rdp, wrp, NULL, &tv); @@ -514,9 +547,12 @@ static void pt_poll_now_with_select(pt_Continuation *op) } else if ((rv == 0) || ((errno == EINTR) || (errno == EAGAIN))) { - if (rv == 0) /* select timed out */ - now += PR_MillisecondsToInterval(msecs); - else + if (rv == 0) { /* select timed out */ + if (wait_for_remaining) + now += remaining; + else + now += PR_MillisecondsToInterval(msecs); + } else now = PR_IntervalNow(); elapsed = (PRIntervalTime) (now - epoch); if (elapsed >= op->timeout) { @@ -542,6 +578,7 @@ static void pt_poll_now(pt_Continuation *op) { PRInt32 msecs; PRIntervalTime epoch, now, elapsed, remaining; + PRBool wait_for_remaining; PRThread *self = PR_GetCurrentThread(); PR_ASSERT(PR_INTERVAL_NO_WAIT != op->timeout); @@ -618,9 +655,13 @@ static void pt_poll_now(pt_Continuation *op) tmp_pfd.fd = op->arg1.osfd; tmp_pfd.events = op->event; + wait_for_remaining = PR_TRUE; msecs = (PRInt32)PR_IntervalToMilliseconds(remaining); if (msecs > PT_DEFAULT_POLL_MSEC) + { + wait_for_remaining = PR_FALSE; msecs = PT_DEFAULT_POLL_MSEC; + } rv = poll(&tmp_pfd, 1, msecs); if (self->state & PT_THREAD_ABORTED) @@ -654,7 +695,12 @@ static void pt_poll_now(pt_Continuation *op) } else if ((rv == 0) || ((errno == EINTR) || (errno == EAGAIN))) { if (rv == 0) /* poll timed out */ - now += PR_MillisecondsToInterval(msecs); + { + if (wait_for_remaining) + now += remaining; + else + now += PR_MillisecondsToInterval(msecs); + } else now = PR_IntervalNow(); elapsed = (PRIntervalTime) (now - epoch); @@ -1024,17 +1070,18 @@ static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents) ssize_t count; count = SOLARIS_SENDFILEV(op->arg1.osfd, vec, op->arg3.amount, &xferred); - PR_ASSERT((count == -1) || (count == xferred)); - PR_ASSERT(xferred <= op->nbytes_to_send); op->syserrno = errno; + PR_ASSERT((count == -1) || (count == xferred)); if (count == -1) { - if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) { + if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN + && op->syserrno != EINTR) { op->result.code = -1; return PR_TRUE; } count = xferred; } + PR_ASSERT(count <= op->nbytes_to_send); op->result.code += count; if (count < op->nbytes_to_send) { @@ -1059,7 +1106,34 @@ static PRBool pt_solaris_sendfile_cont(pt_Continuation *op, PRInt16 revents) } #endif /* SOLARIS */ -void _PR_InitIO() +#ifdef LINUX +static PRBool pt_linux_sendfile_cont(pt_Continuation *op, PRInt16 revents) +{ + ssize_t rv; + off_t oldoffset; + + oldoffset = op->offset; + rv = sendfile(op->arg1.osfd, op->in_fd, &op->offset, op->count); + op->syserrno = errno; + + if (rv == -1) { + if (op->syserrno != EWOULDBLOCK && op->syserrno != EAGAIN) { + op->result.code = -1; + return PR_TRUE; + } + rv = 0; + } + PR_ASSERT(rv == op->offset - oldoffset); + op->result.code += rv; + if (rv < op->count) { + op->count -= rv; + return PR_FALSE; + } + return PR_TRUE; +} +#endif /* LINUX */ + +void _PR_InitIO(void) { #if defined(DEBUG) memset(&pt_debug, 0, sizeof(PTDebug)); @@ -1080,6 +1154,26 @@ void _PR_InitIO() _pr_stderr = pt_SetMethods(2, PR_DESC_FILE, PR_FALSE, PR_TRUE); PR_ASSERT(_pr_stdin && _pr_stdout && _pr_stderr); +#ifdef DARWIN + /* In Mac OS X v10.3 Panther Beta the IPV6_V6ONLY socket option + * is turned on by default, contrary to what RFC 3493, Section + * 5.3 says. So we have to turn it off. Find out whether we + * are running on such a system. + */ + { + int osfd; + osfd = socket(AF_INET6, SOCK_STREAM, 0); + if (osfd != -1) { + int on; + int optlen = sizeof(on); + if (getsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, + &on, &optlen) == 0) { + _pr_ipv6_v6only_on_by_default = on; + } + close(osfd); + } + } +#endif } /* _PR_InitIO */ void _PR_CleanupIO(void) @@ -1569,6 +1663,18 @@ static PRFileDesc* pt_Accept( if (pt_TestAbort()) return newfd; +#ifdef _PR_STRICT_ADDR_LEN + if (addr) + { + /* + * Set addr->raw.family just so that we can use the + * PR_NETADDR_SIZE macro. + */ + addr->raw.family = fd->secret->af; + addr_len = PR_NETADDR_SIZE(addr); + } +#endif + osfd = accept(fd->secret->md.osfd, (struct sockaddr*)addr, &addr_len); syserrno = errno; @@ -1614,6 +1720,14 @@ static PRFileDesc* pt_Accept( { PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE); PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE); +#ifdef LINUX + /* + * On Linux, experiments showed that the accepted sockets + * inherit the TCP_NODELAY socket option of the listening + * socket. + */ + newfd->secret->md.tcp_nodelay = fd->secret->md.tcp_nodelay; +#endif } return newfd; @@ -2107,7 +2221,7 @@ static PRInt32 pt_AIXSendFile(PRFileDesc *sd, PRSendFileData *sfd, } if (count == -1) { - _MD_aix_map_sendfile_error(syserrno); + pt_MapError(_MD_aix_map_sendfile_error, syserrno); return -1; } if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) { @@ -2146,14 +2260,16 @@ static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, PRInt32 count; int syserrno; - /* Get file size */ - if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) { - _PR_MD_MAP_FSTAT_ERROR(errno); - return -1; + if (sfd->file_nbytes == 0) { + /* Get file size */ + if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) { + _PR_MD_MAP_FSTAT_ERROR(errno); + return -1; + } + file_nbytes_to_send = statbuf.st_size - sfd->file_offset; + } else { + file_nbytes_to_send = sfd->file_nbytes; } - file_nbytes_to_send = (sfd->file_nbytes == 0) ? - statbuf.st_size - sfd->file_offset : - sfd->file_nbytes; nbytes_to_send = sfd->hlen + sfd->tlen + file_nbytes_to_send; hdtrl[0].iov_base = (void *) sfd->header; /* cast away the 'const' */ @@ -2228,7 +2344,7 @@ static PRInt32 pt_HPUXSendFile(PRFileDesc *sd, PRSendFileData *sfd, } if (count == -1) { - _MD_hpux_map_sendfile_error(syserrno); + pt_MapError(_MD_hpux_map_sendfile_error, syserrno); return -1; } if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) { @@ -2358,7 +2474,7 @@ static PRInt32 pt_SolarisSendFile(PRFileDesc *sd, PRSendFileData *sfd, done: if (count == -1) { - _MD_solaris_map_sendfile_error(syserrno); + pt_MapError(_MD_solaris_map_sendfile_error, syserrno); return -1; } if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) { @@ -2425,6 +2541,140 @@ static PRInt32 pt_SolarisDispatchSendFile(PRFileDesc *sd, PRSendFileData *sfd, #endif /* SOLARIS */ +#ifdef LINUX +/* + * pt_LinuxSendFile + * + * Send file sfd->fd across socket sd. If specified, header and trailer + * buffers are sent before and after the file, respectively. + * + * PR_TRANSMITFILE_CLOSE_SOCKET flag - close socket after sending file + * + * return number of bytes sent or -1 on error + * + * This implementation takes advantage of the sendfile() system + * call available in Linux kernel 2.2 or higher. + */ + +static PRInt32 pt_LinuxSendFile(PRFileDesc *sd, PRSendFileData *sfd, + PRTransmitFileFlags flags, PRIntervalTime timeout) +{ + struct stat statbuf; + size_t file_nbytes_to_send; + PRInt32 count = 0; + ssize_t rv; + int syserrno; + off_t offset; + PRBool tcp_cork_enabled = PR_FALSE; + int tcp_cork; + + if (sfd->file_nbytes == 0) { + /* Get file size */ + if (fstat(sfd->fd->secret->md.osfd, &statbuf) == -1) { + _PR_MD_MAP_FSTAT_ERROR(errno); + return -1; + } + file_nbytes_to_send = statbuf.st_size - sfd->file_offset; + } else { + file_nbytes_to_send = sfd->file_nbytes; + } + + if ((sfd->hlen != 0 || sfd->tlen != 0) + && sd->secret->md.tcp_nodelay == 0) { + tcp_cork = 1; + if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, + &tcp_cork, sizeof tcp_cork) == 0) { + tcp_cork_enabled = PR_TRUE; + } else { + syserrno = errno; + if (syserrno != EINVAL) { + _PR_MD_MAP_SETSOCKOPT_ERROR(syserrno); + return -1; + } + /* + * The most likely reason for the EINVAL error is that + * TCP_NODELAY is set (with a function other than + * PR_SetSocketOption). This is not fatal, so we keep + * on going. + */ + PR_LOG(_pr_io_lm, PR_LOG_WARNING, + ("pt_LinuxSendFile: " + "setsockopt(TCP_CORK) failed with EINVAL\n")); + } + } + + if (sfd->hlen != 0) { + count = PR_Send(sd, sfd->header, sfd->hlen, 0, timeout); + if (count == -1) { + goto failed; + } + } + + if (file_nbytes_to_send != 0) { + offset = sfd->file_offset; + do { + rv = sendfile(sd->secret->md.osfd, sfd->fd->secret->md.osfd, + &offset, file_nbytes_to_send); + } while (rv == -1 && (syserrno = errno) == EINTR); + if (rv == -1) { + if (syserrno != EAGAIN && syserrno != EWOULDBLOCK) { + _MD_linux_map_sendfile_error(syserrno); + count = -1; + goto failed; + } + rv = 0; + } + PR_ASSERT(rv == offset - sfd->file_offset); + count += rv; + + if (rv < file_nbytes_to_send) { + pt_Continuation op; + + op.arg1.osfd = sd->secret->md.osfd; + op.in_fd = sfd->fd->secret->md.osfd; + op.offset = offset; + op.count = file_nbytes_to_send - rv; + op.result.code = count; + op.timeout = timeout; + op.function = pt_linux_sendfile_cont; + op.event = POLLOUT | POLLPRI; + count = pt_Continue(&op); + syserrno = op.syserrno; + if (count == -1) { + pt_MapError(_MD_linux_map_sendfile_error, syserrno); + goto failed; + } + } + } + + if (sfd->tlen != 0) { + rv = PR_Send(sd, sfd->trailer, sfd->tlen, 0, timeout); + if (rv == -1) { + count = -1; + goto failed; + } + count += rv; + } + +failed: + if (tcp_cork_enabled) { + tcp_cork = 0; + if (setsockopt(sd->secret->md.osfd, SOL_TCP, TCP_CORK, + &tcp_cork, sizeof tcp_cork) == -1 && count != -1) { + _PR_MD_MAP_SETSOCKOPT_ERROR(errno); + count = -1; + } + } + if (count != -1) { + if (flags & PR_TRANSMITFILE_CLOSE_SOCKET) { + PR_Close(sd); + } + PR_ASSERT(count == sfd->hlen + sfd->tlen + file_nbytes_to_send); + } + return count; +} +#endif /* LINUX */ + #ifdef AIX extern int _pr_aix_send_file_use_disabled; #endif @@ -2465,6 +2715,8 @@ static PRInt32 pt_SendFile( #else return(pt_SolarisDispatchSendFile(sd, sfd, flags, timeout)); #endif /* HAVE_SENDFILEV */ +#elif defined(LINUX) + return(pt_LinuxSendFile(sd, sfd, flags, timeout)); #else return(PR_EmulateSendFile(sd, sfd, flags, timeout)); #endif @@ -2728,6 +2980,12 @@ static PRStatus pt_SetSocketOption(PRFileDesc *fd, const PRSocketOptionData *dat rv = setsockopt( fd->secret->md.osfd, level, name, (char*)&value, sizeof(PRIntn)); +#ifdef LINUX + /* for pt_LinuxSendFile */ + if (name == TCP_NODELAY && rv == 0) { + fd->secret->md.tcp_nodelay = value; + } +#endif break; } case PR_SockOpt_McastLoopback: @@ -3086,27 +3344,27 @@ static PRFileDesc *pt_SetMethods( return fd; } /* pt_SetMethods */ -PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods() +PR_IMPLEMENT(const PRIOMethods*) PR_GetFileMethods(void) { return &_pr_file_methods; } /* PR_GetFileMethods */ -PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods() +PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods(void) { return &_pr_pipe_methods; } /* PR_GetPipeMethods */ -PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods() +PR_IMPLEMENT(const PRIOMethods*) PR_GetTCPMethods(void) { return &_pr_tcp_methods; } /* PR_GetTCPMethods */ -PR_IMPLEMENT(const PRIOMethods*) PR_GetUDPMethods() +PR_IMPLEMENT(const PRIOMethods*) PR_GetUDPMethods(void) { return &_pr_udp_methods; } /* PR_GetUDPMethods */ -static const PRIOMethods* PR_GetSocketPollFdMethods() +static const PRIOMethods* PR_GetSocketPollFdMethods(void) { return &_pr_socketpollfd_methods; } /* PR_GetSocketPollFdMethods */ @@ -3116,11 +3374,6 @@ PR_IMPLEMENT(PRFileDesc*) PR_AllocFileDesc( { PRFileDesc *fd = _PR_Getfd(); - /* - * Assert that the file descriptor is small enough to fit in the - * fd_set passed to select - */ - PR_ASSERT(osfd < FD_SETSIZE); if (NULL == fd) goto failed; fd->methods = methods; @@ -3149,12 +3402,18 @@ PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket() { PRInt32 osfd; - osfd = socket(AF_INET6, SOCK_STREAM, 0); - if (osfd != -1) { - close(osfd); - return PR_TRUE; - } - return PR_FALSE; + /* + * HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001) + * suggests that we call open("/dev/ip6", O_RDWR) to determine + * whether IPv6 APIs and the IPv6 stack are on the system. + * Our portable test below seems to work fine, so I am using it. + */ + osfd = socket(AF_INET6, SOCK_STREAM, 0); + if (osfd != -1) { + close(osfd); + return PR_TRUE; + } + return PR_FALSE; } #endif /* _PR_INET6_PROBE */ #endif @@ -3203,9 +3462,20 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) if (osfd == -1) pt_MapError(_PR_MD_MAP_SOCKET_ERROR, errno); else { +#ifdef DARWIN + if ((domain == AF_INET6) && _pr_ipv6_v6only_on_by_default) + { + int on = 0; + (void)setsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, + &on, sizeof(on)); + } +#endif fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE); if (fd == NULL) close(osfd); } +#ifdef _PR_STRICT_ADDR_LEN + if (fd != NULL) fd->secret->af = domain; +#endif #if defined(_PR_INET6_PROBE) || !defined(_PR_INET6) if (fd != NULL) { /* @@ -3598,6 +3868,8 @@ static PRInt32 _pr_poll_with_poll( { /* make poll() ignore this entry */ syspoll[index].fd = -1; + syspoll[index].events = 0; + pds[index].out_flags = 0; } } if (0 == ready) @@ -3805,43 +4077,65 @@ static PRInt32 _pr_poll_with_select( { if (0 == ready) { + PRBool add_to_rd = PR_FALSE; + PRBool add_to_wr = PR_FALSE; + PRBool add_to_ex = PR_FALSE; + selectfd[index] = bottom->secret->md.osfd; if (in_flags_read & PR_POLL_READ) { pds[index].out_flags |= _PR_POLL_READ_SYS_READ; - FD_SET(bottom->secret->md.osfd, &rd); - rdp = &rd; + add_to_rd = PR_TRUE; } if (in_flags_read & PR_POLL_WRITE) { pds[index].out_flags |= _PR_POLL_READ_SYS_WRITE; - FD_SET(bottom->secret->md.osfd, &wr); - wrp = ≀ + add_to_wr = PR_TRUE; } if (in_flags_write & PR_POLL_READ) { pds[index].out_flags |= _PR_POLL_WRITE_SYS_READ; - FD_SET(bottom->secret->md.osfd, &rd); - rdp = &rd; + add_to_rd = PR_TRUE; } if (in_flags_write & PR_POLL_WRITE) { pds[index].out_flags |= _PR_POLL_WRITE_SYS_WRITE; - FD_SET(bottom->secret->md.osfd, &wr); - wrp = ≀ + add_to_wr = PR_TRUE; + } + if (pds[index].in_flags & PR_POLL_EXCEPT) + { + add_to_ex = PR_TRUE; + } + if ((selectfd[index] > maxfd) && + (add_to_rd || add_to_wr || add_to_ex)) + { + maxfd = selectfd[index]; + /* + * If maxfd is too large to be used with + * select, fall back to calling poll. + */ + if (maxfd >= FD_SETSIZE) + break; + } + if (add_to_rd) + { + FD_SET(bottom->secret->md.osfd, &rd); + rdp = &rd; + } + if (add_to_wr) + { + FD_SET(bottom->secret->md.osfd, &wr); + wrp = ≀ + } + if (add_to_ex) + { + FD_SET(bottom->secret->md.osfd, &ex); + exp = &ex; } - if (pds[index].in_flags & PR_POLL_EXCEPT) { - FD_SET(bottom->secret->md.osfd, &ex); - exp = &ex; - } - if ((selectfd[index] > maxfd) && - (pds[index].out_flags || - (pds[index].in_flags & PR_POLL_EXCEPT))) - maxfd = selectfd[index]; } } else @@ -3859,10 +4153,14 @@ static PRInt32 _pr_poll_with_select( } } } + else + { + pds[index].out_flags = 0; + } } if (0 == ready) { - if ((maxfd + 1) > FD_SETSIZE) + if (maxfd >= FD_SETSIZE) { /* * maxfd too large to be used with select, fall back to @@ -4017,14 +4315,14 @@ PR_IMPLEMENT(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags) return &dir->d; } /* PR_ReadDir */ -PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket() +PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket(void) { PRIntn domain = PF_INET; return PR_Socket(domain, SOCK_DGRAM, 0); } /* PR_NewUDPSocket */ -PR_IMPLEMENT(PRFileDesc*) PR_NewTCPSocket() +PR_IMPLEMENT(PRFileDesc*) PR_NewTCPSocket(void) { PRIntn domain = PF_INET; @@ -4122,7 +4420,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable( { return PR_FAILURE; } - fd->secret->inheritable = inheritable; + fd->secret->inheritable = (_PRTriStateBool) inheritable; } return PR_SUCCESS; } @@ -4158,6 +4456,9 @@ PR_IMPLEMENT(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd) if (!_pr_initialized) _PR_ImplicitInitialization(); fd = pt_SetMethods(osfd, PR_DESC_SOCKET_TCP, PR_FALSE, PR_TRUE); if (NULL == fd) close(osfd); +#ifdef _PR_STRICT_ADDR_LEN + if (NULL != fd) fd->secret->af = PF_INET; +#endif return fd; } /* PR_ImportTCPSocket */ @@ -4552,4 +4853,39 @@ retry: } #endif /* defined(_PR_PTHREADS) */ +#ifdef MOZ_UNICODE +/* ================ UTF16 Interfaces ================================ */ +PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16( + const PRUnichar *name, PRIntn flags, PRIntn mode) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +} + +PR_IMPLEMENT(PRStatus) PR_CloseDirUTF16(PRDir *dir) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRDirUTF16*) PR_OpenDirUTF16(const PRUnichar *name) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +} + +PR_IMPLEMENT(PRDirEntryUTF16*) PR_ReadDirUTF16(PRDirUTF16 *dir, PRDirFlags flags) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +} + +PR_IMPLEMENT(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} +/* ================ UTF16 Interfaces ================================ */ +#endif /* MOZ_UNICODE */ + /* ptio.c */ diff --git a/pr/src/pthreads/ptsynch.c b/pr/src/pthreads/ptsynch.c index 4400e8df..17334af3 100644 --- a/pr/src/pthreads/ptsynch.c +++ b/pr/src/pthreads/ptsynch.c @@ -71,6 +71,13 @@ void _PR_InitLocks(void) rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr); PR_ASSERT(0 == rv); +#ifdef LINUX +#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) + rv = pthread_mutexattr_settype(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP); + PR_ASSERT(0 == rv); +#endif +#endif + rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr); PR_ASSERT(0 == rv); } @@ -1041,7 +1048,7 @@ PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock *lock) return (PT_TRYLOCK_SUCCESS == rv) ? PR_SUCCESS : PR_FAILURE; } /* PRP_TryLock */ -PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar() +PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void) { PRCondVar *cv; diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index dc8cc127..7fc2ad4d 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -607,9 +607,9 @@ PR_IMPLEMENT(PRStatus) PR_JoinThread(PRThread *thred) return (0 == rv) ? PR_SUCCESS : PR_FAILURE; } /* PR_JoinThread */ -PR_IMPLEMENT(void) PR_DetachThread() { } /* PR_DetachThread */ +PR_IMPLEMENT(void) PR_DetachThread(void) { } /* PR_DetachThread */ -PR_IMPLEMENT(PRThread*) PR_GetCurrentThread() +PR_IMPLEMENT(PRThread*) PR_GetCurrentThread(void) { void *thred; @@ -724,25 +724,25 @@ PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread *thred) return PR_SUCCESS; } /* PR_Interrupt */ -PR_IMPLEMENT(void) PR_ClearInterrupt() +PR_IMPLEMENT(void) PR_ClearInterrupt(void) { PRThread *me = PR_CurrentThread(); me->state &= ~PT_THREAD_ABORTED; } /* PR_ClearInterrupt */ -PR_IMPLEMENT(void) PR_BlockInterrupt() +PR_IMPLEMENT(void) PR_BlockInterrupt(void) { PRThread *me = PR_CurrentThread(); _PT_THREAD_BLOCK_INTERRUPT(me); } /* PR_BlockInterrupt */ -PR_IMPLEMENT(void) PR_UnblockInterrupt() +PR_IMPLEMENT(void) PR_UnblockInterrupt(void) { PRThread *me = PR_CurrentThread(); _PT_THREAD_UNBLOCK_INTERRUPT(me); } /* PR_UnblockInterrupt */ -PR_IMPLEMENT(PRStatus) PR_Yield() +PR_IMPLEMENT(PRStatus) PR_Yield(void) { static PRBool warning = PR_TRUE; if (warning) warning = _PR_Obsolete( @@ -908,7 +908,7 @@ void _PR_InitThreads( PR_SetThreadPriority(thred, priority); } /* _PR_InitThreads */ -PR_IMPLEMENT(PRStatus) PR_Cleanup() +PR_IMPLEMENT(PRStatus) PR_Cleanup(void) { PRThread *me = PR_CurrentThread(); PR_LOG(_pr_thread_lm, PR_LOG_MIN, ("PR_Cleanup: shutting down NSPR")); @@ -920,7 +920,12 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup() PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT); PR_Unlock(pt_book.ml); + _PR_CleanupMW(); + _PR_CleanupDtoa(); + _PR_CleanupCallOnce(); + _PR_ShutdownLinker(); _PR_LogCleanup(); + _PR_CleanupNet(); /* Close all the fd's before calling _PR_CleanupIO */ _PR_CleanupIO(); @@ -1026,7 +1031,7 @@ static void null_signal_handler(PRIntn sig); * conflict with the use of these two signals in our GC support. * So we don't know how to support GC on Linux pthreads. */ -static void init_pthread_gc_support() +static void init_pthread_gc_support(void) { PRIntn rv; @@ -1066,14 +1071,14 @@ static void init_pthread_gc_support() #endif /* defined(_PR_DCETHREADS) */ } -PR_IMPLEMENT(void) PR_SetThreadGCAble() +PR_IMPLEMENT(void) PR_SetThreadGCAble(void) { PR_Lock(pt_book.ml); PR_CurrentThread()->state |= PT_THREAD_GCABLE; PR_Unlock(pt_book.ml); } -PR_IMPLEMENT(void) PR_ClearThreadGCAble() +PR_IMPLEMENT(void) PR_ClearThreadGCAble(void) { PR_Lock(pt_book.ml); PR_CurrentThread()->state &= (~PT_THREAD_GCABLE); @@ -1086,12 +1091,6 @@ static PRBool suspendAllOn = PR_FALSE; static PRBool suspendAllSuspended = PR_FALSE; -/* Are all GCAble threads (except gc'ing thread) suspended? */ -PR_IMPLEMENT(PRBool) PR_SuspendAllSuspended() -{ - return suspendAllSuspended; -} /* PR_SuspendAllSuspended */ - PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg) { PRIntn count = 0; @@ -1215,7 +1214,7 @@ static void suspend_signal_handler(PRIntn sig) while (me->suspend & PT_THREAD_SUSPENDED) { #if !defined(FREEBSD) && !defined(NETBSD) && !defined(OPENBSD) \ - && !defined(BSDI) && !defined(VMS) && !defined(UNIXWARE) /*XXX*/ + && !defined(BSDI) && !defined(VMS) && !defined(UNIXWARE) && !defined(DARWIN) /*XXX*/ PRIntn rv; sigwait(&sigwait_set, &rv); #endif @@ -1242,12 +1241,12 @@ static void suspend_signal_handler(PRIntn sig) ("End suspend_signal_handler thred = %X tid = %X\n", me, me->id)); } /* suspend_signal_handler */ -static void PR_SuspendSet(PRThread *thred) +static void pt_SuspendSet(PRThread *thred) { PRIntn rv; PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("PR_SuspendSet thred %X thread id = %X\n", thred, thred->id)); + ("pt_SuspendSet thred %X thread id = %X\n", thred, thred->id)); /* @@ -1257,7 +1256,7 @@ static void PR_SuspendSet(PRThread *thred) PR_ASSERT((thred->suspend & PT_THREAD_SUSPENDED) == 0); PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("doing pthread_kill in PR_SuspendSet thred %X tid = %X\n", + ("doing pthread_kill in pt_SuspendSet thred %X tid = %X\n", thred, thred->id)); #if defined(VMS) rv = thread_suspend(thred); @@ -1267,10 +1266,10 @@ static void PR_SuspendSet(PRThread *thred) PR_ASSERT(0 == rv); } -static void PR_SuspendTest(PRThread *thred) +static void pt_SuspendTest(PRThread *thred) { PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("Begin PR_SuspendTest thred %X thread id = %X\n", thred, thred->id)); + ("Begin pt_SuspendTest thred %X thread id = %X\n", thred, thred->id)); /* @@ -1296,13 +1295,13 @@ static void PR_SuspendTest(PRThread *thred) #endif PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("End PR_SuspendTest thred %X tid %X\n", thred, thred->id)); -} /* PR_SuspendTest */ + ("End pt_SuspendTest thred %X tid %X\n", thred, thred->id)); +} /* pt_SuspendTest */ -PR_IMPLEMENT(void) PR_ResumeSet(PRThread *thred) +static void pt_ResumeSet(PRThread *thred) { PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("PR_ResumeSet thred %X thread id = %X\n", thred, thred->id)); + ("pt_ResumeSet thred %X thread id = %X\n", thred, thred->id)); /* * Clear the global state and set the thread state so that it will @@ -1322,12 +1321,12 @@ PR_IMPLEMENT(void) PR_ResumeSet(PRThread *thred) #endif #endif -} /* PR_ResumeSet */ +} /* pt_ResumeSet */ -PR_IMPLEMENT(void) PR_ResumeTest(PRThread *thred) +static void pt_ResumeTest(PRThread *thred) { PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, - ("Begin PR_ResumeTest thred %X thread id = %X\n", thred, thred->id)); + ("Begin pt_ResumeTest thred %X thread id = %X\n", thred, thred->id)); /* * Wait for the threads resume state to change @@ -1351,12 +1350,12 @@ PR_IMPLEMENT(void) PR_ResumeTest(PRThread *thred) thred->suspend &= ~PT_THREAD_RESUMED; PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ( - "End PR_ResumeTest thred %X tid %X\n", thred, thred->id)); -} /* PR_ResumeTest */ + "End pt_ResumeTest thred %X tid %X\n", thred, thred->id)); +} /* pt_ResumeTest */ static pthread_once_t pt_gc_support_control = PTHREAD_ONCE_INIT; -PR_IMPLEMENT(void) PR_SuspendAll() +PR_IMPLEMENT(void) PR_SuspendAll(void) { #ifdef DEBUG PRIntervalTime stime, etime; @@ -1379,7 +1378,7 @@ PR_IMPLEMENT(void) PR_SuspendAll() while (thred != NULL) { if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) - PR_SuspendSet(thred); + pt_SuspendSet(thred); thred = thred->next; } @@ -1388,7 +1387,7 @@ PR_IMPLEMENT(void) PR_SuspendAll() while (thred != NULL) { if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) - PR_SuspendTest(thred); + pt_SuspendTest(thred); thred = thred->next; } @@ -1402,7 +1401,7 @@ PR_IMPLEMENT(void) PR_SuspendAll() #endif } /* PR_SuspendAll */ -PR_IMPLEMENT(void) PR_ResumeAll() +PR_IMPLEMENT(void) PR_ResumeAll(void) { #ifdef DEBUG PRIntervalTime stime, etime; @@ -1421,7 +1420,7 @@ PR_IMPLEMENT(void) PR_ResumeAll() while (thred != NULL) { if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) - PR_ResumeSet(thred); + pt_ResumeSet(thred); thred = thred->next; } @@ -1429,7 +1428,7 @@ PR_IMPLEMENT(void) PR_ResumeAll() while (thred != NULL) { if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) - PR_ResumeTest(thred); + pt_ResumeTest(thred); thred = thred->next; } diff --git a/pr/src/threads/combined/prucpu.c b/pr/src/threads/combined/prucpu.c index d9159b52..3d575d6c 100644 --- a/pr/src/threads/combined/prucpu.c +++ b/pr/src/threads/combined/prucpu.c @@ -59,7 +59,8 @@ static PRUintn _pr_cpuID; static void PR_CALLBACK _PR_CPU_Idle(void *); -static _PRCPU *_PR_CreateCPU(PRThread *thread, PRBool needQueue); +static _PRCPU *_PR_CreateCPU(void); +static PRStatus _PR_StartCPU(_PRCPU *cpu, PRThread *thread); #if !defined(_PR_LOCAL_THREADS_ONLY) static void _PR_RunCPU(void *arg); @@ -69,6 +70,9 @@ void _PR_InitCPUs() { PRThread *me = _PR_MD_CURRENT_THREAD(); + if (_native_threads_only) + return; + _pr_cpuID = 0; _MD_NEW_LOCK( &_pr_cpuLock); #if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY) @@ -80,13 +84,13 @@ void _PR_InitCPUs() #ifdef _PR_LOCAL_THREADS_ONLY #ifdef HAVE_CUSTOM_USER_THREADS - if (!_native_threads_only) - _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me); + _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(me); #endif /* Now start the first CPU. */ - _pr_primordialCPU = _PR_CreateCPU(me, PR_TRUE); + _pr_primordialCPU = _PR_CreateCPU(); _pr_numCPU = 1; + _PR_StartCPU(_pr_primordialCPU, me); _PR_MD_SET_CURRENT_CPU(_pr_primordialCPU); @@ -97,21 +101,47 @@ void _PR_InitCPUs() #else /* Combined MxN model */ + _pr_primordialCPU = _PR_CreateCPU(); + _pr_numCPU = 1; _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, - me, + _pr_primordialCPU, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0, _PR_IDLE_THREAD); - _PR_MD_WAIT(me, PR_INTERVAL_NO_TIMEOUT); #endif /* _PR_LOCAL_THREADS_ONLY */ _PR_MD_INIT_CPUS(); } +#ifdef WINNT +/* + * Right now this function merely stops the CPUs and does + * not do any other cleanup. + * + * It is only implemented for WINNT because bug 161998 only + * affects the WINNT version of NSPR, but it would be nice + * to implement this function for other platforms too. + */ +void _PR_CleanupCPUs(void) +{ + PRUintn i; + PRCList *qp; + _PRCPU *cpu; + + _pr_cpus_exit = 1; + for (i = 0; i < _pr_numCPU; i++) { + _PR_MD_WAKEUP_WAITER(NULL); + } + for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) { + cpu = _PR_CPU_PTR(qp); + _PR_MD_JOIN_THREAD(&cpu->thread->md); + } +} +#endif static _PRCPUQueue *_PR_CreateCPUQueue(void) { @@ -137,89 +167,113 @@ static _PRCPUQueue *_PR_CreateCPUQueue(void) /* * Create a new CPU. + * + * This function initializes enough of the _PRCPU structure so + * that it can be accessed safely by a global thread or another + * CPU. This function does not create the native thread that + * will run the CPU nor does it initialize the parts of _PRCPU + * that must be initialized by that native thread. + * + * The reason we cannot simply have the native thread create + * and fully initialize a new CPU is that we need to be able to + * create a usable _pr_primordialCPU in _PR_InitCPUs without + * assuming that the primordial CPU thread we created can run + * during NSPR initialization. For example, on Windows while + * new threads can be created by DllMain, they won't be able + * to run during DLL initialization. If NSPR is initialized + * by DllMain, the primordial CPU thread won't run until DLL + * initialization is finished. */ -static _PRCPU *_PR_CreateCPU(PRThread *thread, PRBool needQueue) +static _PRCPU *_PR_CreateCPU(void) { _PRCPU *cpu; - /* - ** Create a new cpu. The assumption this code makes is that the - ** underlying operating system creates a stack to go with the new - ** native thread. That stack will be used by the cpu when pausing. - */ cpu = PR_NEWZAP(_PRCPU); if (cpu) { - cpu->last_clock = PR_IntervalNow(); - - if (needQueue == PR_TRUE) - cpu->queue = _PR_CreateCPUQueue(); - else - cpu->queue = _PR_MD_CURRENT_CPU()->queue; - + cpu->queue = _PR_CreateCPUQueue(); if (!cpu->queue) { PR_DELETE(cpu); return NULL; } - - /* Before we create any threads on this CPU we have to - * set the current CPU - */ - _PR_MD_SET_CURRENT_CPU(cpu); - _PR_MD_INIT_RUNNING_CPU(cpu); - thread->cpu = cpu; - - if (!_native_threads_only) { - - cpu->idle_thread = _PR_CreateThread(PR_SYSTEM_THREAD, - _PR_CPU_Idle, - (void *)cpu, - PR_PRIORITY_NORMAL, - PR_LOCAL_THREAD, - PR_UNJOINABLE_THREAD, - 0, - _PR_IDLE_THREAD); - - if (!cpu->idle_thread) { - /* didn't clean up CPU queue XXXMB */ - PR_DELETE(cpu); - return NULL; - } - cpu->idle_thread->cpu = cpu; - - cpu->idle_thread->no_sched = 0; - } - - cpu->thread = thread; - - if (_pr_cpu_affinity_mask) - PR_SetThreadAffinityMask(thread, _pr_cpu_affinity_mask); - - /* Created a new CPU */ - _PR_CPU_LIST_LOCK(); - cpu->id = _pr_cpuID++; - PR_APPEND_LINK(&cpu->links, &_PR_CPUQ()); - _PR_CPU_LIST_UNLOCK(); - } + } return cpu; } +/* + * Start a new CPU. + * + * 'cpu' is a _PRCPU structure created by _PR_CreateCPU(). + * 'thread' is the native thread that will run the CPU. + * + * If this function fails, 'cpu' is destroyed. + */ +static PRStatus _PR_StartCPU(_PRCPU *cpu, PRThread *thread) +{ + /* + ** Start a new cpu. The assumption this code makes is that the + ** underlying operating system creates a stack to go with the new + ** native thread. That stack will be used by the cpu when pausing. + */ + + PR_ASSERT(!_native_threads_only); + + cpu->last_clock = PR_IntervalNow(); + + /* Before we create any threads on this CPU we have to + * set the current CPU + */ + _PR_MD_SET_CURRENT_CPU(cpu); + _PR_MD_INIT_RUNNING_CPU(cpu); + thread->cpu = cpu; + + cpu->idle_thread = _PR_CreateThread(PR_SYSTEM_THREAD, + _PR_CPU_Idle, + (void *)cpu, + PR_PRIORITY_NORMAL, + PR_LOCAL_THREAD, + PR_UNJOINABLE_THREAD, + 0, + _PR_IDLE_THREAD); + + if (!cpu->idle_thread) { + /* didn't clean up CPU queue XXXMB */ + PR_DELETE(cpu); + return PR_FAILURE; + } + PR_ASSERT(cpu->idle_thread->cpu == cpu); + + cpu->idle_thread->no_sched = 0; + + cpu->thread = thread; + + if (_pr_cpu_affinity_mask) + PR_SetThreadAffinityMask(thread, _pr_cpu_affinity_mask); + + /* Created and started a new CPU */ + _PR_CPU_LIST_LOCK(); + cpu->id = _pr_cpuID++; + PR_APPEND_LINK(&cpu->links, &_PR_CPUQ()); + _PR_CPU_LIST_UNLOCK(); + + return PR_SUCCESS; +} + #if !defined(_PR_GLOBAL_THREADS_ONLY) && !defined(_PR_LOCAL_THREADS_ONLY) /* ** This code is used during a cpu's initial creation. */ static void _PR_RunCPU(void *arg) { - _PRCPU *cpu; + _PRCPU *cpu = (_PRCPU *)arg; PRThread *me = _PR_MD_CURRENT_THREAD(); - PRThread *waiter = (PRThread *) arg; PR_ASSERT(NULL != me); /* - * _PR_CreateCPU calls _PR_CreateThread to create the + * _PR_StartCPU calls _PR_CreateThread to create the * idle thread. Because _PR_CreateThread calls PR_Lock, * the current thread has to remain a global thread - * during the _PR_CreateCPU call so that it can wait for + * during the _PR_StartCPU call so that it can wait for * the lock if the lock is held by another thread. If * we clear the _PR_GLOBAL_SCOPE flag in * _PR_MD_CREATE_PRIMORDIAL_THREAD, the current thread @@ -227,7 +281,7 @@ static void _PR_RunCPU(void *arg) * waiting for the lock because the CPU is not fully * constructed yet. * - * After the CPU is created, it is safe to mark the + * After the CPU is started, it is safe to mark the * current thread as a local thread. */ @@ -236,7 +290,7 @@ static void _PR_RunCPU(void *arg) #endif me->no_sched = 1; - cpu = _PR_CreateCPU(me, PR_TRUE); + _PR_StartCPU(cpu, me); #ifdef HAVE_CUSTOM_USER_THREADS me->flags &= (~_PR_GLOBAL_SCOPE); @@ -246,12 +300,6 @@ static void _PR_RunCPU(void *arg) _PR_MD_SET_CURRENT_THREAD(cpu->thread); me->cpu = cpu; - if (waiter) { - _pr_primordialCPU = cpu; - _pr_numCPU = 1; - _PR_MD_WAKEUP_WAITER(waiter); - } - while(1) { PRInt32 is; if (!_PR_IS_NATIVE_THREAD(me)) _PR_INTSOFF(is); @@ -309,6 +357,12 @@ static void PR_CALLBACK _PR_CPU_Idle(void *_cpu) /* Wait for an IO to complete */ (void)_PR_MD_PAUSE_CPU(timeout); +#ifdef WINNT + if (_pr_cpus_exit) { + /* _PR_CleanupCPUs tells us to exit */ + _PR_MD_END_THREAD(); + } +#endif #if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY) #ifdef _PR_HAVE_ATOMIC_OPS @@ -344,7 +398,8 @@ PR_IMPLEMENT(void) PR_SetConcurrency(PRUintn numCPUs) #else /* combined, MxN thread model */ PRUintn newCPU; - PRThread *cpu; + _PRCPU *cpu; + PRThread *thr; if (!_pr_initialized) _PR_ImplicitInitialization(); @@ -360,9 +415,10 @@ PR_IMPLEMENT(void) PR_SetConcurrency(PRUintn numCPUs) _PR_CPU_LIST_UNLOCK(); for (; newCPU; newCPU--) { - cpu = _PR_CreateThread(PR_SYSTEM_THREAD, + cpu = _PR_CreateCPU(); + thr = _PR_CreateThread(PR_SYSTEM_THREAD, _PR_RunCPU, - NULL, + cpu, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, diff --git a/pr/src/threads/combined/pruthr.c b/pr/src/threads/combined/pruthr.c index 77236df1..cbdfd2c0 100644 --- a/pr/src/threads/combined/pruthr.c +++ b/pr/src/threads/combined/pruthr.c @@ -85,7 +85,6 @@ PRThread *suspendAllThread = NULL; extern PRCList _pr_active_global_threadQ; extern PRCList _pr_active_local_threadQ; -extern _PRCPU *_pr_primordialCPU; static void _PR_DecrActiveThreadCount(PRThread *thread); static PRThread *_PR_AttachThread(PRThreadType, PRThreadPriority, PRThreadStack *); @@ -1510,6 +1509,18 @@ PR_IMPLEMENT(PRThread*) PR_AttachThread(PRThreadType type, PR_IMPLEMENT(void) PR_DetachThread(void) { + /* + * On IRIX and Windows, foreign threads are detached when + * they terminate. + */ +#if !defined(IRIX) && !defined(WIN32) + PRThread *me; + if (_pr_initialized) { + me = _MD_GET_ATTACHED_THREAD(); + if ((me != NULL) && (me->flags & _PR_ATTACHED)) + _PRI_DetachThread(); + } +#endif } void _PRI_DetachThread(void) diff --git a/pr/src/threads/prcthr.c b/pr/src/threads/prcthr.c index 71dafca4..ff4c2364 100644 --- a/pr/src/threads/prcthr.c +++ b/pr/src/threads/prcthr.c @@ -55,8 +55,6 @@ extern PRLock *_pr_sleeplock; /* allocated and initialized in prinit */ */ void _PR_CleanupThread(PRThread *thread) { - PRUintn i; - /* Free up per-thread-data */ _PR_DestroyThreadPrivate(thread); diff --git a/pr/src/threads/prtpd.c b/pr/src/threads/prtpd.c index 42139329..6d8fd416 100644 --- a/pr/src/threads/prtpd.c +++ b/pr/src/threads/prtpd.c @@ -88,7 +88,7 @@ static PRThreadPrivateDTOR *_pr_tpd_destructors = NULL; /* ** Initialize the thread private data manipulation */ -void _PR_InitTPD() +void _PR_InitTPD(void) { _pr_tpd_destructors = (PRThreadPrivateDTOR*) PR_CALLOC(_PR_TPD_LIMIT * sizeof(PRThreadPrivateDTOR*)); diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index 7e8dbaf7..17105b4e 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -45,10 +45,6 @@ include $(topsrcdir)/config/config.mk DIRS = dll -ifeq ($(OS_TARGET),OS2) -OS_CFLAGS = $(OS_EXE_CFLAGS) -endif - CSRCS = \ accept.c \ acceptread.c \ @@ -98,6 +94,7 @@ CSRCS = \ joinuu.c \ layer.c \ lazyinit.c \ + libfilename.c \ lltest.c \ lock.c \ lockfile.c \ @@ -221,19 +218,23 @@ TARGETS = $(PROGS) INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private ifeq ($(OS_ARCH), WINNT) +ifdef NS_USE_GCC + EXTRA_LIBS += -lws2_32 +else + EXTRA_LIBS += wsock32.lib LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO ifdef PROFILE LDOPTS += -PROFILE -MAP endif # profile +endif # NS_USE_GCC endif ifeq ($(OS_ARCH),OS2) ifeq ($(MOZ_OS2_TOOLS),VACPP) LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO else -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) - LDOPTS = -Zlinker /PM:VIO -endif + EXTRA_LIBS = $(OS_LIBS) + LDOPTS = -Zmtd -Zomf -Zlinker /PM:VIO -Zlinker /ST:0x30000 endif endif @@ -296,8 +297,10 @@ endif ifeq ($(OS_ARCH), HP-UX) LDOPTS += -z -Wl,+s,+b,$(ABSOLUTE_LIB_DIR) ifeq ($(USE_64),1) - LDOPTS += +DA2.0W - EXTRA_LIBS = -lpthread + LDOPTS += +DD64 + endif + ifeq ($(USE_PTHREADS),1) + EXTRA_LIBS = $(LIBPTHREAD) endif endif @@ -480,11 +483,11 @@ else $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH), WINNT) - link $(LDOPTS) $(EXTRA_LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) wsock32.lib -out:$@ +ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) + link $(LDOPTS) $(EXTRA_LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -out:$@ else -ifeq ($(OS_ARCH),OS2) - $(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(OS_LIBS) $(EXTRA_LIBS) +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(LD) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(OS_LIBS) $(EXTRA_LIBS) else $(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -o $@ endif # OS/2 diff --git a/pr/tests/affinity.c b/pr/tests/affinity.c index 513775f7..ee78434a 100644 --- a/pr/tests/affinity.c +++ b/pr/tests/affinity.c @@ -40,6 +40,7 @@ #include #include +#ifndef XP_BEOS /* * Test PR_GetThreadAffinityMask @@ -109,3 +110,12 @@ 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 f13d7f3f..a17b31f5 100644 --- a/pr/tests/attach.c +++ b/pr/tests/attach.c @@ -329,19 +329,25 @@ int main(int argc, char **argv) #elif defined(OS2) +# ifdef __EMX__ + threadID = (TID) _beginthread((void *)threadStartFunc, NULL, + 32768, NULL); +# else threadID = (TID) _beginthread((void(* _Optlink)(void*))threadStartFunc, NULL, 32768, NULL); +# endif if (threadID == -1) { fprintf(stderr, "thread creation failed: error code %d\n", errno); - failed_already=1; - goto exit_now; + failed_already=1; + goto exit_now; } rv = DosWaitThread(&threadID, DCWW_WAIT); - if (debug_mode)PR_ASSERT(rv == NO_ERROR); - else if (rv == NO_ERROR) { - failed_already=1; - goto exit_now; - } + if (debug_mode) { + PR_ASSERT(rv == NO_ERROR); + } else if (rv != NO_ERROR) { + failed_already=1; + goto exit_now; + } #elif defined(XP_BEOS) diff --git a/pr/tests/dll/Makefile.in b/pr/tests/dll/Makefile.in index cd0cca6e..38ad5b8e 100644 --- a/pr/tests/dll/Makefile.in +++ b/pr/tests/dll/Makefile.in @@ -64,7 +64,11 @@ ifeq ($(OS_ARCH), WINNT) ifeq ($(OS_TARGET), WIN16) # do nothing else +ifdef NS_USE_GCC +DLLBASE=-Wl,--image-base -Wl,0x30000000 +else DLLBASE=/BASE:0x30000000 +endif RES=$(OBJDIR)/my.res RESNAME=../../../pr/src/nspr.rc endif diff --git a/pr/tests/libfilename.c b/pr/tests/libfilename.c new file mode 100644 index 00000000..4be50b09 --- /dev/null +++ b/pr/tests/libfilename.c @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 2003 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the + * terms of the GNU General Public License Version 2 or later (the + * "GPL"), in which case the provisions of the GPL are applicable + * instead of those above. If you wish to allow use of your + * version of this file only under the terms of the GPL and not to + * allow others to use your version of this file under the MPL, + * indicate your decision by deleting the provisions above and + * replace them with the notice and other provisions required by + * the GPL. If you do not delete the provisions above, a recipient + * may use your version of this file under either the MPL or the + * GPL. + */ + +/*********************************************************************** +** +** Name: libfilename.c +** +** Description: test PR_GetLibraryFilePathname. +** +***********************************************************************/ + +#include "nspr.h" +#include "pprio.h" +#include +#include +#include + +PRBool debug_mode = PR_FALSE; + +static PRStatus RunTest(const char *name, PRFuncPtr addr) +{ + char *pathname; + PRFileDesc *fd; + + pathname = PR_GetLibraryFilePathname(name, addr); + if (pathname == NULL) { + fprintf(stderr, "PR_GetLibraryFilePathname failed\n"); + /* we let this test pass if this function is not implemented */ + if (PR_GetError() == PR_NOT_IMPLEMENTED_ERROR) { + return PR_SUCCESS; + } + return PR_FAILURE; + } + + if (debug_mode) printf("Pathname is %s\n", pathname); + fd = PR_OpenFile(pathname, PR_RDONLY, 0); + if (fd == NULL) { + fprintf(stderr, "PR_Open failed: %d\n", (int)PR_GetError()); + return PR_FAILURE; + } + if (PR_Close(fd) == PR_FAILURE) { + fprintf(stderr, "PR_Close failed: %d\n", (int)PR_GetError()); + return PR_FAILURE; + } + PR_Free(pathname); + return PR_SUCCESS; +} + +int main(int argc, char *argv[]) +{ + char *name; + PRFuncPtr addr; + PRLibrary *lib; + PRBool failed = PR_FALSE; + + if (argc >= 2 && strcmp(argv[1], "-d") == 0) { + debug_mode = PR_TRUE; + } + + /* First test a library that is implicitly linked. */ +#ifdef WINNT + name = PR_Malloc(strlen("libnspr4.dll")+1); + strcpy(name, "libnspr4.dll"); +#else + name = PR_GetLibraryName(NULL, "nspr4"); +#endif + addr = (PRFuncPtr)PR_GetTCPMethods()->close; + if (RunTest(name, addr) == PR_FAILURE) { + failed = PR_TRUE; + } + PR_FreeLibraryName(name); + + /* Next test a library that is dynamically loaded. */ + name = PR_GetLibraryName("dll", "my"); + if (debug_mode) printf("Loading library %s\n", name); + lib = PR_LoadLibrary(name); + if (!lib) { + fprintf(stderr, "PR_LoadLibrary failed\n"); + exit(1); + } + PR_FreeLibraryName(name); + name = PR_GetLibraryName(NULL, "my"); + addr = PR_FindFunctionSymbol(lib, "My_GetValue"); + if (RunTest(name, addr) == PR_FAILURE) { + failed = PR_TRUE; + } + PR_FreeLibraryName(name); + PR_UnloadLibrary(lib); + if (failed) { + printf("FAIL\n"); + return 1; + } + printf("PASS\n"); + return 0; +} diff --git a/pr/tests/macbuild/NSPR20TestApp.mcp b/pr/tests/macbuild/NSPR20TestApp.mcp deleted file mode 100644 index aad1a297..00000000 Binary files a/pr/tests/macbuild/NSPR20TestApp.mcp and /dev/null differ diff --git a/pr/tests/runtests.ksh b/pr/tests/runtests.ksh index c4d027ad..6c64cb4a 100755 --- a/pr/tests/runtests.ksh +++ b/pr/tests/runtests.ksh @@ -39,7 +39,7 @@ SYSTEM_INFO=`uname -a` OS_ARCH=`uname -s` -if [ $OS_ARCH = "Windows_NT" ] +if [ $OS_ARCH = "Windows_NT" ] || [ $OS_ARCH = "OS/2" ] then NULL_DEVICE=nul else @@ -132,6 +132,7 @@ joinuk joinuu layer lazyinit +libfilename lltest lock lockfile @@ -224,7 +225,7 @@ echo "\nNSPR Test Results - $OBJDIR\n" echo "BEGIN\t\t\t`date`" echo "NSPR_TEST_LOGFILE\t${LOGFILE}\n" echo "Test\t\t\tResult\n" -if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] ; then +if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] || [ $OS_PLATFORM = "OS/2" ] ; then for prog in $TESTS do echo "$prog\c" @@ -254,7 +255,7 @@ else fi wait $test_pid test_rval=$? - [ sleep_pid -eq 0 ] || kill $sleep_pid >/dev/null 2>&1 + [ $sleep_pid -eq 0 ] || kill $sleep_pid >/dev/null 2>&1 if [ 0 = $test_rval ] ; then echo "\t\t\tPassed"; else diff --git a/pr/tests/runtests.sh b/pr/tests/runtests.sh new file mode 100755 index 00000000..959b5d50 --- /dev/null +++ b/pr/tests/runtests.sh @@ -0,0 +1,287 @@ +#!/bin/sh +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape Portable Runtime (NSPR). +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1998-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# + +# +# tests.ksh +# korn shell script for nspr tests +# + +SYSTEM_INFO=`uname -a` +OS_ARCH=`uname -s` +if [ $OS_ARCH = "Windows_NT" ] || [ $OS_ARCH = "OS/2" ] +then + NULL_DEVICE=nul +else + NULL_DEVICE=/dev/null +fi + +# +# Irrevelant tests +# +#bug1test - used to demonstrate a bug on NT +#bigfile2 - requires 4Gig file creation. See BugZilla #5451 +#bigfile3 - requires 4Gig file creation. See BugZilla #5451 +#dbmalloc - obsolete; originally for testing debug version of nspr's malloc +#dbmalloc1 - obsolete; originally for testing debug version of nspr's malloc +#depend - obsolete; used to test a initial spec for library dependencies +#dceemu - used to tests special functions in NSPR for DCE emulation +#ipv6 - IPV6 not in use by NSPR clients +#mbcs - tests use of multi-byte charset for filenames. See BugZilla #25140 +#sproc_ch - obsolete; sproc-based tests for Irix +#sproc_p - obsolete; sproc-based tests for Irix +#io_timeoutk - obsolete; subsumed in io_timeout +#io_timeoutu - obsolete; subsumed in io_timeout +#prftest1 - obsolete; subsumed by prftest +#prftest2 - obsolete; subsumed by prftest +#prselect - obsolete; PR_Select is obsolete +#select2 - obsolete; PR_Select is obsolete +#sem - obsolete; PRSemaphore is obsolete +#stat - for OS2? +#suspend - private interfaces PR_SuspendAll, PR_ResumeAll, etc.. +#thruput - needs to be run manually as client/server +#time - used to measure time with native calls and nspr calls +#tmoacc - should be run with tmocon +#tmocon - should be run with tmoacc +#op_noacc - limited use +#yield - limited use for PR_Yield + +# +# Tests not run (but should) +# + +#forktest (failed on IRIX) +#nbconn - fails on some platforms +#poll_er - fails on some platforms? limited use? +#prpoll - the bad-FD test needs to be moved to a different test +#sleep - specific to OS/2 + +LOGFILE=${NSPR_TEST_LOGFILE:-$NULL_DEVICE} + +# +# Tests run on all platforms +# + +TESTS=" +accept +acceptread +acceptreademu +affinity +alarm +anonfm +atomic +attach +bigfile +cleanup +cltsrv +concur +cvar +cvar2 +dlltest +dtoa +errcodes +exit +fdcach +fileio +foreign +fsync +gethost +getproto +i2l +initclk +inrval +instrumt +intrio +intrupt +io_timeout +ioconthr +join +joinkk +joinku +joinuk +joinuu +layer +lazyinit +libfilename +lltest +lock +lockfile +logger +many_cv +multiwait +nameshm1 +nblayer +nonblock +ntioto +ntoh +op_2long +op_excl +op_filnf +op_filok +op_nofil +parent +peek +perf +pipeping +pipeping2 +pipeself +poll_nm +poll_to +pollable +prftest +primblok +provider +prpollml +ranfile +randseed +rwlocktest +sel_spd +selct_er +selct_nm +selct_to +selintr +sema +semaerr +semaping +sendzlf +server_test +servr_kk +servr_uk +servr_ku +servr_uu +short_thread +sigpipe +socket +sockopt +sockping +sprintf +stack +stdio +str2addr +strod +switch +system +testbit +testfile +threads +timemac +timetest +tpd +udpsrv +vercheck +version +writev +xnotify +zerolen" + +rval=0 + + +# +# When set, value of the environment variable TEST_TIMEOUT is the maximum +# time (secs) allowed for a test program beyond which it is terminated. +# If TEST_TIMEOUT is not set or if it's value is 0, then test programs +# don't timeout. +# +# Running runtests.ksh under MKS toolkit on NT, 95, 98 does not cause +# timeout detection correctly. For these platforms, do not attempt timeout +# test. (lth). +# +# + +OS_PLATFORM=`uname` +OBJDIR=`basename $PWD` +printf "\nNSPR Test Results - $OBJDIR\n\n" +printf "BEGIN\t\t\t`date`\n" +printf "NSPR_TEST_LOGFILE\t${LOGFILE}\n\n" +printf "Test\t\t\tResult\n\n" +if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] || [ $OS_PLATFORM = "OS/2" ] ; then + for prog in $TESTS + do + printf "$prog" + printf "\nBEGIN TEST: $prog\n\n" >> ${LOGFILE} 2>&1 + ./$prog >> ${LOGFILE} 2>&1 + if [ 0 = $? ] ; then + printf "\t\t\tPassed\n"; + else + printf "\t\t\tFAILED\n"; + rval=1 + fi; + printf "\nEND TEST: $prog\n\n" >> ${LOGFILE} 2>&1 + done +else + for prog in $TESTS + do + printf "$prog" + printf "\nBEGIN TEST: $prog\n\n" >> ${LOGFILE} 2>&1 + export test_rval + ./$prog >> ${LOGFILE} 2>&1 & + test_pid=$! + sleep_pid=0 + if test -n "$TEST_TIMEOUT" && test "$TEST_TIMEOUT" -gt 0 + then + (sleep $TEST_TIMEOUT; kill $test_pid >/dev/null 2>&1 ) & + sleep_pid=$! + fi + wait $test_pid + test_rval=$? + [ $sleep_pid -eq 0 ] || kill $sleep_pid >/dev/null 2>&1 + if [ 0 = $test_rval ] ; then + printf "\t\t\tPassed\n"; + else + printf "\t\t\tFAILED\n"; + rval=1 + fi; + printf "\nEND TEST: $prog\n\n" >> ${LOGFILE} 2>&1 + done +fi; + +printf "END\t\t\t`date`\n" +exit $rval + + + + + + + + + + + + + + + + + diff --git a/pr/tests/sigpipe.c b/pr/tests/sigpipe.c index 2c708e29..28e7e251 100644 --- a/pr/tests/sigpipe.c +++ b/pr/tests/sigpipe.c @@ -69,7 +69,7 @@ int main(void) #endif #include -int main(void) +static void Test(void *arg) { #ifdef XP_OS2 HFILE pipefd[2]; @@ -79,9 +79,6 @@ int main(void) int rv; char c = '\0'; - /* This initializes NSPR. */ - PR_SetError(0, 0); - #ifdef XP_OS2 if (DosCreatePipe(&pipefd[0], &pipefd[1], 4096) != 0) { #else @@ -103,6 +100,27 @@ int main(void) } close(pipefd[1]); printf("write to broken pipe failed with EPIPE, as expected\n"); +} + +int main(void) +{ + PRThread *thread; + + /* This initializes NSPR. */ + PR_SetError(0, 0); + + thread = PR_CreateThread(PR_USER_THREAD, Test, NULL, PR_PRIORITY_NORMAL, + PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0); + if (thread == NULL) { + fprintf(stderr, "PR_CreateThread failed\n"); + exit(1); + } + if (PR_JoinThread(thread) == PR_FAILURE) { + fprintf(stderr, "PR_JoinThread failed\n"); + exit(1); + } + Test(NULL); + printf("PASSED\n"); return 0; } diff --git a/pr/tests/thrpool_server.c b/pr/tests/thrpool_server.c index df56560e..e10dd5bd 100644 --- a/pr/tests/thrpool_server.c +++ b/pr/tests/thrpool_server.c @@ -54,6 +54,13 @@ #include #endif +/* for getcwd */ +#if defined(XP_UNIX) || defined (XP_OS2_EMX) || defined(XP_BEOS) +#include +#elif defined(XP_PC) +#include +#endif + #ifdef WIN32 #include #endif diff --git a/pr/tests/vercheck.c b/pr/tests/vercheck.c index 4235a832..9cec4302 100644 --- a/pr/tests/vercheck.c +++ b/pr/tests/vercheck.c @@ -49,12 +49,13 @@ #include /* - * This release (4.2) is backward compatible with the - * 4.0.x and 4.1.x releases. It, of course, is compatible + * This release (4.3) is backward compatible with the + * 4.0.x, 4.1.x, and 4.2.x releases. It, of course, is compatible * with itself. */ static char *compatible_version[] = { - "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3", PR_VERSION + "4.0", "4.0.1", "4.1", "4.1.1", "4.1.2", "4.1.3", + "4.2", "4.2.1", "4.2.2", PR_VERSION }; /* @@ -69,8 +70,8 @@ static char *incompatible_version[] = { "3.0", "3.0.1", "3.1", "3.1.1", "3.1.2", "3.1.3", "3.5", "3.5.1", - "4.2.3", - "4.3", "4.3.1", + "4.3.3", + "4.4", "4.4.1", "10.0", "11.1", "12.14.20" }; -- cgit v1.2.1