From 375e2a3d45acc831bccd36227b8d72c146f9b010 Mon Sep 17 00:00:00 2001 From: cvs2hg Date: Sun, 10 Dec 2000 15:23:14 +0000 Subject: fixup commit for branch 'DARIN_AsyncWrite_20001227_BRANCH' --- Makefile | 5 + Makefile.in | 8 + config/BSD_OS.mk | 4 +- config/BeOS.mk | 1 + config/Linux.mk | 6 +- config/Makefile.in | 4 + config/NTO.mk | 6 +- config/NetBSD.mk | 21 +- config/OS2.mk | 9 +- config/OpenBSD.mk | 4 +- config/Rhapsody.mk | 17 +- config/UNIX.mk | 1 + config/WIN32.mk | 8 +- config/arch.mk | 14 +- config/autoconf.mk.in | 4 + config/config.mk | 8 + config/rules.mk | 12 + config/win16.mk | 1 + configure | 514 +++++++++++++++------------ configure.in | 148 ++++++-- lib/ds/plhash.c | 45 +++ lib/ds/plhash.h | 7 + lib/libc/src/strccmp.c | 18 +- macbuild/NSPR20PPC.mcp | Bin 97889 -> 153941 bytes macbuild/NSPRConfig.h | 2 +- pr/include/md/_aix32in6.cfg | 3 - pr/include/md/_aix64.cfg | 3 - pr/include/md/_beos.cfg | 2 + pr/include/md/_beos.h | 5 +- pr/include/md/_bsdi.cfg | 2 + pr/include/md/_darwin.cfg | 2 + pr/include/md/_darwin.h | 2 +- pr/include/md/_freebsd.cfg | 2 + pr/include/md/_linux.cfg | 15 +- pr/include/md/_linux.h | 20 +- pr/include/md/_macos.h | 13 + pr/include/md/_netbsd.cfg | 8 +- pr/include/md/_netbsd.h | 115 ++++-- pr/include/md/_nto.cfg | 2 + pr/include/md/_nto.h | 6 +- pr/include/md/_openbsd.cfg | 2 + pr/include/md/_openvms.cfg | 2 + pr/include/md/_openvms.h | 11 + pr/include/md/_os2.cfg | 2 + pr/include/md/_pth.h | 6 +- pr/include/md/_rhapsody.cfg | 2 + pr/include/md/_rhapsody.h | 2 +- pr/include/md/_solaris.h | 23 ++ pr/include/obsolete/protypes.h | 3 +- pr/include/prinit.h | 6 +- pr/include/prio.h | 30 -- pr/include/private/primpl.h | 71 ++++ pr/include/prtypes.h | 8 +- pr/src/Makefile | 14 +- pr/src/Makefile.in | 14 +- pr/src/bthreads/btcvar.c | 64 ++-- pr/src/bthreads/btthread.c | 740 +++++++++++++++++---------------------- pr/src/io/pripv6.c | 32 +- pr/src/io/prlog.c | 35 +- pr/src/io/prprf.c | 4 +- pr/src/io/prsocket.c | 4 +- pr/src/linking/prlink.c | 136 +++++-- pr/src/md/mac/macdll.c | 9 + pr/src/md/mac/macsockotpt.c | 129 ++++--- pr/src/md/mac/mdmac.c | 4 +- pr/src/md/mac/prcpucfg.h | 2 +- pr/src/md/os2/os2io.c | 59 +++- pr/src/md/unix/Makefile | 6 + pr/src/md/unix/Makefile.in | 6 + pr/src/md/unix/darwin.c | 27 +- pr/src/md/unix/objs.mk | 6 + pr/src/md/unix/os_Linux_x86.s | 95 +++++ pr/src/md/unix/rhapsody.c | 27 +- pr/src/md/unix/uxproces.c | 108 +++++- pr/src/md/unix/uxrng.c | 3 +- pr/src/md/unix/uxshm.c | 2 +- pr/src/md/windows/ntinrval.c | 2 +- pr/src/md/windows/ntio.c | 9 +- pr/src/md/windows/w95io.c | 5 +- pr/src/memory/Makefile | 4 + pr/src/memory/Makefile.in | 4 + pr/src/memory/prgcleak.c | 105 ++++++ pr/src/misc/prnetdb.c | 4 +- pr/src/misc/prthinfo.c | 14 +- pr/src/misc/prtime.c | 2 +- pr/src/pthreads/ptio.c | 7 +- pr/src/pthreads/ptsynch.c | 52 ++- pr/src/pthreads/ptthread.c | 53 ++- pr/src/threads/combined/pruthr.c | 8 + pr/tests/Makefile | 2 +- pr/tests/Makefile.in | 2 +- pr/tests/attach.c | 41 ++- pr/tests/ipv6.c | 29 +- pr/tests/tpd.c | 6 +- 94 files changed, 2071 insertions(+), 1039 deletions(-) create mode 100644 pr/src/md/unix/os_Linux_x86.s create mode 100644 pr/src/memory/prgcleak.c diff --git a/Makefile b/Makefile index e92f2d40..8c8d497b 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,11 @@ ifdef PR_CLIENT_BUILD_UNIX endif endif +distclean:: + @echo "cd pr/tests; $(MAKE) $@" + @$(MAKE) -C pr/tests $@ + rm -f config/my_config.mk config/my_overrides.mk + release:: echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df @if test -f imports.df; then \ diff --git a/Makefile.in b/Makefile.in index 8ff221b8..46cfe727 100644 --- a/Makefile.in +++ b/Makefile.in @@ -31,6 +31,8 @@ PR_CLIENT_BUILD = 1 PR_CLIENT_BUILD_UNIX = 1 endif +DIST_GARBAGE = config.cache config.log config.status + include $(topsrcdir)/config/rules.mk # @@ -49,6 +51,12 @@ ifdef PR_CLIENT_BUILD_UNIX endif endif +# Delete config/autoconf.mk last because it is included by every makefile. +distclean:: + @echo "cd pr/tests; $(MAKE) $@" + @$(MAKE) -C pr/tests $@ + rm -f config/autoconf.mk + release:: echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df @if test -f imports.df; then \ diff --git a/config/BSD_OS.mk b/config/BSD_OS.mk index f3d96ffe..dba353db 100644 --- a/config/BSD_OS.mk +++ b/config/BSD_OS.mk @@ -21,7 +21,7 @@ include $(MOD_DEPTH)/config/UNIX.mk -ifeq (,$(filter-out 1.1 4.0 4.0.1,$(OS_RELEASE))) +ifeq (,$(filter-out 1.1 4.%,$(OS_RELEASE))) CC = gcc -Wall -Wno-format CCC = g++ else @@ -64,7 +64,7 @@ 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.0 4.0.1,$(OS_RELEASE))) +ifeq (,$(filter-out 4.%,$(OS_RELEASE))) MKSHLIB = $(CC) $(DSO_LDOPTS) DSO_CFLAGS = -fPIC DSO_LDOPTS = -shared -Wl,-soname,$(@:$(OBJDIR)/%.so=%.so) diff --git a/config/BeOS.mk b/config/BeOS.mk index 87dc2085..ef2a6a46 100644 --- a/config/BeOS.mk +++ b/config/BeOS.mk @@ -30,6 +30,7 @@ OBJ_SUFFIX = o LIB_SUFFIX = a DLL_SUFFIX = so AR = ar cr $@ +STRIP = strip ifdef BUILD_OPT DEFINES = -UDEBUG -DNDEBUG diff --git a/config/Linux.mk b/config/Linux.mk index 29832d08..c7aae11b 100644 --- a/config/Linux.mk +++ b/config/Linux.mk @@ -47,12 +47,10 @@ IMPL_STRATEGY = _PTH DEFINES += -D_REENTRANT endif -USE_IPV6 = 1 - ifeq (86,$(findstring 86,$(OS_TEST))) CPU_ARCH := x86 else -ifeq (,$(filter-out armv4l sa110,$(OS_TEST))) +ifeq (,$(filter-out arm% sa110,$(OS_TEST))) CPU_ARCH := arm else CPU_ARCH := $(OS_TEST) @@ -101,6 +99,8 @@ endif MKSHLIB = $(LD) $(DSO_LDOPTS) -soname $(notdir $@) ifdef BUILD_OPT OPTIMIZER = -O2 +# invoke 'strip' on *.so files in optimized builds +STRIP = strip endif ###################################################################### diff --git a/config/Makefile.in b/config/Makefile.in index a0004143..4302c6e1 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -27,6 +27,10 @@ include $(MOD_DEPTH)/config/autoconf.mk # Indicate that this directory builds build tools. INTERNAL_TOOLS = 1 +# autoconf.mk must be deleted last (from the top-level directory) +# because it is included by every makefile. +DIST_GARBAGE = nsprincl.mk nsprincl.sh + include $(topsrcdir)/config/config.mk CSRCS = nsinstall.c now.c diff --git a/config/NTO.mk b/config/NTO.mk index a0b53ecd..49eee1fe 100644 --- a/config/NTO.mk +++ b/config/NTO.mk @@ -55,7 +55,7 @@ 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) -g2 -M +MKSHLIB = qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M RANLIB = ranlib G++INCLUDES = @@ -63,9 +63,9 @@ OS_LIBS = EXTRA_LIBS = -lsocket ifdef BUILD_OPT -OPTIMIZER = -O2 +OPTIMIZER = -O1 else -OPTIMIZER = -O2 -gdwarf-2 +OPTIMIZER = -O1 -gstabs endif NOSUCHFILE = /no-such-file diff --git a/config/NetBSD.mk b/config/NetBSD.mk index 1aeac473..cb2211ad 100644 --- a/config/NetBSD.mk +++ b/config/NetBSD.mk @@ -25,6 +25,10 @@ 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 @@ -44,20 +48,15 @@ endif ARCH = netbsd +ifeq ($(OBJECT_FMT),ELF) +DLL_SUFFIX = so +else DLL_SUFFIX = so.1.0 +endif -DSO_CFLAGS = -fPIC +DSO_CFLAGS = -fPIC -DPIC DSO_LDFLAGS = -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 +DSO_LDOPTS = -x -shared ifdef LIBRUNPATH DSO_LDOPTS += -R$(LIBRUNPATH) diff --git a/config/OS2.mk b/config/OS2.mk index 3f008cb9..dba3901d 100644 --- a/config/OS2.mk +++ b/config/OS2.mk @@ -49,10 +49,11 @@ 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 /,\\,$@) +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 @@ -67,8 +68,8 @@ LIB_SUFFIX = lib DLL_SUFFIX = dll OBJ_SUFFIX = obj -OS_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge- -OS_EXE_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 +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 diff --git a/config/OpenBSD.mk b/config/OpenBSD.mk index 35d474fd..b3314605 100644 --- a/config/OpenBSD.mk +++ b/config/OpenBSD.mk @@ -35,16 +35,16 @@ endif OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -ansi -Wall -pipe $(THREAD_FLAG) -DOPENBSD -DHAVE_STRERROR -DHAVE_BSD_FLOCK ifeq ($(USE_PTHREADS),1) -OS_LIBS = -lc_r THREAD_FLAG += -pthread # XXX probably should define _THREAD_SAFE too. else -OS_LIBS = -lc DEFINES += -D_PR_LOCAL_THREADS_ONLY endif ARCH = openbsd +DLL_SUFFIX = so.1.0 + DSO_CFLAGS = -fPIC DSO_LDFLAGS = DSO_LDOPTS = -Bshareable diff --git a/config/Rhapsody.mk b/config/Rhapsody.mk index 7f3c9116..afc1352e 100644 --- a/config/Rhapsody.mk +++ b/config/Rhapsody.mk @@ -21,12 +21,19 @@ include $(MOD_DEPTH)/config/UNIX.mk -CC = cc -ifeq ($(OS_RELEASE),5.0) -CCC = cc++ +# +# The default implementation strategy for Rhapsody is pthreads. +# +ifeq ($(CLASSIC_NSPR),1) +IMPL_STRATEGY = _EMU +DEFINES += -D_PR_LOCAL_THREADS_ONLY else -CCC = c++ +USE_PTHREADS = 1 +IMPL_STRATEGY = _PTH endif + +CC = cc +CCC = c++ RANLIB = ranlib ifeq (86,$(findstring 86,$(OS_TEST))) @@ -49,8 +56,6 @@ endif OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wmost -fno-common -pipe -DRHAPSODY -DHAVE_STRERROR -DHAVE_BSD_FLOCK -DEFINES += -D_PR_LOCAL_THREADS_ONLY - ARCH = rhapsody # May override this with -bundle to create a loadable module. diff --git a/config/UNIX.mk b/config/UNIX.mk index b9868973..e3fab8d1 100644 --- a/config/UNIX.mk +++ b/config/UNIX.mk @@ -21,6 +21,7 @@ OBJ_SUFFIX = o LIB_SUFFIX = a DLL_SUFFIX = so AR = ar cr $@ +STRIP = true ifdef BUILD_OPT OPTIMIZER = -O diff --git a/config/WIN32.mk b/config/WIN32.mk index 375c80c3..9121d724 100644 --- a/config/WIN32.mk +++ b/config/WIN32.mk @@ -35,6 +35,7 @@ LINK = link AR = lib -NOLOGO -OUT:"$@" RANLIB = echo BSDECHO = echo +STRIP = echo NSINSTALL = nsinstall INSTALL = $(NSINSTALL) define MAKE_OBJDIR @@ -53,14 +54,7 @@ OS_CFLAGS = -W3 -nologo -GF -Gy ifdef BUILD_OPT OS_CFLAGS += -MD -# The -O2 optimization of MSVC 6.0 SP3 appears to generate -# code that is unsafe for our use of fibers and static thread -# local storage. We temporarily work around this problem by -# turning off global optimizations (-Og). OPTIMIZER = -O2 -ifeq ($(OS_TARGET),WINNT) -OPTIMIZER += -Og- -endif DEFINES = -UDEBUG -U_DEBUG -DNDEBUG DLLFLAGS = -OUT:"$@" OBJDIR_TAG = _OPT diff --git a/config/arch.mk b/config/arch.mk index 67734e44..35a448aa 100644 --- a/config/arch.mk +++ b/config/arch.mk @@ -50,6 +50,9 @@ OS_ARCH := UNIXWARE OS_RELEASE := $(shell uname -v) endif endif +ifeq ($(OS_ARCH),Mac OS) +OS_ARCH := Rhapsody +endif ifeq ($(OS_ARCH),ncr) OS_ARCH := NCR endif @@ -57,10 +60,6 @@ endif ifeq ($(OS_ARCH),NCR) OS_RELEASE := $(shell awk '{print $$3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$$/\2.\3/') endif -ifeq ($(OS_ARCH),procnto) -OS_ARCH := NTO -OS_RELEASE := _$(OS_TEST)$(OS_RELEASE) -endif ifeq ($(OS_ARCH),UNIX_System_V) OS_ARCH := NEC endif @@ -70,7 +69,12 @@ CPU_ARCH := $(shell uname -Wh) OS_RELEASE := $(shell uname -v) endif ifeq ($(OS_ARCH),QNX) -OS_RELEASE := $(shell uname -v | sed 's/^\([0-9]\)\([0-9]*\)$$/\1.\2/') + 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 diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 83b7a86f..c5e24c0b 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -10,6 +10,9 @@ DLL_SUFFIX = @DLL_SUFFIX@ MOD_VERSION = @NSPR_VERSION@ MOD_NAME = @NSPR_MODNAME@ +CROSS_COMPILE = @CROSS_COMPILE@ +BUILD_OPT = @MOZ_OPTIMIZE@ + USE_CPLUS = @USE_CPLUS@ USE_IPV6 = @USE_IPV6@ USE_N32 = @USE_N32@ @@ -32,6 +35,7 @@ PERL = @PERL@ DLLTOOL = @DLLTOOL@ WINDRES = @WINDRES@ RC = $(WINDRES) +STRIP = @STRIP@ OS_CFLAGS = @CFLAGS@ $(DSO_CFLAGS) OS_CXXFLAGS = @CXXFLAGS@ $(DSO_CFLAGS) diff --git a/config/config.mk b/config/config.mk index 4f7863f2..a3c1674d 100644 --- a/config/config.mk +++ b/config/config.mk @@ -75,6 +75,10 @@ endif GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*) +ifdef USE_AUTOCONF +DIST_GARBAGE += Makefile +endif + DEFINES += -DFORCE_PR_LOG ifeq ($(_PR_NO_CLOCK_TIMER),1) @@ -184,6 +188,10 @@ ifeq ($(USE_IPV6),1) OS_CFLAGS += -D_PR_INET6 endif +ifdef GC_LEAK_DETECTOR +OS_CFLAGS += -DGC_LEAK_DETECTOR +endif + #################################################################### # # Configuration for the release process diff --git a/config/rules.mk b/config/rules.mk index b885c33e..0a3dc334 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -61,6 +61,7 @@ include $(topsrcdir)/config/config.mk endif ifdef USE_AUTOCONF +ifdef CROSS_COMPILE ifdef INTERNAL_TOOLS CC=$(HOST_CC) CCC=$(HOST_CXX) @@ -68,6 +69,7 @@ CFLAGS=$(HOST_CFLAGS) CXXFLAGS=$(HOST_CXXFLAGS) endif endif +endif # # This makefile contains rules for building the following kinds of @@ -193,6 +195,10 @@ realclean clobber_all:: rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) +$(LOOP_OVER_DIRS) +distclean:: + rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) $(DIST_GARBAGE) + +$(LOOP_OVER_DIRS) + release:: export ifdef RELEASE_BINS @echo "Copying executable programs and scripts to release directory" @@ -263,6 +269,9 @@ else $(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) endif endif +ifdef BUILD_OPT + $(STRIP) $@ +endif $(LIBRARY): $(OBJS) @$(MAKE_OBJDIR) @@ -349,6 +358,9 @@ endif # OS2 endif # WINNT endif # AIX 4.1 endif # USE_AUTOCONF +ifdef BUILD_OPT + $(STRIP) $@ +endif ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) diff --git a/config/win16.mk b/config/win16.mk index e1cfd938..d47ed561 100644 --- a/config/win16.mk +++ b/config/win16.mk @@ -55,6 +55,7 @@ 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) diff --git a/configure b/configure index 56a87989..01193a95 100755 --- a/configure +++ b/configure @@ -15,7 +15,7 @@ ac_default_prefix=\${MOD_DEPTH}/dist ac_help="$ac_help --with-mozilla Compile NSPR with Mozilla support" ac_help="$ac_help - --enable-optimize Enable code optimizations" + --enable-optimize(=val) Enable code optimizations level (val)" ac_help="$ac_help --disable-debug Do not compile in debugging symbols" ac_help="$ac_help @@ -23,7 +23,7 @@ ac_help="$ac_help ac_help="$ac_help --enable-target=\$t Turn on features for target \$t when build has multiple targets" ac_help="$ac_help - --enable-n32 Enable n32 support (IRIX only)" + --enable-n32 Enable n32 ABI support (IRIX only)" ac_help="$ac_help --enable-64bit Enable 64-bit support (on certain platforms)" ac_help="$ac_help @@ -668,25 +668,6 @@ test "$host_alias" != "$target_alias" && program_prefix=${target_alias}- - - echo $ac_n "checking cached system tuple""... $ac_c" 1>&6 -echo "configure:674: checking cached system tuple" >&5 - if { test x"${ac_cv_host_system_type+set}" = x"set" && - test x"$ac_cv_host_system_type" != x"$host"; } || - { test x"${ac_cv_build_system_type+set}" = x"set" && - test x"$ac_cv_build_system_type" != x"$build"; } || - { test x"${ac_cv_target_system_type+set}" = x"set" && - test x"$ac_cv_target_system_type" != x"$target"; }; then - echo "$ac_t""different" 1>&6 - { echo "configure: error: remove config.cache and re-run configure" 1>&2; exit 1; } - else - echo "$ac_t""ok" 1>&6 - fi - ac_cv_host_system_type="$host" - ac_cv_build_system_type="$build" - ac_cv_target_system_type="$target" - - cat >> confdefs.h <<\EOF #define USE_AUTOCONF 1 @@ -716,6 +697,11 @@ LDFLAGS="${LDFLAGS=}" HOST_CFLAGS="${HOST_CFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" +case "$target" in +*-irix6*) + USE_N32=1 ;; +esac + # Check whether --with-mozilla or --without-mozilla was given. if test "${with_mozilla+set}" = set; then withval="$with_mozilla" @@ -741,7 +727,13 @@ fi # Check whether --enable-optimize or --disable-optimize was given. if test "${enable_optimize+set}" = set; then enableval="$enable_optimize" - MOZ_OPTIMIZE=1 + if test "$enableval" != "no"; then + MOZ_OPTIMIZE=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _OPTIMIZE_FLAGS="$enableval" + _SAVE_OPTIMIZE_FLAGS="$enableval" + fi + fi fi @@ -775,6 +767,9 @@ if test "${enable_n32+set}" = set; then enableval="$enable_n32" if test "$enableval" = "yes"; then USE_N32=1 + else if test "$enableval" = "no"; then + USE_N32= + fi fi fi @@ -800,7 +795,7 @@ fi # Extract the first word of "whoami", so it can be a program name with args. set dummy whoami; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:804: checking for $ac_word" >&5 +echo "configure:799: 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 @@ -860,14 +855,14 @@ if test "$target" != "$host"; then _SAVE_LDFLAGS="$LDFLAGS" echo $ac_n "checking for $host compiler""... $ac_c" 1>&6 -echo "configure:864: checking for $host compiler" >&5 +echo "configure:859: 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:871: checking for $ac_word" >&5 +echo "configure:866: 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 @@ -914,16 +909,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:918: checking whether the $host compiler ($HOST_CC $HOST_CFLAGS $HOST_LDFLAGS) works" >&5 +echo "configure:913: 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:922: \"$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 @@ -944,7 +939,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:948: checking for $ac_word" >&5 +echo "configure:943: 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 @@ -979,7 +974,7 @@ test -n "$CC" || CC=":" # 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:983: checking for $ac_word" >&5 +echo "configure:978: 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 @@ -1009,7 +1004,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:1013: checking for $ac_word" >&5 +echo "configure:1008: 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 @@ -1060,7 +1055,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:1064: checking for $ac_word" >&5 +echo "configure:1059: 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 @@ -1092,7 +1087,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1096: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1091: 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. @@ -1103,12 +1098,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1107 "configure" +#line 1102 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1107: \"$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 @@ -1134,12 +1129,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:1138: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1133: 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:1143: checking whether we are using GNU C" >&5 +echo "configure:1138: 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 @@ -1148,7 +1143,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1152: \"$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:1147: \"$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 @@ -1167,7 +1162,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:1171: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1166: 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 @@ -1204,7 +1199,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:1208: checking for $ac_word" >&5 +echo "configure:1203: 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 @@ -1241,7 +1236,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:1245: checking for $ac_word" >&5 +echo "configure:1240: 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 @@ -1273,7 +1268,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1277: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1272: 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. @@ -1284,12 +1279,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1288 "configure" +#line 1283 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1288: \"$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 @@ -1315,12 +1310,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:1319: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1314: 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:1324: checking whether we are using GNU C++" >&5 +echo "configure:1319: 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 @@ -1329,7 +1324,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1333: \"$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:1328: \"$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 @@ -1348,7 +1343,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:1352: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1347: 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 @@ -1385,7 +1380,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:1389: checking for $ac_word" >&5 +echo "configure:1384: 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 @@ -1422,7 +1417,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:1426: checking for $ac_word" >&5 +echo "configure:1421: 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 @@ -1459,7 +1454,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:1463: checking for $ac_word" >&5 +echo "configure:1458: 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 @@ -1496,7 +1491,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:1500: checking for $ac_word" >&5 +echo "configure:1495: 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 @@ -1526,6 +1521,43 @@ test -n "$LD" && break done test -n "$LD" || LD=":" + fi + if test -z "$STRIP"; then + for ac_prog in "${target_alias}-strip" "${target}-strip" +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:1532: 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 + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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_STRIP="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +STRIP="$ac_cv_prog_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$STRIP" && break +done +test -n "$STRIP" || STRIP=":" + fi if test -z "$DLLTOOL"; then for ac_prog in "${target_alias}-dlltool" "${target}-dlltool" @@ -1533,7 +1565,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:1537: checking for $ac_word" >&5 +echo "configure:1569: 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 @@ -1570,7 +1602,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:1574: checking for $ac_word" >&5 +echo "configure:1606: 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 @@ -1601,11 +1633,12 @@ done test -n "$WINDRES" || WINDRES=":" fi + else # 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:1609: checking for $ac_word" >&5 +echo "configure:1642: 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 @@ -1635,7 +1668,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:1639: checking for $ac_word" >&5 +echo "configure:1672: 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 @@ -1686,7 +1719,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:1690: checking for $ac_word" >&5 +echo "configure:1723: 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 @@ -1718,7 +1751,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1722: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1755: 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. @@ -1729,12 +1762,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1733 "configure" +#line 1766 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1771: \"$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 @@ -1760,12 +1793,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:1764: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1797: 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:1769: checking whether we are using GNU C" >&5 +echo "configure:1802: 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 @@ -1774,7 +1807,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1778: \"$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:1811: \"$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 @@ -1793,7 +1826,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:1797: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1830: 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 @@ -1829,7 +1862,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:1833: checking for $ac_word" >&5 +echo "configure:1866: 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 @@ -1861,7 +1894,7 @@ test -n "$CXX" || CXX="gcc" echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1865: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5 +echo "configure:1898: 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. @@ -1872,12 +1905,12 @@ cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext << EOF -#line 1876 "configure" +#line 1909 "configure" #include "confdefs.h" int main(){return(0);} EOF -if { (eval echo configure:1881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1914: \"$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 @@ -1903,12 +1936,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:1907: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1940: 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:1912: checking whether we are using GNU C++" >&5 +echo "configure:1945: 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 @@ -1917,7 +1950,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1921: \"$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:1954: \"$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 @@ -1936,7 +1969,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:1940: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1973: 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 @@ -1970,7 +2003,7 @@ fi # 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:1974: checking for $ac_word" >&5 +echo "configure:2007: 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 @@ -2002,7 +2035,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:2006: checking for $ac_word" >&5 +echo "configure:2039: 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 @@ -2043,7 +2076,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:2047: checking for $ac_word" >&5 +echo "configure:2080: 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 @@ -2084,7 +2117,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:2088: checking for $ac_word" >&5 +echo "configure:2121: 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 @@ -2120,12 +2153,53 @@ test -n "$LD" && break done test -n "$LD" || LD=":" + for ac_prog in strip +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:2162: 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 + case "$STRIP" in + /*) + ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_STRIP="$STRIP" # 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_STRIP="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + ;; +esac +fi +STRIP="$ac_cv_path_STRIP" +if test -n "$STRIP"; then + echo "$ac_t""$STRIP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$STRIP" && break +done +test -n "$STRIP" || 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:2129: checking for $ac_word" >&5 +echo "configure:2203: 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 @@ -2166,7 +2240,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:2170: checking for $ac_word" >&5 +echo "configure:2244: 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 @@ -2218,6 +2292,12 @@ if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then fi rm -f a.out +if test "$cross_compiling" = "yes"; then + CROSS_COMPILE=1 +else + CROSS_COMPILE= +fi + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -2230,7 +2310,7 @@ rm -f a.out # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:2234: checking for a BSD compatible install" >&5 +echo "configure:2314: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2283,7 +2363,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:2287: checking whether ln -s works" >&5 +echo "configure:2367: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2308,7 +2388,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:2312: checking for $ac_word" >&5 +echo "configure:2392: 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 @@ -2353,12 +2433,22 @@ PR_MD_ASFILES= PR_MD_CSRCS= PR_MD_ARCH_DIR=unix AR_FLAGS='cr $@' +AS='$(CC)' OS_TARGET=`uname -s` OS_ARCH=`uname -s | sed -e 's|/|_|g'` OS_RELEASE=`uname -r` OS_TEST=`uname -m` +if test "${OS_ARCH}" = "IRIX64"; then + OS_ARCH=IRIX +fi + +if test "${OS_TARGET}" = "IRIX64"; then + OS_TARGET=IRIX +fi + + case "$host" in *-mingw*) ;; @@ -2746,8 +2836,8 @@ EOF PR_MD_CSRCS=irix.c PR_MD_ASFILES=os_Irix.s - MKSHLIB='$(LD) $(SHLIB_LD_OPTS) -rdata_shared -shared -soname $(notdir $@) -o $@' - DSO_LDOPTS='-elf -shared -all' + MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@' + #DSO_LDOPTS='-elf -shared -all' if test -n "$USE_64"; then MDCPUCFG_H=_irix64.cfg else @@ -2758,7 +2848,6 @@ EOF USE_NSPR_THREADS=1 ;; *) - USE_N32=1 USE_PTHREADS=1 ;; esac @@ -2767,7 +2856,11 @@ EOF CFLAGS="$CFLAGS -Wall -Wno-format" _OPTIMIZE_FLAGS="-O6" else - AS="as -D_ASM $(INCLUDES) -n32" + if test -n "$USE_N32"; then + AS='as -D_ASM $(INCLUDES) -n32' + else + AS='as -D_ASM $(INCLUDES)' + fi CFLAGS="$CFLAGS -fullwarn -xansi" if test "$USE_N32"; then _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" @@ -2780,14 +2873,14 @@ EOF case "$target}" in *-irix6.*) CFLAGS="$CFLAGS -multigot" - SHLIB_LD_OPTS="-no_unresolved" - if test "USE_N32"; then + DSO_LDOPTS="-no_unresolved" + if test "$USE_N32"; then CFLAGS="$CFLAGS -n32 -woff 1209" LDFLAGS="$LDFLAGS -n32" - SHLIB_LD_OPTS="$SHLIB_LD_OPTS -n32" + DSO_LDOPTS="$DSO_LDOPTS -n32" if test "${target_os}" = "irix6.2"; then LDFLAGS="$LDFLAGS -Wl,-woff,85" - SHLIB_LD_OPTS="$SHLIB_LD_OPTS -woff 85" + DSO_LDOPTS="$DSO_LDOPTS -woff 85" fi else if test "$USE_64"; then @@ -2891,6 +2984,10 @@ EOF CXXFLAGS="$CXXFLAGS -mieee" _OPTIMIZE_FLAGS=-O2 ;; + i?86) + PR_MD_ASFILES=os_Linux_x86.s + _OPTIMIZE_FLAGS=-O2 + ;; m68k) _OPTIMIZE_FLAGS=-O CFLAGS="$CFLAGS -m68020-40" @@ -2972,11 +3069,11 @@ EOF MDCPUCFG_H=_nto.cfg PR_MD_CSRCS=nto.c - MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -o $(@:$(OBJDIR)/%.so=%.so)' + MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)' CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -DNTO -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared" OS_LIBS="-lsocket" - _OPTIMIZE_FLAGS="-O2" - _DEBUG_FLAGS="-O2 -gdwarf-2" + _OPTIMIZE_FLAGS="-O1" + _DEBUG_FLAGS="-O1 -gstabs" COMPILER_TAG="_qcc" CC="qcc -Vgcc_ntox86 -w" CXX="QCC -Vgcc_ntox86 -w" @@ -3113,7 +3210,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:3117: checking how to run the C preprocessor" >&5 +echo "configure:3214: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -3128,13 +3225,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:3138: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3235: \"$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 : @@ -3145,13 +3242,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:3155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3252: \"$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 : @@ -3162,13 +3259,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:3172: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3269: \"$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 : @@ -3194,13 +3291,13 @@ echo "$ac_t""$CPP" 1>&6 if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:3198: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:3295: 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 @@ -3218,7 +3315,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -3242,12 +3339,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:3246: checking for $ac_func" >&5 +echo "configure:3343: 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:3371: \"$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 @@ -3298,7 +3395,7 @@ done echo $ac_n "checking for pthread_attr_init in -lpthread""... $ac_c" 1>&6 -echo "configure:3302: checking for pthread_attr_init in -lpthread" >&5 +echo "configure:3399: checking for pthread_attr_init in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_attr_init | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3306,7 +3403,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3418: \"$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 @@ -3336,7 +3433,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_attr_init in -lc_r""... $ac_c" 1>&6 -echo "configure:3340: checking for pthread_attr_init in -lc_r" >&5 +echo "configure:3437: checking for pthread_attr_init in -lc_r" >&5 ac_lib_var=`echo c_r'_'pthread_attr_init | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3344,7 +3441,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc_r $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3456: \"$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 @@ -3374,7 +3471,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_attr_init in -lc""... $ac_c" 1>&6 -echo "configure:3378: checking for pthread_attr_init in -lc" >&5 +echo "configure:3475: checking for pthread_attr_init in -lc" >&5 ac_lib_var=`echo c'_'pthread_attr_init | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3382,7 +3479,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3494: \"$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 @@ -3520,7 +3617,7 @@ 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:3524: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:3621: 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 @@ -3533,6 +3630,23 @@ echo "configure:3524: checking whether ${CC-cc} accepts -pthread" >&5 rm -f conftest* echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6 + 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:3637: 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 + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthreads=yes + CFLAGS="$CFLAGS -pthreads" + CXXFLAGS="$CXXFLAGS -pthreads" + fi + fi + rm -f conftest* + echo "$ac_t""$ac_cv_have_dash_pthreads" 1>&6 + fi + case "$target" in *-mingw*|*-cygwin*|*-uwin*) ;; @@ -3541,6 +3655,9 @@ echo "configure:3524: checking whether ${CC-cc} accepts -pthread" >&5 #define _REENTRANT 1 EOF + if test "$ac_cv_have_dash_pthreads" = "yes"; then + PTHREAD_LDFLAGS= + fi ;; *-freebsd*) cat >> confdefs.h <<\EOF @@ -3590,12 +3707,12 @@ EOF esac echo $ac_n "checking for pthread_create""... $ac_c" 1>&6 -echo "configure:3594: checking for pthread_create" >&5 +echo "configure:3711: checking for pthread_create" >&5 if eval "test \"`echo '$''{'ac_cv_func_pthread_create'+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:3739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_pthread_create=yes" else @@ -3637,7 +3754,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:3641: checking for pthread_create in -lpthread" >&5 +echo "configure:3758: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3645,7 +3762,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3777: \"$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 @@ -3755,12 +3872,12 @@ EOF esac echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:3759: checking for dlopen" >&5 +echo "configure:3876: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3904: \"$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 @@ -3802,7 +3919,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:3806: checking for dlopen in -ldl" >&5 +echo "configure:3923: 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 @@ -3810,7 +3927,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:3942: \"$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 @@ -3845,6 +3962,10 @@ fi fi +if test -n "$_SAVE_OPTIMIZE_FLAGS"; then + _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" +fi + if test -n "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" @@ -3915,6 +4036,52 @@ fi + + + + + +MAKEFILES=" +Makefile +config/Makefile +config/autoconf.mk +config/nsprincl.mk +config/nsprincl.sh +lib/Makefile +lib/ds/Makefile +lib/libc/Makefile +lib/libc/include/Makefile +lib/libc/src/Makefile +pr/Makefile +pr/include/Makefile +pr/include/md/Makefile +pr/include/obsolete/Makefile +pr/include/private/Makefile +pr/src/Makefile +pr/src/io/Makefile +pr/src/linking/Makefile +pr/src/malloc/Makefile +pr/src/md/Makefile +pr/src/md/${PR_MD_ARCH_DIR}/Makefile +pr/src/memory/Makefile +pr/src/misc/Makefile +pr/src/threads/Makefile +pr/tests/Makefile +pr/tests/dll/Makefile +" + + +if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile" +elif test -n "$USE_PTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile" +elif test -n "$USE_BTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile" +fi + +if test -n "$USE_CPLUS"; then + MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile" +fi trap '' 1 2 15 cat > confcache <<\EOF @@ -4029,50 +4196,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo " -Makefile -config/Makefile -config/autoconf.mk -config/nsprincl.mk -config/nsprincl.sh -lib/Makefile -lib/ds/Makefile -lib/libc/Makefile -lib/libc/include/Makefile -lib/libc/src/Makefile -lib/msgc/Makefile -lib/msgc/include/Makefile -lib/msgc/src/Makefile -lib/msgc/tests/Makefile -lib/prstreams/Makefile -lib/tests/Makefile -pr/Makefile -pr/include/Makefile -pr/include/md/Makefile -pr/include/obsolete/Makefile -pr/include/private/Makefile -pr/src/Makefile -pr/src/bthreads/Makefile -pr/src/cplus/Makefile -pr/src/cplus/tests/Makefile -pr/src/io/Makefile -pr/src/linking/Makefile -pr/src/malloc/Makefile -pr/src/md/Makefile -pr/src/md/beos/Makefile -pr/src/md/os2/Makefile -pr/src/md/unix/Makefile -pr/src/md/windows/Makefile -pr/src/memory/Makefile -pr/src/misc/Makefile -pr/src/pthreads/Makefile -pr/src/threads/Makefile -pr/src/threads/combined/Makefile -pr/tests/Makefile -pr/tests/dll/Makefile -pr/tests/w16gui/Makefile -tools/Makefile -" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "$MAKEFILES" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then @@ -4328,4 +4413,3 @@ chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - diff --git a/configure.in b/configure.in index aa7fa6a0..b08454c1 100644 --- a/configure.in +++ b/configure.in @@ -31,7 +31,6 @@ fi AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf) AC_CANONICAL_SYSTEM -AC_VALIDATE_CACHED_SYSTEM_TUPLE AC_PREFIX_DEFAULT(\${MOD_DEPTH}/dist) dnl Set this define to make fixes w/o breaking anything else. @@ -71,6 +70,14 @@ LDFLAGS="${LDFLAGS=}" HOST_CFLAGS="${HOST_CFLAGS=}" HOST_LDFLAGS="${HOST_LDFLAGS=}" +dnl ======================================================== +dnl = Irix 6.x should use n32 ABI by default +dnl ======================================================== +case "$target" in +*-irix6*) + USE_N32=1 ;; +esac + dnl ======================================================== dnl = dnl = Check options that may affect the compiler @@ -92,8 +99,14 @@ AC_ARG_WITH(mozilla, fi]) AC_ARG_ENABLE(optimize, - [ --enable-optimize Enable code optimizations], - MOZ_OPTIMIZE=1) + [ --enable-optimize(=val) Enable code optimizations level (val)], + [ if test "$enableval" != "no"; then + MOZ_OPTIMIZE=1 + if test -n "$enableval" && test "$enableval" != "yes"; then + _OPTIMIZE_FLAGS="$enableval" + _SAVE_OPTIMIZE_FLAGS="$enableval" + fi + fi ]) AC_ARG_ENABLE(debug, [ --disable-debug Do not compile in debugging symbols], @@ -110,9 +123,12 @@ AC_ARG_ENABLE(target, MOZ_TARGET=) AC_ARG_ENABLE(n32, - [ --enable-n32 Enable n32 support (IRIX only)], + [ --enable-n32 Enable n32 ABI support (IRIX only)], [ if test "$enableval" = "yes"; then USE_N32=1 + else if test "$enableval" = "no"; then + USE_N32= + fi fi ]) AC_ARG_ENABLE(64bit, @@ -198,12 +214,16 @@ if test "$target" != "$host"; then if test -z "$LD"; then AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :) fi + if test -z "$STRIP"; then + AC_CHECK_PROGS(STRIP, "${target_alias}-strip" "${target}-strip", :) + fi if test -z "$DLLTOOL"; then AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", :) fi if test -z "$WINDRES"; then AC_CHECK_PROGS(WINDRES, "${target_alias}-windres" "${target}-windres", :) fi + else AC_PROG_CC AC_PROG_CXX @@ -211,6 +231,7 @@ else AC_PATH_PROGS(AS, as, $CC) AC_PATH_PROGS(AR, ar, :) AC_PATH_PROGS(LD, ld, :) + AC_PATH_PROGS(STRIP, strip, :) AC_PATH_PROGS(DLLTOOL, dlltool, :) AC_PATH_PROGS(WINDRES, windres, :) if test -z "$HOST_CC"; then @@ -229,6 +250,12 @@ if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then fi rm -f a.out +if test "$cross_compiling" = "yes"; then + CROSS_COMPILE=1 +else + CROSS_COMPILE= +fi + dnl ======================================================== dnl Checks for programs. dnl ======================================================== @@ -247,12 +274,23 @@ PR_MD_ASFILES= PR_MD_CSRCS= PR_MD_ARCH_DIR=unix AR_FLAGS='cr $@' +AS='$(CC)' OS_TARGET=`uname -s` OS_ARCH=`uname -s | sed -e 's|/|_|g'` OS_RELEASE=`uname -r` OS_TEST=`uname -m` +if test "${OS_ARCH}" = "IRIX64"; then + OS_ARCH=IRIX +fi + +if test "${OS_TARGET}" = "IRIX64"; then + OS_TARGET=IRIX +fi + +dnl ======================================================== + dnl ======================================================== dnl Override of system specific host options dnl ======================================================== @@ -475,8 +513,8 @@ case "$target" in AC_DEFINE(_SGI_MP_SOURCE) PR_MD_CSRCS=irix.c PR_MD_ASFILES=os_Irix.s - MKSHLIB='$(LD) $(SHLIB_LD_OPTS) -rdata_shared -shared -soname $(notdir $@) -o $@' - DSO_LDOPTS='-elf -shared -all' + MKSHLIB='$(LD) $(DSO_LDOPTS) -rdata_shared -shared -soname $(notdir $@) -o $@' + #DSO_LDOPTS='-elf -shared -all' if test -n "$USE_64"; then MDCPUCFG_H=_irix64.cfg else @@ -487,7 +525,6 @@ case "$target" in USE_NSPR_THREADS=1 ;; *) - USE_N32=1 USE_PTHREADS=1 ;; esac @@ -496,7 +533,11 @@ case "$target" in CFLAGS="$CFLAGS -Wall -Wno-format" _OPTIMIZE_FLAGS="-O6" else - AS="as -D_ASM $(INCLUDES) -n32" + if test -n "$USE_N32"; then + AS='as -D_ASM $(INCLUDES) -n32' + else + AS='as -D_ASM $(INCLUDES)' + fi CFLAGS="$CFLAGS -fullwarn -xansi" if test "$USE_N32"; then _OPTIMIZE_FLAGS="-O -OPT:Olimit=4000" @@ -509,14 +550,14 @@ case "$target" in case "$target}" in *-irix6.*) CFLAGS="$CFLAGS -multigot" - SHLIB_LD_OPTS="-no_unresolved" - if test "USE_N32"; then + DSO_LDOPTS="-no_unresolved" + if test "$USE_N32"; then CFLAGS="$CFLAGS -n32 -woff 1209" LDFLAGS="$LDFLAGS -n32" - SHLIB_LD_OPTS="$SHLIB_LD_OPTS -n32" + DSO_LDOPTS="$DSO_LDOPTS -n32" if test "${target_os}" = "irix6.2"; then LDFLAGS="$LDFLAGS -Wl,-woff,85" - SHLIB_LD_OPTS="$SHLIB_LD_OPTS -woff 85" + DSO_LDOPTS="$DSO_LDOPTS -woff 85" fi else if test "$USE_64"; then @@ -578,6 +619,10 @@ case "$target" in CXXFLAGS="$CXXFLAGS -mieee" _OPTIMIZE_FLAGS=-O2 ;; + i?86) + PR_MD_ASFILES=os_Linux_x86.s + _OPTIMIZE_FLAGS=-O2 + ;; m68k) _OPTIMIZE_FLAGS=-O CFLAGS="$CFLAGS -m68020-40" @@ -638,11 +683,11 @@ case "$target" in AC_DEFINE(XP_UNIX) MDCPUCFG_H=_nto.cfg PR_MD_CSRCS=nto.c - MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -o $(@:$(OBJDIR)/%.so=%.so)' + MKSHLIB='qcc -Vgcc_ntox86 -shared -Wl,-h$(@:$(OBJDIR)/%.so=%.so) -M -o $(@:$(OBJDIR)/%.so=%.so)' CFLAGS="$CFLAGS -Wc,-Wall -Wc,-Wno-parentheses -DNTO -D_QNX_SOURCE -DHAVE_POINTER_LOCALTIME_R -shared" OS_LIBS="-lsocket" - _OPTIMIZE_FLAGS="-O2" - _DEBUG_FLAGS="-O2 -gdwarf-2" + _OPTIMIZE_FLAGS="-O1" + _DEBUG_FLAGS="-O1 -gstabs" COMPILER_TAG="_qcc" CC="qcc -Vgcc_ntox86 -w" CXX="QCC -Vgcc_ntox86 -w" @@ -906,11 +951,33 @@ if test -n "$USE_PTHREADS"; then rm -f conftest* AC_MSG_RESULT($ac_cv_have_dash_pthread) + dnl + dnl See if -pthreads is supported. + dnl + ac_cv_have_dash_pthreads=no + if test "$ac_cv_have_dash_pthread" = "no"; then + AC_MSG_CHECKING(whether ${CC-cc} accepts -pthreads) + echo 'int main() { return 0; }' | cat > conftest.c + ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 + if test $? -eq 0; then + if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then + ac_cv_have_dash_pthreads=yes + CFLAGS="$CFLAGS -pthreads" + CXXFLAGS="$CXXFLAGS -pthreads" + fi + fi + rm -f conftest* + AC_MSG_RESULT($ac_cv_have_dash_pthreads) + fi + case "$target" in *-mingw*|*-cygwin*|*-uwin*) ;; *-solaris*) AC_DEFINE(_REENTRANT) + if test "$ac_cv_have_dash_pthreads" = "yes"; then + PTHREAD_LDFLAGS= + fi ;; *-freebsd*) AC_DEFINE(_REENTRANT) @@ -1000,6 +1067,12 @@ AC_CHECK_FUNC(dlopen,,[ AC_CHECK_LIB(dl, dlopen, [OS_LIBS="-ldl $OS_LIBS"]) ]) +dnl If the user passed in arg to --enable-optimize, +dnl make sure that we use it. +if test -n "$_SAVE_OPTIMIZE_FLAGS"; then + _OPTIMIZE_FLAGS="$_SAVE_OPTIMIZE_FLAGS" +fi + if test -n "$MOZ_OPTIMIZE"; then CFLAGS="$CFLAGS $_OPTIMIZE_FLAGS" CXXFLAGS="$CXXFLAGS $_OPTIMIZE_FLAGS" @@ -1022,6 +1095,9 @@ AC_SUBST(HOST_CC) AC_SUBST(HOST_CFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(GNU_CC) +AC_SUBST(CROSS_COMPILE) + +AC_SUBST(MOZ_OPTIMIZE) AC_SUBST(USE_CPLUS) AC_SUBST(USE_IPV6) @@ -1065,6 +1141,7 @@ AC_SUBST(DLLTOOL) AC_SUBST(WINDRES) AC_SUBST(RANLIB) AC_SUBST(PERL) +AC_SUBST(STRIP) AC_SUBST(OS_LIBS) AC_SUBST(RESOLVE_LINK_SYMBOLS) @@ -1077,7 +1154,7 @@ AC_SUBST(ULTRASPARC_FILTER_LIBRARY) dnl ======================================================== dnl Generate output files. dnl ======================================================== -AC_OUTPUT([ +MAKEFILES=" Makefile config/Makefile config/autoconf.mk @@ -1088,39 +1165,38 @@ lib/ds/Makefile lib/libc/Makefile lib/libc/include/Makefile lib/libc/src/Makefile -lib/msgc/Makefile -lib/msgc/include/Makefile -lib/msgc/src/Makefile -lib/msgc/tests/Makefile -lib/prstreams/Makefile -lib/tests/Makefile pr/Makefile pr/include/Makefile pr/include/md/Makefile pr/include/obsolete/Makefile pr/include/private/Makefile pr/src/Makefile -pr/src/bthreads/Makefile -pr/src/cplus/Makefile -pr/src/cplus/tests/Makefile pr/src/io/Makefile pr/src/linking/Makefile pr/src/malloc/Makefile pr/src/md/Makefile -pr/src/md/beos/Makefile -pr/src/md/os2/Makefile -pr/src/md/unix/Makefile -pr/src/md/windows/Makefile +pr/src/md/${PR_MD_ARCH_DIR}/Makefile pr/src/memory/Makefile pr/src/misc/Makefile -pr/src/pthreads/Makefile pr/src/threads/Makefile -pr/src/threads/combined/Makefile pr/tests/Makefile pr/tests/dll/Makefile -pr/tests/w16gui/Makefile -tools/Makefile -]) +" + +dnl lib/tests/Makefile +dnl pr/tests/w16gui/Makefile +dnl tools/Makefile + +if test -z "$USE_PTHREADS" && test -z "$USE_BTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/threads/combined/Makefile" +elif test -n "$USE_PTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/pthreads/Makefile" +elif test -n "$USE_BTHREADS"; then + MAKEFILES="$MAKEFILES pr/src/bthreads/Makefile" +fi + +if test -n "$USE_CPLUS"; then + MAKEFILES="$MAKEFILES pr/src/cplus/Makefile pr/src/cplus/tests/Makefile" +fi -dnl lib/prstreams/tests/testprstrm/Makefile -dnl lib/tests/windows/makefile +AC_OUTPUT([$MAKEFILES]) diff --git a/lib/ds/plhash.c b/lib/ds/plhash.c index 30b46fdc..c5837603 100644 --- a/lib/ds/plhash.c +++ b/lib/ds/plhash.c @@ -195,6 +195,34 @@ PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key) return hep; } +/* +** Same as PL_HashTableRawLookup but doesn't reorder the hash entries. +*/ +PR_IMPLEMENT(PLHashEntry **) +PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash, + const void *key) +{ + PLHashEntry *he, **hep; + PLHashNumber h; + +#ifdef HASHMETER + ht->nlookups++; +#endif + h = keyHash * GOLDEN_RATIO; + h >>= ht->shift; + hep = &ht->buckets[h]; + while ((he = *hep) != 0) { + if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) { + break; + } + hep = &he->next; +#ifdef HASHMETER + ht->nsteps++; +#endif + } + return hep; +} + PR_IMPLEMENT(PLHashEntry *) PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash, const void *key, void *value) @@ -348,6 +376,23 @@ PL_HashTableLookup(PLHashTable *ht, const void *key) return 0; } +/* +** Same as PL_HashTableLookup but doesn't reorder the hash entries. +*/ +PR_IMPLEMENT(void *) +PL_HashTableLookupConst(PLHashTable *ht, const void *key) +{ + PLHashNumber keyHash; + PLHashEntry *he, **hep; + + keyHash = (*ht->keyHash)(key); + hep = PL_HashTableRawLookupConst(ht, keyHash, key); + if ((he = *hep) != 0) { + return he->value; + } + return 0; +} + /* ** Iterate over the entries in the hash table calling func for each ** entry found. Stop if "f" says to (return value & PR_ENUMERATE_STOP). diff --git a/lib/ds/plhash.h b/lib/ds/plhash.h index 3110d8ab..e3cd7a63 100644 --- a/lib/ds/plhash.h +++ b/lib/ds/plhash.h @@ -104,6 +104,9 @@ PL_HashTableRemove(PLHashTable *ht, const void *key); PR_EXTERN(void *) PL_HashTableLookup(PLHashTable *ht, const void *key); +PR_EXTERN(void *) +PL_HashTableLookupConst(PLHashTable *ht, const void *key); + PR_EXTERN(PRIntn) PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg); @@ -123,6 +126,10 @@ PL_CompareValues(const void *v1, const void *v2); PR_EXTERN(PLHashEntry **) PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key); +PR_EXTERN(PLHashEntry **) +PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash, + const void *key); + PR_EXTERN(PLHashEntry *) PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash, const void *key, void *value); diff --git a/lib/libc/src/strccmp.c b/lib/libc/src/strccmp.c index 58ba559c..7d1e620c 100644 --- a/lib/libc/src/strccmp.c +++ b/lib/libc/src/strccmp.c @@ -35,7 +35,23 @@ static const unsigned char uc[] = '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', '{', '|', '}', '~', '\177' + 'X', 'Y', 'Z', '{', '|', '}', '~', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377' }; PR_IMPLEMENT(PRIntn) diff --git a/macbuild/NSPR20PPC.mcp b/macbuild/NSPR20PPC.mcp index fa75d4da..ba5ad553 100644 Binary files a/macbuild/NSPR20PPC.mcp and b/macbuild/NSPR20PPC.mcp differ diff --git a/macbuild/NSPRConfig.h b/macbuild/NSPRConfig.h index 07a9783f..36f467a5 100644 --- a/macbuild/NSPRConfig.h +++ b/macbuild/NSPRConfig.h @@ -24,4 +24,4 @@ #define FORCE_PR_LOG 1 #define NSPR20 1 #define NSPR_AS_SHARED_LIB - +#define TARGET_CARBON 0 diff --git a/pr/include/md/_aix32in6.cfg b/pr/include/md/_aix32in6.cfg index 0385e86a..fcaec9d9 100644 --- a/pr/include/md/_aix32in6.cfg +++ b/pr/include/md/_aix32in6.cfg @@ -73,9 +73,6 @@ #undef HAVE_ALIGNED_DOUBLES #undef HAVE_ALIGNED_LONGLONGS -#ifndef _PR_INET6 -#define _PR_INET6 -#endif #define PR_AF_INET6 24 /* same as AF_INET6 */ #ifndef NO_NSPR_10_SUPPORT diff --git a/pr/include/md/_aix64.cfg b/pr/include/md/_aix64.cfg index 59bb1a79..8606ff74 100644 --- a/pr/include/md/_aix64.cfg +++ b/pr/include/md/_aix64.cfg @@ -74,9 +74,6 @@ #undef HAVE_ALIGNED_DOUBLES #undef HAVE_ALIGNED_LONGLONGS -#ifndef _PR_INET6 -#define _PR_INET6 -#endif #define PR_AF_INET6 24 /* same as AF_INET6 */ #ifndef NO_NSPR_10_SUPPORT diff --git a/pr/include/md/_beos.cfg b/pr/include/md/_beos.cfg index a1e3d89d..cbdaecdd 100644 --- a/pr/include/md/_beos.cfg +++ b/pr/include/md/_beos.cfg @@ -27,6 +27,8 @@ #define BEOS #endif +#define PR_AF_INET6 5 /* same as AF_INET6 */ + #ifdef __powerpc__ #undef IS_LITTLE_ENDIAN #define IS_BIG_ENDIAN 1 diff --git a/pr/include/md/_beos.h b/pr/include/md/_beos.h index 8b56dec3..2cb25407 100644 --- a/pr/include/md/_beos.h +++ b/pr/include/md/_beos.h @@ -72,8 +72,9 @@ /* Define threading functions and objects as native BeOS */ struct _MDThread { thread_id tid; /* BeOS thread handle */ - bool is_joinable; /* TRUE if PR_JOINABLE */ - bool is_joining; /* TRUE if we were woken up to join */ + sem_id joinSem; /* sems used to synchronzie joining */ + PRBool is_joining; /* TRUE if someone is currently waiting to + join this thread */ }; struct _MDThreadStack { diff --git a/pr/include/md/_bsdi.cfg b/pr/include/md/_bsdi.cfg index 8a9839a4..5b7fa33f 100644 --- a/pr/include/md/_bsdi.cfg +++ b/pr/include/md/_bsdi.cfg @@ -27,6 +27,8 @@ #define BSDI #endif +#define PR_AF_INET6 24 /* same as AF_INET6 */ + #if defined(__i386__) #define IS_LITTLE_ENDIAN 1 diff --git a/pr/include/md/_darwin.cfg b/pr/include/md/_darwin.cfg index 87a76c95..33da779e 100644 --- a/pr/include/md/_darwin.cfg +++ b/pr/include/md/_darwin.cfg @@ -27,6 +27,8 @@ #define RHAPOSDY #endif +#define PR_AF_INET6 30 /* same as AF_INET6 */ + #if defined(i386) #undef IS_BIG_ENDIAN #define IS_LITTLE_ENDIAN 1 diff --git a/pr/include/md/_darwin.h b/pr/include/md/_darwin.h index d97e6a3c..98a2f1ed 100644 --- a/pr/include/md/_darwin.h +++ b/pr/include/md/_darwin.h @@ -42,8 +42,8 @@ #define USE_MACH_DYLD #define _PR_HAVE_SOCKADDR_LEN #define _PR_STAT_HAS_ST_ATIMESPEC -#define _PR_TIMESPEC_HAS_TS_SEC #define _PR_NO_LARGE_FILES +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY #define USE_SETJMP diff --git a/pr/include/md/_freebsd.cfg b/pr/include/md/_freebsd.cfg index b61641cf..167cf8b6 100644 --- a/pr/include/md/_freebsd.cfg +++ b/pr/include/md/_freebsd.cfg @@ -33,6 +33,8 @@ #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 diff --git a/pr/include/md/_linux.cfg b/pr/include/md/_linux.cfg index 33fa2683..6ad20d1b 100644 --- a/pr/include/md/_linux.cfg +++ b/pr/include/md/_linux.cfg @@ -65,9 +65,9 @@ #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_INT64 8 #define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_DOUBLE 8 #define PR_ALIGN_OF_POINTER 4 #define PR_ALIGN_OF_WORD 4 @@ -359,11 +359,12 @@ #endif #define HAVE_LONG_LONG -/* - * XXX These two macros need to be investigated for different architectures. - */ -#undef HAVE_ALIGNED_DOUBLES -#undef HAVE_ALIGNED_LONGLONGS +#if PR_ALIGN_OF_DOUBLE == 8 +#define HAVE_ALIGNED_DOUBLES +#endif +#if PR_ALIGN_OF_INT64 == 8 +#define HAVE_ALIGNED_LONGLONGS +#endif #ifndef NO_NSPR_10_SUPPORT diff --git a/pr/include/md/_linux.h b/pr/include/md/_linux.h index 11885b41..96905cf2 100644 --- a/pr/include/md/_linux.h +++ b/pr/include/md/_linux.h @@ -59,6 +59,19 @@ #define HAVE_DLL #define USE_DLFCN +#if defined(__i386__) +#define _PR_HAVE_ATOMIC_OPS +#define _MD_INIT_ATOMIC() +extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val); +#define _MD_ATOMIC_INCREMENT _PR_x86_AtomicIncrement +extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val); +#define _MD_ATOMIC_DECREMENT _PR_x86_AtomicDecrement +extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val); +#define _MD_ATOMIC_ADD _PR_x86_AtomicAdd +extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval); +#define _MD_ATOMIC_SET _PR_x86_AtomicSet +#endif + #define USE_SETJMP #if defined(__GLIBC__) && __GLIBC__ >= 2 #define _PR_POLL_AVAILABLE @@ -70,7 +83,8 @@ #else #define _PR_NO_LARGE_FILES #endif -#ifdef _PR_INET6 +#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) +#define _PR_INET6 #define _PR_HAVE_GETHOSTBYNAME2 #define _PR_INET6_PROBE #endif @@ -97,11 +111,11 @@ extern void _MD_CleanupBeforeExit(void); * On the PowerPC, the new style jmp_buf isn't used until glibc * 2.1. */ -#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 +#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1] #else #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0] -#endif /* __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 */ +#endif /* glibc 2.1 or later */ #define _MD_SET_FP(_t, val) #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) #define _MD_GET_FP_PTR(_t) ((void *) 0) diff --git a/pr/include/md/_macos.h b/pr/include/md/_macos.h index cf38977f..5bb4d72d 100644 --- a/pr/include/md/_macos.h +++ b/pr/include/md/_macos.h @@ -382,6 +382,19 @@ extern char* _MD_ReadDir(struct _MDDir *md,PRIntn flags); ** Socket I/O Related definitions */ +#if UNIVERSAL_INTERFACES_VERSION >= 0x0330 +/* In Universal Interfaces 3.3 and later, these are enums. */ +#define IP_TTL IP_TTL +#define IP_TOS IP_TOS +#define IP_ADD_MEMBERSHIP IP_ADD_MEMBERSHIP +#define IP_DROP_MEMBERSHIP IP_DROP_MEMBERSHIP +#define IP_MULTICAST_IF IP_MULTICAST_IF +#define IP_MULTICAST_TTL IP_MULTICAST_TTL +#define IP_MULTICAST_LOOP IP_MULTICAST_LOOP +#define TCP_NODELAY TCP_NODELAY +#define TCP_MAXSEG TCP_MAXSEG +#endif + #define _MD_SOCKET _MD_socket #define _MD_BIND _MD_bind #define _MD_LISTEN _MD_listen diff --git a/pr/include/md/_netbsd.cfg b/pr/include/md/_netbsd.cfg index ef52198e..92a0b81c 100644 --- a/pr/include/md/_netbsd.cfg +++ b/pr/include/md/_netbsd.cfg @@ -27,7 +27,9 @@ #define NETBSD #endif -#if defined(__i386__) || defined(__arm32__) +#define PR_AF_INET6 24 /* same as AF_INET6 */ + +#if defined(__i386__) || defined(__arm32__) || defined(__MIPSEL__) #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN @@ -73,9 +75,9 @@ #define PR_ALIGN_OF_DOUBLE 4 #define PR_ALIGN_OF_POINTER 4 -#elif defined(__sparc__) || defined(__mips__) +#elif defined(__sparc__) || defined(__MIPSEB__) -#undef IS_LITTLE_ENDIAN 1 +#undef IS_LITTLE_ENDIAN #define IS_BIG_ENDIAN 1 #define HAVE_LONG_LONG #define HAVE_ALIGNED_DOUBLES diff --git a/pr/include/md/_netbsd.h b/pr/include/md/_netbsd.h index 49aca74b..8edc6ab9 100644 --- a/pr/include/md/_netbsd.h +++ b/pr/include/md/_netbsd.h @@ -20,6 +20,7 @@ #define nspr_netbsd_defs_h___ #include +#include /* for __NetBSD_Version__ */ #define PR_LINKER_ARCH "netbsd" #define _PR_SI_SYSNAME "NetBSD" @@ -39,7 +40,11 @@ #define _PR_SI_ARCHITECTURE "arm32" #endif +#if defined(__ELF__) +#define PR_DLL_SUFFIX ".so" +#else #define PR_DLL_SUFFIX ".so.1.0" +#endif #define _PR_VMBASE 0x30000000 #define _PR_STACK_VMBASE 0x50000000 @@ -52,6 +57,8 @@ #define _PR_HAVE_SOCKADDR_LEN #define _PR_NO_LARGE_FILES #define _PR_STAT_HAS_ST_ATIMESPEC +#define _PR_POLL_AVAILABLE +#define _PR_USE_POLL #define _PR_HAVE_SYSV_SEMAPHORES #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY @@ -64,40 +71,89 @@ #define CONTEXT(_th) ((_th)->md.context) -#if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__) -#define JB_SP_INDEX 2 -#elif defined(__mips__) -#define JB_SP_INDEX 4 -#elif defined(__alpha__) -#define JB_SP_INDEX 34 -#elif defined(__arm32__) /* - * On the arm32, the jmpbuf regs underwent a name change after NetBSD 1.3. - */ -#ifdef JMPBUF_REG_R13 -#define JB_SP_INDEX JMPBUF_REG_R13 -#else -#define JB_SP_INDEX _JB_REG_R13 +** Initialize a thread context to run "_main()" when started +*/ +#ifdef __i386__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[0] = (int) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[2] #endif -#else -#error "Need to define SP index in jmp_buf here" +#ifdef __sparc__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[3] = (int) _main; \ + CONTEXT(_thread)[4] = (int) _main + 4; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[2] +#endif +#ifdef __powerpc__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[3] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[4] = (int) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[3] +#endif +#ifdef __m68k__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[2] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[5] = (int) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[2] +#endif +#ifdef __mips__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[32] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[2] = (int) _main; \ + CONTEXT(_thread)[28] = (int) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[32] +#endif +#ifdef __arm32__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[23] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[24] = (int) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[23] +#endif +#ifdef __alpha__ +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ +{ \ + sigsetjmp(CONTEXT(_thread), 1); \ + CONTEXT(_thread)[34] = (unsigned char*) ((_sp) - 128); \ + CONTEXT(_thread)[2] = (long) _main; \ + CONTEXT(_thread)[30] = (long) _main; \ + CONTEXT(_thread)[31] = (long) _main; \ + *status = PR_TRUE; \ +} +#define _MD_GET_SP(_thread) CONTEXT(_thread)[34] +#endif +#ifndef _MD_INIT_CONTEXT +#error "Need to define _MD_INIT_CONTEXT for this platform" #endif -#define _MD_GET_SP(_th) (_th)->md.context[JB_SP_INDEX] #define PR_NUM_GCREGS _JBLEN -/* -** Initialize a thread context to run "_main()" when started -*/ -#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ -{ \ - *status = PR_TRUE; \ - if (sigsetjmp(CONTEXT(_thread), 1)) { \ - _main(); \ - } \ - _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \ -} - #define _MD_SWITCH_CONTEXT(_thread) \ if (!sigsetjmp(CONTEXT(_thread), 1)) { \ (_thread)->md.errcode = errno; \ @@ -210,7 +266,10 @@ struct _MDCPU { * unwrapped version. */ #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv) +#if defined(_PR_POLL_AVAILABLE) +#include #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout) +#endif #if NetBSD1_3 == 1L typedef unsigned int nfds_t; diff --git a/pr/include/md/_nto.cfg b/pr/include/md/_nto.cfg index dd3a5aef..cae799f7 100644 --- a/pr/include/md/_nto.cfg +++ b/pr/include/md/_nto.cfg @@ -27,6 +27,8 @@ #define NTO #endif +#define PR_AF_INET6 24 /* same as AF_INET6 */ + #ifdef __i386__ #define IS_LITTLE_ENDIAN 1 diff --git a/pr/include/md/_nto.h b/pr/include/md/_nto.h index c3720ab3..c23d9f8a 100644 --- a/pr/include/md/_nto.h +++ b/pr/include/md/_nto.h @@ -46,6 +46,9 @@ #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY #define _PR_HAVE_POSIX_SEMAPHORES +#define FD_SETSIZE 4096 +#include +#include #include #undef HAVE_STACK_GROWING_UP @@ -190,9 +193,6 @@ struct _MDCPU { ** We wrapped the select() call. _MD_SELECT refers to the built-in, ** unwrapped version. */ -#include -#include -#include #define _MD_SELECT select #endif /* nspr_nto_defs_h___ */ diff --git a/pr/include/md/_openbsd.cfg b/pr/include/md/_openbsd.cfg index ae3bfcda..994daf32 100644 --- a/pr/include/md/_openbsd.cfg +++ b/pr/include/md/_openbsd.cfg @@ -27,6 +27,8 @@ #define OPENBSD #endif +#define PR_AF_INET6 24 /* same as AF_INET6 */ + #if defined(__i386__) || defined(__arm32__) #define IS_LITTLE_ENDIAN 1 diff --git a/pr/include/md/_openvms.cfg b/pr/include/md/_openvms.cfg index b9dd6d97..17548c27 100644 --- a/pr/include/md/_openvms.cfg +++ b/pr/include/md/_openvms.cfg @@ -36,6 +36,8 @@ #undef IS_64 #endif +#define PR_AF_INET6 26 /* same as AF_INET6 */ + #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 #define PR_BYTES_PER_INT 4 diff --git a/pr/include/md/_openvms.h b/pr/include/md/_openvms.h index 6f888b72..091f202b 100644 --- a/pr/include/md/_openvms.h +++ b/pr/include/md/_openvms.h @@ -81,6 +81,17 @@ struct ip_mreq { #define _PR_STAT_HAS_ONLY_ST_ATIME #define _PR_NO_LARGE_FILES +/* IPv6 support */ +#define _PR_HAVE_GETIPNODEBYNAME +#define _PR_HAVE_GETIPNODEBYADDR +#define _PR_INET6_PROBE +#ifndef _PR_INET6 +#define AF_INET6 26 +#define AI_V4MAPPED 0x00000010 +#define AI_ALL 0x00000008 +#define AI_ADDRCONFIG 0x00000020 +#endif + #undef USE_SETJMP #include diff --git a/pr/include/md/_os2.cfg b/pr/include/md/_os2.cfg index f72eab69..a11e7cf3 100644 --- a/pr/include/md/_os2.cfg +++ b/pr/include/md/_os2.cfg @@ -39,6 +39,8 @@ #define HAVE_LONG_LONG 1 #endif +#define PR_AF_INET6 24 /* same as AF_INET6 */ + #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 #define PR_BYTES_PER_INT 4 diff --git a/pr/include/md/_pth.h b/pr/include/md/_pth.h index 6e2e90c0..2fe641ff 100644 --- a/pr/include/md/_pth.h +++ b/pr/include/md/_pth.h @@ -93,7 +93,7 @@ #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \ || defined(HPUX) || defined(LINUX) || defined(FREEBSD) \ || defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \ - || defined(VMS) || defined(NTO) + || defined(VMS) || defined(NTO) || defined(RHAPSODY) #define _PT_PTHREAD_ZERO_THR_HANDLE(t) (t) = 0 #define _PT_PTHREAD_THR_HANDLE_IS_ZERO(t) (t) == 0 #define _PT_PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st) @@ -204,7 +204,7 @@ #define PT_PRIO_MIN 1 #define PT_PRIO_MAX 127 #elif defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) /* XXX */ + || defined(BSDI) || defined(RHAPSODY) /* XXX */ #define PT_PRIO_MIN 0 #define PT_PRIO_MAX 126 #else @@ -237,7 +237,7 @@ extern int (*_PT_aix_yield_fcn)(); PR_END_MACRO #elif defined(HPUX) || defined(LINUX) || defined(SOLARIS) \ || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) || defined(NTO) + || defined(BSDI) || defined(NTO) || defined(RHAPSODY) #define _PT_PTHREAD_YIELD() sched_yield() #else #error "Need to define _PT_PTHREAD_YIELD for this platform" diff --git a/pr/include/md/_rhapsody.cfg b/pr/include/md/_rhapsody.cfg index 87a76c95..33da779e 100644 --- a/pr/include/md/_rhapsody.cfg +++ b/pr/include/md/_rhapsody.cfg @@ -27,6 +27,8 @@ #define RHAPOSDY #endif +#define PR_AF_INET6 30 /* same as AF_INET6 */ + #if defined(i386) #undef IS_BIG_ENDIAN #define IS_LITTLE_ENDIAN 1 diff --git a/pr/include/md/_rhapsody.h b/pr/include/md/_rhapsody.h index d97e6a3c..98a2f1ed 100644 --- a/pr/include/md/_rhapsody.h +++ b/pr/include/md/_rhapsody.h @@ -42,8 +42,8 @@ #define USE_MACH_DYLD #define _PR_HAVE_SOCKADDR_LEN #define _PR_STAT_HAS_ST_ATIMESPEC -#define _PR_TIMESPEC_HAS_TS_SEC #define _PR_NO_LARGE_FILES +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY #define USE_SETJMP diff --git a/pr/include/md/_solaris.h b/pr/include/md/_solaris.h index 081636e0..88c5a44e 100644 --- a/pr/include/md/_solaris.h +++ b/pr/include/md/_solaris.h @@ -70,8 +70,13 @@ #define _PR_POLL_AVAILABLE #define _PR_USE_POLL #define _PR_STAT_HAS_ST_ATIM +#ifdef SOLARIS2_5 +#define _PR_HAVE_SYSV_SEMAPHORES +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY +#else #define _PR_HAVE_POSIX_SEMAPHORES #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY +#endif #define _PR_HAVE_GETIPNODEBYNAME #define _PR_HAVE_GETIPNODEBYADDR #define _PR_INET6_PROBE @@ -81,6 +86,24 @@ #define AI_V4MAPPED 0x0001 #define AI_ALL 0x0002 #define AI_ADDRCONFIG 0x0004 +#define _PR_HAVE_MD_SOCKADDR_IN6 +/* isomorphic to struct in6_addr on Solaris 8 */ +struct _md_in6_addr { + union { + PRUint8 _S6_u8[16]; + PRUint32 _S6_u32[4]; + PRUint32 __S6_align; + } _S6_un; +}; +/* isomorphic to struct sockaddr_in6 on Solaris 8 */ +struct _md_sockaddr_in6 { + PRUint16 sin6_family; + PRUint16 sin6_port; + PRUint32 sin6_flowinfo; + struct _md_in6_addr sin6_addr; + PRUint32 sin6_scope_id; + PRUint32 __sin6_src_id; +}; #endif #include "prinrval.h" diff --git a/pr/include/obsolete/protypes.h b/pr/include/obsolete/protypes.h index 631137e4..23be3aa2 100644 --- a/pr/include/obsolete/protypes.h +++ b/pr/include/obsolete/protypes.h @@ -51,7 +51,8 @@ typedef PRIntn intn; /* SVR4 typedef of uint is commonly found on UNIX machines. */ #ifdef XP_UNIX #include -#else +#endif +#if !defined(XP_UNIX) || defined(NTO) typedef PRUintn uint; #endif diff --git a/pr/include/prinit.h b/pr/include/prinit.h index 500182c3..dd319360 100644 --- a/pr/include/prinit.h +++ b/pr/include/prinit.h @@ -44,11 +44,11 @@ PR_BEGIN_EXTERN_C ** The format of the version string is ** ". " */ -#define PR_VERSION "4.0" +#define PR_VERSION "4.0.2 Beta" #define PR_VMAJOR 4 #define PR_VMINOR 0 -#define PR_VPATCH 0 -#define PR_BETA PR_FALSE +#define PR_VPATCH 2 +#define PR_BETA PR_TRUE /* ** PRVersionCheck diff --git a/pr/include/prio.h b/pr/include/prio.h index 36017128..015e9be2 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -178,34 +178,6 @@ union PRNetAddr { #endif }; -/* -** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union -** whose 'family' field is set. It returns the size of the union -** member corresponding to the specified address family. -*/ - -#if defined(_PR_INET6) - -#define PR_NETADDR_SIZE(_addr) PR_NetAddrSize(_addr) - -#else - -#if defined(XP_UNIX) -#define PR_NETADDR_SIZE(_addr) \ - ((_addr)->raw.family == PR_AF_INET \ - ? sizeof((_addr)->inet) \ - : ((_addr)->raw.family == PR_AF_INET6 \ - ? sizeof((_addr)->ipv6) \ - : sizeof((_addr)->local))) -#else -#define PR_NETADDR_SIZE(_addr) \ - ((_addr)->raw.family == PR_AF_INET \ - ? sizeof((_addr)->inet) \ - : sizeof((_addr)->ipv6)) -#endif /* defined(XP_UNIX) */ - -#endif /* defined(_PR_INET6) */ - /* *************************************************************************** ** PRSockOption @@ -1108,8 +1080,6 @@ NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode); NSPR_API(PRStatus) PR_RmDir(const char *name); -NSPR_API(PRUintn) PR_NetAddrSize(const PRNetAddr* addr); - /* ************************************************************************* * FUNCTION: PR_NewUDPSocket diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index 926c2585..8c1d3e12 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -172,6 +172,14 @@ struct _PT_Notified (thr->interrupt_blocked = 1) #define _PT_THREAD_UNBLOCK_INTERRUPT(thr) \ (thr->interrupt_blocked = 0) + +#ifdef GC_LEAK_DETECTOR +/* All threads are GCable. */ +#define _PT_IS_GCABLE_THREAD(thr) 1 +#else +#define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE) +#endif /* GC_LEAK_DETECTOR */ + /* ** Possible values for thread's suspend field ** Note that the first two can be the same as they are really mutually exclusive, @@ -1268,6 +1276,69 @@ extern PRFileDesc *_PR_InvalidDesc(void); extern PRIOMethods _pr_faulty_methods; +/* +** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union +** whose 'family' field is set. It returns the size of the union +** member corresponding to the specified address family. +*/ + +extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr); + +#if defined(_PR_INET6) + +#define PR_NETADDR_SIZE(_addr) _PR_NetAddrSize(_addr) + +#elif defined(_PR_HAVE_MD_SOCKADDR_IN6) + +/* +** Under the following conditions: +** 1. _PR_INET6 is not defined; +** 2. _PR_INET6_PROBE is defined; +** 3. struct sockaddr_in6 has nonstandard fields at the end +** (e.g., on Solaris 8), +** (_addr)->ipv6 is smaller than struct sockaddr_in6, and +** hence we can't pass sizeof((_addr)->ipv6) to socket +** functions such as connect because they would fail with +** EINVAL. +** +** To pass the correct socket address length to socket +** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and +** define struct _md_sockaddr_in6 to be isomorphic to +** struct sockaddr_in6. +*/ + +#if defined(XP_UNIX) +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : ((_addr)->raw.family == PR_AF_INET6 \ + ? sizeof(struct _md_sockaddr_in6) \ + : sizeof((_addr)->local))) +#else +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : sizeof(struct _md_sockaddr_in6) +#endif /* defined(XP_UNIX) */ + +#else + +#if defined(XP_UNIX) +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : ((_addr)->raw.family == PR_AF_INET6 \ + ? sizeof((_addr)->ipv6) \ + : sizeof((_addr)->local))) +#else +#define PR_NETADDR_SIZE(_addr) \ + ((_addr)->raw.family == PR_AF_INET \ + ? sizeof((_addr)->inet) \ + : sizeof((_addr)->ipv6)) +#endif /* defined(XP_UNIX) */ + +#endif /* defined(_PR_INET6) */ + extern PRStatus _PR_MapOptionName( PRSockOption optname, PRInt32 *level, PRInt32 *name); extern void _PR_InitThreads( diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index 02ea6412..b84682ca 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -158,13 +158,9 @@ #define PR_IMPLEMENT(__type) __type #define PR_EXTERN_DATA(__type) extern __type #define PR_IMPLEMENT_DATA(__type) __type -#define PR_CALLBACK +#define PR_CALLBACK _Optlink #define PR_CALLBACK_DECL -#ifndef XP_OS2_VACPP -#define PR_STATIC_CALLBACK(__x) static __x -#else -#define PR_STATIC_CALLBACK(__x) static __x _Optlink -#endif +#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK #else /* Unix */ diff --git a/pr/src/Makefile b/pr/src/Makefile index 9f584e48..774951e4 100644 --- a/pr/src/Makefile +++ b/pr/src/Makefile @@ -141,10 +141,14 @@ endif ifeq ($(OS_ARCH),WINNT) ifneq ($(OS_TARGET),WIN16) -OS_LIBS = advapi32.lib wsock32.lib winmm.lib +OS_LIBS = advapi32.lib wsock32.lib endif endif +ifdef GC_LEAK_DETECTOR +OS_LIBS += -L$(DIST)/lib -lboehm +endif + # # Define platform-dependent OBJS # @@ -242,6 +246,10 @@ OBJS += \ cplus/$(OBJDIR)/rctime.$(OBJ_SUFFIX) endif +ifdef GC_LEAK_DETECTOR +OBJS += memory/$(OBJDIR)/prgcleak.$(OBJ_SUFFIX) +endif + ifeq ($(OS_ARCH), WINNT) ifneq ($(OS_TARGET),WIN16) DLLBASE=/BASE:0x30000000 @@ -353,7 +361,7 @@ endif # Version information generation (begin) # ECHO = echo -INCLUDES = -I$(DIST)/include +INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private TINC = $(OBJDIR)/_pr_bld.h ifeq ($(OS_TARGET),OS2) @@ -374,6 +382,8 @@ endif DEFINES += -D_NSPR_BUILD_ +GARBAGE += $(TINC) + $(TINC): @$(MAKE_OBJDIR) @$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC) diff --git a/pr/src/Makefile.in b/pr/src/Makefile.in index bad88779..7be4f13b 100644 --- a/pr/src/Makefile.in +++ b/pr/src/Makefile.in @@ -146,11 +146,15 @@ ifeq ($(OS_TARGET),OS2) # We define this in os2.mk. else ifneq ($(OS_TARGET),WIN16) -OS_LIBS = wsock32.lib winmm.lib +OS_LIBS = advapi32.lib wsock32.lib endif endif endif +ifdef GC_LEAK_DETECTOR +OS_LIBS += -L$(DIST)/lib -lboehm +endif + endif # USE_AUTOCONF # # Define platform-dependent OBJS @@ -244,6 +248,10 @@ OBJS += \ cplus/$(OBJDIR)/rctime.$(OBJ_SUFFIX) endif +ifdef GC_LEAK_DETECTOR +OBJS += memory/$(OBJDIR)/prgcleak.$(OBJ_SUFFIX) +endif + ifdef USE_AUTOCONF include $(srcdir)/md/$(PR_MD_ARCH_DIR)/objs.mk @@ -361,7 +369,7 @@ endif # Version information generation (begin) # ECHO = echo -INCLUDES = -I$(DIST)/include +INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private TINC = $(OBJDIR)/_pr_bld.h PROD = $(notdir $(SHARED_LIBRARY)) NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now @@ -380,6 +388,8 @@ endif DEFINES += -D_NSPR_BUILD_ +GARBAGE += $(TINC) + $(TINC): @$(MAKE_OBJDIR) @$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC) diff --git a/pr/src/bthreads/btcvar.c b/pr/src/bthreads/btcvar.c index 9e77e27b..b151f332 100644 --- a/pr/src/bthreads/btcvar.c +++ b/pr/src/bthreads/btcvar.c @@ -88,34 +88,46 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar (PRCondVar *cvar, PRIntervalTime timeout) { status_t result; - - /* - ** This is an entirely stupid bug, but... If you call - ** acquire_sem_etc with a timeout of exactly 1,000,000 microseconds - ** it returns immediately with B_NO_ERROR. 1,000,010 microseconds - ** returns as expected. Running BeOS/Intel R3.1 at this time. - ** Forwarded to Be, Inc. for resolution, Bug ID 980624-225956 - ** - ** Update: Be couldn't reproduce it, but removing timeout++ still - ** exhibits the problem on BeOS/Intel R4 and BeOS/PPC R4. - */ - - timeout++; + bigtime_t interval; PR_Unlock( cvar->lock ); - if( PR_INTERVAL_NO_WAIT != timeout ) - { - if( PR_INTERVAL_NO_TIMEOUT == timeout ) - { - if( acquire_sem( cvar->isem ) != B_NO_ERROR ) return PR_FAILURE; - - } else - { - result = acquire_sem_etc( cvar->isem, 1, B_TIMEOUT, PR_IntervalToMicroseconds( timeout ) ); - if( result != B_NO_ERROR && result != B_TIMED_OUT ) - return PR_FAILURE; - } + switch (timeout) { + case PR_INTERVAL_NO_WAIT: + /* nothing to do */ + break; + + case PR_INTERVAL_NO_TIMEOUT: + /* wait as long as necessary */ + if( acquire_sem( cvar->isem ) != B_NO_ERROR ) return PR_FAILURE; + break; + + default: + interval = (bigtime_t)PR_IntervalToMicroseconds(timeout); + + /* + ** in R5, this problem seems to have been resolved, so we + ** won't bother with it + */ +#if !defined(B_BEOS_VERSION_5) || (B_BEOS_VERSION < B_BEOS_VERSION_5) + /* + ** This is an entirely stupid bug, but... If you call + ** acquire_sem_etc with a timeout of exactly 1,000,000 microseconds + ** it returns immediately with B_NO_ERROR. 1,000,010 microseconds + ** returns as expected. Running BeOS/Intel R3.1 at this time. + ** Forwarded to Be, Inc. for resolution, Bug ID 980624-225956 + ** + ** Update: Be couldn't reproduce it, but removing timeout++ still + ** exhibits the problem on BeOS/Intel R4 and BeOS/PPC R4. + */ + if (interval == 1000000) + interval = 1000010; +#endif /* !defined(B_BEOS_VERSION_5) || (B_BEOS_VERSION < B_BEOS_VERSION_5) */ + + result = acquire_sem_etc( cvar->isem, 1, B_RELATIVE_TIMEOUT, interval); + if( result != B_NO_ERROR && result != B_TIMED_OUT ) + return PR_FAILURE; + break; } PR_Lock( cvar->lock ); @@ -162,4 +174,6 @@ PR_IMPLEMENT(PRStatus) if( release_sem_etc( cvar->isem, semInfo.count, 0 ) != B_NO_ERROR ) return PR_FAILURE; + + return PR_SUCCESS; } diff --git a/pr/src/bthreads/btthread.c b/pr/src/bthreads/btthread.c index fde9189a..35fdba38 100644 --- a/pr/src/bthreads/btthread.c +++ b/pr/src/bthreads/btthread.c @@ -12,6 +12,7 @@ */ #include +#include #include "prlog.h" #include "primpl.h" @@ -22,67 +23,63 @@ #include #include +/* values for PRThread.state */ #define BT_THREAD_PRIMORD 0x01 /* this is the primordial thread */ #define BT_THREAD_SYSTEM 0x02 /* this is a system thread */ +#define BT_THREAD_JOINABLE 0x04 /* this is a joinable thread */ struct _BT_Bookeeping { PRLock *ml; /* a lock to protect ourselves */ - PRCondVar *cv; /* used to signal global things */ + sem_id cleanUpSem; /* the primoridal thread will block on this + sem while waiting for the user threads */ PRInt32 threadCount; /* user thred count */ -} bt_book = { 0 }; +} bt_book = { NULL, B_ERROR, 0 }; -/* -** A structure at the root of the thread private data. Each member of -** the array keys[] points to a hash table based on the thread's ID. -*/ -struct _BT_PrivateData -{ - PRLock *lock; /* A lock to coordinate access */ - struct _BT_PrivateHash *keys[128]; /* Up to 128 keys, pointing to a hash table */ +#define BT_TPD_LIMIT 128 /* number of TPD slots we'll provide (arbitrary) */ -} bt_privateRoot = { 0 }; +/* these will be used to map an index returned by PR_NewThreadPrivateIndex() + to the corresponding beos native TLS slot number, and to the destructor + for that slot - note that, because it is allocated globally, this data + will be automatically zeroed for us when the program begins */ +static int32 tpd_beosTLSSlots[BT_TPD_LIMIT]; +static PRThreadPrivateDTOR tpd_dtors[BT_TPD_LIMIT]; -/* -** A dynamically allocated structure that contains 256 hash buckets that -** contain a linked list of thread IDs. The hash is simply the last 8 bits -** of the thread_id. ( current thread_id & 0x000000FF ) -*/ +static vint32 tpd_slotsUsed=0; /* number of currently-allocated TPD slots */ +static int32 tls_prThreadSlot; /* TLS slot in which PRThread will be stored */ -struct _BT_PrivateHash -{ - void (PR_CALLBACK *destructor)(void *arg); /* The destructor */ - struct _BT_PrivateEntry *next[256]; /* Pointer to the first element in the list */ -}; +/* this mutex will be used to synchronize access to every + PRThread.md.joinSem and PRThread.md.is_joining (we could + actually allocate one per thread, but that seems a bit excessive, + especially considering that there will probably be little + contention, PR_JoinThread() is allowed to block anyway, and the code + protected by the mutex is short/fast) */ +static PRLock *joinSemLock; -/* -** A dynamically allocated structure that is a member of a linked list of -** thread IDs. -*/ - -struct _BT_PrivateEntry -{ - struct _BT_PrivateEntry *next; /* Pointer to the next thread */ - thread_id threadID; /* The BeOS thread ID */ - void *data; /* The data */ -}; - -PRUint32 _bt_mapPriority( PRThreadPriority priority ); -PR_IMPLEMENT(void *) _bt_getThreadPrivate(PRUintn index); +static PRUint32 _bt_MapNSPRToNativePriority( PRThreadPriority priority ); +static PRThreadPriority _bt_MapNativeToNSPRPriority( PRUint32 priority ); +static void _bt_CleanupThread(void *arg); +static PRThread *_bt_AttachThread(); void _PR_InitThreads (PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs) { PRThread *primordialThread; - PRLock *tempLock; - PRUintn tempKey; PRUint32 beThreadPriority; + /* allocate joinSem mutex */ + joinSemLock = PR_NewLock(); + if (joinSemLock == NULL) + { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return; + } + /* - ** Create a NSPR structure for our primordial thread. + ** Create and initialize NSPR structure for our primordial thread. */ primordialThread = PR_NEWZAP(PRThread); @@ -92,82 +89,75 @@ _PR_InitThreads (PRThreadType type, PRThreadPriority priority, return; } + primordialThread->md.joinSem = B_ERROR; + /* ** Set the priority to the desired level. */ - beThreadPriority = _bt_mapPriority( priority ); + beThreadPriority = _bt_MapNSPRToNativePriority( priority ); set_thread_priority( find_thread( NULL ), beThreadPriority ); - primordialThread->state |= BT_THREAD_PRIMORD; primordialThread->priority = priority; - /* - ** Initialize the thread tracking data structures - */ - bt_privateRoot.lock = PR_NewLock(); - if( NULL == bt_privateRoot.lock ) - { - PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); - return; - } + /* set the thread's state - note that the thread is not joinable */ + primordialThread->state |= BT_THREAD_PRIMORD; + if (type == PR_SYSTEM_THREAD) + primordialThread->state |= BT_THREAD_SYSTEM; /* - ** Grab a key. We're guaranteed to be key #0, since we are - ** always the first one in. + ** Allocate a TLS slot for the PRThread structure (just using + ** native TLS, as opposed to NSPR TPD, will make PR_GetCurrentThread() + ** somewhat faster, and will leave one more TPD slot for our client) */ - - if( PR_NewThreadPrivateIndex( &tempKey, NULL ) != PR_SUCCESS ) - { - PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); - return; - } - PR_ASSERT( tempKey == 0 ); + tls_prThreadSlot = tls_allocate(); /* ** Stuff our new PRThread structure into our thread specific ** slot. */ - - if( PR_SetThreadPrivate( (PRUint8) 0, (void *) primordialThread ) == PR_FAILURE ) - { - PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); - return; - } - /* - ** Allocate some memory to hold our global lock. We never clean it - ** up later, but BeOS automatically frees memory when the thread - ** dies. - */ + tls_set(tls_prThreadSlot, primordialThread); + /* allocate lock for bt_book */ bt_book.ml = PR_NewLock(); if( NULL == bt_book.ml ) { PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); return; } +} - tempLock = PR_NewLock(); - if( NULL == tempLock ) +PRUint32 +_bt_MapNSPRToNativePriority( PRThreadPriority priority ) { - PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); - return; + switch( priority ) + { + case PR_PRIORITY_LOW: return( B_LOW_PRIORITY ); + case PR_PRIORITY_NORMAL: return( B_NORMAL_PRIORITY ); + case PR_PRIORITY_HIGH: return( B_DISPLAY_PRIORITY ); + case PR_PRIORITY_URGENT: return( B_URGENT_DISPLAY_PRIORITY ); + default: return( B_NORMAL_PRIORITY ); } +} - bt_book.cv = PR_NewCondVar( tempLock ); - if( NULL == bt_book.cv ) +PRThreadPriority +_bt_MapNativeToNSPRPriority(PRUint32 priority) { - PR_SetError( PR_OUT_OF_MEMORY_ERROR, 0 ); - return; - } + if (priority < B_NORMAL_PRIORITY) + return PR_PRIORITY_LOW; + if (priority < B_DISPLAY_PRIORITY) + return PR_PRIORITY_NORMAL; + if (priority < B_URGENT_DISPLAY_PRIORITY) + return PR_PRIORITY_HIGH; + return PR_PRIORITY_URGENT; } PRUint32 -_bt_mapPriority( PRThreadPriority priority ) +_bt_mapNativeToNSPRPriority( int32 priority ) { switch( priority ) { @@ -179,97 +169,97 @@ _bt_mapPriority( PRThreadPriority priority ) } } -/** - * This is a wrapper that all threads invoke that allows us to set some - * things up prior to a thread's invocation and clean up after a thread has - * exited. - */ -static void* -_bt_root (void* arg) +/* This method is called by all NSPR threads as they exit */ +void _bt_CleanupThread(void *arg) { - PRThread *thred = (PRThread*)arg; - PRIntn rv; - void *privData; - status_t result; - int i; - - struct _BT_PrivateHash *hashTable; - - /* Set within the current thread the pointer to our object. This - object will be deleted when the thread termintates. */ + PRThread *me = PR_GetCurrentThread(); + int32 i; - result = PR_SetThreadPrivate( 0, (void *) thred ); - PR_ASSERT( result == PR_SUCCESS ); + /* first, clean up all thread-private data */ + for (i = 0; i < tpd_slotsUsed; i++) + { + void *oldValue = tls_get(tpd_beosTLSSlots[i]); + if ( oldValue != NULL && tpd_dtors[i] != NULL ) + (*tpd_dtors[i])(oldValue); + } - thred->startFunc(thred->arg); /* run the dang thing */ + /* if this thread is joinable, wait for someone to join it */ + if (me->state & BT_THREAD_JOINABLE) + { + /* protect access to our joinSem */ + PR_Lock(joinSemLock); - /* - ** Call the destructor, if available. - */ + if (me->md.is_joining) + { + /* someone is already waiting to join us (they've + allocated a joinSem for us) - let them know we're + ready */ + delete_sem(me->md.joinSem); - PR_Lock( bt_privateRoot.lock ); + PR_Unlock(joinSemLock); - for( i = 0; i < 128; i++ ) + } + else { - hashTable = bt_privateRoot.keys[i]; + /* noone is currently waiting for our demise - it + is our responsibility to allocate the joinSem + and block on it */ + me->md.joinSem = create_sem(0, "join sem"); - if( hashTable != NULL ) - { - if( hashTable->destructor != NULL ) - { - privData = _bt_getThreadPrivate( i ); + /* we're done accessing our joinSem */ + PR_Unlock(joinSemLock); - if( privData != NULL ) - { - PR_Unlock( bt_privateRoot.lock ); - hashTable->destructor( privData ); - PR_Lock( bt_privateRoot.lock ); - } + /* wait for someone to join us */ + while (acquire_sem(me->md.joinSem) == B_INTERRUPTED); } } - } - - PR_Unlock( bt_privateRoot.lock ); - - /* decrement our thread counters */ + /* if this is a user thread, we must update our books */ + if ((me->state & BT_THREAD_SYSTEM) == 0) + { + /* synchronize access to bt_book */ PR_Lock( bt_book.ml ); - if (thred->state & BT_THREAD_SYSTEM) { -#if 0 - bt_book.system -= 1; -#endif - } else - { + /* decrement the number of currently-alive user threads */ bt_book.threadCount--; - if( 0 == bt_book.threadCount ) - { - PR_NotifyAllCondVar(bt_book.cv); + if (bt_book.threadCount == 0 && bt_book.cleanUpSem != B_ERROR) { + /* we are the last user thread, and the primordial thread is + blocked in PR_Cleanup() waiting for us to finish - notify + it */ + delete_sem(bt_book.cleanUpSem); } - } PR_Unlock( bt_book.ml ); + } - if( thred->md.is_joinable == 1 ) - { - /* - ** This is a joinable thread. Keep suspending - ** until is_joining is set to 1 - */ + /* finally, delete this thread's PRThread */ + PR_DELETE(me); +} - if( thred->md.is_joining == 0 ) +/** + * This is a wrapper that all threads invoke that allows us to set some + * things up prior to a thread's invocation and clean up after a thread has + * exited. + */ +static void* +_bt_root (void* arg) { - suspend_thread( thred->md.tid ); - } - } + PRThread *thred = (PRThread*)arg; + PRIntn rv; + void *privData; + status_t result; + int i; + + /* save our PRThread object into our TLS */ + tls_set(tls_prThreadSlot, thred); - /* delete the thread object */ - PR_DELETE(thred); + thred->startFunc(thred->arg); /* run the dang thing */ + + /* clean up */ + _bt_CleanupThread(NULL); - result = PR_SetThreadPrivate( (PRUint8) 0, (void *) NULL ); - PR_ASSERT( result == PR_SUCCESS ); - exit_thread( NULL ); + return 0; } PR_IMPLEMENT(PRThread*) @@ -279,62 +269,70 @@ PR_IMPLEMENT(PRThread*) { PRUint32 bePriority; - PRThread* thred = PR_NEWZAP(PRThread); + PRThread* thred; if (!_pr_initialized) _PR_ImplicitInitialization(); - if (thred != NULL) { + thred = PR_NEWZAP(PRThread); + if (thred == NULL) + { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return NULL; + } + + thred->md.joinSem = B_ERROR; + thred->arg = arg; thred->startFunc = start; thred->priority = priority; if( state == PR_JOINABLE_THREAD ) { - thred->md.is_joinable = 1; - } - else - { - thred->md.is_joinable = 0; + thred->state |= BT_THREAD_JOINABLE; } - thred->md.is_joining = 0; - /* keep some books */ PR_Lock( bt_book.ml ); - if (PR_SYSTEM_THREAD == type) { - thred->state |= BT_THREAD_SYSTEM; -#if 0 - bt_book.system += 1; -#endif - } else { + if (type == PR_USER_THREAD) + { bt_book.threadCount++; } PR_Unlock( bt_book.ml ); - bePriority = _bt_mapPriority( priority ); + bePriority = _bt_MapNSPRToNativePriority( priority ); thred->md.tid = spawn_thread((thread_func)_bt_root, "moz-thread", bePriority, thred); if (thred->md.tid < B_OK) { PR_SetError(PR_UNKNOWN_ERROR, thred->md.tid); PR_DELETE(thred); - thred = NULL; + return NULL; } if (resume_thread(thred->md.tid) < B_OK) { PR_SetError(PR_UNKNOWN_ERROR, 0); PR_DELETE(thred); - thred = NULL; + return NULL; } - } else { - PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return thred; } - return thred; +PR_IMPLEMENT(PRThread*) + PR_AttachThread(PRThreadType type, PRThreadPriority priority, + PRThreadStack *stack) +{ + /* PR_GetCurrentThread() will attach a thread if necessary */ + return PR_GetCurrentThread(); +} + +PR_IMPLEMENT(void) + PR_DetachThread() +{ + /* we don't support detaching */ } PR_IMPLEMENT(PRStatus) @@ -344,36 +342,71 @@ PR_IMPLEMENT(PRStatus) PR_ASSERT(thred != NULL); - if( thred->md.is_joinable != 1 ) + if ((thred->state & BT_THREAD_JOINABLE) == 0) { - PR_SetError( PR_UNKNOWN_ERROR, 0 ); + PR_SetError( PR_INVALID_ARGUMENT_ERROR, 0 ); return( PR_FAILURE ); } - thred->md.is_joining = 1; + /* synchronize access to the thread's joinSem */ + PR_Lock(joinSemLock); + + if (thred->md.is_joining) + { + /* another thread is already waiting to join the specified + thread - we must fail */ + PR_Unlock(joinSemLock); + return PR_FAILURE; + } + + /* let others know we are waiting to join */ + thred->md.is_joining = PR_TRUE; + + if (thred->md.joinSem == B_ERROR) + { + /* the thread hasn't finished yet - it is our responsibility to + allocate a joinSem and wait on it */ + thred->md.joinSem = create_sem(0, "join sem"); - status = wait_for_thread(thred->md.tid, &eval); + /* we're done changing the joinSem now */ + PR_Unlock(joinSemLock); - if (status < B_NO_ERROR) { + /* wait for the thread to finish */ + while (acquire_sem(thred->md.joinSem) == B_INTERRUPTED); - PR_SetError(PR_UNKNOWN_ERROR, status); - return PR_FAILURE; + } + else + { + /* the thread has already finished, and has allocated the + joinSem itself - let it know it can finally die */ + delete_sem(thred->md.joinSem); + + PR_Unlock(joinSemLock); } + /* make sure the thread is dead */ + wait_for_thread(thred->md.tid, &eval); + return PR_SUCCESS; } PR_IMPLEMENT(PRThread*) PR_GetCurrentThread () { - void* thred; + PRThread* thred; if (!_pr_initialized) _PR_ImplicitInitialization(); - thred = PR_GetThreadPrivate( (PRUint8) 0 ); + thred = (PRThread *)tls_get( tls_prThreadSlot); + if (thred == NULL) + { + /* this thread doesn't have a PRThread structure (it must be + a native thread not created by the NSPR) - assimilate it */ + thred = _bt_AttachThread(); + } PR_ASSERT(NULL != thred); - return (PRThread*)thred; + return thred; } PR_IMPLEMENT(PRThreadScope) @@ -395,7 +428,8 @@ PR_IMPLEMENT(PRThreadState) PR_GetThreadState (const PRThread* thred) { PR_ASSERT(thred != NULL); - return PR_JOINABLE_THREAD; + return (thred->state & BT_THREAD_JOINABLE)? + PR_JOINABLE_THREAD: PR_UNJOINABLE_THREAD; } PR_IMPLEMENT(PRThreadPriority) @@ -413,7 +447,7 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PR_ASSERT( thred != NULL ); thred->priority = newPri; - bePriority = _bt_mapPriority( newPri ); + bePriority = _bt_MapNSPRToNativePriority( newPri ); set_thread_priority( thred->md.tid, bePriority ); } @@ -421,56 +455,28 @@ PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex (PRUintn* newIndex, PRThreadPrivateDTOR destructor) { - PRUintn index; - struct _BT_PrivateHash *tempPointer; + int32 index; if (!_pr_initialized) _PR_ImplicitInitialization(); - /* - ** Grab the lock, or hang until it is free. This is critical code, - ** and only one thread at a time should be going through it. - */ - - PR_Lock( bt_privateRoot.lock ); - - /* - ** Run through the array of keys, find the first one that's zero. - ** Exit if we hit the top of the array. - */ - - index = 0; - - while( bt_privateRoot.keys[index] != 0 ) - { - index++; - - if( 128 == index ) + /* reserve the next available tpd slot */ + index = atomic_add( &tpd_slotsUsed, 1 ); + if (index >= BT_TPD_LIMIT) { - PR_Unlock( bt_privateRoot.lock ); + /* no slots left - decrement value, then fail */ + atomic_add( &tpd_slotsUsed, -1 ); + PR_SetError( PR_TPD_RANGE_ERROR, 0 ); return( PR_FAILURE ); } - } - - /* - ** Index has the first available zeroed slot. Allocate a - ** _BT_PrivateHash structure, all zeroed. Assuming that goes - ** well, return the index. - */ - - tempPointer = PR_NEWZAP( struct _BT_PrivateHash ); - - if( 0 == tempPointer ) { - - PR_Unlock( bt_privateRoot.lock ); - return( PR_FAILURE ); - } - bt_privateRoot.keys[index] = tempPointer; - tempPointer->destructor = destructor; + /* allocate a beos-native TLS slot for this index (the new slot + automatically contains NULL) */ + tpd_beosTLSSlots[index] = tls_allocate(); - PR_Unlock( bt_privateRoot.lock ); + /* remember the destructor */ + tpd_dtors[index] = destructor; - *newIndex = index; + *newIndex = (PRUintn)index; return( PR_SUCCESS ); } @@ -478,195 +484,44 @@ PR_IMPLEMENT(PRStatus) PR_IMPLEMENT(PRStatus) PR_SetThreadPrivate (PRUintn index, void* priv) { - thread_id currentThread; - PRUint8 hashBucket; - void *tempPointer; - - struct _BT_PrivateHash *hashTable; - struct _BT_PrivateEntry *currentEntry; - struct _BT_PrivateEntry *previousEntry; + void *oldValue; /* ** Sanity checking */ - if( index < 0 || index > 127 ) return( PR_FAILURE ); - - /* - ** Grab the thread ID for this thread. Assign it to a hash bucket. - */ - - currentThread = find_thread( NULL ); - hashBucket = currentThread & 0x000000FF; - - /* - ** Lock out all other threads then grab the proper hash table based - ** on the passed index. - */ - - PR_Lock( bt_privateRoot.lock ); - - hashTable = bt_privateRoot.keys[index]; - - if( 0 == hashTable ) + if(index < 0 || index >= tpd_slotsUsed || index >= BT_TPD_LIMIT) { - PR_Unlock( bt_privateRoot.lock ); + PR_SetError( PR_TPD_RANGE_ERROR, 0 ); return( PR_FAILURE ); } - /* - ** Search through the linked list the end is reached or an existing - ** entry is found. - */ - - currentEntry = hashTable->next[ hashBucket ]; - previousEntry = NULL; + /* if the old value isn't NULL, and the dtor for this slot isn't + NULL, we must destroy the data */ + oldValue = tls_get(tpd_beosTLSSlots[index]); + if (oldValue != NULL && tpd_dtors[index] != NULL) + (*tpd_dtors[index])(oldValue); - while( currentEntry != 0 ) - { - if( currentEntry->threadID == currentThread ) - { - /* - ** Found a structure previously created for this thread. - ** Is there a destructor to be called? - */ - - if( hashTable->destructor != NULL ) - { - if( currentEntry->data != NULL ) - { - PR_Unlock( bt_privateRoot.lock ); - hashTable->destructor( currentEntry->data ); - PR_Lock( bt_privateRoot.lock ); - } - } - - /* - ** If the data was not NULL, and there was a destructor, - ** it has already been called. Overwrite the existing - ** data and return with success. - */ + /* save new value */ + tls_set(tpd_beosTLSSlots[index], priv); - currentEntry->data = priv; - PR_Unlock( bt_privateRoot.lock ); return( PR_SUCCESS ); } - previousEntry = currentEntry; - currentEntry = previousEntry->next; - } - - /* - ** If we're here, we didn't find an entry for this thread. Create - ** one and attach it to the end of the list. - */ - - currentEntry = PR_NEWZAP( struct _BT_PrivateEntry ); - - if( 0 == currentEntry ) - { - PR_Unlock( bt_privateRoot.lock ); - return( PR_FAILURE ); - } - - currentEntry->threadID = currentThread; - currentEntry->data = priv; - - if( 0 == previousEntry ) - { - /* - ** This is a special case. This is the first entry in the list - ** so set the hash table to point to this entry. - */ - - hashTable->next[ hashBucket ] = currentEntry; - } - else - { - previousEntry->next = currentEntry; - } - - PR_Unlock( bt_privateRoot.lock ); - - return( PR_SUCCESS ); -} - PR_IMPLEMENT(void*) - _bt_getThreadPrivate(PRUintn index) + PR_GetThreadPrivate (PRUintn index) { - thread_id currentThread; - PRUint8 hashBucket; - void *tempPointer; - - struct _BT_PrivateHash *hashTable; - struct _BT_PrivateEntry *currentEntry; - - /* - ** Sanity checking - */ - - if( index < 0 || index > 127 ) return( NULL ); - - /* - ** Grab the thread ID for this thread. Assign it to a hash bucket. - */ - - currentThread = find_thread( NULL ); - hashBucket = currentThread & 0x000000FF; - - /* - ** Grab the proper hash table based on the passed index. - */ - - hashTable = bt_privateRoot.keys[index]; - - if( 0 == hashTable ) + /* make sure the index is valid */ + if (index < 0 || index >= tpd_slotsUsed || index >= BT_TPD_LIMIT) { - return( NULL ); + PR_SetError( PR_TPD_RANGE_ERROR, 0 ); + return NULL; } - /* - ** Search through the linked list the end is reached or an existing - ** entry is found. - */ - - currentEntry = hashTable->next[ hashBucket ]; - - while( currentEntry != 0 ) - { - if( currentEntry->threadID == currentThread ) - { - /* - ** Found a structure previously created for this thread. - ** Copy out the data, unlock, and return. - */ - - tempPointer = currentEntry->data; - return( tempPointer ); + /* return the value */ + return tls_get( tpd_beosTLSSlots[index] ); } - currentEntry = currentEntry->next; - } - - /* - ** Ooops, we ran out of entries. This thread isn't listed. - */ - - return( NULL ); -} - -PR_IMPLEMENT(void*) - PR_GetThreadPrivate (PRUintn index) -{ - void *returnValue; - - PR_Lock( bt_privateRoot.lock ); - returnValue = _bt_getThreadPrivate( index ); - PR_Unlock( bt_privateRoot.lock ); - - return( returnValue ); -} - PR_IMPLEMENT(PRStatus) PR_Interrupt (PRThread* thred) @@ -674,38 +529,34 @@ PR_IMPLEMENT(PRStatus) PRIntn rv; PR_ASSERT(thred != NULL); - rv = resume_thread( thred->md.tid ); - if( rv == B_BAD_THREAD_STATE ) + /* + ** there seems to be a bug in beos R5 in which calling + ** resume_thread() on a blocked thread returns B_OK instead + ** of B_BAD_THREAD_STATE (beos bug #20000422-19095). as such, + ** to interrupt a thread, we will simply suspend then resume it + ** (no longer call resume_thread(), check for B_BAD_THREAD_STATE, + ** the suspend/resume to wake up a blocked thread). this wakes + ** up blocked threads properly, and doesn't hurt unblocked threads + ** (they simply get stopped then re-started immediately) + */ + + rv = suspend_thread( thred->md.tid ); + if( rv != B_NO_ERROR ) { - /* - ** We have a thread that's not suspended, but is - ** blocked. Suspend it THEN resume it. The - ** function call that's hanging will return - ** B_INTERRUPTED - */ - - rv = suspend_thread( thred->md.tid ); - if( rv != B_NO_ERROR ) - { - PR_SetError( PR_UNKNOWN_ERROR, rv ); - return( PR_FAILURE ); - } - rv = resume_thread( thred->md.tid ); - if( rv != B_NO_ERROR ) - { - PR_SetError( PR_UNKNOWN_ERROR, rv ); - return( PR_FAILURE ); - } + /* this doesn't appear to be a valid thread_id */ + PR_SetError( PR_UNKNOWN_ERROR, rv ); + return PR_FAILURE; } + rv = resume_thread( thred->md.tid ); if( rv != B_NO_ERROR ) { - PR_SetError( PR_UNKNOWN_ERROR, rv ); - return( PR_FAILURE ); + PR_SetError( PR_UNKNOWN_ERROR, rv ); + return PR_FAILURE; } - return( PR_SUCCESS ); + return PR_SUCCESS; } PR_IMPLEMENT(void) @@ -752,25 +603,19 @@ PR_IMPLEMENT(PRStatus) PR_Lock( bt_book.ml ); - while( bt_book.threadCount > 0 ) + if (bt_book.threadCount != 0) { - PR_Unlock( bt_book.ml ); - PR_WaitCondVar(bt_book.cv, PR_INTERVAL_NO_TIMEOUT); - PR_Lock( bt_book.ml ); + /* we'll have to wait for some threads to finish - create a + sem to block on */ + bt_book.cleanUpSem = create_sem(0, "cleanup sem"); } PR_Unlock( bt_book.ml ); -#if 0 - /* I am not sure if it's safe to delete the cv and lock here, since - * there may still be "system" threads around. If this call isn't - * immediately prior to exiting, then there's a problem. */ - if (0 == bt_book.system) { - PR_DestroyCondVar(bt_book.cv); bt_book.cv = NULL; - PR_DestroyLock(bt_book.ml); bt_book.ml = NULL; - } - PR_DELETE(me); -#endif + /* note that, if all the user threads were already dead, we + wouldn't have created a sem above, so this acquire_sem() + will fail immediately */ + while (acquire_sem(bt_book.cleanUpSem) == B_INTERRUPTED); return PR_SUCCESS; } @@ -780,3 +625,46 @@ PR_IMPLEMENT(void) { exit(status); } + +PRThread *_bt_AttachThread() +{ + PRThread *thread; + thread_info tInfo; + + /* make sure this thread doesn't already have a PRThread structure */ + PR_ASSERT(tls_get(tls_prThreadSlot) == NULL); + + /* allocate a PRThread structure for this thread */ + thread = PR_NEWZAP(PRThread); + if (thread == NULL) + { + PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); + return NULL; + } + + /* get the native thread's current state */ + get_thread_info(find_thread(NULL), &tInfo); + + /* initialize new PRThread */ + thread->md.tid = tInfo.thread; + thread->md.joinSem = B_ERROR; + thread->priority = _bt_MapNativeToNSPRPriority(tInfo.priority); + + /* attached threads are always non-joinable user threads */ + thread->state = 0; + + /* increment user thread count */ + PR_Lock(bt_book.ml); + bt_book.threadCount++; + PR_Unlock(bt_book.ml); + + /* store this thread's PRThread */ + tls_set(tls_prThreadSlot, thread); + + /* the thread must call _bt_CleanupThread() before it dies, in order + to clean up its PRThread, synchronize with the primordial thread, + etc. */ + on_exit_thread(_bt_CleanupThread, NULL); + + return thread; +} diff --git a/pr/src/io/pripv6.c b/pr/src/io/pripv6.c index 485e449d..f5635a59 100644 --- a/pr/src/io/pripv6.c +++ b/pr/src/io/pripv6.c @@ -149,6 +149,7 @@ static PRFileDesc* PR_CALLBACK Ipv6ToIpv4SocketAccept ( PRFileDesc *newfd; PRFileDesc *newstack; PRNetAddr tmp_ipv4addr; + PRNetAddr *addrlower = NULL; PR_ASSERT(fd != NULL); PR_ASSERT(fd->lower != NULL); @@ -161,13 +162,16 @@ static PRFileDesc* PR_CALLBACK Ipv6ToIpv4SocketAccept ( } *newstack = *fd; /* make a copy of the accepting layer */ - newfd = (fd->lower->methods->accept)(fd->lower, &tmp_ipv4addr, timeout); + if (addr) + addrlower = &tmp_ipv4addr; + newfd = (fd->lower->methods->accept)(fd->lower, addrlower, timeout); if (NULL == newfd) { PR_DELETE(newstack); return NULL; } - _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr); + if (addr) + _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr); rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack); PR_ASSERT(PR_SUCCESS == rv); @@ -272,11 +276,29 @@ PRStatus _pr_init_ipv6() #if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME) PRLibrary *lib; - _pr_getipnodebyname_fp = PR_FindSymbolAndLibrary("getipnodebyname", &lib); +#if defined(VMS) +#define GETIPNODEBYNAME "DECC$GETIPNODEBYNAME" +#define GETIPNODEBYADDR "DECC$GETIPNODEBYADDR" +#define FREEHOSTENT "DECC$FREEHOSTENT" +#define GAISTRERROR "DECC$GAISTRERROR" + typedef char * (*_pr_getstrerror_t)(int); + _pr_getstrerror_t _pr_gaistrerror_fp; + _pr_getipnodebyname_fp = NULL; + _pr_gaistrerror_fp = (_pr_getstrerror_t)PR_FindSymbolAndLibrary(GAISTRERROR, &lib); + if (NULL != _pr_gaistrerror_fp) { + if (NULL != (*_pr_gaistrerror_fp)(0)) + _pr_getipnodebyname_fp = PR_FindSymbol(lib, GETIPNODEBYNAME); + } +#else +#define GETIPNODEBYNAME "getipnodebyname" +#define GETIPNODEBYADDR "getipnodebyaddr" +#define FREEHOSTENT "freehostent" + _pr_getipnodebyname_fp = PR_FindSymbolAndLibrary(GETIPNODEBYNAME, &lib); +#endif if (NULL != _pr_getipnodebyname_fp) { - _pr_freehostent_fp = PR_FindSymbol(lib, "freehostent"); + _pr_freehostent_fp = PR_FindSymbol(lib, FREEHOSTENT); if (NULL != _pr_freehostent_fp) { - _pr_getipnodebyaddr_fp = PR_FindSymbol(lib, "getipnodebyaddr"); + _pr_getipnodebyaddr_fp = PR_FindSymbol(lib, GETIPNODEBYADDR); if (NULL != _pr_getipnodebyaddr_fp) _pr_ipv6_is_present = PR_TRUE; else diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c index a43fe5a3..e5033bbd 100644 --- a/pr/src/io/prlog.c +++ b/pr/src/io/prlog.c @@ -14,6 +14,17 @@ * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. + * + * Contributors: + * + * This Original Code has been modified by IBM Corporation. + * Modifications made by IBM described herein are + * Copyright (c) International Business Machines Corporation, 2000. + * Modifications to Mozilla code or documentation identified per + * MPL Section 3.3 + * + * Date Modified by Description of modification + * 04/10/2000 IBM Corp. Added DebugBreak() definitions for OS/2 */ #include "primpl.h" @@ -55,7 +66,7 @@ static PRLock *_pr_logLock; #endif -#if defined(XP_PC) && !defined(XP_OS2_VACPP) +#if defined(XP_PC) #define strcasecmp stricmp #define strncasecmp strnicmp #endif @@ -104,7 +115,7 @@ static FILE *logFile = NULL; static PRFileDesc *logFile = 0; #endif -#define LINE_BUF_SIZE 200 +#define LINE_BUF_SIZE 512 #define DEFAULT_BUF_SIZE 16384 #ifdef _PR_NEED_STRCASECMP @@ -432,6 +443,24 @@ PR_IMPLEMENT(void) PR_Abort(void) } #ifdef DEBUG +#if defined(XP_OS2) +/* + * Added definitions for DebugBreak() for 2 different OS/2 compilers. + * Doing the int3 on purpose for Visual Age so that a developer can + * step over the instruction if so desired. Not always possible if + * trapping due to exception handling IBM-AKR + */ +#if defined(XP_OS2_VACPP) +#include +static void DebugBreak(void) { _interrupt(3); } +#elif defined(XP_OS2_EMX) +/* Force a trap */ +static void DebugBreak(void) { int *pTrap=NULL; *pTrap = 1; } +#else +static void DebugBreak(void) { } +#endif +#endif /* XP_OS2 */ + PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) { PR_LogPrint("Assertion failure: %s, at %s:%d\n", s, file, ln); @@ -441,7 +470,7 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) #ifdef XP_MAC dprintf("Assertion failure: %s, at %s:%d\n", s, file, ln); #endif -#ifdef WIN32 +#if defined(WIN32) || defined(XP_OS2) DebugBreak(); #endif #ifndef XP_MAC diff --git a/pr/src/io/prprf.c b/pr/src/io/prprf.c index 1da92e84..92856359 100644 --- a/pr/src/io/prprf.c +++ b/pr/src/io/prprf.c @@ -36,7 +36,9 @@ ** and requires array notation. */ #if (defined(LINUX) && defined(__powerpc__)) || defined(WIN16) || \ - defined(QNX) || (defined(__NetBSD__) && defined(__powerpc__)) + defined(QNX) || \ + (defined(__NetBSD__) && defined(__powerpc__) && \ + __NetBSD_Version__ < 105000000) #define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0] #else #define VARARGS_ASSIGN(foo, bar) (foo) = (bar) diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index 4ee568fd..8a3493bf 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -1304,7 +1304,7 @@ PR_IMPLEMENT(PRStatus) PR_NewTCPSocketPair(PRFileDesc *f[]) } selfAddr.sin_family = AF_INET; selfAddr.sin_port = 0; - selfAddr.sin_addr.s_addr = htonl(INADDR_ANY); + selfAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* BugZilla: 35408 */ addrLen = sizeof(selfAddr); if (bind(listenSock, (struct sockaddr *) &selfAddr, addrLen) == SOCKET_ERROR) { @@ -1382,7 +1382,7 @@ failed: if (listenSock == NULL) { goto failed; } - PR_InitializeNetAddr(PR_IpAddrAny, 0, &selfAddr); + PR_InitializeNetAddr(PR_IpAddrLoopback, 0, &selfAddr); /* BugZilla: 35408 */ if (PR_Bind(listenSock, &selfAddr) == PR_FAILURE) { goto failed; } diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index e4d093f1..57bc6a43 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -64,7 +64,8 @@ * On these platforms, symbols have a leading '_'. */ #if defined(SUNOS4) || defined(RHAPSODY) || defined(NEXTSTEP) \ - || defined(OPENBSD) || defined(WIN16) || defined(NETBSD) + || defined(OPENBSD) || defined(WIN16) \ + || (defined(NETBSD) && !defined(__ELF__)) #define NEED_LEADING_UNDERSCORE #endif @@ -480,6 +481,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) { PRLibrary *lm; PRLibrary* result; + PRInt32 oserr; if (!_pr_initialized) _PR_ImplicitInitialization(); @@ -490,7 +492,10 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) if (result != NULL) goto unlock; lm = PR_NEWZAP(PRLibrary); - if (lm == NULL) goto unlock; + if (lm == NULL) { + oserr = _MD_ERRNO(); + goto unlock; + } lm->staticTable = NULL; #ifdef XP_OS2 /* Why isn't all this stuff in MD code?! */ @@ -502,6 +507,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) retry: ulRc = DosLoadModule(pszError, _MAX_PATH, (PSZ) name, &h); if (ulRc != NO_ERROR) { + oserr = ulRc; PR_DELETE(lm); goto unlock; } @@ -519,6 +525,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) h = LoadLibrary(name); if (h < (HINSTANCE)HINSTANCE_ERROR) { + oserr = _MD_ERRNO(); PR_DELETE(lm); goto unlock; } @@ -538,7 +545,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) } #endif /* WIN32 || WIN16 */ -#if defined(XP_MAC) && GENERATINGCFM +#if defined(XP_MAC) && TARGET_RT_MAC_CFM { OSErr err; Ptr main; @@ -562,7 +569,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) 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 @@ -594,7 +601,10 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) &connectionID, &main, errName); #endif if (err != noErr) + { + oserr = err; goto unlock; + } libName = name; } @@ -624,7 +634,10 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) /* Copy the name: we'll change it */ cMacPath = strdup(name); if (cMacPath == NULL) + { + oserr = _MD_ERRNO(); goto unlock; + } /* First, get the vRefNum */ position = strchr(cMacPath, PR_PATH_SEPARATOR); @@ -646,6 +659,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) index--; if (index == 0 || index == strlen(cMacPath)) { + oserr = _MD_ERRNO(); PR_DELETE(cMacPath); goto unlock; } @@ -653,10 +667,8 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) cFileName = &(cMacPath[index + 1]); /* Convert the path and name into Pascal strings */ - strcpy((char*) &pName, cMacPath); - c2pstr((char*) &pName); - strcpy((char*) &fileSpec.name, cFileName); - c2pstr((char*) &fileSpec.name); + PStrFromCStr(cMacPath, pName); + PStrFromCStr(cFileName, fileSpec.name); strcpy(cName, cFileName); PR_DELETE(cMacPath); cMacPath = NULL; @@ -668,14 +680,20 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) pb.dirInfo.ioFDirIndex = 0; err = PBGetCatInfoSync(&pb); if (err != noErr) + { + oserr = err; goto unlock; + } fileSpec.parID = pb.dirInfo.ioDrDirID; /* Resolve an alias if this was one */ err = ResolveAliasFile(&fileSpec, true, &tempUnusedBool, &tempUnusedBool); if (err != noErr) + { + oserr = err; goto unlock; + } /* Finally, try to load the library */ err = GetDiskFragment(&fileSpec, 0, kCFragGoesToEOF, fileSpec.name, @@ -683,7 +701,10 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) libName = cName; if (err != noErr) + { + oserr = err; goto unlock; + } } lm->name = strdup(libName); @@ -691,7 +712,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) lm->next = pr_loadmap; pr_loadmap = lm; } -#elif defined(XP_MAC) && !GENERATINGCFM +#elif defined(XP_MAC) && !TARGET_RT_MAC_CFM { } @@ -734,12 +755,13 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) NSModule h = NULL; if (NSCreateObjectFileImageFromFile(name, &ofi) == NSObjectFileImageSuccess) { - h = NSLinkModule(ofi, name, TRUE); + h = NSLinkModule(ofi, name, NSLINKMODULE_OPTION_PRIVATE); } #else #error Configuration error #endif if (!h) { + oserr = _MD_ERRNO(); PR_DELETE(lm); goto unlock; } @@ -758,21 +780,82 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) image_info info; int32 cookie = 0; image_id h = B_ERROR; + PRLibrary *p; - while(get_next_image_info(0, &cookie, &info) == B_OK) - if(strcmp(name, info.name + strlen(info.name) - strlen(name)) == 0) { + for (p = pr_loadmap; p != NULL; p = p->next) { + /* hopefully, our caller will always use the same string + to refer to the same library */ + if (strcmp(name, p->name) == 0) { + /* we've already loaded this library */ h = info.id; - lm->refCount++; /* it has been already loaded implcitly, so pretend it already had a control structure and ref */ + lm->refCount++; + break; } + } - if(h == B_ERROR) - h = load_add_on( name ); + if(h == B_ERROR) { + /* it appears the library isn't yet loaded - load it now */ + char stubName [B_PATH_NAME_LENGTH + 1]; + + /* the following is a work-around to a "bug" in the beos - + the beos system loader allows only 32M (system-wide) + to be used by code loaded as "add-ons" (code loaded + through the 'load_add_on()' system call, which includes + mozilla components), but allows 256M to be used by + shared libraries. + + unfortunately, mozilla is too large to fit into the + "add-on" space, so we must trick the loader into + loading some of the components as shared libraries. this + is accomplished by creating a "stub" add-on (an empty + shared object), and linking it with the component + (the actual .so file generated by the build process, + without any modifications). when this stub is loaded + by load_add_on(), the loader will automatically load the + component into the shared library space. + */ + + strcpy(stubName, name); + strcat(stubName, ".stub"); + + /* first, attempt to load the stub (thereby loading the + component as a shared library */ + if ((h = load_add_on(stubName)) > B_ERROR) { + /* the stub was loaded successfully. however, the stub + itself is useless (so useless, in fact, that we will + simply unload it) */ + unload_add_on(h); + h = B_FILE_NOT_FOUND; + + cookie = 0; + while (get_next_image_info(0, &cookie, &info) == B_OK) { + char *endOfSystemName = strrchr(info.name, '/'); + char *endOfPassedName = strrchr(name, '/'); + if( 0 == endOfSystemName ) + endOfSystemName=info.name; + else + endOfSystemName++; + if( 0 == endOfPassedName ) + endOfPassedName=name; + else + endOfPassedName++; + if (strcmp(endOfSystemName, endOfPassedName) == 0) { + /* this is the actual component - remember it */ + h = info.id; + break; + } + } + + } else { + /* we failed to load the "stub" - try to load the + component directly as an add-on */ + h = load_add_on(name); + } + } - if( h == B_ERROR || h <= 0 ) { - h = 0; - result = NULL; + if (h <= B_ERROR) { + oserr = h; PR_DELETE( lm ); - lm = NULL; goto unlock; } lm->name = strdup(name); @@ -787,8 +870,8 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) unlock: if (result == NULL) { - PR_SetError(PR_LOAD_LIBRARY_ERROR, _MD_ERRNO()); - DLLErrorInternal(_MD_ERRNO()); /* sets error text */ + PR_SetError(PR_LOAD_LIBRARY_ERROR, oserr); + DLLErrorInternal(oserr); /* sets error text */ } PR_ExitMonitor(pr_linker_lock); return result; @@ -976,7 +1059,7 @@ PR_UnloadLibrary(PRLibrary *lib) } #endif /* XP_PC */ -#if defined(XP_MAC) && GENERATINGCFM +#if defined(XP_MAC) && TARGET_RT_MAC_CFM /* Close the connection */ CloseConnection(&(lib->dlh)); #endif @@ -1083,7 +1166,14 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) f = NULL; } #elif defined(USE_MACH_DYLD) - f = NSAddressOfSymbol(NSLookupAndBindSymbol(name)); + { + NSSymbol symbol; + symbol = NSLookupSymbolInModule(lm->dlh, name); + if (symbol != NULL) + f = NSAddressOfSymbol(symbol); + else + f = NULL; + } #endif #endif /* HAVE_DLL */ #endif /* XP_UNIX */ diff --git a/pr/src/md/mac/macdll.c b/pr/src/md/mac/macdll.c index bebf2356..ba9465d0 100644 --- a/pr/src/md/mac/macdll.c +++ b/pr/src/md/mac/macdll.c @@ -530,6 +530,15 @@ OSErr NSLoadIndexedFragment(const FSSpec *fileSpec, PRUint32 fragmentIndex, 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) diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c index 7b6e4441..53023ad0 100644 --- a/pr/src/md/mac/macsockotpt.c +++ b/pr/src/md/mac/macsockotpt.c @@ -29,6 +29,12 @@ #define GESTALT_OPEN_TPT_TCP_PRESENT gestaltOpenTptTCPPresentMask #include // All the internet typedefs + +#if (UNIVERSAL_INTERFACES_VERSION >= 0x0330) +// for some reason Apple removed this typedef. +typedef struct OTConfiguration OTConfiguration; +#endif + #include "primpl.h" typedef enum SndRcvOpCode { @@ -45,11 +51,10 @@ static struct { void * cookie; } dnsContext; -static PRBool gOTInitialized; static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie); -static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, - OTResult result, void * cookie); +static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie); +static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie); static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady); @@ -59,24 +64,20 @@ extern void DoneWaitingOnThisThread(PRThread *thread); #if TARGET_CARBON OTClientContextPtr clientContext = NULL; -OTNotifyUPP DNSNotifierRoutineUPP; -OTNotifyUPP notifierRoutineUPP; - -#define DNS_NOTIFIER_ROUTINE DNSNotifierRoutineUPP -#define NOTIFIER_ROUTINE notifierRoutineUPP -#define INIT_OPEN_TRANSPORT() InitOpenTransport(clientContext, kInitOTForExtensionMask) -#define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServices(config, flags, err, clientContext) -#define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpoint(config, flags, info, err, clientContext) +#define INIT_OPEN_TRANSPORT() InitOpenTransportInContext(kInitOTForExtensionMask, &clientContext) +#define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServicesInContext(config, flags, err, clientContext) +#define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpointInContext(config, flags, info, err, clientContext) #else -#define DNS_NOTIFIER_ROUTINE DNSNotifierRoutine -#define NOTIFIER_ROUTINE NotifierRoutine #define INIT_OPEN_TRANSPORT() InitOpenTransport() #define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServices(config, flags, err) #define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpoint(config, flags, info, err) #endif /* TARGET_CARBON */ +static OTNotifyUPP DNSNotifierRoutineUPP; +static OTNotifyUPP NotifierRoutineUPP; +static OTNotifyUPP RawEndpointNotifierRoutineUPP; void _MD_InitNetAccess() { @@ -97,26 +98,20 @@ void _MD_InitNetAccess() PR_ASSERT(hasOTTCPIP == PR_TRUE); -#if TARGET_CARBON DNSNotifierRoutineUPP = NewOTNotifyUPP(DNSNotifierRoutine); - notifierRoutineUPP = NewOTNotifyUPP(NotifierRoutine); - - errOT = OTAllocClientContext((UInt32)0, &clientContext); - PR_ASSERT(err == kOTNoError); -#endif - + NotifierRoutineUPP = NewOTNotifyUPP(NotifierRoutine); + RawEndpointNotifierRoutineUPP = NewOTNotifyUPP(RawEndpointNotifierRoutine); errOT = INIT_OPEN_TRANSPORT(); PR_ASSERT(err == kOTNoError); + dnsContext.serviceRef = NULL; dnsContext.lock = PR_NewLock(); PR_ASSERT(dnsContext.lock != NULL); dnsContext.thread = _PR_MD_CURRENT_THREAD(); dnsContext.cookie = NULL; - gOTInitialized = PR_FALSE; - /* XXX Does not handle absence of open tpt and tcp yet! */ } @@ -124,36 +119,65 @@ static void _MD_FinishInitNetAccess() { OSStatus errOT; + if (dnsContext.serviceRef) + return; + dnsContext.serviceRef = OT_OPEN_INTERNET_SERVICES(kDefaultInternetServicesPath, NULL, &errOT); - if (errOT != kOTNoError) return; /* no network -- oh well */ + if (errOT != kOTNoError) { + dnsContext.serviceRef = NULL; + return; /* no network -- oh well */ + } + PR_ASSERT((dnsContext.serviceRef != NULL) && (errOT == kOTNoError)); /* Install notify function for DNR Address To String completion */ - errOT = OTInstallNotifier(dnsContext.serviceRef, DNS_NOTIFIER_ROUTINE, &dnsContext); + errOT = OTInstallNotifier(dnsContext.serviceRef, DNSNotifierRoutineUPP, &dnsContext); PR_ASSERT(errOT == kOTNoError); /* Put us into async mode */ errOT = OTSetAsynchronous(dnsContext.serviceRef); PR_ASSERT(errOT == kOTNoError); - - gOTInitialized = PR_TRUE; } -pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) +static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode otEvent, OTResult result, void * cookie) { #pragma unused(contextPtr) _PRCPU * cpu = _PR_MD_CURRENT_CPU(); - - if (code == T_DNRSTRINGTOADDRCOMPLETE) { + OSStatus errOT; + dnsContext.thread->md.osErrCode = result; dnsContext.cookie = cookie; - if (_PR_MD_GET_INTSOFF()) { - cpu->u.missed[cpu->where] |= _PR_MISSED_IO; - dnsContext.thread->md.missedIONotify = PR_TRUE; - return; - } - DoneWaitingOnThisThread(dnsContext.thread); + + switch (otEvent) { + case T_DNRSTRINGTOADDRCOMPLETE: + if (_PR_MD_GET_INTSOFF()) { + cpu->u.missed[cpu->where] |= _PR_MISSED_IO; + dnsContext.thread->md.missedIONotify = PR_TRUE; + return; + } + DoneWaitingOnThisThread(dnsContext.thread); + break; + + case kOTProviderWillClose: + errOT = OTSetSynchronous(dnsContext.serviceRef); + // fall through to kOTProviderIsClosed case + + case kOTProviderIsClosed: + errOT = OTCloseProvider((ProviderRef)dnsContext.serviceRef); + dnsContext.serviceRef = nil; + + if (_PR_MD_GET_INTSOFF()) { + cpu->u.missed[cpu->where] |= _PR_MISSED_IO; + dnsContext.thread->md.missedIONotify = PR_TRUE; + return; + } + DoneWaitingOnThisThread(dnsContext.thread); + break; + + default: // or else we don't handle the event + PR_ASSERT(otEvent==NULL); + } // or else we don't handle the event } @@ -262,7 +286,7 @@ WakeUpNotifiedThread(PRThread *thread, OTResult result) // Notification routine // Async callback routine. // A5 is OK. Cannot allocate memory here -pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) +static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) { PRFilePrivate *secret = (PRFilePrivate *) contextPtr; _MDFileDesc * md = &(secret->md); @@ -473,7 +497,6 @@ PRInt32 _MD_socket(int domain, int type, int protocol) OSStatus err; EndpointRef endpoint; - if (!gOTInitialized) _MD_FinishInitNetAccess(); // We only deal with internet domain @@ -1037,7 +1060,7 @@ typedef struct RawEndpointAndThread // Notification routine for raw endpoints not yet attached to a PRFileDesc. // Async callback routine. // A5 is OK. Cannot allocate memory here -pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) +static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie) { RawEndpointAndThread *endthr = (RawEndpointAndThread *) contextPtr; PRThread * thread = endthr->thread; @@ -1194,7 +1217,7 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRInterva endthr->thread = me; endthr->endpoint = (EndpointRef) newosfd; - err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutine, endthr); + err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutineUPP, endthr); PR_ASSERT(err == kOTNoError); err = OTSetAsynchronous((EndpointRef) newosfd); @@ -1350,6 +1373,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, PRInt32 bytesLeft = amount; PR_ASSERT(flags == 0); + PR_ASSERT(opCode == kSTREAM_SEND || opCode == kSTREAM_RECEIVE); if (endpoint == NULL) { err = kEBADFErr; @@ -1361,11 +1385,6 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, goto ErrorExit; } - if (opCode != kSTREAM_SEND && opCode != kSTREAM_RECEIVE) { - err = kEINVALErr; - goto ErrorExit; - } - while (bytesLeft > 0) { PrepareForAsyncCompletion(me, fd->secret->md.osfd); @@ -1434,6 +1453,10 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, } me->io_pending = PR_FALSE; + if (opCode == kSTREAM_SEND) + fd->secret->md.write.thread = nil; + else + fd->secret->md.read.thread = nil; if (result > 0) { buf = (void *) ( (UInt32) buf + (UInt32)result ); @@ -1442,9 +1465,6 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, return result; } else { switch (result) { - case kOTOutStateErr: // it has been closed - return 0; - case kOTLookErr: PR_ASSERT(!"call to OTLook() required after all."); break; @@ -1464,6 +1484,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, goto ErrorExit; break; + case kOTOutStateErr: // it has been closed, fall through to handle error default: err = result; goto ErrorExit; @@ -1471,9 +1492,13 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, } } + PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil : + fd->secret->md.read.thread == nil); return amount; ErrorExit: + PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil : + fd->secret->md.read.thread == nil); macsock_map_error(err); return -1; } @@ -1789,7 +1814,7 @@ void _MD_makenonblock(PRFileDesc *fd) // fd changes, but the secret structure does not; // (b) the notifier func refers only to the secret data structure // anyway. - err = OTInstallNotifier(endpointRef, NOTIFIER_ROUTINE, fd->secret); + err = OTInstallNotifier(endpointRef, NotifierRoutineUPP, fd->secret); PR_ASSERT(err == kOTNoError); // Now that we have a NotifierRoutine installed, we can make the endpoint asynchronous @@ -1862,11 +1887,11 @@ PR_IMPLEMENT(unsigned long) inet_addr(const char *cp) OSStatus err; InetHost host; - if (!gOTInitialized) _MD_FinishInitNetAccess(); err = OTInetStringToHost((char*) cp, &host); - PR_ASSERT(err == kOTNoError); + if (err != kOTNoError) + return -1; return host; } @@ -1884,7 +1909,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyname(const char * name) PRUint32 index; PRThread *me = _PR_MD_CURRENT_THREAD(); - if (!gOTInitialized) _MD_FinishInitNetAccess(); me->io_pending = PR_TRUE; @@ -1925,7 +1949,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int PR_ASSERT(type == AF_INET); PR_ASSERT(addrlen == sizeof(struct in_addr)); - if (!gOTInitialized) _MD_FinishInitNetAccess(); OTInetHostToString((InetHost)addr, sHostInfo.name); @@ -1936,7 +1959,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int PR_IMPLEMENT(char *) inet_ntoa(struct in_addr addr) { - if (!gOTInitialized) _MD_FinishInitNetAccess(); OTInetHostToString((InetHost)addr.s_addr, sHostInfo.name); @@ -1950,7 +1972,6 @@ PRStatus _MD_gethostname(char *name, int namelen) OSStatus err; InetInterfaceInfo info; - if (!gOTInitialized) _MD_FinishInitNetAccess(); /* diff --git a/pr/src/md/mac/mdmac.c b/pr/src/md/mac/mdmac.c index c762baa7..bca487a7 100644 --- a/pr/src/md/mac/mdmac.c +++ b/pr/src/md/mac/mdmac.c @@ -344,7 +344,7 @@ void PR_InitMemory(void) { #if TARGET_CARBON extern OTClientContextPtr clientContext; -#define CLOSE_OPEN_TRANSPORT() CloseOpenTransport(clientContext) +#define CLOSE_OPEN_TRANSPORT() CloseOpenTransportInContext(clientContext) #else @@ -739,7 +739,7 @@ extern long _MD_GetArchitecture(char *buf, long count) { long len; -#if defined(GENERATINGPOWERPC) && GENERATINGPOWERPC +#if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC len = PR_snprintf(buf, count, "PowerPC"); #else len = PR_snprintf(buf, count, "Motorola68k"); diff --git a/pr/src/md/mac/prcpucfg.h b/pr/src/md/mac/prcpucfg.h index bc203a42..9483f1f3 100644 --- a/pr/src/md/mac/prcpucfg.h +++ b/pr/src/md/mac/prcpucfg.h @@ -112,6 +112,6 @@ #define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 #define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 #define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 -#endif NO_NSPR_10_SUPPORT +#endif /* NO_NSPR_10_SUPPORT */ #endif /* nspr_cpucfg___ */ diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index e6977ff7..e7e7b705 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -14,6 +14,23 @@ * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. + * + * This Original Code has been modified by IBM Corporation. + * Modifications made by IBM described herein are + * Copyright (c) International Business Machines + * Corporation, 2000 + * + * Modifications to Mozilla code or documentation + * identified per MPL Section 3.3 + * + * Date Modified by Description of modification + * 03/23/2000 IBM Corp. Changed write() to DosWrite(). EMX i/o + * calls cannot be intermixed with DosXXX + * calls since EMX remaps file/socket + * handles. + * 04/27/2000 IBM Corp. Changed open file to be more like NT and + * better handle PR_TRUNCATE | PR_CREATE_FILE + * and also fixed _PR_MD_SET_FD_INHERITABLE */ /* OS2 IO module @@ -107,25 +124,40 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) { HFILE file; PRInt32 access = OPEN_SHARE_DENYNONE; - PRInt32 flags = OPEN_ACTION_OPEN_IF_EXISTS; + PRInt32 flags = 0L; PRInt32 rc; PRUword actionTaken; ULONG CurMaxFH = 0; LONG ReqCount = 1; ULONG fattr; - + + if (osflags & PR_SYNC) access |= OPEN_FLAGS_WRITE_THROUGH; + if (osflags & PR_RDONLY) access |= OPEN_ACCESS_READONLY; else if (osflags & PR_WRONLY) access |= OPEN_ACCESS_WRITEONLY; else if(osflags & PR_RDWR) access |= OPEN_ACCESS_READWRITE; - if (osflags & PR_CREATE_FILE) - flags |= OPEN_ACTION_CREATE_IF_NEW; - else if (osflags & PR_TRUNCATE){ - flags &= ~OPEN_ACTION_OPEN_IF_EXISTS; - flags |= OPEN_ACTION_REPLACE_IF_EXISTS; + + if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL ) + { + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS; + } + else if (osflags & PR_CREATE_FILE) + { + if (osflags & PR_TRUNCATE) + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; + else + flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; + } + else + { + if (osflags & PR_TRUNCATE) + flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS; + else + flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; } if (isxdigit(mode) == 0) /* file attribs are hex, UNIX modes octal */ @@ -182,23 +214,16 @@ _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) PRInt32 bytes; int rv; - /* No longer using DosWrite since it doesn't convert \n to \n\r like C runtime does */ -#if 0 rv = DosWrite((HFILE)fd->secret->md.osfd, (PVOID)buf, len, - &bytes); + (PULONG)&bytes); if (rv != NO_ERROR) { - _PR_MD_MAP_WRITE_ERROR(rv); + _PR_MD_MAP_WRITE_ERROR(rv); return -1; } -#else - bytes = write(fd->secret->md.osfd, buf, len); - if (bytes == -1) - _PR_MD_MAP_WRITE_ERROR(errno); -#endif return bytes; } /* --- end _PR_MD_WRITE() --- */ @@ -718,7 +743,7 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable) } if (inheritable) - flags &= OPEN_FLAGS_NOINHERIT; + flags &= ~OPEN_FLAGS_NOINHERIT; else flags |= OPEN_FLAGS_NOINHERIT; diff --git a/pr/src/md/unix/Makefile b/pr/src/md/unix/Makefile index de8baadd..97248fb5 100644 --- a/pr/src/md/unix/Makefile +++ b/pr/src/md/unix/Makefile @@ -237,6 +237,12 @@ ifeq ($(OS_ARCH),SunOS) endif endif +ifeq ($(OS_ARCH),Linux) + ifeq ($(CPU_ARCH),x86) + ASFILES = os_Linux_x86.s + endif +endif + ifeq ($(OS_ARCH), SINIX) ifeq ($(CPU_ARCH),mips) ASFILES = os_ReliantUNIX.s diff --git a/pr/src/md/unix/Makefile.in b/pr/src/md/unix/Makefile.in index 9fb73bf8..6951873e 100644 --- a/pr/src/md/unix/Makefile.in +++ b/pr/src/md/unix/Makefile.in @@ -248,6 +248,12 @@ ifeq ($(OS_ARCH),SunOS) endif endif +ifeq ($(OS_ARCH),Linux) + ifeq ($(CPU_ARCH),x86) + ASFILES = os_Linux_x86.s + endif +endif + ifeq ($(OS_ARCH), SINIX) ifeq ($(CPU_ARCH),mips) ASFILES = os_ReliantUNIX.s diff --git a/pr/src/md/unix/darwin.c b/pr/src/md/unix/darwin.c index ff5f1ad7..93421318 100644 --- a/pr/src/md/unix/darwin.c +++ b/pr/src/md/unix/darwin.c @@ -87,13 +87,32 @@ _MD_CREATE_THREAD( } #endif /* ! _PR_PTHREADS */ +#if defined(_PR_PTHREADS) + /* -** Whoops, we don't have a syscall stub for this +** Stubs for unimplemented functions */ -int mprotect (caddr_t addr, size_t size, int prot) + +int pthread_condattr_init(pthread_condattr_t *attr) +{ + return 0; +} + +int pthread_kill(pthread_t thread, int sig) { - return -1; -} + 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 */ /* rhapsody.c */ diff --git a/pr/src/md/unix/objs.mk b/pr/src/md/unix/objs.mk index d8196c81..d2aa9cb4 100644 --- a/pr/src/md/unix/objs.mk +++ b/pr/src/md/unix/objs.mk @@ -235,6 +235,12 @@ ifeq ($(OS_ARCH),SunOS) endif endif +ifeq ($(OS_ARCH),Linux) + ifeq ($(CPU_ARCH),x86) + ASFILES = os_Linux_x86.s + endif +endif + ifeq ($(OS_ARCH), SINIX) ifeq ($(CPU_ARCH),mips) ASFILES = os_ReliantUNIX.s diff --git a/pr/src/md/unix/os_Linux_x86.s b/pr/src/md/unix/os_Linux_x86.s new file mode 100644 index 00000000..f72f28d2 --- /dev/null +++ b/pr/src/md/unix/os_Linux_x86.s @@ -0,0 +1,95 @@ +/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +/ +/ The contents of this file are subject to the Netscape Public License +/ Version 1.1 (the "NPL"); you may not use this file except in +/ compliance with the NPL. You may obtain a copy of the NPL at +/ http://www.mozilla.org/NPL/ +/ +/ Software distributed under the NPL is distributed on an "AS IS" basis, +/ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL +/ for the specific language governing rights and limitations under the +/ NPL. +/ +/ The Initial Developer of this code under the NPL is Netscape +/ Communications Corporation. Portions created by Netscape are +/ Copyright (C) 2000 Netscape Communications Corporation. All Rights +/ Reserved. +/ + +/ PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val) +/ +/ Atomically increment the integer pointed to by 'val' and return +/ the result of the increment. +/ + .text + .globl _PR_x86_AtomicIncrement + .align 4 +_PR_x86_AtomicIncrement: + movl 4(%esp), %ecx + movl $1, %eax + lock + xaddl %eax, (%ecx) + incl %eax + ret + +/ PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val) +/ +/ Atomically decrement the integer pointed to by 'val' and return +/ the result of the decrement. +/ + .text + .globl _PR_x86_AtomicDecrement + .align 4 +_PR_x86_AtomicDecrement: + movl 4(%esp), %ecx + movl $-1, %eax + lock + xaddl %eax, (%ecx) + decl %eax + ret + +/ PRInt32 _PR_x86_AtomicSet(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_x86_AtomicSet +/ .align 4 +/_PR_x86_AtomicSet: +/ movl 4(%esp), %ecx +/ movl 8(%esp), %edx +/ movl (%ecx), %eax +/retry: +/ lock +/ cmpxchgl %edx, (%ecx) +/ jne retry +/ ret +/ + .text + .globl _PR_x86_AtomicSet + .align 4 +_PR_x86_AtomicSet: + movl 4(%esp), %ecx + movl 8(%esp), %eax + lock + xchgl %eax, (%ecx) + ret + +/ PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val) +/ +/ Atomically add 'val' to the integer pointed to by 'ptr' +/ and return the result of the addition. +/ + .text + .globl _PR_x86_AtomicAdd + .align 4 +_PR_x86_AtomicAdd: + 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/unix/rhapsody.c b/pr/src/md/unix/rhapsody.c index ff5f1ad7..93421318 100644 --- a/pr/src/md/unix/rhapsody.c +++ b/pr/src/md/unix/rhapsody.c @@ -87,13 +87,32 @@ _MD_CREATE_THREAD( } #endif /* ! _PR_PTHREADS */ +#if defined(_PR_PTHREADS) + /* -** Whoops, we don't have a syscall stub for this +** Stubs for unimplemented functions */ -int mprotect (caddr_t addr, size_t size, int prot) + +int pthread_condattr_init(pthread_condattr_t *attr) +{ + return 0; +} + +int pthread_kill(pthread_t thread, int sig) { - return -1; -} + 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 */ /* rhapsody.c */ diff --git a/pr/src/md/unix/uxproces.c b/pr/src/md/unix/uxproces.c index 8c0a9b96..d6cacf6d 100644 --- a/pr/src/md/unix/uxproces.c +++ b/pr/src/md/unix/uxproces.c @@ -27,7 +27,11 @@ #include /* For dlopen, dlsym, dlclose */ #endif +#if defined(RHAPSODY) +#include +#else extern char **environ; +#endif /* * HP-UX 9 doesn't have the SA_RESTART flag. @@ -36,6 +40,10 @@ extern char **environ; #define SA_RESTART 0 #endif +#if defined(VMS) +static PRLock *_pr_vms_fork_lock = NULL; +#endif + /* ********************************************************************** * @@ -146,7 +154,10 @@ ForkAndExec( char *const *childEnvp; char **newEnvp = NULL; int flags; - +#ifdef VMS + char VMScurdir[FILENAME_MAX+1] = { '\0' } ; +#endif + process = PR_NEW(PRProcess); if (!process) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); @@ -156,7 +167,11 @@ ForkAndExec( childEnvp = envp; if (attr && attr->fdInheritBuffer) { if (NULL == childEnvp) { +#ifdef RHAPSODY + childEnvp = *(_NSGetEnviron()); +#else childEnvp = environ; +#endif } for (nEnv = 0; childEnvp[nEnv]; nEnv++) { } @@ -173,6 +188,65 @@ ForkAndExec( newEnvp[idx] = NULL; childEnvp = newEnvp; } +#ifdef VMS +/* +** Since vfork/exec is implemented VERY differently on OpenVMS, we have to +** handle the setting up of the standard streams very differently. And since +** none of this code can ever execute in the context of the child, we have +** to perform the chdir in the parent so the child is born into the correct +** directory (and then switch the parent back again). +*/ +{ + int decc$set_child_standard_streams(int,int,int); + int n, fd_stdin=0, fd_stdout=1, fd_stderr=2; + + /* Set up any standard streams we are given, assuming defaults */ + if (attr) { + if (attr->stdinFd) + fd_stdin = attr->stdinFd->secret->md.osfd; + if (attr->stdoutFd) + fd_stdout = attr->stdoutFd->secret->md.osfd; + if (attr->stderrFd) + fd_stderr = attr->stderrFd->secret->md.osfd; + } + + /* + ** Put a lock around anything that isn't going to be thread-safe. + */ + PR_Lock(_pr_vms_fork_lock); + + /* + ** Prepare the child's streams. We always do this in case a previous fork + ** has left the stream assignments in some non-standard way. + */ + n = decc$set_child_standard_streams(fd_stdin,fd_stdout,fd_stderr); + if (n == -1) { + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, errno); + PR_DELETE(process); + if (newEnvp) { + PR_DELETE(newEnvp); + } + PR_Unlock(_pr_vms_fork_lock); + return NULL; + } + + /* Switch directory if we have to */ + if (attr) { + if (attr->currentDirectory) { + if ( (getcwd(VMScurdir,sizeof(VMScurdir)) == NULL) || + (chdir(attr->currentDirectory) < 0) ) { + PR_SetError(PR_DIRECTORY_OPEN_ERROR, errno); + PR_DELETE(process); + if (newEnvp) { + PR_DELETE(newEnvp); + } + PR_Unlock(_pr_vms_fork_lock); + return NULL; + } + } + } +} +#endif /* VMS */ #ifdef AIX process->md.pid = (*pr_wp.forkptr)(); @@ -193,7 +267,9 @@ ForkAndExec( * the standard I/O file descriptors, and hence corrupt * the parent process's standard I/O data structures. */ - +#ifdef VMS + /* OpenVMS has already handled all this above */ +#else if (attr) { if (attr->stdinFd && attr->stdinFd->secret->md.osfd != 0) { @@ -234,6 +310,7 @@ ForkAndExec( } } } +#endif /* !VMS */ if (childEnvp) { (void)execve(path, argv, childEnvp); @@ -242,12 +319,35 @@ ForkAndExec( (void)execv(path, argv); } /* Whoops! It returned. That's a bad sign. */ +#ifdef VMS + /* + ** On OpenVMS we are still in the context of the parent, and so we + ** can (and should!) perform normal error handling. + */ + PR_SetError(PR_UNKNOWN_ERROR, errno); + PR_DELETE(process); + if (newEnvp) { + PR_DELETE(newEnvp); + } + if (VMScurdir[0] != '\0') + chdir(VMScurdir); + PR_Unlock(_pr_vms_fork_lock); + return NULL; +#else _exit(1); +#endif /* VMS */ } if (newEnvp) { PR_DELETE(newEnvp); } +#ifdef VMS + /* If we switched directories, then remember to switch back */ + if (VMScurdir[0] != '\0') { + chdir(VMScurdir); /* can't do much if it fails */ + } + PR_Unlock(_pr_vms_fork_lock); +#endif /* VMS */ #if defined(_PR_NATIVE_THREADS) PR_Lock(pr_wp.ml); @@ -655,6 +755,10 @@ static PRStatus _MD_InitProcesses() pr_wp.ml = PR_NewLock(); PR_ASSERT(NULL != pr_wp.ml); +#if defined(VMS) + _pr_vms_fork_lock = PR_NewLock(); + PR_ASSERT(NULL != _pr_vms_fork_lock); +#endif #if defined(_PR_NATIVE_THREADS) pr_wp.numProcs = 0; pr_wp.cv = PR_NewCondVar(pr_wp.ml); diff --git a/pr/src/md/unix/uxrng.c b/pr/src/md/unix/uxrng.c index 23b88705..305d13af 100644 --- a/pr/src/md/unix/uxrng.c +++ b/pr/src/md/unix/uxrng.c @@ -261,7 +261,8 @@ GetHighResClock(void *buf, size_t maxbytes) { return 0; } -#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) || defined(QNX) +#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) \ + || defined(QNX) || defined(RHAPSODY) #include static size_t diff --git a/pr/src/md/unix/uxshm.c b/pr/src/md/unix/uxshm.c index 162ffb46..070f9fba 100644 --- a/pr/src/md/unix/uxshm.c +++ b/pr/src/md/unix/uxshm.c @@ -609,7 +609,7 @@ extern PRFileMap * _md_ImportFileMapFromString( PRInt32 osfd; PRIntn prot; /* really: a PRFileMapProtect */ PRFileDesc *fd; - PRFileMap *fm; + PRFileMap *fm = NULL; /* default return value */ PRFileInfo64 info; PR_sscanf( fmstring, "%ld:%d", &osfd, &prot ); diff --git a/pr/src/md/windows/ntinrval.c b/pr/src/md/windows/ntinrval.c index ba5e1e8e..ea67302d 100644 --- a/pr/src/md/windows/ntinrval.c +++ b/pr/src/md/windows/ntinrval.c @@ -72,7 +72,7 @@ _PR_MD_GET_INTERVAL() #elif defined(WIN16) return clock(); /* milliseconds since application start */ #else - return timeGetTime(); /* milliseconds since system start */ + return GetTickCount(); /* milliseconds since system start */ #endif } diff --git a/pr/src/md/windows/ntio.c b/pr/src/md/windows/ntio.c index 5326be68..fb8cc5ff 100644 --- a/pr/src/md/windows/ntio.c +++ b/pr/src/md/windows/ntio.c @@ -744,7 +744,7 @@ void _PR_Unblock_IO_Wait(PRThread *thr) * this thread will continue to run on the same cpu until the * I/O is aborted by closing the FD or calling CancelIO */ - thr->md.thr_bound_cpu = me->cpu; + thr->md.thr_bound_cpu = cpu; PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD)); _PR_AddThreadToRunQ(me, thr); @@ -2044,7 +2044,7 @@ _PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len) PR_SetError(PR_NOT_CONNECTED_ERROR, 0); return PR_FAILURE; } - *len = PR_NETADDR_SIZE(addr); + *len = PR_NETADDR_SIZE(&fd->secret->md.peer_addr); memcpy(addr, &fd->secret->md.peer_addr, *len); return PR_SUCCESS; } else { @@ -3016,7 +3016,10 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) } len = GetFullPathName(fn, sizeof(pathbuf), pathbuf, &filePart); - PR_ASSERT(0 != len); + if (0 == len) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } if (len > sizeof(pathbuf)) { PR_SetError(PR_NAME_TOO_LONG_ERROR, 0); return -1; diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c index d80736fe..3832eb4b 100644 --- a/pr/src/md/windows/w95io.c +++ b/pr/src/md/windows/w95io.c @@ -773,7 +773,10 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) } len = GetFullPathName(fn, sizeof(pathbuf), pathbuf, &filePart); - PR_ASSERT(0 != len); + if (0 == len) { + _PR_MD_MAP_OPENDIR_ERROR(GetLastError()); + return -1; + } if (len > sizeof(pathbuf)) { PR_SetError(PR_NAME_TOO_LONG_ERROR, 0); return -1; diff --git a/pr/src/memory/Makefile b/pr/src/memory/Makefile index 25762308..28c15b13 100644 --- a/pr/src/memory/Makefile +++ b/pr/src/memory/Makefile @@ -30,6 +30,10 @@ endif CSRCS = prseg.c prshm.c prshma.c +ifdef GC_LEAK_DETECTOR +CSRCS += prgcleak.c +endif + TARGETS = $(OBJS) INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private diff --git a/pr/src/memory/Makefile.in b/pr/src/memory/Makefile.in index 7fa317e3..53c9dde1 100644 --- a/pr/src/memory/Makefile.in +++ b/pr/src/memory/Makefile.in @@ -37,6 +37,10 @@ endif #!USE_AUTOCONF CSRCS = prseg.c prshm.c prshma.c +ifdef GC_LEAK_DETECTOR +CSRCS += prgcleak.c +endif + TARGETS = $(OBJS) INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private diff --git a/pr/src/memory/prgcleak.c b/pr/src/memory/prgcleak.c new file mode 100644 index 00000000..4006ad71 --- /dev/null +++ b/pr/src/memory/prgcleak.c @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All Rights + * Reserved. + * + * Contributor(s): + * Patrick Beard + */ + +/* + * prgcleak.c + */ + +#ifdef GC_LEAK_DETECTOR + +/* for FILE */ +#include + +/* NSPR stuff */ +#include "generic_threads.h" +#include "primpl.h" + +extern FILE *GC_stdout, *GC_stderr; + +extern void GC_gcollect(void); +extern void GC_clear_roots(void); + +static PRStatus PR_CALLBACK scanner(PRThread* t, void** baseAddr, + PRUword count, void* closure) +{ + if (count) { + char* begin = (char*)baseAddr; + char* end = (char*)(baseAddr + count); + GC_mark_range_proc marker = (GC_mark_range_proc) closure; + marker(begin, end); + } + return PR_SUCCESS; +} + +static void mark_all_stacks(GC_mark_range_proc marker) +{ + PR_ScanStackPointers(&scanner, (void *)marker); +} + +#if defined(_PR_PTHREADS) +#define _PR_MD_CURRENT_CPU() 1 +#endif + +static void locker(void* mutex) +{ + if (_PR_MD_CURRENT_CPU()) + PR_EnterMonitor(mutex); +} + +static void unlocker(void* mutex) +{ + if (_PR_MD_CURRENT_CPU()) + PR_ExitMonitor(mutex); +} + +static void stopper(void* unused) +{ + if (_PR_MD_CURRENT_CPU()) + PR_SuspendAll(); +} + +static void starter(void* unused) +{ + if (_PR_MD_CURRENT_CPU()) + PR_ResumeAll(); +} + +void _PR_InitGarbageCollector() +{ + void* mutex; + + /* redirect GC's stderr to catch startup leaks. */ + GC_stderr = fopen("StartupLeaks", "w"); + + mutex = PR_NewMonitor(); + PR_ASSERT(mutex != NULL); + + GC_generic_init_threads(&mark_all_stacks, mutex, + &locker, &unlocker, + &stopper, &starter); +} + +void _PR_ShutdownGarbageCollector() +{ + /* do anything you need to shut down the collector. */ +} + +#endif /* GC_LEAK_DETECTOR */ diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c index f31374b3..38b81cd1 100644 --- a/pr/src/misc/prnetdb.c +++ b/pr/src/misc/prnetdb.c @@ -863,7 +863,7 @@ PR_IMPLEMENT(PRStatus) PR_GetProtoByNumber( } -PR_IMPLEMENT(PRUintn) PR_NetAddrSize(const PRNetAddr* addr) +PRUintn _PR_NetAddrSize(const PRNetAddr* addr) { PRUintn addrsize; @@ -890,7 +890,7 @@ PR_IMPLEMENT(PRUintn) PR_NetAddrSize(const PRNetAddr* addr) else addrsize = 0; return addrsize; -} /* PR_NetAddrSize */ +} /* _PR_NetAddrSize */ PR_IMPLEMENT(PRIntn) PR_EnumerateHostEnt( PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address) diff --git a/pr/src/misc/prthinfo.c b/pr/src/misc/prthinfo.c index 2cfac1b2..a278e0ad 100644 --- a/pr/src/misc/prthinfo.c +++ b/pr/src/misc/prthinfo.c @@ -134,24 +134,14 @@ PR_ThreadScanStackPointers(PRThread* t, if (status != PR_SUCCESS) return status; +#ifndef GC_LEAK_DETECTOR + /* if thread is not allocated on stack, this is redundant. */ ptd = t->privateData; for (index = 0; index < t->tpdLength; index++, ptd++) { status = scanFun(t, (void**)ptd, 1, scanClosure); if (status != PR_SUCCESS) return status; } - -#ifdef GC_LEAK_DETECTOR - /* - ** if the thread was allocated on its own stack, conservatively - ** scan the thread object itself to keep all data structures - ** referenced by the thread visible to the garbage collector. - */ - if (t->threadAllocatedOnStack) { - status = scanFun(t, (void**)t, (sizeof(PRThread) + 3) / sizeof(void*), scanClosure); - if (status != PR_SUCCESS) - return status; - } #endif return PR_SUCCESS; diff --git a/pr/src/misc/prtime.c b/pr/src/misc/prtime.c index b5cbb6cf..9c4a5944 100644 --- a/pr/src/misc/prtime.c +++ b/pr/src/misc/prtime.c @@ -1649,7 +1649,7 @@ PR_FormatTime(char *buf, int buflen, const char *fmt, const PRExplodedTime *tm) * values for these two fields. */ -#if defined(SUNOS4) || (__GLIBC__ >= 2) +#if defined(SUNOS4) || (__GLIBC__ >= 2) || defined(XP_BEOS) if (mktime(&a) == -1) { PR_snprintf(buf, buflen, "can't get timezone"); return 0; diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index b301ebd5..9dfcffeb 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -123,7 +123,7 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; #define _PRSockOptVal_t char * #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(HPUX) \ || defined(LINUX) || defined(FREEBSD) || defined(BSDI) || defined(VMS) \ - || defined(NTO) || defined(OPENBSD) + || defined(NTO) || defined(OPENBSD) || defined(RHAPSODY) #define _PRSockOptVal_t void * #else #error "Cannot determine architecture" @@ -137,7 +137,7 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL; || defined(OSF1) || defined(SOLARIS) \ || defined(HPUX10_30) || defined(HPUX11) || defined(LINUX) \ || defined(FREEBSD) || defined(NETBSD) || defined(OPENBSD) \ - || defined(BSDI) || defined(VMS) || defined(NTO) + || defined(BSDI) || defined(VMS) || defined(NTO) || defined(RHAPSODY) #define _PRSelectFdSetArg_t fd_set * #else #error "Cannot determine architecture" @@ -2424,7 +2424,8 @@ static PRIOMethods _pr_socketpollfd_methods = { #if defined(HPUX) || defined(OSF1) || defined(SOLARIS) || defined (IRIX) \ || defined(AIX) || defined(LINUX) || defined(FREEBSD) || defined(NETBSD) \ - || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) + || defined(OPENBSD) || defined(BSDI) || defined(VMS) || defined(NTO) \ + || defined(RHAPSODY) #define _PR_FCNTL_FLAGS O_NONBLOCK #else #error "Can't determine architecture" diff --git a/pr/src/pthreads/ptsynch.c b/pr/src/pthreads/ptsynch.c index b3ff68da..5cdd0fd3 100644 --- a/pr/src/pthreads/ptsynch.c +++ b/pr/src/pthreads/ptsynch.c @@ -248,7 +248,7 @@ static PRIntn pt_TimedWait( /* - * Notifies just get posted to the to the protecting mutex. The + * Notifies just get posted to the protecting mutex. The * actual notification is done when the lock is released so that * MP systems don't contend for a lock that they can't have. */ @@ -649,6 +649,14 @@ PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value) return NULL; } +/* + * Define the interprocess named semaphore functions. + * There are three implementations: + * 1. POSIX semaphore based; + * 2. System V semaphore based; + * 3. unsupported (fails with PR_NOT_IMPLEMENTED_ERROR). + */ + #ifdef _PR_HAVE_POSIX_SEMAPHORES #include @@ -750,9 +758,7 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) return PR_SUCCESS; } -#endif /* _PR_HAVE_POSIX_SEMAPHORES */ - -#ifdef _PR_HAVE_SYSV_SEMAPHORES +#elif defined(_PR_HAVE_SYSV_SEMAPHORES) #include #include @@ -961,7 +967,43 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) return PR_SUCCESS; } -#endif /* _PR_HAVE_SYSV_SEMAPHORES */ +#else /* neither POSIX nor System V semaphores are available */ + +PR_IMPLEMENT(PRSem *) PR_OpenSemaphore( + const char *name, + PRIntn flags, + PRIntn mode, + PRUintn value) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return NULL; +} + +PR_IMPLEMENT(PRStatus) PR_WaitSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_PostSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_CloseSemaphore(PRSem *sem) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name) +{ + PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0); + return PR_FAILURE; +} + +#endif /* end of interprocess named semaphore functions */ /**************************************************************/ /**************************************************************/ diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index 23189c53..af751db8 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -75,6 +75,42 @@ static PRIntn pt_PriorityMap(PRThreadPriority pri) } #endif +#if defined(GC_LEAK_DETECTOR) && (__GLIBC__ >= 2) && defined(__i386__) + +#include + +typedef struct stack_frame stack_frame; + +struct stack_frame { + stack_frame* next; + void* pc; +}; + +static stack_frame* GetStackFrame() +{ + jmp_buf jb; + stack_frame* currentFrame; + setjmp(jb); + currentFrame = (stack_frame*)(jb[0].__jmpbuf[JB_BP]); + currentFrame = currentFrame->next; + return currentFrame; +} + +static void* GetStackTop() +{ + stack_frame* frame; + frame = GetStackFrame(); + while (frame != NULL) + { + ptrdiff_t pc = (ptrdiff_t)frame->pc; + if ((pc < 0x08000000) || (pc > 0x7fffffff) || (frame->next < frame)) + return frame; + frame = frame->next; + } + return NULL; +} +#endif /* GC_LEAK_DETECTOR && (__GLIBC__ >= 2) && __i386__ */ + /* ** Initialize a stack for a native pthread thread */ @@ -90,9 +126,14 @@ static void _PR_InitializeStack(PRThreadStack *ts) #ifdef HAVE_STACK_GROWING_UP ts->stackBottom = ts->allocBase + ts->stackSize; ts->stackTop = ts->allocBase; +#else +#ifdef GC_LEAK_DETECTOR + ts->stackTop = GetStackTop(); + ts->stackBottom = ts->stackTop - ts->stackSize; #else ts->stackTop = ts->allocBase; ts->stackBottom = ts->allocBase - ts->stackSize; +#endif #endif } } @@ -1031,7 +1072,7 @@ PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg) */ PRThread* next = thred->next; - if (thred->state & PT_THREAD_GCABLE) + if (_PT_IS_GCABLE_THREAD(thred)) { #if !defined(_PR_DCETHREADS) PR_ASSERT((thred == me) || (thred->suspend & PT_THREAD_SUSPENDED)); @@ -1095,7 +1136,7 @@ static void suspend_signal_handler(PRIntn sig) PRThread *me = PR_CurrentThread(); PR_ASSERT(me != NULL); - PR_ASSERT(me->state & PT_THREAD_GCABLE); + PR_ASSERT(_PT_IS_GCABLE_THREAD(me)); PR_ASSERT((me->suspend & PT_THREAD_SUSPENDED) == 0); PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, @@ -1286,7 +1327,7 @@ PR_IMPLEMENT(void) PR_SuspendAll() #endif while (thred != NULL) { - if ((thred != me) && (thred->state & PT_THREAD_GCABLE)) + if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) PR_SuspendSet(thred); thred = thred->next; } @@ -1295,7 +1336,7 @@ PR_IMPLEMENT(void) PR_SuspendAll() thred = pt_book.first; while (thred != NULL) { - if ((thred != me) && (thred->state & PT_THREAD_GCABLE)) + if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) PR_SuspendTest(thred); thred = thred->next; } @@ -1328,7 +1369,7 @@ PR_IMPLEMENT(void) PR_ResumeAll() while (thred != NULL) { - if ((thred != me) && (thred->state & PT_THREAD_GCABLE)) + if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) PR_ResumeSet(thred); thred = thred->next; } @@ -1336,7 +1377,7 @@ PR_IMPLEMENT(void) PR_ResumeAll() thred = pt_book.first; while (thred != NULL) { - if ((thred != me) && (thred->state & PT_THREAD_GCABLE)) + if ((thred != me) && _PT_IS_GCABLE_THREAD(thred)) PR_ResumeTest(thred); thred = thred->next; } diff --git a/pr/src/threads/combined/pruthr.c b/pr/src/threads/combined/pruthr.c index 0025bcbb..0bada3d1 100644 --- a/pr/src/threads/combined/pruthr.c +++ b/pr/src/threads/combined/pruthr.c @@ -1247,6 +1247,14 @@ PR_IMPLEMENT(PRThread*) _PR_CreateThread(PRThreadType type, if ((PRUptrdiff)top & 0x3f) { top = (char*)((PRUptrdiff)top & ~0x3f); } +#endif +#if defined(GC_LEAK_DETECTOR) + /* + * sorry, it is not safe to allocate the thread on the stack, + * because we assign to this object before the GC can learn + * about this thread. we'll just leak thread objects instead. + */ + thread = PR_NEW(PRThread); #endif stack->thr = thread; memset(thread, 0, sizeof(PRThread)); diff --git a/pr/tests/Makefile b/pr/tests/Makefile index d1851723..943eaa10 100644 --- a/pr/tests/Makefile +++ b/pr/tests/Makefile @@ -423,7 +423,7 @@ LIBPTHREAD = -lpthread ifeq ($(OS_ARCH),AIX) LIBPTHREAD = -lpthreads endif -ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO,$(OS_ARCH))) +ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Rhapsody,$(OS_ARCH))) LIBPTHREAD = endif ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10) diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index 30dad6d7..56104459 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -425,7 +425,7 @@ LIBPTHREAD = -lpthread ifeq ($(OS_ARCH),AIX) LIBPTHREAD = -lpthreads endif -ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO,$(OS_ARCH))) +ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS NTO Rhapsody,$(OS_ARCH))) LIBPTHREAD = endif ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10) diff --git a/pr/tests/attach.c b/pr/tests/attach.c index 4b890063..980fd6d4 100644 --- a/pr/tests/attach.c +++ b/pr/tests/attach.c @@ -36,15 +36,6 @@ ** 12-June-97 Revert to return code 0 and 1. ***********************************************************************/ -#ifdef XP_BEOS -#include -int main() -{ - printf( "This test currently does not run on BeOS\n" ); - return 0; -} -#else - /*********************************************************************** ** Includes ***********************************************************************/ @@ -74,6 +65,8 @@ int main() #define INCL_ERRORS #include #include +#elif defined(XP_BEOS) +#include #endif #define DEFAULT_COUNT 1000 @@ -125,6 +118,8 @@ static void Measure(void (*func)(void), const char *msg) static unsigned __stdcall threadStartFunc(void *arg) #elif defined(IRIX) && !defined(_PR_PTHREADS) static void threadStartFunc(void *arg) +#elif defined(XP_BEOS) +static int32 threadStartFunc(void *arg) #else static void * threadStartFunc(void *arg) #endif @@ -165,6 +160,10 @@ int main(int argc, char **argv) #elif defined(OS2) int rv; TID threadID; +#elif defined(XP_BEOS) + thread_id threadID; + int32 threadRV; + status_t waitRV; #endif /* The command line argument: -d is used to determine if the test is being run @@ -328,6 +327,28 @@ int main(int argc, char **argv) goto exit_now; } +#elif defined(XP_BEOS) + + threadID = spawn_thread(threadStartFunc, NULL, B_NORMAL_PRIORITY, NULL); + if (threadID <= B_ERROR) { + fprintf(stderr, "thread creation failed: error code %08lx\n", threadID); + failed_already = 1; + goto exit_now; + } + if (resume_thread(threadID) != B_OK) { + fprintf(stderr, "failed starting thread: error code %08lx\n", threadID); + failed_already = 1; + goto exit_now; + } + + waitRV = wait_for_thread(threadID, &threadRV); + if (debug_mode) + PR_ASSERT(waitRV == B_OK); + else if (waitRV != B_OK) { + failed_already = 1; + goto exit_now; + } + #else if (!debug_mode) failed_already=1; @@ -344,5 +365,3 @@ exit_now: else return 0; } - -#endif /* XP_BEOS */ diff --git a/pr/tests/ipv6.c b/pr/tests/ipv6.c index 4029fedd..5914cbda 100644 --- a/pr/tests/ipv6.c +++ b/pr/tests/ipv6.c @@ -16,15 +16,6 @@ * Reserved. */ -#ifdef XP_BEOS -#include -int main() -{ - printf( "BeOS does not support IPv6\n" ); - return 0; -} -#else - #include "prio.h" #include "prenv.h" #include "prmem.h" @@ -45,6 +36,10 @@ int main() #define HOST_BUFFER 1024 #define PROTO_BUFFER 1500 +#define NETADDR_SIZE(addr) \ + (PR_AF_INET == (addr)->raw.family ? \ + sizeof((addr)->inet) : sizeof((addr)->ipv6)) + static PRFileDesc *err = NULL; static void Help(void) @@ -59,7 +54,7 @@ static void DumpAddr(const PRNetAddr* address, const char *msg) { PRUint32 *word = (PRUint32*)address; PRUint32 addr_len = sizeof(PRNetAddr); - PR_fprintf(err, "%s[%d]\t", msg, PR_NETADDR_SIZE(address)); + PR_fprintf(err, "%s[%d]\t", msg, NETADDR_SIZE(address)); while (addr_len > 0) { PR_fprintf(err, " %08x", *word++); @@ -73,7 +68,6 @@ static PRStatus PrintAddress(const PRNetAddr* address) PRNetAddr translation; char buffer[ADDR_BUFFER]; PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer)); - memset(&translation, 0, sizeof(PRNetAddr)); if (PR_FAILURE == rv) PL_FPrintError(err, "PR_NetAddrToString"); else { @@ -83,7 +77,7 @@ static PRStatus PrintAddress(const PRNetAddr* address) if (PR_FAILURE == rv) PL_FPrintError(err, "PR_StringToNetAddr"); else { - PRSize addr_len = PR_NETADDR_SIZE(address); + PRSize addr_len = NETADDR_SIZE(address); if (0 != memcmp(address, &translation, addr_len)) { PR_fprintf(err, "Address translations do not match\n"); @@ -102,7 +96,6 @@ PRIntn main(PRIntn argc, char **argv) PLOptStatus os; PRHostEnt host; PRProtoEnt proto; - PRBool ipv6 = PR_FALSE; const char *name = NULL; PRBool failed = PR_FALSE, version = PR_FALSE; PLOptState *opt = PL_CreateOptState(argc, argv, "Vh"); @@ -130,12 +123,10 @@ PRIntn main(PRIntn argc, char **argv) if (version) { -#if defined(XP_UNIX) || defined(XP_OS2) -#define NSPR_LIB "nspr21" -#elif defined(WIN32) -#define NSPR_LIB "libnspr21" +#if defined(WINNT) +#define NSPR_LIB "libnspr4" #else -#error "Architecture not supported" +#define NSPR_LIB "nspr4" #endif const PRVersionDescription *version_info; char *nspr_path = PR_GetEnv("LD_LIBRARY_PATH"); @@ -236,5 +227,3 @@ PRIntn main(PRIntn argc, char **argv) return (failed) ? 1 : 0; } - -#endif /* XP_BEOS */ diff --git a/pr/tests/tpd.c b/pr/tests/tpd.c index 62166937..42180949 100644 --- a/pr/tests/tpd.c +++ b/pr/tests/tpd.c @@ -109,7 +109,6 @@ static void PR_CALLBACK Thread(void *null) } PrintProgress(__LINE__); -#if !defined(DEBUG) did = should = PR_FALSE; for (keys = 4; keys < 8; ++keys) { @@ -117,7 +116,6 @@ static void PR_CALLBACK Thread(void *null) MY_ASSERT(PR_FAILURE == rv); } PrintProgress(__LINE__); -#endif did = PR_FALSE; should = PR_TRUE; for (keys = 0; keys < 4; ++keys) @@ -214,7 +212,8 @@ static PRIntn PR_CALLBACK Tpd(PRIntn argc, char **argv) } PrintProgress(__LINE__); -#if !defined(DEBUG) + for (keys = 4; keys < 8; ++keys) + key[keys] = 4096; /* set to invalid value */ did = should = PR_FALSE; for (keys = 4; keys < 8; ++keys) { @@ -222,7 +221,6 @@ static PRIntn PR_CALLBACK Tpd(PRIntn argc, char **argv) MY_ASSERT(PR_FAILURE == rv); } PrintProgress(__LINE__); -#endif did = PR_FALSE; should = PR_TRUE; for (keys = 0; keys < 4; ++keys) -- cgit v1.2.1