Landed NSPRPUB_RELEASE_4_0_20000223 onto the main trunk.

git-svn-id: svn://10.0.0.236/trunk@61538 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
wtc%netscape.com
2000-02-23 23:38:19 +00:00
parent ce4560ad60
commit 7f138566c6
135 changed files with 3979 additions and 2380 deletions

View File

@@ -101,5 +101,5 @@ endif
cp -f mdheader.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(OBJDIR_NAME); \
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/mdheader.jar
depend: clean
depend:
@echo "NSPR20 has no dependencies. Skipped."

View File

@@ -106,5 +106,5 @@ endif
cp -f mdheader.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(OBJDIR_NAME); \
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/mdheader.jar
depend: clean
depend:
@echo "NSPR20 has no dependencies. Skipped."

View File

@@ -47,6 +47,8 @@ IMPL_STRATEGY = _PTH
DEFINES += -D_REENTRANT
endif
USE_IPV6 = 1
ifeq (86,$(findstring 86,$(OS_TEST)))
CPU_ARCH := x86
else

View File

@@ -26,6 +26,7 @@ CC = @CC@
CCC = @CXX@
AR = @AR@
AR_FLAGS = @AR_FLAGS@
LD = @LD@
RANLIB = @RANLIB@
PERL = @PERL@
DLLTOOL = @DLLTOOL@

View File

@@ -20,4 +20,4 @@
# A module is also called a component or a subsystem.
MOD_NAME = nspr20
MOD_VERSION = 3
MOD_VERSION = 4

View File

@@ -23,3 +23,4 @@
*/
#error "Do not include this header file."

View File

@@ -62,14 +62,12 @@ endif
ifdef USE_AUTOCONF
ifdef INTERNAL_TOOLS
ifdef CROSS_COMPILE
CC=$(HOST_CC)
CCC=$(HOST_CXX)
CFLAGS=$(HOST_CFLAGS)
CXXFLAGS=$(HOST_CXXFLAGS)
endif
endif
endif
#
# This makefile contains rules for building the following kinds of
@@ -410,6 +408,29 @@ $(OBJDIR)/%.$(OBJ_SUFFIX): %.s
%: %.pl
rm -f $@; cp $< $@; chmod +x $@
#
# HACK ALERT
#
# The only purpose of this rule is to pass Mozilla's Tinderbox depend
# builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's
# Tinderbox builds NSPR continuously as part of the Mozilla client.
# Because NSPR's make depend is not implemented, whenever we change
# an NSPR header file, the depend build does not recompile the NSPR
# files that depend on the header.
#
# This rule makes all the objects depend on a dummy header file.
# Touch this dummy header file to force the depend build to recompile
# everything.
#
# This rule should be removed when make depend is implemented.
#
DUMMY_DEPEND_H = $(topsrcdir)/config/prdepend.h
$(filter $(OBJDIR)/%.$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%.$(OBJ_SUFFIX): $(DUMMY_DEPEND_H)
# END OF HACK
################################################################################
# Special gmake rules.
################################################################################

View File

@@ -693,7 +693,7 @@ cat >> confdefs.h <<\EOF
EOF
NSPR_VERSION=3
NSPR_VERSION=4
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@@ -1489,6 +1489,43 @@ test -n "$AS" && break
done
test -n "$AS" || AS=":"
fi
if test -z "$LD"; then
for ac_prog in "${target_alias}-ld" "${target}-ld"
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
if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$LD"; then
ac_cv_prog_LD="$LD" # 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_LD="$ac_prog"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
LD="$ac_cv_prog_LD"
if test -n "$LD"; then
echo "$ac_t""$LD" 1>&6
else
echo "$ac_t""no" 1>&6
fi
test -n "$LD" && break
done
test -n "$LD" || LD=":"
fi
if test -z "$DLLTOOL"; then
for ac_prog in "${target_alias}-dlltool" "${target}-dlltool"
@@ -1496,7 +1533,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:1537: 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
@@ -1533,7 +1570,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:1574: 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
@@ -1568,7 +1605,7 @@ 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:1572: checking for $ac_word" >&5
echo "configure:1609: 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
@@ -1598,7 +1635,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:1602: checking for $ac_word" >&5
echo "configure:1639: 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
@@ -1649,7 +1686,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:1653: checking for $ac_word" >&5
echo "configure:1690: 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
@@ -1681,7 +1718,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:1685: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
echo "configure:1722: 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.
@@ -1692,12 +1729,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 1696 "configure"
#line 1733 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:1701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1738: \"$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
@@ -1723,12 +1760,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:1727: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:1764: 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:1732: checking whether we are using GNU C" >&5
echo "configure:1769: 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
@@ -1737,7 +1774,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1741: \"$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:1778: \"$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
@@ -1756,7 +1793,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:1760: checking whether ${CC-cc} accepts -g" >&5
echo "configure:1797: 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
@@ -1792,7 +1829,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:1796: checking for $ac_word" >&5
echo "configure:1833: 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
@@ -1824,7 +1861,7 @@ test -n "$CXX" || CXX="gcc"
echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:1828: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
echo "configure:1865: 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.
@@ -1835,12 +1872,12 @@ cross_compiling=$ac_cv_prog_cxx_cross
cat > conftest.$ac_ext << EOF
#line 1839 "configure"
#line 1876 "configure"
#include "confdefs.h"
int main(){return(0);}
EOF
if { (eval echo configure:1844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1881: \"$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
@@ -1866,12 +1903,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:1870: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:1907: 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:1875: checking whether we are using GNU C++" >&5
echo "configure:1912: 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
@@ -1880,7 +1917,7 @@ else
yes;
#endif
EOF
if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1884: \"$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:1921: \"$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
@@ -1899,7 +1936,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:1903: checking whether ${CXX-g++} accepts -g" >&5
echo "configure:1940: 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
@@ -1933,7 +1970,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:1937: checking for $ac_word" >&5
echo "configure:1974: 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
@@ -1965,7 +2002,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:1969: checking for $ac_word" >&5
echo "configure:2006: 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
@@ -2006,7 +2043,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:2010: checking for $ac_word" >&5
echo "configure:2047: 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
@@ -2042,12 +2079,53 @@ test -n "$AR" && break
done
test -n "$AR" || AR=":"
for ac_prog in ld
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
if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$LD" in
/*)
ac_cv_path_LD="$LD" # Let the user override the test with a path.
;;
?:/*)
ac_cv_path_LD="$LD" # 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_LD="$ac_dir/$ac_word"
break
fi
done
IFS="$ac_save_ifs"
;;
esac
fi
LD="$ac_cv_path_LD"
if test -n "$LD"; then
echo "$ac_t""$LD" 1>&6
else
echo "$ac_t""no" 1>&6
fi
test -n "$LD" && break
done
test -n "$LD" || LD=":"
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:2051: checking for $ac_word" >&5
echo "configure:2129: 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
@@ -2088,7 +2166,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:2092: checking for $ac_word" >&5
echo "configure:2170: 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
@@ -2152,7 +2230,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:2156: checking for a BSD compatible install" >&5
echo "configure:2234: 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
@@ -2205,7 +2283,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:2209: checking whether ln -s works" >&5
echo "configure:2287: 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
@@ -2230,7 +2308,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:2234: checking for $ac_word" >&5
echo "configure:2312: 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
@@ -2284,6 +2362,9 @@ OS_TEST=`uname -m`
case "$host" in
*-mingw*)
;;
*-beos*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
;;
*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
;;
@@ -2783,6 +2864,10 @@ EOF
cat >> confdefs.h <<\EOF
#define _SVID_SOURCE 1
EOF
cat >> confdefs.h <<\EOF
#define LINUX 1
EOF
CFLAGS="$CFLAGS -pipe -ansi"
@@ -2820,6 +2905,10 @@ EOF
*-mingw*)
cat >> confdefs.h <<\EOF
#define XP_PC 1
EOF
cat >> confdefs.h <<\EOF
#define NONAMELESSUNION 1
EOF
PR_MD_ARCH_DIR=windows
@@ -3024,7 +3113,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:3028: checking how to run the C preprocessor" >&5
echo "configure:3117: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -3039,13 +3128,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 3043 "configure"
#line 3132 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3138: \"$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
:
@@ -3056,13 +3145,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 3060 "configure"
#line 3149 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3155: \"$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
:
@@ -3073,13 +3162,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 3077 "configure"
#line 3166 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:3083: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:3172: \"$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
:
@@ -3105,13 +3194,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:3109: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:3198: 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 <<EOF
#line 3115 "configure"
#line 3204 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -3129,7 +3218,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 3133 "configure"
#line 3222 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -3153,12 +3242,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:3157: checking for $ac_func" >&5
echo "configure:3246: 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 <<EOF
#line 3162 "configure"
#line 3251 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3181,7 +3270,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:3185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3274: \"$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
@@ -3209,7 +3298,7 @@ done
echo $ac_n "checking for pthread_attr_init in -lpthread""... $ac_c" 1>&6
echo "configure:3213: checking for pthread_attr_init in -lpthread" >&5
echo "configure:3302: 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
@@ -3217,7 +3306,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3221 "configure"
#line 3310 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3228,7 +3317,7 @@ int main() {
pthread_attr_init()
; return 0; }
EOF
if { (eval echo configure:3232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3321: \"$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
@@ -3247,7 +3336,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:3251: checking for pthread_attr_init in -lc_r" >&5
echo "configure:3340: 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
@@ -3255,7 +3344,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lc_r $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3259 "configure"
#line 3348 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3266,7 +3355,7 @@ int main() {
pthread_attr_init()
; return 0; }
EOF
if { (eval echo configure:3270: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3359: \"$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
@@ -3285,7 +3374,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:3289: checking for pthread_attr_init in -lc" >&5
echo "configure:3378: 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
@@ -3293,7 +3382,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lc $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3297 "configure"
#line 3386 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3304,7 +3393,7 @@ int main() {
pthread_attr_init()
; return 0; }
EOF
if { (eval echo configure:3308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3397: \"$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
@@ -3431,7 +3520,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:3435: checking whether ${CC-cc} accepts -pthread" >&5
echo "configure:3524: 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
@@ -3501,12 +3590,12 @@ EOF
esac
echo $ac_n "checking for pthread_create""... $ac_c" 1>&6
echo "configure:3505: checking for pthread_create" >&5
echo "configure:3594: 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 <<EOF
#line 3510 "configure"
#line 3599 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char pthread_create(); below. */
@@ -3529,7 +3618,7 @@ pthread_create();
; return 0; }
EOF
if { (eval echo configure:3533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3622: \"$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
@@ -3548,7 +3637,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:3552: checking for pthread_create in -lpthread" >&5
echo "configure:3641: 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
@@ -3556,7 +3645,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3560 "configure"
#line 3649 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3567,7 +3656,7 @@ int main() {
pthread_create()
; return 0; }
EOF
if { (eval echo configure:3571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3660: \"$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
@@ -3666,12 +3755,12 @@ EOF
esac
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
echo "configure:3670: checking for dlopen" >&5
echo "configure:3759: 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 <<EOF
#line 3675 "configure"
#line 3764 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -3694,7 +3783,7 @@ dlopen();
; return 0; }
EOF
if { (eval echo configure:3698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3787: \"$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
@@ -3713,7 +3802,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
echo "configure:3717: checking for dlopen in -ldl" >&5
echo "configure:3806: 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
@@ -3721,7 +3810,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 3725 "configure"
#line 3814 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3732,7 +3821,7 @@ int main() {
dlopen()
; return 0; }
EOF
if { (eval echo configure:3736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:3825: \"$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
@@ -3824,6 +3913,7 @@ fi
trap '' 1 2 15
@@ -4036,6 +4126,7 @@ s%@CXX@%$CXX%g
s%@RANLIB@%$RANLIB%g
s%@AR@%$AR%g
s%@AS@%$AS%g
s%@LD@%$LD%g
s%@DLLTOOL@%$DLLTOOL%g
s%@WINDRES@%$WINDRES%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g

View File

@@ -40,7 +40,7 @@ AC_DEFINE(USE_AUTOCONF)
dnl ========================================================
dnl = Defaults
dnl ========================================================
NSPR_VERSION=3
NSPR_VERSION=4
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
USE_PTHREADS=
@@ -195,6 +195,9 @@ if test "$target" != "$host"; then
if test -z "$AS"; then
AC_CHECK_PROGS(AS, "${target_alias}-as" "${target}-as", :)
fi
if test -z "$LD"; then
AC_CHECK_PROGS(LD, "${target_alias}-ld" "${target}-ld", :)
fi
if test -z "$DLLTOOL"; then
AC_CHECK_PROGS(DLLTOOL, "${target_alias}-dlltool" "${target}-dlltool", :)
fi
@@ -207,6 +210,7 @@ else
AC_PROG_RANLIB
AC_PATH_PROGS(AS, as, $CC)
AC_PATH_PROGS(AR, ar, :)
AC_PATH_PROGS(LD, ld, :)
AC_PATH_PROGS(DLLTOOL, dlltool, :)
AC_PATH_PROGS(WINDRES, windres, :)
if test -z "$HOST_CC"; then
@@ -255,6 +259,9 @@ dnl ========================================================
case "$host" in
*-mingw*)
;;
*-beos*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
;;
*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
;;
@@ -555,6 +562,7 @@ case "$target" in
AC_DEFINE(_POSIX_SOURCE)
AC_DEFINE(_BSD_SOURCE)
AC_DEFINE(_SVID_SOURCE)
AC_DEFINE(LINUX)
CFLAGS="$CFLAGS -pipe -ansi"
CXXFLAGS="$CXXFLAGS -pipe -ansi"
MDCPUCFG_H=_linux.cfg
@@ -583,6 +591,7 @@ case "$target" in
*-mingw*)
AC_DEFINE(XP_PC)
AC_DEFINE(NONAMELESSUNION)
PR_MD_ARCH_DIR=windows
if test -z "$GNU_CC"; then
OBJ_SUFFIX=obj
@@ -1051,6 +1060,7 @@ AC_SUBST(AR)
AC_SUBST(AR_FLAGS)
AC_SUBST(AS)
AC_SUBST(ASFLAGS)
AC_SUBST(LD)
AC_SUBST(DLLTOOL)
AC_SUBST(WINDRES)
AC_SUBST(RANLIB)

View File

@@ -25,10 +25,6 @@ include $(MOD_DEPTH)/config/config.mk
DIRS = ds libc
ifneq (,$(filter-out Rhapsody WIN16 NEWS-OS,$(OS_TARGET)))
DIRS += prstreams
endif
include $(MOD_DEPTH)/config/rules.mk
export:: $(TARGETS)

View File

@@ -30,10 +30,6 @@ include $(topsrcdir)/config/config.mk
DIRS = ds libc
ifneq (,$(filter-out Rhapsody WIN16 NEWS-OS,$(OS_TARGET)))
DIRS += prstreams
endif
include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)

View File

@@ -22,6 +22,10 @@
#define MY_LIBNAME "plds"
#define MY_FILEDESCRIPTION "PLDS Library"
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
#ifdef _DEBUG
#define MY_DEBUG_STR " (debug)"
#define MY_FILEFLAGS_1 VS_FF_DEBUG
@@ -66,7 +70,7 @@ BEGIN
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
VALUE "FileVersion", PR_VERSION "\0"
VALUE "InternalName", MY_INTERNAL_NAME "\0"
VALUE "LegalCopyright", "Copyright \251 1996-1999 Netscape Communications Corporation\0"
VALUE "LegalCopyright", "Copyright \251 1996-2000 Netscape Communications Corporation\0"
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
VALUE "ProductName", "Netscape Portable Runtime\0"
VALUE "ProductVersion", PR_VERSION "\0"

View File

@@ -42,7 +42,14 @@
#define _DEBUG_STRING ""
#endif
PRVersionDescription prVersionDescription_libplds3 =
/*
* A trick to expand the PR_VMAJOR macro before concatenation.
*/
#define CONCAT(x, y) x ## y
#define CONCAT2(x, y) CONCAT(x, y)
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplds, PR_VMAJOR)
PRVersionDescription VERSION_DESC_NAME =
{
/* version */ 2, /* this is the only one supported */
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
@@ -92,7 +99,7 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
dummy = rcsid;
dummy = sccsid;
#endif
return &prVersionDescription_libplds3;
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
/* plvrsion.c */

View File

@@ -22,6 +22,10 @@
#define MY_LIBNAME "plc"
#define MY_FILEDESCRIPTION "PLC Library"
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
#ifdef _DEBUG
#define MY_DEBUG_STR " (debug)"
#define MY_FILEFLAGS_1 VS_FF_DEBUG
@@ -66,7 +70,7 @@ BEGIN
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
VALUE "FileVersion", PR_VERSION "\0"
VALUE "InternalName", MY_INTERNAL_NAME "\0"
VALUE "LegalCopyright", "Copyright \251 1996-1999 Netscape Communications Corporation\0"
VALUE "LegalCopyright", "Copyright \251 1996-2000 Netscape Communications Corporation\0"
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
VALUE "ProductName", "Netscape Portable Runtime\0"
VALUE "ProductVersion", PR_VERSION "\0"

View File

@@ -42,7 +42,14 @@
#define _DEBUG_STRING ""
#endif
PRVersionDescription prVersionDescription_libplc3 =
/*
* A trick to expand the PR_VMAJOR macro before concatenation.
*/
#define CONCAT(x, y) x ## y
#define CONCAT2(x, y) CONCAT(x, y)
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplc, PR_VMAJOR)
PRVersionDescription VERSION_DESC_NAME =
{
/* version */ 2, /* this is the only one supported */
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
@@ -92,7 +99,7 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
dummy = rcsid;
dummy = sccsid;
#endif
return &prVersionDescription_libplc3;
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
/* plvrsion.c */

View File

@@ -42,7 +42,14 @@
#define _DEBUG_STRING ""
#endif
PRVersionDescription prVersionDescription_libprstrms3 =
/*
* A trick to expand the PR_VMAJOR macro before concatenation.
*/
#define CONCAT(x, y) x ## y
#define CONCAT2(x, y) CONCAT(x, y)
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libprstrms, PR_VMAJOR)
PRVersionDescription VERSION_DESC_NAME =
{
/* version */ 2, /* this is the only one supported */
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
@@ -92,7 +99,7 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
dummy = rcsid;
dummy = sccsid;
#endif
return &prVersionDescription_libprstrms3;
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
/* plvrsion.c */

View File

@@ -222,7 +222,7 @@ PRfilebuf::underflow()
}
streambuf*
PRfilebuf::setbuf(char *buffptr, int bufflen)
PRfilebuf::setbuf(char *buffptr, PRstreambuflen bufflen)
{
if (is_open() && (ebuf()))
return 0;

View File

@@ -31,6 +31,12 @@
#endif
#include <iostream.h>
#if defined(AIX) && defined(__64BIT__)
typedef long PRstreambuflen;
#else
typedef int PRstreambuflen;
#endif
#if defined (PRFSTREAMS_BROKEN)
// fix it sometime
@@ -51,7 +57,7 @@ public:
~PRfilebuf();
virtual int overflow(int=EOF);
virtual int underflow();
virtual streambuf *setbuf(char *buff, int bufflen);
virtual streambuf *setbuf(char *buff, PRstreambuflen bufflen);
virtual streampos seekoff(streamoff, ios::seek_dir, int);
virtual int sync();
PRfilebuf *open(const char *name, int mode, int flags);

View File

@@ -22,6 +22,10 @@
#define MY_LIBNAME "prstrms"
#define MY_FILEDESCRIPTION "PRSTRMS Library"
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
#ifdef _DEBUG
#define MY_DEBUG_STR " (debug)"
#define MY_FILEFLAGS_1 VS_FF_DEBUG
@@ -66,7 +70,7 @@ BEGIN
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
VALUE "FileVersion", PR_VERSION "\0"
VALUE "InternalName", MY_INTERNAL_NAME "\0"
VALUE "LegalCopyright", "Copyright \251 1996-1999 Netscape Communications Corporation\0"
VALUE "LegalCopyright", "Copyright \251 1996-2000 Netscape Communications Corporation\0"
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
VALUE "ProductName", "Netscape Portable Runtime\0"
VALUE "ProductVersion", PR_VERSION "\0"

View File

@@ -82,7 +82,7 @@ PR_OBJDIR = WIN954.0_OPT.OBJ
all:: export libs install
export libs install clobber clobber_all clean::
export libs install clobber clobber_all clean depend::
!if "$(MOZ_BITS)" == "16"
set PATH=%WATCPATH%
set INCLUDE=%WATC_INC%
@@ -103,6 +103,3 @@ export::
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\lib\*.lib $(DIST)\lib
$(MAKE_INSTALL) $(XPDIST)\$(PR_OBJDIR)\lib\*.dll $(DIST)\bin
!endif
depend::
@echo NSPR20 has no dependencies. Skipped.

View File

@@ -37,6 +37,7 @@ prshma.h
prsystem.h
prthread.h
prtime.h
prtpool.h
prtrace.h
prtypes.h
prvrsion.h

View File

@@ -59,6 +59,7 @@
#endif
#define _PR_HAVE_SYSV_SEMAPHORES
#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
#define _PR_ACCEPT_INHERIT_NONBLOCK
/* Timer operations */
#if defined(AIX_TIMERS)

View File

@@ -73,6 +73,8 @@
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE

View File

@@ -76,6 +76,7 @@
#ifndef _PR_INET6
#define _PR_INET6
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef NO_NSPR_10_SUPPORT

View File

@@ -77,6 +77,7 @@
#ifndef _PR_INET6
#define _PR_INET6
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef NO_NSPR_10_SUPPORT

View File

@@ -285,6 +285,7 @@ struct protoent* getprotobynumber(int number);
#define _MD_CLOSE_DIR _MD_close_dir
#define _MD_MAKE_NONBLOCK _MD_make_nonblock
#define _MD_OPEN _MD_open
#define _MD_OPEN_FILE _MD_open
#define _MD_CLOSE_FILE _MD_close_file
#define _MD_READ _MD_read
#define _MD_WRITE _MD_write
@@ -301,6 +302,7 @@ struct protoent* getprotobynumber(int number);
#define _MD_ACCESS _MD_access
#define _MD_STAT stat
#define _MD_MKDIR _MD_mkdir
#define _MD_MAKE_DIR _MD_mkdir
#define _MD_RMDIR _MD_rmdir
#define _MD_PR_POLL _MD_pr_poll

View File

@@ -48,6 +48,7 @@
#define _PR_STAT_HAS_ONLY_ST_ATIME
#define _PR_HAVE_POSIX_SEMAPHORES
#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
#define _PR_ACCEPT_INHERIT_NONBLOCK
#undef _PR_HAVE_ATOMIC_OPS

View File

@@ -30,6 +30,8 @@
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_AF_INET6 22 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4

View File

@@ -31,6 +31,8 @@
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_AF_INET6 22 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4

View File

@@ -60,6 +60,7 @@
#define HAVE_POINTER_LOCALTIME_R
#define _PR_HAVE_POSIX_SEMAPHORES
#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
#define _PR_ACCEPT_INHERIT_NONBLOCK
/* Initialization entry points */
NSPR_API(void) _MD_EarlyInit(void);

View File

@@ -34,6 +34,8 @@
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#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

View File

@@ -35,6 +35,8 @@
#define IS_BIG_ENDIAN 1
#define IS_64
#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

View File

@@ -27,6 +27,8 @@
#define LINUX
#endif
#define PR_AF_INET6 10 /* same as AF_INET6 */
#ifdef __powerpc__
#undef IS_LITTLE_ENDIAN

View File

@@ -70,6 +70,10 @@
#else
#define _PR_NO_LARGE_FILES
#endif
#ifdef _PR_INET6
#define _PR_HAVE_GETHOSTBYNAME2
#define _PR_INET6_PROBE
#endif
#define _PR_HAVE_SYSV_SEMAPHORES
#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY

View File

@@ -318,6 +318,7 @@ typedef enum IOOperation {
#define _MD_INIT_IO()
#define _MD_OPEN _MD_Open
#define _MD_OPEN_FILE _MD_Open
#define _MD_CLOSE_FILE FSClose
#define _MD_READ(fd,buf,amount) ReadWriteProc(fd,buf,amount,READ_ASYNC)
#define _MD_WRITE(fd,buf,amount) ReadWriteProc(fd,buf,amount,WRITE_ASYNC)
@@ -368,6 +369,7 @@ extern char* _MD_ReadDir(struct _MDDir *md,PRIntn flags);
#define _MD_CLOSE_DIR _MD_CloseDir
#define _MD_MKDIR _MD_MkDir
#define _MD_MAKE_DIR _MD_MkDir
#define _MD_RMDIR _MD_Delete
/*

View File

@@ -182,6 +182,7 @@ struct _MDProcess {
/* --- IO stuff --- */
#define _MD_OPEN (_PR_MD_OPEN)
#define _MD_OPEN_FILE (_PR_MD_OPEN)
#define _MD_READ (_PR_MD_READ)
#define _MD_WRITE (_PR_MD_WRITE)
#define _MD_WRITEV (_PR_MD_WRITEV)
@@ -198,6 +199,7 @@ extern PRInt32 _MD_CloseFile(PRInt32 osfd);
#define _MD_ACCESS (_PR_MD_ACCESS)
#define _MD_DELETE (_PR_MD_DELETE)
#define _MD_MKDIR (_PR_MD_MKDIR)
#define _MD_MAKE_DIR (_PR_MD_MKDIR)
#define _MD_RMDIR (_PR_MD_RMDIR)
#define _MD_LOCKFILE (_PR_MD_LOCKFILE)
#define _MD_TLOCKFILE (_PR_MD_TLOCKFILE)

View File

@@ -36,6 +36,8 @@
#define 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

View File

@@ -46,9 +46,14 @@
#define _PR_USE_POLL
#define _PR_STAT_HAS_ONLY_ST_ATIME
#define _PR_HAVE_LARGE_OFF_T
#ifdef _PR_INET6
#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
#define _PR_HAVE_POSIX_SEMAPHORES
#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY

View File

@@ -73,6 +73,15 @@
#define _PR_HAVE_POSIX_SEMAPHORES
#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
#define _PR_HAVE_GETIPNODEBYNAME
#define _PR_HAVE_GETIPNODEBYADDR
#define _PR_INET6_PROBE
#define _PR_ACCEPT_INHERIT_NONBLOCK
#ifndef _PR_INET6
#define AF_INET6 26
#define AI_V4MAPPED 0x0001
#define AI_ALL 0x0002
#define AI_ADDRCONFIG 0x0004
#endif
#include "prinrval.h"
NSPR_API(PRIntervalTime) _MD_Solaris_GetInterval(void);

View File

@@ -41,6 +41,8 @@
#error unknown processor
#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

View File

@@ -42,6 +42,8 @@
#endif
#define IS_64
#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

View File

@@ -334,7 +334,8 @@ extern PRStatus _MD_UnlockFile(PRInt32 osfd);
#define _MD_OPEN_DIR(dir, name) _MD_open_dir(dir, name)
#define _MD_CLOSE_DIR(dir) _MD_close_dir(dir)
#define _MD_READ_DIR(dir, flags) _MD_read_dir(dir, flags)
#define _MD_OPEN(name, osflags, mode ) _MD_open(name, osflags, mode)
#define _MD_OPEN(name, osflags, mode) _MD_open(name, osflags, mode)
#define _MD_OPEN_FILE(name, osflags, mode) _MD_open(name, osflags, mode)
extern PRInt32 _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
#define _MD_READ(fd,buf,amount) _MD_read(fd,buf,amount)
extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
@@ -347,6 +348,7 @@ extern PRInt32 _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
#define _MD_RENAME(from, to) _MD_rename(from, to)
#define _MD_ACCESS(name, how) _MD_access(name, how)
#define _MD_MKDIR(name, mode) _MD_mkdir(name, mode)
#define _MD_MAKE_DIR(name, mode) _MD_mkdir(name, mode)
#define _MD_RMDIR(name) _MD_rmdir(name)
#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)

View File

@@ -33,6 +33,8 @@
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_AF_INET6 27 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4

View File

@@ -31,6 +31,8 @@
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1

View File

@@ -158,9 +158,23 @@ struct _MDProcess {
/* --- Misc stuff --- */
#define _MD_GET_SP(thread) (thread)->md.gcContext[6]
/* --- NT security stuff --- */
extern void _PR_NT_InitSids(void);
extern void _PR_NT_FreeSids(void);
extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
PRIntn mode,
DWORD accessTable[],
PSECURITY_DESCRIPTOR *resultSD,
PACL *resultACL
);
extern void _PR_NT_FreeSecurityDescriptorACL(
PSECURITY_DESCRIPTOR pSD, PACL pACL);
/* --- IO stuff --- */
#define _MD_OPEN _PR_MD_OPEN
#define _MD_OPEN_FILE _PR_MD_OPEN_FILE
#define _MD_READ _PR_MD_READ
#define _MD_WRITE _PR_MD_WRITE
#define _MD_WRITEV _PR_MD_WRITEV
@@ -177,6 +191,7 @@ extern PRInt32 _MD_CloseFile(PRInt32 osfd);
#define _MD_ACCESS _PR_MD_ACCESS
#define _MD_DELETE _PR_MD_DELETE
#define _MD_MKDIR _PR_MD_MKDIR
#define _MD_MAKE_DIR _PR_MD_MAKE_DIR
#define _MD_RMDIR _PR_MD_RMDIR
#define _MD_LOCKFILE _PR_MD_LOCKFILE
#define _MD_TLOCKFILE _PR_MD_TLOCKFILE

View File

@@ -31,6 +31,8 @@
#define WINNT
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1

View File

@@ -200,12 +200,26 @@ struct _MDProcess {
/* --- Misc stuff --- */
#define _MD_GET_SP(thread) (thread)->md.gcContext[6]
/* --- NT security stuff --- */
extern void _PR_NT_InitSids(void);
extern void _PR_NT_FreeSids(void);
extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
PRIntn mode,
DWORD accessTable[],
PSECURITY_DESCRIPTOR *resultSD,
PACL *resultACL
);
extern void _PR_NT_FreeSecurityDescriptorACL(
PSECURITY_DESCRIPTOR pSD, PACL pACL);
/* --- IO stuff --- */
extern PRInt32 _md_Associate(HANDLE);
extern PRInt32 _PR_MD_CLOSE(PRInt32 osfd, PRBool socket);
#define _MD_OPEN _PR_MD_OPEN
#define _MD_OPEN_FILE _PR_MD_OPEN_FILE
#define _MD_READ _PR_MD_READ
#define _MD_WRITE _PR_MD_WRITE
#define _MD_WRITEV _PR_MD_WRITEV
@@ -221,6 +235,7 @@ extern PRInt32 _PR_MD_CLOSE(PRInt32 osfd, PRBool socket);
#define _MD_ACCESS _PR_MD_ACCESS
#define _MD_DELETE _PR_MD_DELETE
#define _MD_MKDIR _PR_MD_MKDIR
#define _MD_MAKE_DIR _PR_MD_MAKE_DIR
#define _MD_RMDIR _PR_MD_RMDIR
#define _MD_LOCKFILE _PR_MD_LOCKFILE
#define _MD_TLOCKFILE _PR_MD_TLOCKFILE

View File

@@ -49,6 +49,8 @@
#include "prsystem.h"
#include "prthread.h"
#include "prtime.h"
#include "prtpool.h"
#include "prtrace.h"
#include "prtypes.h"
#endif /* nspr_h___ */

View File

@@ -34,17 +34,6 @@ PR_BEGIN_EXTERN_C
*/
NSPR_API(PRStatus) PR_Yield(void);
/*
** These are obsolete and are replaced by PR_GetSocketOption() and
** PR_SetSocketOption().
*/
NSPR_API(PRStatus) PR_GetSockOpt(
PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen);
NSPR_API(PRStatus) PR_SetSockOpt(
PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen);
/************************************************************************/
/************* The following definitions are for select *****************/
/************************************************************************/
@@ -160,64 +149,6 @@ NSPR_API(PRInt32) PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set);
NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
#endif /* NO_NSPR_10_SUPPORT */
/***********************************************************************
** FUNCTION: PR_CreateNetAddr(), PR_DestroyNetAddr()
** DESCRIPTION:
** Create an instance of a PRNetAddr, assigning well known values as
** appropriate.
**
** INPUTS
** PRNetAddrValue val The value to be assigned to the IP Address portion
** of the network address. This can only specify the
** special well known values that are equivalent to
** INADDR_ANY and INADDR_LOOPBACK.
**
** PRUInt16 port The port number to be assigned in the structure.
**
** OUTPUTS:
** None
**
** RETURN:
** PRNetAddr *addr The initialized address that has been allocated
** from the heap. It must be freed by the caller.
** A returned value of zero indicates an error. The
** cause of the error (most likely low memory) may
** be retrieved by calling PR_GetError().
**
***********************************************************************/
NSPR_API(PRNetAddr*) PR_CreateNetAddr(PRNetAddrValue val, PRUint16 port);
NSPR_API(PRStatus) PR_DestroyNetAddr(PRNetAddr *addr);
/***********************************************************************
** FUNCTION: PR_GetHostName() **OBSOLETE**
** Use PR_GetSystemInfo() (prsystem.h) with an argument of
** PR_SI_HOSTNAME instead.
** DESCRIPTION:
** Get the DNS name of the hosting computer.
**
** INPUTS:
** char *name The location where the host's name is stored.
** PRIntn bufsize Number of bytes in 'name'.
** OUTPUTS:
** PRHostEnt *name
** This string is filled in by the runtime if the
** function returns PR_SUCCESS. The string must be
** allocated by the caller
** RETURN:
** PRStatus PR_SUCCESS if the succeeds. If it fails the
** result will be PR_FAILURE and the reason for
** the failure can be retrieved by PR_GetError().
***********************************************************************/
NSPR_API(PRStatus) PR_GetHostName(char *name, PRUint32 namelen);
/*
** Return the current thread's last error string.
** obsoleted by PR_GetErrorText().
*/
NSPR_API(const char *) PR_GetErrorString(void);
PR_END_EXTERN_C
#endif /* defined(PROBSLET_H) */

View File

@@ -220,8 +220,8 @@
/* The file is busy */
#define PR_FILE_IS_BUSY_ERROR (-5936L)
/* Reserved Error Code -5935 */
#define PR_RESERVED_ERROR_5935 (-5935L)
/* The I/O operation was aborted */
#define PR_OPERATION_ABORTED_ERROR (-5935L)
/* Operation is still in progress (probably a non-blocking connect) */
#define PR_IN_PROGRESS_ERROR (-5934L)

View File

@@ -44,10 +44,9 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version> <build date>"
*/
#define PR_VERSION "3.5"
#define PR_VMAJOR 3
#define PR_VMAJOR_STR "3"
#define PR_VMINOR 5
#define PR_VERSION "4.0"
#define PR_VMAJOR 4
#define PR_VMINOR 0
#define PR_VPATCH 0
#define PR_BETA PR_FALSE

View File

@@ -104,15 +104,21 @@ typedef enum PRTransmitFileFlags {
#define PR_AF_INET AF_INET
#define PR_AF_LOCAL AF_UNIX
#ifdef AF_INET6
#define PR_AF_INET6 AF_INET6
#endif
#define PR_INADDR_ANY INADDR_ANY
#define PR_INADDR_LOOPBACK INADDR_LOOPBACK
#define PR_INADDR_BROADCAST INADDR_BROADCAST
#endif /* WIN32 */
/*
** Define PR_AF_INET6 in prcpucfg.h with the same
** value as AF_INET6 on platforms with IPv6 support.
** Otherwise define it here.
*/
#ifndef PR_AF_INET6
#define PR_AF_INET6 100
#endif
/*
**************************************************************************
** A network address
@@ -122,15 +128,21 @@ typedef enum PRTransmitFileFlags {
** or IPv6 (AF_INET6).
**************************************************************************
*************************************************************************/
#if defined(_PR_INET6)
#if !defined(AF_INET6)
#error "AF_INET6 is not defined"
#endif
struct PRIPv6Addr {
union {
PRUint8 _S6_u8[16];
PRUint16 _S6_u16[8];
PRUint32 _S6_u32[4];
PRUint64 _S6_u64[2];
} _S6_un;
};
#define pr_s6_addr _S6_un._S6_u8
#define pr_s6_addr16 _S6_un._S6_u16
#define pr_s6_addr32 _S6_un._S6_u32
#define pr_s6_addr64 _S6_un._S6_addr64
typedef struct in6_addr PRIPv6Addr;
#endif /* defined(_PR_INET6) */
typedef struct PRIPv6Addr PRIPv6Addr;
union PRNetAddr {
struct {
@@ -151,7 +163,6 @@ union PRNetAddr {
char pad[8];
#endif
} inet;
#if defined(_PR_INET6)
struct {
PRUint16 family; /* address family (AF_INET6) */
PRUint16 port; /* port number */
@@ -159,7 +170,6 @@ union PRNetAddr {
PRIPv6Addr ip; /* the actual 128 bits of address */
PRUint32 scope_id; /* set of interfaces for a scope */
} ipv6;
#endif /* defined(_PR_INET6) */
#if defined(XP_UNIX)
struct { /* Unix domain socket address */
PRUint16 family; /* address family (AF_UNIX) */
@@ -181,12 +191,17 @@ union PRNetAddr {
#else
#if defined(XP_UNIX)
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == AF_UNIX \
? sizeof((_addr)->local) \
: sizeof((_addr)->inet))
#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) sizeof((_addr)->inet)
#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) */
@@ -351,10 +366,6 @@ typedef PRInt32 (PR_CALLBACK *PRTransmitfileFN)(
PRInt32 hlen, PRTransmitFileFlags flags, PRIntervalTime t);
typedef PRStatus (PR_CALLBACK *PRGetsocknameFN)(PRFileDesc *fd, PRNetAddr *addr);
typedef PRStatus (PR_CALLBACK *PRGetpeernameFN)(PRFileDesc *fd, PRNetAddr *addr);
typedef PRStatus (PR_CALLBACK *PRGetsockoptFN)( /* OBSOLETE */
PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32 *optlen);
typedef PRStatus (PR_CALLBACK *PRSetsockoptFN)( /* OBSOLETE */
PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen);
typedef PRStatus (PR_CALLBACK *PRGetsocketoptionFN)(
PRFileDesc *fd, PRSocketOptionData *data);
typedef PRStatus (PR_CALLBACK *PRSetsocketoptionFN)(
@@ -391,8 +402,8 @@ struct PRIOMethods {
PRTransmitfileFN transmitfile; /* Transmit at entire file */
PRGetsocknameFN getsockname; /* Get (net) address associated with fd */
PRGetpeernameFN getpeername; /* Get peer's (net) address */
PRGetsockoptFN getsockopt; /* OBSOLETE */
PRSetsockoptFN setsockopt; /* OBSOLETE */
PRReservedFN reserved_fn_6; /* reserved for future use */
PRReservedFN reserved_fn_5; /* reserved for future use */
PRGetsocketoptionFN getsocketoption;
/* Get current setting of specified option */
PRSetsocketoptionFN setsocketoption;
@@ -574,7 +585,6 @@ NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id);
**************************************************************************
*/
NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);
/* Open flags */
#define PR_RDONLY 0x01
#define PR_WRONLY 0x02
@@ -588,8 +598,8 @@ NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);
/*
** File modes ....
**
** CAVEAT: 'mode' is currently only applicable on UNIX platforms. We are
** still in the process of seeing how these apply to other file systems.
** CAVEAT: 'mode' is currently only applicable on UNIX platforms.
** The 'mode' argument may be ignored by PR_Open on other platforms.
**
** 00400 Read by owner.
** 00200 Write by owner.
@@ -603,6 +613,35 @@ NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);
**
*/
NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);
/*
**************************************************************************
* FUNCTION: PR_OpenFile
* DESCRIPTION:
* Open a file for reading, writing, or both.
* PR_OpenFile has the same prototype as PR_Open but implements
* the specified file mode where possible.
**************************************************************************
*/
/* File mode bits */
#define PR_IRWXU 00700 /* read, write, execute/search by owner */
#define PR_IRUSR 00400 /* read permission, owner */
#define PR_IWUSR 00200 /* write permission, owner */
#define PR_IXUSR 00100 /* execute/search permission, owner */
#define PR_IRWXG 00070 /* read, write, execute/search by group */
#define PR_IRGRP 00040 /* read permission, group */
#define PR_IWGRP 00020 /* write permission, group */
#define PR_IXGRP 00010 /* execute/search permission, group */
#define PR_IRWXO 00007 /* read, write, execute/search by others */
#define PR_IROTH 00004 /* read permission, others */
#define PR_IWOTH 00002 /* write permission, others */
#define PR_IXOTH 00001 /* execute/search permission, others */
NSPR_API(PRFileDesc*) PR_OpenFile(
const char *name, PRIntn flags, PRIntn mode);
/*
**************************************************************************
* FUNCTION: PR_Close
@@ -1037,6 +1076,18 @@ NSPR_API(PRStatus) PR_CloseDir(PRDir *dir);
NSPR_API(PRStatus) PR_MkDir(const char *name, PRIntn mode);
/*
*************************************************************************
* FUNCTION: PR_MakeDir
* DESCRIPTION:
* Create a new directory with the given name and access mode.
* PR_MakeDir has the same prototype as PR_MkDir but implements
* the specified access mode where possible.
*************************************************************************
*/
NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode);
/*
*************************************************************************
* FUNCTION: PR_RmDir
@@ -1529,7 +1580,8 @@ NSPR_API(PRInt32) PR_SendFile(
** void *buf
** A pointer to a buffer to receive data sent by the client. This
** buffer must be large enough to receive <amount> bytes of data
** and two PRNetAddr structures, plus an extra 32 bytes.
** and two PRNetAddr structures, plus an extra 32 bytes. See:
** PR_ACCEPT_READ_BUF_OVERHEAD.
** PRInt32 amount
** The number of bytes of client data to receive. Does not include
** the size of the PRNetAddr structures. If 0, no data will be read
@@ -1552,7 +1604,16 @@ NSPR_API(PRInt32) PR_SendFile(
** The number of bytes read from the client or -1 on failure. The reason
** for the failure is obtained by calling PR_GetError().
**************************************************************************
**/
**/
/* define buffer overhead constant. Add this value to the user's
** data length when allocating a buffer to accept data.
** Example:
** #define USER_DATA_SIZE 10
** char buf[USER_DATA_SIZE + PR_ACCEPT_READ_BUF_OVERHEAD];
** bytesRead = PR_AcceptRead( s, fd, &a, &p, USER_DATA_SIZE, ...);
*/
#define PR_ACCEPT_READ_BUF_OVERHEAD (32+(2*sizeof(PRNetAddr)))
NSPR_API(PRInt32) PR_AcceptRead(
PRFileDesc *listenSock, PRFileDesc **acceptedSock,
PRNetAddr **peerAddr, void *buf, PRInt32 amount, PRIntervalTime timeout);

View File

@@ -38,6 +38,7 @@
#define pripcsem_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C

View File

@@ -208,18 +208,6 @@ NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock,
PRFileDesc *listenSock);
/* FUNCTION: PR_NT_UseNonblock
** DESCRIPTION:
** This function only works on NT. It tells nspr to use nonblocking io
** rather than async IO. There is no way to use some of each. This
** function should be called immediately after calling PR_Init().
**
** WARNING: THIS FUNCTION IS A TEMPORARY HACK AND WILL BE REMOVED SHORTLY
** (LIKE ALL FUNCTIONS IN THE PRIVATE AREA). DO NOT USE THIS FUNCTION AT
** ALL WITHOUT CONTACTING mbelshe@netscape.com.
*/
NSPR_API(void) PR_NT_UseNonblock();
/* FUNCTION: PR_NT_CancelIo
** DESCRIPTION:
** Cancel IO operations on fd.

View File

@@ -186,11 +186,6 @@ struct _PT_Notified
typedef struct PTDebug
{
PRTime timeStarted;
PRUintn predictionsFoiled;
PRUintn pollingListMax;
PRUintn continuationsServed;
PRUintn recyclesNeeded;
PRUintn quiescentIO;
PRUintn locks_created, locks_destroyed;
PRUintn locks_acquired, locks_released;
PRUintn cvars_created, cvars_destroyed;
@@ -1035,6 +1030,9 @@ extern void _PR_MD_MAKE_NONBLOCK(PRFileDesc *fd);
extern PRInt32 _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode);
#define _PR_MD_OPEN _MD_OPEN
extern PRInt32 _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode);
#define _PR_MD_OPEN_FILE _MD_OPEN_FILE
extern PRInt32 _PR_MD_CLOSE_FILE(PRInt32 osfd);
#define _PR_MD_CLOSE_FILE _MD_CLOSE_FILE
@@ -1067,6 +1065,9 @@ extern PRInt32 _PR_MD_STAT(const char *name, struct stat *buf);
extern PRInt32 _PR_MD_MKDIR(const char *name, PRIntn mode);
#define _PR_MD_MKDIR _MD_MKDIR
extern PRInt32 _PR_MD_MAKE_DIR(const char *name, PRIntn mode);
#define _PR_MD_MAKE_DIR _MD_MAKE_DIR
extern PRInt32 _PR_MD_RMDIR(const char *name);
#define _PR_MD_RMDIR _MD_RMDIR
@@ -1421,9 +1422,7 @@ struct PRThread {
#if defined(_PR_PTHREADS)
pthread_t id; /* pthread identifier for the thread */
PRBool okToDelete; /* ok to delete the PRThread struct? */
PRCondVar *io_cv; /* a condition used to run i/o */
PRCondVar *waiting; /* where the thread is waiting | NULL */
PRIntn io_tq_index; /* the io-queue index for this thread */
void *sp; /* recorded sp for garbage collection */
PRThread *next, *prev; /* simple linked list of all threads */
PRUint32 suspend; /* used to store suspend and resume flags */
@@ -1549,36 +1548,8 @@ struct PRFilePrivate {
PRFileDesc *next;
PRIntn lockCount;
_MDFileDesc md;
#ifdef _PR_PTHREADS
PRIntn eventMask[1]; /* An array of _pt_tq_count bitmasks.
* eventMask[i] is only accessed by
* the i-th i/o continuation thread.
* A 0 in a bitmask means the event
* should be igored in the revents
* bitmask returned by poll.
*
* poll's revents bitmask is a short,
* but we need to declare eventMask
* as an array of PRIntn's so that
* each bitmask can be updated
* individually without disturbing
* adjacent memory. Only the lower
* 16 bits of each PRIntn are used. */
#endif
/* IMPORTANT: eventMask MUST BE THE LAST FIELD OF THIS STRUCTURE */
};
/*
* The actual size of the PRFilePrivate structure,
* including the eventMask array at the end
*/
#ifdef _PR_PTHREADS
extern PRIntn _pt_tq_count;
#define PRFILEPRIVATE_SIZE (sizeof(PRFilePrivate) + (_pt_tq_count-1) * sizeof(PRIntn))
#else
#define PRFILEPRIVATE_SIZE sizeof(PRFilePrivate)
#endif
struct PRDir {
PRDirEntry d;
_MDDir md;
@@ -1674,10 +1645,6 @@ extern PRFileDesc *_pr_stdin;
extern PRFileDesc *_pr_stdout;
extern PRFileDesc *_pr_stderr;
#if defined(_PR_INET6)
extern PRBool _pr_ipv6_enabled; /* defined in prnetdb.c */
#endif
/* Overriding malloc, free, etc. */
#if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \
&& !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \

View File

@@ -117,13 +117,11 @@ NSPR_API(PRStatus) PR_GetHostByName(
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
/*
* #define PR_AI_ALL 0x08
* #define PR_AI_V4MAPPED 0x10
* #define PR_AI_ADDRCONFIG 0x20
* #define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)
*/
#define PR_AI_DEFAULT 0x30
#define PR_AI_ALL 0x08
#define PR_AI_V4MAPPED 0x10
#define PR_AI_ADDRCONFIG 0x20
#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)
NSPR_API(PRStatus) PR_GetIPNodeByName(
const char *hostname,
@@ -217,7 +215,8 @@ typedef enum PRNetAddrValue
{
PR_IpAddrNull, /* do NOT overwrite the IP address */
PR_IpAddrAny, /* assign logical INADDR_ANY to IP address */
PR_IpAddrLoopback /* assign logical INADDR_LOOPBACK */
PR_IpAddrLoopback, /* assign logical INADDR_LOOPBACK */
PR_IpAddrV4Mapped /* IPv4 mapped address */
} PRNetAddrValue;
NSPR_API(PRStatus) PR_InitializeNetAddr(
@@ -266,6 +265,23 @@ NSPR_API(PRStatus) PR_SetNetAddr(
***********************************************************************/
NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_ConvertIPv4AddrToIPv6()
** Convert an IPv4 addr to an (IPv4-mapped) IPv6 addr
**
** INPUTS:
** PRUint32 v4addr IPv4 address
**
** OUTPUTS:
** PRIPv6Addr *v6addr The converted IPv6 address
**
** RETURN:
** void
**
***********************************************************************/
NSPR_API(void) PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr *v6addr);
/***********************************************************************
** MACRO:
** DESCRIPTION: PR_NetAddrFamily()
@@ -290,12 +306,8 @@ NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val);
** RETURN:
** PRUint16 The 'port' field of 'addr'.
***********************************************************************/
#ifdef _PR_INET6
#define PR_NetAddrInetPort(addr) \
((addr)->raw.family == PR_AF_INET6 ? (addr)->ipv6.port : (addr)->inet.port)
#else
#define PR_NetAddrInetPort(addr) ((addr)->inet.port)
#endif
/***********************************************************************
** FUNCTION:
@@ -357,28 +369,6 @@ NSPR_API(PRStatus) PR_GetProtoByName(
NSPR_API(PRStatus) PR_GetProtoByNumber(
PRInt32 protocolnumber, char* buffer, PRInt32 bufsize, PRProtoEnt* result);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_SetIPv6Enable()
** Enable IPv6 capability on a platform that supports the architecture.
**
** Note: IPv6 must first be enabled for the host platform. If it is not,
** the function will always return PR_FAILURE on any attempt to
** change the setting.
**
** INPUTS:
** PRBool itIs
** Assign it a value of PR_TRUE to turn on IPv6
** addressing, PR_FALSE to turn it off.
** RETURN:
** PRStatus PR_SUCCESS if the IPv6 is enabled for this particular
** host. Otherwise it will return failure and GetError()
** will confirm the result by indicating that the
** protocol is not supported
** (PR_PROTOCOL_NOT_SUPPORTED_ERROR)
***********************************************************************/
NSPR_API(PRStatus) PR_SetIPv6Enable(PRBool itIs);
/***********************************************************************
** FUNCTIONS: PR_ntohs, PR_ntohl, PR_ntohll, PR_htons, PR_htonl, PR_htonll
**
@@ -399,14 +389,6 @@ NSPR_API(PRUint16) PR_htons(PRUint16);
NSPR_API(PRUint32) PR_htonl(PRUint32);
NSPR_API(PRUint64) PR_htonll(PRUint64);
/***********************************************************************
** FUNCTION: PR_FamilyInet
**
** DESCRIPTION: Routine to get value of address family for Internet Protocol
**
***********************************************************************/
NSPR_API(PRUint16) PR_FamilyInet(void);
PR_END_EXTERN_C
#endif /* prnetdb_h___ */

View File

@@ -16,49 +16,10 @@
* Reserved.
*/
/*
** Delete this section of the header after (if) agreement is reached to
** provide the service suggested here. Move some parts of it, if
** appropriate to platform specific implementation files.
**
** Proposal: Nothing in this header file should be construed as a
** commitment on the part of the NSPR team, Netsacpe/AOL/Sun Alliance
** et.al. to provide the API or function suggested in this header file.
** This is a proposal, a draft, yadda. ... So, don't count on it.
** lth. 29-Oct-1999
**
** --------------------------------------------------------------------
**
** Requirements, Discussion:
**
** Goal: foreach platform, find at least 160 bits of "good noise", that
** is: from the platform itself, not extrapolated, stired, hashed,
** xor'd, whatever, from a little available noise.
**
**
** Required on the following platforms:
** MAC, Win9x, WinNT, Solaris, Linux (k: 2.2.x).
** Best effort on:
** AIX, HP-UX.
** Not required on:
** Tru65 Unix (Compaq)
**
** Notes:
**
** I presume it is legal to put this function on Mozilla.org,
** that it is not regulated as "cryptographic 'munitions'".
**
** Cartman says they need it 15-Jan-2000.
**
** --------------------------------------------------------------------
*/
/*
** prrng.h -- NSPR Random Number Generator
**
**
**
**
**
** lth. 29-Oct-1999.
*/
@@ -113,8 +74,7 @@ PR_BEGIN_EXTERN_C
** History:
** Parts of the model dependent implementation for PR_GetRandomNoise()
** were taken in whole or part from code previously in Netscape's NSS
** component. There is no Goddamned Goverenment Munitions is this
** code. Clinton: FOAD.
** component.
**
*/
NSPR_API(PRSize) PR_GetRandomNoise(

View File

@@ -113,6 +113,7 @@
#define prshm_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C

View File

@@ -22,9 +22,14 @@
#include "prtypes.h"
#include "prthread.h"
#include "prio.h"
#include "prerr.h"
#include "prerror.h"
/*
* NOTE:
* THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO
* CHANGE
*/
PR_BEGIN_EXTERN_C
typedef struct PRJobIoDesc {
@@ -35,50 +40,55 @@ typedef struct PRJobIoDesc {
typedef struct PRThreadPool PRThreadPool;
typedef struct PRJob PRJob;
typedef void (PR_CALLBACK *JobFn) (void *arg);
typedef void (PR_CALLBACK *PRJobFn) (void *arg);
/* Create thread pool */
PR_EXTERN(PRThreadPool *)
NSPR_API(PRThreadPool *)
PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads,
PRSize stacksize);
PRUint32 stacksize);
/* queue a job */
PR_EXTERN(PRJob *)
PR_QueueJob(PRThreadPool *tpool, JobFn fn, void *arg, PRBool joinable);
NSPR_API(PRJob *)
PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable);
/* queue a job, when a socket is readable */
PR_EXTERN(PRJob *)
NSPR_API(PRJob *)
PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod,
JobFn fn, void * arg, PRBool joinable);
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a socket is writeable */
PR_EXTERN(PRJob *)
NSPR_API(PRJob *)
PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod,
JobFn fn, void * arg, PRBool joinable);
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a socket has a pending connection */
PR_EXTERN(PRJob *)
NSPR_API(PRJob *)
PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod,
JobFn fn, void * arg, PRBool joinable);
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when the socket connection to addr succeeds or fails */
NSPR_API(PRJob *)
PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod,
const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a timer exipres */
PR_EXTERN(PRJob *)
NSPR_API(PRJob *)
PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
JobFn fn, void * arg, PRBool joinable);
PRJobFn fn, void * arg, PRBool joinable);
/* cancel a job */
PR_EXTERN(PRStatus)
NSPR_API(PRStatus)
PR_CancelJob(PRJob *job);
/* join a job */
PR_EXTERN(PRStatus)
NSPR_API(PRStatus)
PR_JoinJob(PRJob *job);
/* shutdown pool */
PR_EXTERN(PRStatus)
NSPR_API(PRStatus)
PR_ShutdownThreadPool(PRThreadPool *tpool);
/* join pool, wait for exit of all threads */
PR_EXTERN(PRStatus)
NSPR_API(PRStatus)
PR_JoinThreadPool(PRThreadPool *tpool);
PR_END_EXTERN_C

View File

@@ -30,13 +30,6 @@
** for all C files.
**/
/* the following update, a big '#if 0' for most of this file
** intentionally breaks the build of NSPR on the tip of the source tree
** nobody but NSPR should be interested in the tip right now
** anyway.
*/
#if 0
#ifndef prtypes_h___
#define prtypes_h___
@@ -484,4 +477,3 @@ PR_END_EXTERN_C
#endif /* prtypes_h___ */
#endif /* the #if 0 that intentionally breaks the tree */

View File

@@ -74,9 +74,19 @@ typedef struct {
/*
* All components must define an entrypoint named libVersionPoint which
* is of type versionEntryPointType.
*
* For example, for a library named libfoo, we would have:
*
* PRVersionDescription prVersionDescription_libfoo =
* {
* ...
* };
*
* PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
* {
* return &prVersionDescription_libfoo;
* }
*/
NSPR_API(const PRVersionDescription *) libVersionPoint(void);
typedef const PRVersionDescription *(*versionEntryPointType)(void);
/*

View File

@@ -141,7 +141,7 @@ endif
ifeq ($(OS_ARCH),WINNT)
ifneq ($(OS_TARGET),WIN16)
OS_LIBS = wsock32.lib winmm.lib
OS_LIBS = advapi32.lib wsock32.lib winmm.lib
endif
endif
@@ -155,6 +155,7 @@ OBJS = \
io/$(OBJDIR)/prmwait.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prmapopt.$(OBJ_SUFFIX) \
io/$(OBJDIR)/priometh.$(OBJ_SUFFIX) \
io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prlayer.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prlog.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prmmap.$(OBJ_SUFFIX) \
@@ -227,10 +228,6 @@ endif
endif
ifeq ($(USE_IPV6), 1)
OBJS += io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX)
endif
ifeq ($(USE_CPLUS), 1)
OBJS += \
cplus/$(OBJDIR)/rcbase.$(OBJ_SUFFIX) \
@@ -289,6 +286,7 @@ OBJS += md/windows/$(OBJDIR)/w95io.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntgc.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntmisc.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntinrval.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntsec.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntsem.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/win32_errors.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/w32ipcsem.$(OBJ_SUFFIX) \
@@ -303,6 +301,7 @@ OBJS += md/windows/$(OBJDIR)/ntdllmn.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntthread.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntmisc.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntinrval.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntsec.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/ntsem.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/win32_errors.$(OBJ_SUFFIX) \
md/windows/$(OBJDIR)/w32ipcsem.$(OBJ_SUFFIX) \

View File

@@ -162,6 +162,7 @@ OBJS = \
io/$(OBJDIR)/prmwait.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prmapopt.$(OBJ_SUFFIX) \
io/$(OBJDIR)/priometh.$(OBJ_SUFFIX) \
io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prlayer.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prlog.$(OBJ_SUFFIX) \
io/$(OBJDIR)/prmmap.$(OBJ_SUFFIX) \
@@ -229,10 +230,6 @@ endif
endif
ifeq ($(USE_IPV6), 1)
OBJS += io/$(OBJDIR)/pripv6.$(OBJ_SUFFIX)
endif
ifeq ($(USE_CPLUS), 1)
OBJS += \
cplus/$(OBJDIR)/rcbase.$(OBJ_SUFFIX) \

View File

@@ -32,6 +32,7 @@ CSRCS = \
prfdcach.c \
prmwait.c \
priometh.c \
pripv6.c \
prmapopt.c \
prlayer.c \
prlog.c \
@@ -51,10 +52,6 @@ ifndef USE_PTHREADS
$(NULL)
endif
ifdef USE_IPV6
CSRCS += pripv6.c
endif
TARGETS = $(OBJS)
INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private

View File

@@ -37,6 +37,7 @@ CSRCS = \
prfdcach.c \
prmwait.c \
priometh.c \
pripv6.c \
prmapopt.c \
prlayer.c \
prlog.c \
@@ -56,10 +57,6 @@ ifndef USE_PTHREADS
$(NULL)
endif
ifdef USE_IPV6
CSRCS += pripv6.c
endif
TARGETS = $(OBJS)
INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private

View File

@@ -70,6 +70,18 @@ PRInt32 rv;
return PR_SUCCESS;
}
PR_IMPLEMENT(PRStatus) PR_MakeDir(const char *name, PRIntn mode)
{
PRInt32 rv;
if (!_pr_initialized) _PR_ImplicitInitialization();
rv = _PR_MD_MAKE_DIR(name, mode);
if (rv < 0) {
return PR_FAILURE;
} else
return PR_SUCCESS;
}
PR_IMPLEMENT(PRStatus) PR_RmDir(const char *name)
{
PRInt32 rv;

View File

@@ -115,14 +115,14 @@ finished:
fd->dtor = NULL;
fd->lower = fd->higher = NULL;
fd->identity = PR_NSPR_IO_LAYER;
memset(fd->secret, 0, PRFILEPRIVATE_SIZE);
memset(fd->secret, 0, sizeof(PRFilePrivate));
return fd;
allocate:
fd = PR_NEW(PRFileDesc);
if (NULL != fd)
{
fd->secret = (PRFilePrivate *) PR_MALLOC(PRFILEPRIVATE_SIZE);
fd->secret = PR_NEW(PRFilePrivate);
if (NULL == fd->secret) PR_DELETE(fd);
}
if (NULL != fd) goto finished;

View File

@@ -268,8 +268,8 @@ static PRIOMethods _pr_fileMethods = {
(PRTransmitfileFN)_PR_InvalidInt,
(PRGetsocknameFN)_PR_InvalidStatus,
(PRGetpeernameFN)_PR_InvalidStatus,
(PRGetsockoptFN)_PR_InvalidStatus,
(PRSetsockoptFN)_PR_InvalidStatus,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
(PRGetsocketoptionFN)_PR_InvalidStatus,
(PRSetsocketoptionFN)_PR_InvalidStatus,
(PRSendfileFN)_PR_InvalidInt,
@@ -312,8 +312,8 @@ static PRIOMethods _pr_pipeMethods = {
(PRTransmitfileFN)_PR_InvalidInt,
(PRGetsocknameFN)_PR_InvalidStatus,
(PRGetpeernameFN)_PR_InvalidStatus,
(PRGetsockoptFN)_PR_InvalidStatus,
(PRSetsockoptFN)_PR_InvalidStatus,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
(PRGetsocketoptionFN)_PR_InvalidStatus,
(PRSetsocketoptionFN)_PR_InvalidStatus,
(PRSendfileFN)_PR_InvalidInt,
@@ -348,6 +348,26 @@ PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode)
return fd;
}
PR_IMPLEMENT(PRFileDesc*) PR_OpenFile(
const char *name, PRIntn flags, PRIntn mode)
{
PRInt32 osfd;
PRFileDesc *fd = 0;
if (!_pr_initialized) _PR_ImplicitInitialization();
/* Map pr open flags and mode to os specific flags */
osfd = _PR_MD_OPEN_FILE(name, flags, mode);
if (osfd != -1) {
fd = PR_AllocFileDesc(osfd, &_pr_fileMethods);
if (!fd) {
(void) _PR_MD_CLOSE_FILE(osfd);
}
}
return fd;
}
PRInt32 PR_GetSysfdTableMax(void)
{
#if defined(XP_UNIX) && !defined(AIX) && !defined(NEXTSTEP) && !defined(QNX)

View File

@@ -48,8 +48,8 @@ PRIOMethods _pr_faulty_methods = {
(PRTransmitfileFN)_PR_InvalidInt,
(PRGetsocknameFN)_PR_InvalidStatus,
(PRGetpeernameFN)_PR_InvalidStatus,
(PRGetsockoptFN)_PR_InvalidStatus,
(PRSetsockoptFN)_PR_InvalidStatus,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
(PRGetsocketoptionFN)_PR_InvalidStatus,
(PRSetsocketoptionFN)_PR_InvalidStatus,
(PRSendfileFN)_PR_InvalidInt,
@@ -247,26 +247,6 @@ PR_IMPLEMENT(PRStatus) PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr)
return((fd->methods->getpeername)(fd,addr));
}
PR_IMPLEMENT(PRStatus) PR_GetSockOpt(
PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen)
{
#if defined(DEBUG)
static PRBool warn = PR_TRUE;
if (warn) warn = _PR_Obsolete("PR_GetSockOpt()", "PR_GetSocketOption()");
#endif
return((fd->methods->getsockopt)(fd, optname, optval, optlen));
}
PR_IMPLEMENT(PRStatus) PR_SetSockOpt(
PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen)
{
#if defined(DEBUG)
static PRBool warn = PR_TRUE;
if (warn) warn = _PR_Obsolete("PR_SetSockOpt()", "PR_SetSocketOption()");
#endif
return((fd->methods->setsockopt)(fd, optname, optval, optlen));
}
PR_IMPLEMENT(PRStatus) PR_GetSocketOption(
PRFileDesc *fd, PRSocketOptionData *data)
{

View File

@@ -20,7 +20,341 @@
** File: pripv6.c
** Description: Support for various functions unique to IPv6
*/
#include "primpl.h"
#include <string.h>
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
/* pripv6.c */
static PRIOMethods ipv6_to_v4_tcpMethods;
static PRIOMethods ipv6_to_v4_udpMethods;
static PRDescIdentity _pr_ipv6_to_ipv4_id;
extern PRBool IsValidNetAddr(const PRNetAddr *addr);
extern PRIPv6Addr _pr_in6addr_any;
extern PRIPv6Addr _pr_in6addr_loopback;
/*
* convert an IPv4-mapped IPv6 addr to an IPv4 addr
*/
static void _PR_ConvertToIpv4NetAddr(const PRNetAddr *src_v6addr,
PRNetAddr *dst_v4addr)
{
const PRUint8 *srcp;
PR_ASSERT(PR_AF_INET6 == src_v6addr->ipv6.family);
if (PR_IsNetAddrType(src_v6addr, PR_IpAddrV4Mapped)) {
srcp = src_v6addr->ipv6.ip.pr_s6_addr;
memcpy((char *) &dst_v4addr->inet.ip, srcp + 12, 4);
} else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrAny)) {
dst_v4addr->inet.ip = htonl(INADDR_ANY);
} else if (PR_IsNetAddrType(src_v6addr, PR_IpAddrLoopback)) {
dst_v4addr->inet.ip = htonl(INADDR_LOOPBACK);
}
dst_v4addr->inet.family = PR_AF_INET;
dst_v4addr->inet.port = src_v6addr->ipv6.port;
}
/*
* convert an IPv4 addr to an IPv4-mapped IPv6 addr
*/
static void _PR_ConvertToIpv6NetAddr(const PRNetAddr *src_v4addr,
PRNetAddr *dst_v6addr)
{
PRUint8 *dstp;
PR_ASSERT(PR_AF_INET == src_v4addr->inet.family);
dst_v6addr->ipv6.family = PR_AF_INET6;
dst_v6addr->ipv6.port = src_v4addr->inet.port;
if (htonl(INADDR_ANY) == src_v4addr->inet.ip) {
dst_v6addr->ipv6.ip = _pr_in6addr_any;
} else {
dstp = dst_v6addr->ipv6.ip.pr_s6_addr;
memset(dstp, 0, 10);
memset(dstp + 10, 0xff, 2);
memcpy(dstp + 12,(char *) &src_v4addr->inet.ip, 4);
}
}
static PRStatus PR_CALLBACK Ipv6ToIpv4SocketBind(PRFileDesc *fd,
const PRNetAddr *addr)
{
PRNetAddr tmp_ipv4addr;
const PRNetAddr *tmp_addrp;
PRFileDesc *lo = fd->lower;
if (PR_AF_INET6 != addr->raw.family) {
PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
return PR_FAILURE;
}
if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||
PR_IsNetAddrType(addr, PR_IpAddrAny)) {
_PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);
tmp_addrp = &tmp_ipv4addr;
} else {
PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);
return PR_FAILURE;
}
return((lo->methods->bind)(lo,tmp_addrp));
}
static PRStatus PR_CALLBACK Ipv6ToIpv4SocketConnect(
PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
{
PRNetAddr tmp_ipv4addr;
const PRNetAddr *tmp_addrp;
if (PR_AF_INET6 != addr->raw.family) {
PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
return PR_FAILURE;
}
if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||
PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {
_PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);
tmp_addrp = &tmp_ipv4addr;
} else {
PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);
return PR_FAILURE;
}
return (fd->lower->methods->connect)(fd->lower, tmp_addrp, timeout);
}
static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketSendTo(
PRFileDesc *fd, const void *buf, PRInt32 amount,
PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout)
{
PRNetAddr tmp_ipv4addr;
const PRNetAddr *tmp_addrp;
if (PR_AF_INET6 != addr->raw.family) {
PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
return PR_FAILURE;
}
if (PR_IsNetAddrType(addr, PR_IpAddrV4Mapped) ||
PR_IsNetAddrType(addr, PR_IpAddrLoopback)) {
_PR_ConvertToIpv4NetAddr(addr, &tmp_ipv4addr);
tmp_addrp = &tmp_ipv4addr;
} else {
PR_SetError(PR_NETWORK_UNREACHABLE_ERROR, 0);
return PR_FAILURE;
}
return (fd->lower->methods->sendto)(
fd->lower, buf, amount, flags, tmp_addrp, timeout);
}
static PRFileDesc* PR_CALLBACK Ipv6ToIpv4SocketAccept (
PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout)
{
PRStatus rv;
PRFileDesc *newfd;
PRFileDesc *newstack;
PRNetAddr tmp_ipv4addr;
PR_ASSERT(fd != NULL);
PR_ASSERT(fd->lower != NULL);
newstack = PR_NEW(PRFileDesc);
if (NULL == newstack)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return NULL;
}
*newstack = *fd; /* make a copy of the accepting layer */
newfd = (fd->lower->methods->accept)(fd->lower, &tmp_ipv4addr, timeout);
if (NULL == newfd)
{
PR_DELETE(newstack);
return NULL;
}
_PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr);
rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);
PR_ASSERT(PR_SUCCESS == rv);
return newfd; /* that's it */
}
static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketAcceptRead(PRFileDesc *sd,
PRFileDesc **nd, PRNetAddr **ipv6_raddr, void *buf, PRInt32 amount,
PRIntervalTime timeout)
{
PRInt32 nbytes;
PRStatus rv;
PRNetAddr tmp_ipv4addr;
PRFileDesc *newstack;
PR_ASSERT(sd != NULL);
PR_ASSERT(sd->lower != NULL);
newstack = PR_NEW(PRFileDesc);
if (NULL == newstack)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return -1;
}
*newstack = *sd; /* make a copy of the accepting layer */
nbytes = sd->lower->methods->acceptread(
sd->lower, nd, ipv6_raddr, buf, amount, timeout);
if (-1 == nbytes)
{
PR_DELETE(newstack);
return nbytes;
}
tmp_ipv4addr = **ipv6_raddr; /* copy */
_PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, *ipv6_raddr);
/* this PR_PushIOLayer call cannot fail */
rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);
PR_ASSERT(PR_SUCCESS == rv);
return nbytes;
}
static PRStatus PR_CALLBACK Ipv6ToIpv4SocketGetName(PRFileDesc *fd,
PRNetAddr *ipv6addr)
{
PRStatus result;
PRNetAddr tmp_ipv4addr;
result = (fd->lower->methods->getsockname)(fd->lower, &tmp_ipv4addr);
if (PR_SUCCESS == result) {
_PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);
PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);
}
return result;
}
static PRStatus PR_CALLBACK Ipv6ToIpv4SocketGetPeerName(PRFileDesc *fd,
PRNetAddr *ipv6addr)
{
PRStatus result;
PRNetAddr tmp_ipv4addr;
result = (fd->lower->methods->getsockname)(fd->lower, &tmp_ipv4addr);
if (PR_SUCCESS == result) {
_PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);
PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);
}
return result;
}
static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketRecvFrom(PRFileDesc *fd, void *buf,
PRInt32 amount, PRIntn flags, PRNetAddr *ipv6addr,
PRIntervalTime timeout)
{
PRNetAddr tmp_ipv4addr;
PRInt32 result;
result = (fd->lower->methods->recvfrom)(
fd->lower, buf, amount, flags, &tmp_ipv4addr, timeout);
if (-1 != result) {
_PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, ipv6addr);
PR_ASSERT(IsValidNetAddr(ipv6addr) == PR_TRUE);
}
return result;
}
#if defined(_PR_INET6_PROBE)
PRBool _pr_ipv6_is_present;
PR_EXTERN(PRBool) _pr_test_ipv6_socket();
#if defined(_PR_HAVE_GETIPNODEBYNAME)
void *_pr_getipnodebyname_fp;
void *_pr_getipnodebyaddr_fp;
void *_pr_freehostent_fp;
#endif
#endif
PRStatus _pr_init_ipv6()
{
const PRIOMethods *stubMethods;
#if defined(_PR_INET6_PROBE)
#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
PRLibrary *lib;
_pr_getipnodebyname_fp = PR_FindSymbolAndLibrary("getipnodebyname", &lib);
if (NULL != _pr_getipnodebyname_fp) {
_pr_freehostent_fp = PR_FindSymbol(lib, "freehostent");
if (NULL != _pr_freehostent_fp) {
_pr_getipnodebyaddr_fp = PR_FindSymbol(lib, "getipnodebyaddr");
if (NULL != _pr_getipnodebyaddr_fp)
_pr_ipv6_is_present = PR_TRUE;
else
_pr_ipv6_is_present = PR_FALSE;
} else
_pr_ipv6_is_present = PR_FALSE;
(void)PR_UnloadLibrary(lib);
} else
_pr_ipv6_is_present = PR_FALSE;
if (PR_TRUE == _pr_ipv6_is_present)
#endif
_pr_ipv6_is_present = _pr_test_ipv6_socket();
if (PR_TRUE == _pr_ipv6_is_present)
return PR_SUCCESS;
#endif
_pr_ipv6_to_ipv4_id = PR_GetUniqueIdentity("Ipv6_to_Ipv4 layer");
PR_ASSERT(PR_INVALID_IO_LAYER != _pr_ipv6_to_ipv4_id);
stubMethods = PR_GetDefaultIOMethods();
ipv6_to_v4_tcpMethods = *stubMethods; /* first get the entire batch */
/* then override the ones we care about */
ipv6_to_v4_tcpMethods.connect = Ipv6ToIpv4SocketConnect;
ipv6_to_v4_tcpMethods.bind = Ipv6ToIpv4SocketBind;
ipv6_to_v4_tcpMethods.accept = Ipv6ToIpv4SocketAccept;
ipv6_to_v4_tcpMethods.acceptread = Ipv6ToIpv4SocketAcceptRead;
ipv6_to_v4_tcpMethods.getsockname = Ipv6ToIpv4SocketGetName;
ipv6_to_v4_tcpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;
/*
ipv6_to_v4_tcpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;
ipv6_to_v4_tcpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;
*/
ipv6_to_v4_udpMethods = *stubMethods; /* first get the entire batch */
/* then override the ones we care about */
ipv6_to_v4_udpMethods.connect = Ipv6ToIpv4SocketConnect;
ipv6_to_v4_udpMethods.bind = Ipv6ToIpv4SocketBind;
ipv6_to_v4_udpMethods.sendto = Ipv6ToIpv4SocketSendTo;
ipv6_to_v4_udpMethods.recvfrom = Ipv6ToIpv4SocketRecvFrom;
ipv6_to_v4_tcpMethods.getsockname = Ipv6ToIpv4SocketGetName;
ipv6_to_v4_tcpMethods.getpeername = Ipv6ToIpv4SocketGetPeerName;
/*
ipv6_to_v4_tcpMethods.getsocketoption = Ipv6ToIpv4GetSocketOption;
ipv6_to_v4_tcpMethods.setsocketoption = Ipv6ToIpv4SetSocketOption;
*/
return PR_SUCCESS;
}
PR_IMPLEMENT(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd)
{
PRFileDesc *ipv6_fd = NULL;
/*
* For platforms with no support for IPv6
* create layered socket for IPv4-mapped IPv6 addresses
*/
if (fd->methods->file_type == PR_DESC_SOCKET_TCP)
ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id,
&ipv6_to_v4_tcpMethods);
else
ipv6_fd = PR_CreateIOLayerStub(_pr_ipv6_to_ipv4_id,
&ipv6_to_v4_udpMethods);
if (NULL == ipv6_fd) {
goto errorExit;
}
ipv6_fd->secret = NULL;
if (PR_PushIOLayer(fd, PR_TOP_IO_LAYER, ipv6_fd) == PR_FAILURE) {
goto errorExit;
}
return PR_SUCCESS;
errorExit:
if (ipv6_fd)
ipv6_fd->dtor(ipv6_fd);
return PR_FAILURE;
}
#endif /* !defined(_PR_INET6) || defined(_PR_INET6_PROBE) */

View File

@@ -319,24 +319,6 @@ static PRStatus PR_CALLBACK pl_DefGetpeername (PRFileDesc *fd, PRNetAddr *addr)
return (fd->lower->methods->getpeername)(fd->lower, addr);
}
static PRStatus PR_CALLBACK pl_DefGetsockopt (
PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen)
{
PR_ASSERT(fd != NULL);
PR_ASSERT(fd->lower != NULL);
return (fd->lower->methods->getsockopt)(fd->lower, optname, optval, optlen);
}
static PRStatus PR_CALLBACK pl_DefSetsockopt (
PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen)
{
PR_ASSERT(fd != NULL);
PR_ASSERT(fd->lower != NULL);
return (fd->lower->methods->setsockopt)(fd->lower, optname, optval, optlen);
}
static PRStatus PR_CALLBACK pl_DefGetsocketoption (
PRFileDesc *fd, PRSocketOptionData *data)
{
@@ -394,8 +376,8 @@ static PRIOMethods pl_methods = {
pl_DefTransmitfile,
pl_DefGetsockname,
pl_DefGetpeername,
pl_DefGetsockopt,
pl_DefSetsockopt,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
pl_DefGetsocketoption,
pl_DefSetsocketoption,
pl_DefSendfile,

View File

@@ -169,8 +169,8 @@ static PRIOMethods _pr_polevt_methods = {
(PRTransmitfileFN)_PR_InvalidInt,
(PRGetsocknameFN)_PR_InvalidStatus,
(PRGetpeernameFN)_PR_InvalidStatus,
(PRGetsockoptFN)_PR_InvalidStatus,
(PRSetsockoptFN)_PR_InvalidStatus,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
(PRGetsocketoptionFN)_PR_InvalidStatus,
(PRSetsocketoptionFN)_PR_InvalidStatus,
(PRSendfileFN)_PR_InvalidInt,

View File

@@ -25,16 +25,14 @@
/* These two functions are only used in assertions. */
#if defined(DEBUG)
static PRBool IsValidNetAddr(const PRNetAddr *addr)
PRBool IsValidNetAddr(const PRNetAddr *addr)
{
if ((addr != NULL)
#ifdef XP_UNIX
&& (addr->raw.family != AF_UNIX)
&& (addr->raw.family != PR_AF_LOCAL)
#endif
#ifdef _PR_INET6
&& (addr->raw.family != AF_INET6)
#endif
&& (addr->raw.family != AF_INET)) {
&& (addr->raw.family != PR_AF_INET6)
&& (addr->raw.family != PR_AF_INET)) {
return PR_FALSE;
}
return PR_TRUE;
@@ -228,6 +226,10 @@ static PRStatus PR_CALLBACK SocketConnect(
PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
{
PRInt32 rv; /* Return value of _PR_MD_CONNECT */
const PRNetAddr *addrp = addr;
#if defined(_PR_INET6)
PRNetAddr addrCopy;
#endif
PRThread *me = _PR_MD_CURRENT_THREAD();
if (_PR_PENDING_INTERRUPT(me)) {
@@ -235,8 +237,15 @@ static PRStatus PR_CALLBACK SocketConnect(
PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
return PR_FAILURE;
}
#if defined(_PR_INET6)
if (addr->raw.family == PR_AF_INET6) {
addrCopy = *addr;
addrCopy.raw.family = AF_INET6;
addrp = &addrCopy;
}
#endif
rv = _PR_MD_CONNECT(fd, addr, PR_NETADDR_SIZE(addr), timeout);
rv = _PR_MD_CONNECT(fd, addrp, PR_NETADDR_SIZE(addr), timeout);
PR_LOG(_pr_io_lm, PR_LOG_MAX, ("connect -> %d", rv));
if (rv == 0)
return PR_SUCCESS;
@@ -414,6 +423,10 @@ PRIntervalTime timeout)
_PR_MD_MAKE_NONBLOCK(fd2);
#endif
#ifdef _PR_INET6
if (addr && (AF_INET6 == addr->raw.family))
addr->raw.family = PR_AF_INET6;
#endif
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
PR_ASSERT(IsValidNetAddrLen(addr, al) == PR_TRUE);
@@ -458,6 +471,10 @@ PRIntervalTime timeout)
PR_ASSERT(al == PR_NETADDR_SIZE(addr));
fd2->secret->md.accepted_socket = PR_TRUE;
memcpy(&fd2->secret->md.peer_addr, addr, al);
#ifdef _PR_INET6
if (AF_INET6 == addr->raw.family)
addr->raw.family = PR_AF_INET6;
#endif
}
return fd2;
}
@@ -467,6 +484,10 @@ PRIntervalTime timeout)
static PRStatus PR_CALLBACK SocketBind(PRFileDesc *fd, const PRNetAddr *addr)
{
PRInt32 result;
const PRNetAddr *addrp = addr;
#if defined(_PR_INET6)
PRNetAddr addrCopy;
#endif
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
@@ -480,7 +501,14 @@ static PRStatus PR_CALLBACK SocketBind(PRFileDesc *fd, const PRNetAddr *addr)
}
#endif /* XP_UNIX */
result = _PR_MD_BIND(fd, addr, PR_NETADDR_SIZE(addr));
#if defined(_PR_INET6)
if (addr->raw.family == PR_AF_INET6) {
addrCopy = *addr;
addrCopy.raw.family = AF_INET6;
addrp = &addrCopy;
}
#endif
result = _PR_MD_BIND(fd, addrp, PR_NETADDR_SIZE(addr));
if (result < 0) {
return PR_FAILURE;
}
@@ -630,6 +658,10 @@ static PRInt32 PR_CALLBACK SocketSendTo(
PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout)
{
PRInt32 temp, count;
const PRNetAddr *addrp = addr;
#if defined(_PR_INET6)
PRNetAddr addrCopy;
#endif
PRThread *me = _PR_MD_CURRENT_THREAD();
if (_PR_PENDING_INTERRUPT(me)) {
@@ -643,11 +675,18 @@ static PRInt32 PR_CALLBACK SocketSendTo(
}
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
#if defined(_PR_INET6)
if (addr->raw.family == PR_AF_INET6) {
addrCopy = *addr;
addrCopy.raw.family = AF_INET6;
addrp = &addrCopy;
}
#endif
count = 0;
while (amount > 0) {
temp = _PR_MD_SENDTO(fd, buf, amount, flags,
addr, PR_NETADDR_SIZE(addr), timeout);
addrp, PR_NETADDR_SIZE(addr), timeout);
if (temp < 0) {
count = -1;
break;
@@ -681,6 +720,10 @@ PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
al = sizeof(PRNetAddr);
rv = _PR_MD_RECVFROM(fd, buf, amount, flags, addr, &al, timeout);
#ifdef _PR_INET6
if (addr && (AF_INET6 == addr->raw.family))
addr->raw.family = PR_AF_INET6;
#endif
return rv;
}
@@ -730,6 +773,10 @@ PRIntervalTime timeout)
(*nd)->secret->md.accepted_socket = PR_TRUE;
memcpy(&(*nd)->secret->md.peer_addr, *raddr,
PR_NETADDR_SIZE(*raddr));
#ifdef _PR_INET6
if (AF_INET6 == *raddr->raw.family)
*raddr->raw.family = PR_AF_INET6;
#endif
}
}
}
@@ -779,6 +826,10 @@ PRIntervalTime timeout)
(*nd)->secret->md.accepted_socket = PR_TRUE;
memcpy(&(*nd)->secret->md.peer_addr, *raddr,
PR_NETADDR_SIZE(*raddr));
#ifdef _PR_INET6
if (AF_INET6 == *raddr->raw.family)
*raddr->raw.family = PR_AF_INET6;
#endif
}
}
return rv;
@@ -826,6 +877,10 @@ void *callbackArg)
(*nd)->secret->md.accepted_socket = PR_TRUE;
memcpy(&(*nd)->secret->md.peer_addr, *raddr,
PR_NETADDR_SIZE(*raddr));
#ifdef _PR_INET6
if (AF_INET6 == *raddr->raw.family)
*raddr->raw.family = PR_AF_INET6;
#endif
}
}
return rv;
@@ -910,6 +965,10 @@ static PRStatus PR_CALLBACK SocketGetName(PRFileDesc *fd, PRNetAddr *addr)
if (result < 0) {
return PR_FAILURE;
}
#ifdef _PR_INET6
if (AF_INET6 == addr->raw.family)
addr->raw.family = PR_AF_INET6;
#endif
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);
return PR_SUCCESS;
@@ -925,121 +984,15 @@ static PRStatus PR_CALLBACK SocketGetPeerName(PRFileDesc *fd, PRNetAddr *addr)
if (result < 0) {
return PR_FAILURE;
}
#ifdef _PR_INET6
if (AF_INET6 == addr->raw.family)
addr->raw.family = PR_AF_INET6;
#endif
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
PR_ASSERT(IsValidNetAddrLen(addr, addrlen) == PR_TRUE);
return PR_SUCCESS;
}
static PRStatus PR_CALLBACK SocketGetSockOpt(
PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen)
{
PRInt32 level, name;
PRStatus rv;
/*
* PR_SockOpt_Nonblocking is a special case that does not
* translate to a getsockopt() call
*/
if (PR_SockOpt_Nonblocking == optname)
{
PR_ASSERT(sizeof(PRIntn) <= *optlen);
*((PRIntn *) optval) = (PRIntn) fd->secret->nonblocking;
*optlen = sizeof(PRIntn);
return PR_SUCCESS;
}
rv = _PR_MapOptionName(optname, &level, &name);
if (PR_SUCCESS == rv)
{
if (PR_SockOpt_Linger == optname)
{
#if !defined(XP_BEOS)
struct linger linger;
PRInt32 len = sizeof(linger);
rv = _PR_MD_GETSOCKOPT(
fd, level, name, (char *) &linger, &len);
if (PR_SUCCESS == rv)
{
((PRLinger*)(optval))->polarity = linger.l_onoff
? PR_TRUE : PR_FALSE;
((PRLinger*)(optval))->linger = PR_SecondsToInterval(
linger.l_linger);
*optlen = sizeof(PRLinger);
}
#else
PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
return PR_FAILURE;
#endif
}
else
{
rv = _PR_MD_GETSOCKOPT(
fd, level, name, (char*)optval, optlen);
}
}
return rv;
}
static PRStatus PR_CALLBACK SocketSetSockOpt(
PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen)
{
PRInt32 level, name;
PRStatus rv;
/*
* PR_SockOpt_Nonblocking is a special case that does not
* translate to a setsockopt call.
*/
if (PR_SockOpt_Nonblocking == optname)
{
PRBool fNonblocking = *((PRIntn *) optval) ? PR_TRUE : PR_FALSE;
PR_ASSERT(sizeof(PRIntn) == optlen);
#ifdef WINNT
PR_ASSERT((fd->secret->md.io_model_committed == PR_FALSE)
|| (fd->secret->nonblocking == fNonblocking));
if (fd->secret->md.io_model_committed
&& (fd->secret->nonblocking != fNonblocking))
{
/*
* On NT, once we have associated a socket with the io
* completion port, we can't disassociate it. So we
* can't change the nonblocking option of the socket
* afterwards.
*/
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return PR_FAILURE;
}
#endif
fd->secret->nonblocking = fNonblocking;
return PR_SUCCESS;
}
rv = _PR_MapOptionName(optname, &level, &name);
if (PR_SUCCESS == rv)
{
if (PR_SockOpt_Linger == optname)
{
#if !defined(XP_BEOS)
struct linger linger;
linger.l_onoff = ((PRLinger*)(optval))->polarity ? 1 : 0;
linger.l_linger = PR_IntervalToSeconds(
((PRLinger*)(optval))->linger);
rv = _PR_MD_SETSOCKOPT(
fd, level, name, (char *) &linger, sizeof(linger));
#else
PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
return PR_FAILURE;
#endif
}
else
{
rv = _PR_MD_SETSOCKOPT(
fd, level, name, (const char*)optval, optlen);
}
}
return rv;
}
static PRInt16 PR_CALLBACK SocketPoll(
PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags)
{
@@ -1077,8 +1030,8 @@ static PRIOMethods tcpMethods = {
SocketTransmitFile,
SocketGetName,
SocketGetPeerName,
SocketGetSockOpt,
SocketSetSockOpt,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
_PR_SocketGetSocketOption,
_PR_SocketSetSocketOption,
SocketSendFile,
@@ -1116,8 +1069,8 @@ static PRIOMethods udpMethods = {
(PRTransmitfileFN)_PR_InvalidInt,
SocketGetName,
SocketGetPeerName,
SocketGetSockOpt,
SocketSetSockOpt,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
_PR_SocketGetSocketOption,
_PR_SocketSetSocketOption,
(PRSendfileFN)_PR_InvalidInt,
@@ -1156,8 +1109,8 @@ static PRIOMethods socketpollfdMethods = {
(PRTransmitfileFN)_PR_InvalidInt,
(PRGetsocknameFN)_PR_InvalidStatus,
(PRGetpeernameFN)_PR_InvalidStatus,
(PRGetsockoptFN)_PR_InvalidStatus,
(PRSetsockoptFN)_PR_InvalidStatus,
(PRReservedFN)_PR_InvalidInt,
(PRReservedFN)_PR_InvalidInt,
(PRGetsocketoptionFN)_PR_InvalidStatus,
(PRSetsocketoptionFN)_PR_InvalidStatus,
(PRSendfileFN)_PR_InvalidInt,
@@ -1183,24 +1136,65 @@ static const PRIOMethods* PR_GetSocketPollFdMethods()
return &socketpollfdMethods;
} /* PR_GetSocketPollFdMethods */
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
#if defined(_PR_INET6_PROBE)
PR_EXTERN(PRBool) _pr_ipv6_is_present;
PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
{
PRInt32 osfd;
osfd = _PR_MD_SOCKET(AF_INET6, SOCK_STREAM, 0);
if (osfd != -1) {
_PR_MD_CLOSE_SOCKET(osfd);
return PR_TRUE;
}
return PR_FALSE;
}
#endif /* _PR_INET6_PROBE */
#endif
PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
{
PRInt32 osfd;
PRFileDesc *fd;
PRInt32 tmp_domain = domain;
if (!_pr_initialized) _PR_ImplicitInitialization();
if (AF_INET != domain
#if defined(_PR_INET6)
&& AF_INET6 != domain
#endif
if (PR_AF_INET != domain
&& PR_AF_INET6 != domain
#if defined(XP_UNIX)
&& AF_UNIX != domain
&& PR_AF_LOCAL != domain
#endif
) {
PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, 0);
return NULL;
}
#if defined(_PR_INET6)
if (PR_AF_INET6 == domain) {
#if defined(_PR_INET6_PROBE)
if (_pr_ipv6_is_present == PR_FALSE)
domain = AF_INET;
else
#endif
domain = AF_INET6;
}
#elif defined(_PR_INET6_PROBE)
if (PR_AF_INET6 == domain) {
if (_pr_ipv6_is_present == PR_FALSE)
domain = AF_INET;
else
domain = AF_INET6;
}
#else
if (PR_AF_INET6 == domain)
domain = AF_INET;
#endif /* _PR_INET6 */
osfd = _PR_MD_SOCKET(domain, type, proto);
if (osfd == -1) {
return 0;
@@ -1212,10 +1206,23 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
/*
* Make the sockets non-blocking
*/
if (fd != NULL)
if (fd != NULL) {
_PR_MD_MAKE_NONBLOCK(fd);
else
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
/*
* For platforms with no support for IPv6
* create layered socket for IPv4-mapped IPv6 addresses
*/
if (PR_AF_INET6 == tmp_domain && PR_AF_INET == domain) {
if (PR_FAILURE == _pr_push_ipv6toipv4_layer(fd)) {
PR_Close(fd);
fd = NULL;
}
}
#endif
} else
_PR_MD_CLOSE_SOCKET(osfd);
return fd;
}
@@ -1223,11 +1230,6 @@ PR_IMPLEMENT(PRFileDesc *) PR_NewTCPSocket(void)
{
PRInt32 domain = AF_INET;
#if defined(_PR_INET6)
if (_pr_ipv6_enabled) {
domain = AF_INET6;
}
#endif
return PR_Socket(domain, SOCK_STREAM, 0);
}
@@ -1235,11 +1237,6 @@ PR_IMPLEMENT(PRFileDesc*) PR_NewUDPSocket(void)
{
PRInt32 domain = AF_INET;
#if defined(_PR_INET6)
if (_pr_ipv6_enabled) {
domain = AF_INET6;
}
#endif
return PR_Socket(domain, SOCK_DGRAM, 0);
}

View File

@@ -260,6 +260,7 @@ PR_IMPLEMENT(PRStatus) PR_SetLibraryPath(const char *path)
{
PRStatus rv = PR_SUCCESS;
if (!_pr_initialized) _PR_ImplicitInitialization();
PR_EnterMonitor(pr_linker_lock);
PR_FREEIF(_pr_currentLibPath);
if (path) {
@@ -284,6 +285,7 @@ PR_GetLibraryPath()
char *ev;
char *copy = NULL; /* a copy of _pr_currentLibPath */
if (!_pr_initialized) _PR_ImplicitInitialization();
PR_EnterMonitor(pr_linker_lock);
if (_pr_currentLibPath != NULL) {
goto exit;
@@ -797,6 +799,7 @@ PR_FindLibrary(const char *name)
{
PRLibrary* result;
if (!_pr_initialized) _PR_ImplicitInitialization();
PR_EnterMonitor(pr_linker_lock);
result = pr_UnlockedFindLibrary(name);
PR_ExitMonitor(pr_linker_lock);
@@ -1143,6 +1146,7 @@ PR_FindSymbolAndLibrary(const char *raw_name, PRLibrary* *lib)
#endif
PRLibrary* lm;
if (!_pr_initialized) _PR_ImplicitInitialization();
/*
** Mangle the raw symbol name in any way that is platform specific.
*/

View File

@@ -164,8 +164,6 @@ extern int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfd
#define macsock_shutdown PR_Shutdown
#define macsock_getpeername PR_GetPeerName
#define macsock_getsockname PR_GetSockName
#define macsock_getsockopt PR_GetSockOpt
#define macsock_setsockopt PR_SetSockOpt
#define macsock_socketavailable PR_SocketAvailable
#define macsock_send PR_Send
#define macsock_sendto PR_SendTo

View File

@@ -243,6 +243,22 @@ static void PrepareForAsyncCompletion(PRThread * thread, PRInt32 osfd)
}
static void
WakeUpNotifiedThread(PRThread *thread, OTResult result)
{
_PRCPU * cpu = _PR_MD_CURRENT_CPU();
if (thread) {
thread->md.osErrCode = result;
if (_PR_MD_GET_INTSOFF()) {
cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
thread->md.missedIONotify = PR_TRUE;
return;
}
DoneWaitingOnThisThread(thread);
}
}
// Notification routine
// Async callback routine.
// A5 is OK. Cannot allocate memory here
@@ -252,9 +268,9 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
_MDFileDesc * md = &(secret->md);
EndpointRef endpoint = (EndpointRef)secret->md.osfd;
PRThread * thread = NULL;
_PRCPU * cpu = _PR_MD_CURRENT_CPU();
OSStatus err;
OTResult resultOT;
TDiscon discon;
switch (code)
{
@@ -303,10 +319,28 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
return;
case T_DISCONNECT: // A disconnect is available
err = OTRcvDisconnect(endpoint, NULL);
discon.udata.len = 0;
err = OTRcvDisconnect(endpoint, &discon);
PR_ASSERT(err == kOTNoError);
secret->md.exceptReady = PR_TRUE;
secret->md.connectionOpen = PR_FALSE;
// wake up waiting threads, if any
result = -3199 - discon.reason; // obtain the negative error code
if ((thread = secret->md.read.thread) != NULL) {
secret->md.read.thread = NULL;
secret->md.read.cookie = cookie;
WakeUpNotifiedThread(thread, result);
}
if ((thread = secret->md.write.thread) != NULL) {
secret->md.write.thread = NULL;
secret->md.write.cookie = cookie;
WakeUpNotifiedThread(thread, result);
}
thread = NULL; // already took care of notification here
break;
case T_ERROR: // obsolete/unused in library
@@ -323,6 +357,11 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
secret->md.readReady = PR_TRUE; // mark readable (to emulate bsd sockets)
// remember connection is closed, so we can return 0 on read or receive
secret->md.connectionOpen = PR_FALSE;
thread = secret->md.read.thread;
secret->md.read.thread = NULL;
secret->md.read.cookie = cookie;
break;
case T_GODATA: // Flow control lifted on standard data
@@ -391,16 +430,7 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
return;
}
if (thread) {
thread->md.osErrCode = result;
if (_PR_MD_GET_INTSOFF()) {
cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
thread->md.missedIONotify = PR_TRUE;
return;
}
DoneWaitingOnThisThread(thread);
}
WakeUpNotifiedThread(thread, result);
}
@@ -584,6 +614,7 @@ PRInt32 _MD_listen(PRFileDesc *fd, PRIntn backlog)
goto ErrorExit;
}
addr.inet.family = AF_INET;
addr.inet.port = addr.inet.ip = 0;
bindReq.addr.maxlen = PR_NETADDR_SIZE (&addr);
@@ -667,12 +698,6 @@ PRInt32 _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
goto ErrorExit;
}
#if !defined(_PR_INET6)
addr->inet.family = AF_INET;
#endif
PR_ASSERT(PR_NETADDR_SIZE(addr) >= (*addrlen));
bindReq.addr.len = *addrlen;
bindReq.addr.maxlen = *addrlen;
bindReq.addr.buf = (UInt8*) addr;
@@ -696,6 +721,7 @@ PRInt32 _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
if (err != kOTNoError)
goto ErrorExit;
*addrlen = PR_NETADDR_SIZE(addr);
return kOTNoError;
ErrorExit:
@@ -988,7 +1014,7 @@ PRInt32 _MD_socketavailable(PRFileDesc *fd)
err = OTCountDataBytes(endpoint, &bytes);
if ((err == kOTLookErr) || // Not really errors, we just need to do a read,
(err == kOTNoDataErr)) // or theres nothing there.
(err == kOTNoDataErr)) // or there's nothing there.
err = kOTNoError;
if (err != kOTNoError)
@@ -1127,9 +1153,15 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRInterva
memset(&call, 0 , sizeof(call));
call.addr.maxlen = PR_NETADDR_SIZE(&callAddr);
call.addr.len = PR_NETADDR_SIZE(&callAddr);
call.addr.buf = (UInt8*) &callAddr;
if (addr != NULL) {
call.addr.maxlen = *addrlen;
call.addr.len = *addrlen;
call.addr.buf = (UInt8*) addr;
} else {
call.addr.maxlen = sizeof(callAddr);
call.addr.len = sizeof(callAddr);
call.addr.buf = (UInt8*) &callAddr;
}
do {
PrepareForAsyncCompletion(me, fd->secret->md.osfd);
@@ -1169,6 +1201,7 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRInterva
PR_ASSERT(err == kOTNoError);
// Bind to a local port; let the system assign it.
bindAddr.inet.family = AF_INET;
bindAddr.inet.port = bindAddr.inet.ip = 0;
bindReq.addr.maxlen = PR_NETADDR_SIZE (&bindAddr);
@@ -1199,8 +1232,6 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRInterva
if (err != kOTNoError)
goto ErrorExit;
if (addr != NULL)
*addr = callAddr;
if (addrlen != NULL)
*addrlen = call.addr.len;
@@ -1240,6 +1271,7 @@ PRInt32 _MD_connect(PRFileDesc *fd, PRNetAddr *addr, PRUint32 addrlen, PRInterva
// Bind to a local port; let the system assign it.
bindAddr.inet.family = AF_INET;
bindAddr.inet.port = bindAddr.inet.ip = 0;
bindReq.addr.maxlen = PR_NETADDR_SIZE (&bindAddr);
@@ -1784,7 +1816,7 @@ _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen)
TBind peerAddr;
OSErr err;
if (*addrlen < PR_NETADDR_SIZE(addr)) {
if (*addrlen < sizeof(InetAddress)) {
err = (OSErr) kEINVALErr;
goto ErrorExit;

View File

@@ -26,6 +26,8 @@
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_AF_INET6 30 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1L
#define PR_BYTES_PER_SHORT 2L
#define PR_BYTES_PER_INT 4L

View File

@@ -40,6 +40,7 @@ else
ifeq ($(OS_TARGET), WIN95)
CSRCS = \
ntmisc.c \
ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \
@@ -58,6 +59,7 @@ else
CSRCS = \
ntdllmn.c \
ntmisc.c \
ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \

View File

@@ -37,6 +37,7 @@
#include "primpl.h"
#include "pprmwait.h"
#include <direct.h>
#include <mbstring.h>
static HANDLE _pr_completion_port;
static PRThread *_pr_io_completion_thread;
@@ -59,6 +60,24 @@ extern PRUint32 _nt_idleCount;
#define CLOSE_TIMEOUT PR_SecondsToInterval(5)
/*
* NSPR-to-NT access right mapping table for files.
*/
static DWORD fileAccessTable[] = {
FILE_GENERIC_READ,
FILE_GENERIC_WRITE,
FILE_GENERIC_EXECUTE
};
/*
* NSPR-to-NT access right mapping table for directories.
*/
static DWORD dirAccessTable[] = {
FILE_GENERIC_READ,
FILE_GENERIC_WRITE|FILE_DELETE_CHILD,
FILE_GENERIC_EXECUTE
};
/*
* The NSPR epoch (00:00:00 1 Jan 1970 UTC) in FILETIME.
* We store the value in a PRTime variable for convenience.
@@ -76,10 +95,6 @@ PRInt32 IsFileLocal(HANDLE hFile);
static PRInt32 _md_MakeNonblock(HANDLE);
/* The _nt_use_async flag is used to prevent nspr from using any async io.
* this is a temporary hack. Don't learn to rely on it.
*/
static int _nt_use_async = 1;
PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr_in *addr, int *len, PRIntervalTime);
PRInt32 _nt_nonblock_recv(PRFileDesc *fd, char *buf, int len, PRIntervalTime);
PRInt32 _nt_nonblock_send(PRFileDesc *fd, char *buf, int len, PRIntervalTime);
@@ -889,6 +904,8 @@ _PR_MD_INIT_IO()
PR_ASSERT(filetime.prt == _pr_filetime_offset);
}
#endif /* DEBUG */
_PR_NT_InitSids();
}
/* --- SOCKET IO --------------------------------------------------------- */
@@ -913,11 +930,6 @@ _md_get_recycled_socket()
}
_MD_UNLOCK(&_pr_recycle_lock);
#ifdef _PR_INET6
if (_pr_ipv6_enabled) {
af = AF_INET6;
}
#endif
rv = _PR_MD_SOCKET(af, SOCK_STREAM, 0);
if (rv != INVALID_SOCKET && _md_Associate((HANDLE)rv) == 0) {
closesocket(rv);
@@ -1127,7 +1139,7 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
PRThread *cThread;
struct connect_data_s cd;
if (!_nt_use_async || fd->secret->nonblocking) {
if (fd->secret->nonblocking) {
PRInt32 rv;
fd_set wd;
struct timeval tv, *tvp;
@@ -1294,7 +1306,7 @@ _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
PRUint32 llen, err;
int rv;
if (!_nt_use_async || fd->secret->nonblocking || fd->secret->inheritable) {
if (fd->secret->nonblocking || fd->secret->inheritable) {
if (!fd->secret->md.io_model_committed) {
rv = _md_MakeNonblock((HANDLE)osfd);
PR_ASSERT(0 != rv);
@@ -1306,7 +1318,7 @@ _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
* the listening socket.
*/
accept_sock = _nt_nonblock_accept(fd, (struct sockaddr_in *)raddr, rlen, timeout);
if (_nt_use_async && !fd->secret->nonblocking) {
if (!fd->secret->nonblocking) {
u_long zero = 0;
rv = ioctlsocket(accept_sock, FIONBIO, &zero);
@@ -1441,21 +1453,6 @@ _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr,
PRBool isConnected;
PRBool madeCallback = PR_FALSE;
if (!_nt_use_async) {
PRFileDesc *nd;
bytes = _PR_EmulateAcceptRead(sd, &nd, raddr, buf, amount, timeout);
if (bytes != -1) {
/*
* This part is the same as SocketClose(nd), except
* that we don't close the osfd.
*/
PR_ASSERT(nd->secret->state == _PR_FILEDESC_OPEN);
*newSock = nd->secret->md.osfd;
PR_FreeFileDesc(nd);
}
return bytes;
}
if (me->io_suspended) {
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return -1;
@@ -1620,15 +1617,6 @@ _PR_MD_SENDFILE(PRFileDesc *sock, PRSendFileData *sfd,
PRInt32 tflags;
int rv, err;
if (!_nt_use_async) {
if (!sock->secret->md.io_model_committed) {
rv = _md_MakeNonblock((HANDLE)sock->secret->md.osfd);
PR_ASSERT(0 != rv);
sock->secret->md.io_model_committed = PR_TRUE;
}
return _PR_EmulateSendFile(sock, sfd, flags, timeout);
}
if (me->io_suspended) {
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return -1;
@@ -1735,7 +1723,7 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
int bytes;
int rv, err;
if (!_nt_use_async || fd->secret->nonblocking || fd->secret->inheritable) {
if (fd->secret->nonblocking || fd->secret->inheritable) {
if (!fd->secret->md.io_model_committed) {
rv = _md_MakeNonblock((HANDLE)osfd);
PR_ASSERT(0 != rv);
@@ -1834,7 +1822,7 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
int bytes;
int rv, err;
if (!_nt_use_async || fd->secret->nonblocking || fd->secret->inheritable) {
if (fd->secret->nonblocking || fd->secret->inheritable) {
if (!fd->secret->md.io_model_committed) {
rv = _md_MakeNonblock((HANDLE)osfd);
PR_ASSERT(0 != rv);
@@ -1932,7 +1920,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
PR_ASSERT(0 != rv);
fd->secret->md.io_model_committed = PR_TRUE;
}
if (_nt_use_async && !fd->secret->nonblocking && !fd->secret->inheritable)
if (!fd->secret->nonblocking && !fd->secret->inheritable)
return pt_SendTo(osfd, buf, amount, flags, addr, addrlen, timeout);
else
return _nt_nonblock_sendto(fd, buf, amount, (struct sockaddr *)addr, addrlen, timeout);
@@ -1950,7 +1938,7 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
PR_ASSERT(0 != rv);
fd->secret->md.io_model_committed = PR_TRUE;
}
if (_nt_use_async && !fd->secret->nonblocking && !fd->secret->inheritable)
if (!fd->secret->nonblocking && !fd->secret->inheritable)
return pt_RecvFrom(osfd, buf, amount, flags, addr, addrlen, timeout);
else
return _nt_nonblock_recvfrom(fd, buf, amount, (struct sockaddr *)addr, addrlen, timeout);
@@ -1965,7 +1953,7 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTi
int sent = 0;
int rv;
if (!_nt_use_async || fd->secret->nonblocking || fd->secret->inheritable) {
if (fd->secret->nonblocking || fd->secret->inheritable) {
if (!fd->secret->md.io_model_committed) {
rv = _md_MakeNonblock((HANDLE)osfd);
PR_ASSERT(0 != rv);
@@ -2115,79 +2103,102 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode)
if (osflags & PR_SYNC) flag6 = FILE_FLAG_WRITE_THROUGH;
if (_nt_use_async)
{
if (osflags & PR_RDONLY || osflags & PR_RDWR) access |= GENERIC_READ;
if (osflags & PR_WRONLY || osflags & PR_RDWR) access |= GENERIC_WRITE;
if (osflags & PR_RDONLY || osflags & PR_RDWR) access |= GENERIC_READ;
if (osflags & PR_WRONLY || osflags & PR_RDWR) access |= GENERIC_WRITE;
if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
flags = CREATE_NEW;
else if (osflags & PR_CREATE_FILE)
flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;
else if (osflags & PR_TRUNCATE) flags = TRUNCATE_EXISTING;
else flags = OPEN_EXISTING;
if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
flags = CREATE_NEW;
else if (osflags & PR_CREATE_FILE)
flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;
else if (osflags & PR_TRUNCATE) flags = TRUNCATE_EXISTING;
else flags = OPEN_EXISTING;
flag6 |= FILE_FLAG_OVERLAPPED;
file = CreateFile(name,
access,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
flags,
flag6,
NULL);
if (file == INVALID_HANDLE_VALUE) {
_PR_MD_MAP_OPEN_ERROR(GetLastError());
flag6 |= FILE_FLAG_OVERLAPPED;
file = CreateFile(name,
access,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
flags,
flag6,
NULL);
if (file == INVALID_HANDLE_VALUE) {
_PR_MD_MAP_OPEN_ERROR(GetLastError());
return -1;
}
if (osflags & PR_APPEND) {
if ( SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF ) {
_PR_MD_MAP_LSEEK_ERROR(GetLastError());
CloseHandle(file);
return -1;
}
if (osflags & PR_APPEND) {
if ( SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF ) {
_PR_MD_MAP_LSEEK_ERROR(GetLastError());
CloseHandle(file);
return -1;
}
}
return (PRInt32)file;
}
else
{
if (osflags & PR_RDONLY || osflags & PR_RDWR)
access |= GENERIC_READ;
if (osflags & PR_WRONLY || osflags & PR_RDWR)
access |= GENERIC_WRITE;
if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
flags = CREATE_NEW;
else if (osflags & PR_CREATE_FILE) {
if (osflags & PR_TRUNCATE)
flags = CREATE_ALWAYS;
else
flags = OPEN_ALWAYS;
} else {
if (osflags & PR_TRUNCATE)
flags = TRUNCATE_EXISTING;
else
flags = OPEN_EXISTING;
return (PRInt32)file;
}
PRInt32
_PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode)
{
HANDLE file;
PRInt32 access = 0;
PRInt32 flags = 0;
PRInt32 flag6 = 0;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
if (osflags & PR_SYNC) flag6 = FILE_FLAG_WRITE_THROUGH;
if (osflags & PR_RDONLY || osflags & PR_RDWR) access |= GENERIC_READ;
if (osflags & PR_WRONLY || osflags & PR_RDWR) access |= GENERIC_WRITE;
if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
flags = CREATE_NEW;
else if (osflags & PR_CREATE_FILE)
flags = (0 != (osflags & PR_TRUNCATE)) ? CREATE_ALWAYS : OPEN_ALWAYS;
else if (osflags & PR_TRUNCATE) flags = TRUNCATE_EXISTING;
else flags = OPEN_EXISTING;
flag6 |= FILE_FLAG_OVERLAPPED;
if (osflags & PR_CREATE_FILE) {
if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
file = CreateFile(name,
access,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
flags,
flag6,
NULL);
if (file == INVALID_HANDLE_VALUE) {
_PR_MD_MAP_OPEN_ERROR(GetLastError());
return -1;
}
return (PRInt32)file;
}
file = CreateFile(name,
access,
FILE_SHARE_READ|FILE_SHARE_WRITE,
lpSA,
flags,
flag6,
NULL);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if (file == INVALID_HANDLE_VALUE) {
_PR_MD_MAP_OPEN_ERROR(GetLastError());
return -1;
}
if (osflags & PR_APPEND) {
if ( SetFilePointer(file, 0, 0, FILE_END) == 0xFFFFFFFF ) {
_PR_MD_MAP_LSEEK_ERROR(GetLastError());
CloseHandle(file);
return -1;
}
}
return (PRInt32)file;
}
PRInt32
@@ -2196,8 +2207,10 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len)
PRInt32 f = fd->secret->md.osfd;
PRUint32 bytes;
int rv, err;
LONG hiOffset = 0;
LONG loOffset;
if (_nt_use_async && !fd->secret->md.sync_file_io) {
if (!fd->secret->md.sync_file_io) {
PRThread *me = _PR_MD_CURRENT_THREAD();
if (me->io_suspended) {
@@ -2207,7 +2220,8 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len)
memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));
me->md.overlapped.overlapped.Offset = SetFilePointer((HANDLE)f, 0, 0, FILE_CURRENT);
me->md.overlapped.overlapped.Offset = SetFilePointer((HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);
PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) || (GetLastError() == NO_ERROR));
if (fd->secret->inheritable) {
rv = ReadFile((HANDLE)f,
@@ -2216,7 +2230,8 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len)
&bytes,
&me->md.overlapped.overlapped);
if (rv != 0) {
SetFilePointer((HANDLE)f, bytes, 0, FILE_CURRENT);
loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);
PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));
return bytes;
}
err = GetLastError();
@@ -2224,7 +2239,8 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len)
rv = GetOverlappedResult((HANDLE)f,
&me->md.overlapped.overlapped, &bytes, TRUE);
if (rv != 0) {
SetFilePointer((HANDLE)f, bytes, 0, FILE_CURRENT);
loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);
PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));
return bytes;
}
err = GetLastError();
@@ -2342,8 +2358,10 @@ _PR_MD_WRITE(PRFileDesc *fd, void *buf, PRInt32 len)
PRInt32 f = fd->secret->md.osfd;
PRInt32 bytes;
int rv, err;
LONG hiOffset = 0;
LONG loOffset;
if (_nt_use_async && !fd->secret->md.sync_file_io) {
if (!fd->secret->md.sync_file_io) {
PRThread *me = _PR_MD_CURRENT_THREAD();
if (me->io_suspended) {
@@ -2353,7 +2371,8 @@ _PR_MD_WRITE(PRFileDesc *fd, void *buf, PRInt32 len)
memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));
me->md.overlapped.overlapped.Offset = SetFilePointer((HANDLE)f, 0, 0, FILE_CURRENT);
me->md.overlapped.overlapped.Offset = SetFilePointer((HANDLE)f, 0, &me->md.overlapped.overlapped.OffsetHigh, FILE_CURRENT);
PR_ASSERT((me->md.overlapped.overlapped.Offset != 0xffffffff) || (GetLastError() == NO_ERROR));
if (fd->secret->inheritable) {
rv = WriteFile((HANDLE)f,
@@ -2362,7 +2381,8 @@ _PR_MD_WRITE(PRFileDesc *fd, void *buf, PRInt32 len)
&bytes,
&me->md.overlapped.overlapped);
if (rv != 0) {
SetFilePointer((HANDLE)f, bytes, 0, FILE_CURRENT);
loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);
PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));
return bytes;
}
err = GetLastError();
@@ -2370,7 +2390,8 @@ _PR_MD_WRITE(PRFileDesc *fd, void *buf, PRInt32 len)
rv = GetOverlappedResult((HANDLE)f,
&me->md.overlapped.overlapped, &bytes, TRUE);
if (rv != 0) {
SetFilePointer((HANDLE)f, bytes, 0, FILE_CURRENT);
loOffset = SetFilePointer((HANDLE)f, bytes, &hiOffset, FILE_CURRENT);
PR_ASSERT((loOffset != 0xffffffff) || (GetLastError() == NO_ERROR));
return bytes;
}
err = GetLastError();
@@ -2587,62 +2608,50 @@ PRInt32
_PR_MD_CLOSE(PRInt32 osfd, PRBool socket)
{
PRInt32 rv;
if (_nt_use_async) {
PRThread *me = _PR_MD_CURRENT_THREAD();
PRThread *me = _PR_MD_CURRENT_THREAD();
if (socket) {
rv = closesocket((SOCKET)osfd);
if (rv < 0)
_PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());
} else {
rv = CloseHandle((HANDLE)osfd)?0:-1;
if (rv < 0)
_PR_MD_MAP_CLOSE_ERROR(GetLastError());
}
if (socket) {
rv = closesocket((SOCKET)osfd);
if (rv < 0)
_PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());
} else {
rv = CloseHandle((HANDLE)osfd)?0:-1;
if (rv < 0)
_PR_MD_MAP_CLOSE_ERROR(GetLastError());
}
if (rv == 0 && me->io_suspended) {
if (me->io_fd == osfd) {
PRBool fWait;
if (rv == 0 && me->io_suspended) {
if (me->io_fd == osfd) {
PRBool fWait;
_PR_THREAD_LOCK(me);
me->state = _PR_IO_WAIT;
/* The IO could have completed on another thread just after
* calling closesocket while the io_suspended flag was true.
* So we now grab the lock to do a safe check on io_pending to
* see if we need to wait or not.
*/
fWait = me->io_pending;
me->io_suspended = PR_FALSE;
me->md.interrupt_disabled = PR_TRUE;
_PR_THREAD_UNLOCK(me);
_PR_THREAD_LOCK(me);
me->state = _PR_IO_WAIT;
/* The IO could have completed on another thread just after
* calling closesocket while the io_suspended flag was true.
* So we now grab the lock to do a safe check on io_pending to
* see if we need to wait or not.
*/
fWait = me->io_pending;
me->io_suspended = PR_FALSE;
me->md.interrupt_disabled = PR_TRUE;
_PR_THREAD_UNLOCK(me);
if (fWait)
_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);
PR_ASSERT(me->io_suspended == PR_FALSE);
PR_ASSERT(me->io_pending == PR_FALSE);
/*
* I/O operation is no longer pending; the thread can now
* run on any cpu
*/
_PR_THREAD_LOCK(me);
me->md.interrupt_disabled = PR_FALSE;
me->md.thr_bound_cpu = NULL;
me->io_suspended = PR_FALSE;
me->io_pending = PR_FALSE;
me->state = _PR_RUNNING;
_PR_THREAD_UNLOCK(me);
}
if (fWait)
_NT_IO_WAIT(me, PR_INTERVAL_NO_TIMEOUT);
PR_ASSERT(me->io_suspended == PR_FALSE);
PR_ASSERT(me->io_pending == PR_FALSE);
/*
* I/O operation is no longer pending; the thread can now
* run on any cpu
*/
_PR_THREAD_LOCK(me);
me->md.interrupt_disabled = PR_FALSE;
me->md.thr_bound_cpu = NULL;
me->io_suspended = PR_FALSE;
me->io_pending = PR_FALSE;
me->state = _PR_RUNNING;
_PR_THREAD_UNLOCK(me);
}
} else {
if (socket) {
rv = closesocket((SOCKET)osfd);
if (rv == -1)
_PR_MD_MAP_CLOSE_ERROR(WSAGetLastError());
} else {
rv = CloseHandle((HANDLE)osfd)?0:-1;
if (rv == -1)
_PR_MD_MAP_CLOSE_ERROR(GetLastError());
}
}
return rv;
}
@@ -2661,7 +2670,7 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
HANDLE_FLAG_INHERIT,
inheritable ? HANDLE_FLAG_INHERIT : 0);
if (0 == rv) {
PR_SetError(PR_UNKNOWN_ERROR, GetLastError());
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
return PR_FAILURE;
}
return PR_SUCCESS;
@@ -2675,12 +2684,12 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
void FlipSlashes(char *cp, int len)
{
while (--len >= 0) {
if (cp[0] == '/') {
cp[0] = PR_DIRECTORY_SEPARATOR;
if (cp[0] == '/') {
cp[0] = PR_DIRECTORY_SEPARATOR;
}
cp = _mbsinc(cp);
}
cp++;
}
}
} /* end FlipSlashes() */
/*
**
@@ -2979,7 +2988,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
* FindFirstFile() expands wildcard characters. So
* we make sure the pathname contains no wildcard.
*/
if (NULL != strpbrk(fn, "?*")) {
if (NULL != _mbspbrk(fn, "?*")) {
PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0);
return -1;
}
@@ -3001,7 +3010,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
* If the pathname does not contain ., \, and /, it cannot be
* a root directory or a pathname that ends in a slash.
*/
if (NULL == strpbrk(fn, ".\\/")) {
if (NULL == _mbspbrk(fn, ".\\/")) {
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return -1;
}
@@ -3176,6 +3185,34 @@ _PR_MD_MKDIR(const char *name, PRIntn mode)
}
}
PRInt32
_PR_MD_MAKE_DIR(const char *name, PRIntn mode)
{
BOOL rv;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
rv = CreateDirectory(name, lpSA);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if (rv) {
return 0;
} else {
_PR_MD_MAP_MKDIR_ERROR(GetLastError());
return -1;
}
}
PRInt32
_PR_MD_RMDIR(const char *name)
{
@@ -3668,11 +3705,6 @@ PRInt32 IsFileLocal(HANDLE hFile)
}
#endif /* _NEED_351_FILE_LOCKING_HACK */
PR_IMPLEMENT(void) PR_NT_UseNonblock()
{
_nt_use_async = 0;
}
PR_IMPLEMENT(PRStatus) PR_NT_CancelIo(PRFileDesc *fd)
{
PRThread *me = _PR_MD_CURRENT_THREAD();

View File

@@ -0,0 +1,252 @@
/* -*- 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.
*/
#include "primpl.h"
/*
* ntsec.c
*
* Implement the POSIX-style mode bits (access permissions) for
* files and other securable objects in Windows NT using Windows
* NT's security descriptors with appropriate discretionary
* access-control lists.
*/
/*
* The security identifiers (SIDs) for owner, primary group,
* and the Everyone (World) group.
*
* These SIDs are looked up during NSPR initialization and
* saved in this global structure (see _PR_NT_InitSids) so
* that _PR_NT_MakeSecurityDescriptorACL doesn't need to
* look them up every time.
*/
static struct {
PSID owner;
PSID group;
PSID everyone;
} _pr_nt_sids;
/*
* Initialize the SIDs for owner, primary group, and the Everyone
* group in the _pr_nt_sids structure.
*
* This function needs to be called by NSPR initialization.
*/
void _PR_NT_InitSids(void)
{
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
HANDLE hToken;
UCHAR infoBuffer[1024];
PTOKEN_OWNER pTokenOwner = (PTOKEN_OWNER) infoBuffer;
PTOKEN_PRIMARY_GROUP pTokenPrimaryGroup
= (PTOKEN_PRIMARY_GROUP) infoBuffer;
DWORD dwLength;
BOOL rv;
/* Create a well-known SID for the Everyone group. */
if (!AllocateAndInitializeSid(&SIDAuthWorld, 1,
SECURITY_WORLD_RID,
0, 0, 0, 0, 0, 0, 0,
&_pr_nt_sids.everyone)) {
/*
* On non-NT systems, this function is not implemented,
* and neither are the other security functions. There
* is no point in going further.
*/
PR_ASSERT(GetLastError() == ERROR_CALL_NOT_IMPLEMENTED);
return;
}
/*
* Look up and make a copy of the owner and primary group
* SIDs in the access token of the calling process.
*/
rv = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken);
PR_ASSERT(rv != 0);
rv = GetTokenInformation(hToken, TokenOwner, infoBuffer,
sizeof(infoBuffer), &dwLength);
PR_ASSERT(rv != 0);
dwLength = GetLengthSid(pTokenOwner->Owner);
_pr_nt_sids.owner = (PSID) PR_Malloc(dwLength);
PR_ASSERT(_pr_nt_sids.owner != NULL);
rv = CopySid(dwLength, _pr_nt_sids.owner, pTokenOwner->Owner);
PR_ASSERT(rv != 0);
rv = GetTokenInformation(hToken, TokenPrimaryGroup, infoBuffer,
sizeof(infoBuffer), &dwLength);
PR_ASSERT(rv != 0);
dwLength = GetLengthSid(pTokenPrimaryGroup->PrimaryGroup);
_pr_nt_sids.group = (PSID) PR_Malloc(dwLength);
PR_ASSERT(_pr_nt_sids.group != NULL);
rv = CopySid(dwLength, _pr_nt_sids.group,
pTokenPrimaryGroup->PrimaryGroup);
PR_ASSERT(rv != 0);
rv = CloseHandle(hToken);
PR_ASSERT(rv != 0);
}
/*
* Free the SIDs for owner, primary group, and the Everyone group
* in the _pr_nt_sids structure.
*
* This function needs to be called by NSPR cleanup.
*/
void
_PR_NT_FreeSids(void)
{
if (_pr_nt_sids.owner) {
PR_Free(_pr_nt_sids.owner);
}
if (_pr_nt_sids.group) {
PR_Free(_pr_nt_sids.group);
}
if (_pr_nt_sids.everyone) {
FreeSid(_pr_nt_sids.everyone);
}
}
/*
* Construct a security descriptor whose discretionary access-control
* list implements the specified mode bits. The SIDs for owner, group,
* and everyone are obtained from the global _pr_nt_sids structure.
* Both the security descriptor and access-control list are returned
* and should be freed by a _PR_NT_FreeSecurityDescriptorACL call.
*
* The accessTable array maps NSPR's read, write, and execute access
* rights to the corresponding NT access rights for the securable
* object.
*/
PRStatus
_PR_NT_MakeSecurityDescriptorACL(
PRIntn mode,
DWORD accessTable[],
PSECURITY_DESCRIPTOR *resultSD,
PACL *resultACL)
{
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
DWORD cbACL; /* size of ACL */
DWORD accessMask;
if (_pr_nt_sids.owner == NULL) {
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
return PR_FAILURE;
}
pSD = (PSECURITY_DESCRIPTOR) PR_Malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == NULL) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
if (!SetSecurityDescriptorOwner(pSD, _pr_nt_sids.owner, FALSE)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
if (!SetSecurityDescriptorGroup(pSD, _pr_nt_sids.group, FALSE)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
/*
* Construct a discretionary access-control list with three
* access-control entries, one each for owner, primary group,
* and Everyone.
*/
cbACL = sizeof(ACL)
+ 3 * (sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD))
+ GetLengthSid(_pr_nt_sids.owner)
+ GetLengthSid(_pr_nt_sids.group)
+ GetLengthSid(_pr_nt_sids.everyone);
pACL = (PACL) PR_Malloc(cbACL);
if (pACL == NULL) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
if (!InitializeAcl(pACL, cbACL, ACL_REVISION)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
accessMask = 0;
if (mode & 00400) accessMask |= accessTable[0];
if (mode & 00200) accessMask |= accessTable[1];
if (mode & 00100) accessMask |= accessTable[2];
if (accessMask && !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask,
_pr_nt_sids.owner)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
accessMask = 0;
if (mode & 00040) accessMask |= accessTable[0];
if (mode & 00020) accessMask |= accessTable[1];
if (mode & 00010) accessMask |= accessTable[2];
if (accessMask && !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask,
_pr_nt_sids.group)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
accessMask = 0;
if (mode & 00004) accessMask |= accessTable[0];
if (mode & 00002) accessMask |= accessTable[1];
if (mode & 00001) accessMask |= accessTable[2];
if (accessMask && !AddAccessAllowedAce(pACL, ACL_REVISION, accessMask,
_pr_nt_sids.everyone)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
if (!SetSecurityDescriptorDacl(pSD, TRUE, pACL, FALSE)) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
goto failed;
}
*resultSD = pSD;
*resultACL = pACL;
return PR_SUCCESS;
failed:
if (pSD) {
PR_Free(pSD);
}
if (pACL) {
PR_Free(pACL);
}
return PR_FAILURE;
}
/*
* Free the specified security descriptor and access-control list
* previously created by _PR_NT_MakeSecurityDescriptorACL.
*/
void
_PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD, PACL pACL)
{
if (pSD) {
PR_Free(pSD);
}
if (pACL) {
PR_Free(pACL);
}
}

View File

@@ -118,6 +118,8 @@ _PR_MD_EARLY_INIT()
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
{
_PR_NT_FreeSids();
WSACleanup();
if (!_pr_use_static_tls) {

View File

@@ -23,6 +23,22 @@
#include "primpl.h"
/*
* NSPR-to-NT access right mapping table for semaphore objects.
*
* The SYNCHRONIZE access is required by WaitForSingleObject.
* The SEMAPHORE_MODIFY_STATE access is required by ReleaseSemaphore.
* The OR of these three access masks must equal SEMAPHORE_ALL_ACCESS.
* This is because if a semaphore object with the specified name
* exists, CreateSemaphore requests SEMAPHORE_ALL_ACCESS access to
* the existing object.
*/
static DWORD semAccessTable[] = {
STANDARD_RIGHTS_REQUIRED|0x1, /* read (0x1 is "query state") */
STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|SEMAPHORE_MODIFY_STATE, /* write */
0 /* execute */
};
#ifndef _PR_GLOBAL_THREADS_ONLY
/*
@@ -94,6 +110,10 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
const char *osname, PRIntn flags, PRIntn mode, PRUintn value)
{
PRSem *sem;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
sem = PR_NEW(PRSem);
if (sem == NULL) {
@@ -101,7 +121,17 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
return NULL;
}
if (flags & PR_SEM_CREATE) {
sem->sem = CreateSemaphore(NULL, value, 0x7fffffff, osname);
if (_PR_NT_MakeSecurityDescriptorACL(mode, semAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
sem->sem = CreateSemaphore(lpSA, value, 0x7fffffff, osname);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if (sem->sem == NULL) {
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
PR_DELETE(sem);
@@ -114,7 +144,8 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
return NULL;
}
} else {
sem->sem = OpenSemaphore(SEMAPHORE_ALL_ACCESS, FALSE, osname);
sem->sem = OpenSemaphore(
SEMAPHORE_MODIFY_STATE|SYNCHRONIZE, FALSE, osname);
if (sem->sem == NULL) {
DWORD err = GetLastError();

View File

@@ -26,6 +26,20 @@
extern PRLogModuleInfo *_pr_shm_lm;
/*
* NSPR-to-NT access right mapping table for file-mapping objects.
*
* The OR of these three access masks must equal FILE_MAP_ALL_ACCESS.
* This is because if a file-mapping object with the specified name
* exists, CreateFileMapping requests full access to the existing
* object.
*/
static DWORD filemapAccessTable[] = {
FILE_MAP_ALL_ACCESS & ~FILE_MAP_WRITE, /* read */
FILE_MAP_ALL_ACCESS & ~FILE_MAP_READ, /* write */
0 /* execute */
};
extern PRSharedMemory * _MD_OpenSharedMemory(
const char *name,
PRSize size,
@@ -38,6 +52,10 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
DWORD dwHi, dwLo;
PRSharedMemory *shm;
DWORD flProtect = ( PAGE_READWRITE );
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
rc = _PR_MakeNativeIPCName( name, ipcname, PR_IPC_NAME_SIZE, _PRIPCShm );
if ( PR_FAILURE == rc )
@@ -72,23 +90,33 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
shm->ident = _PR_SHM_IDENT;
if (flags & PR_SHM_CREATE ) {
/* XXX: Not 64bit safe. Fix when WinNT goes 64bit, if ever */
/* XXX: Not 64bit safe. Fix when WinNT goes 64bit. */
dwHi = 0;
dwLo = shm->size;
if (_PR_NT_MakeSecurityDescriptorACL(mode, filemapAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
shm->handle = CreateFileMapping(
(HANDLE)-1 ,
NULL,
lpSA,
flProtect,
dwHi,
dwLo,
shm->ipcname);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if ( NULL == shm->handle ) {
PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,
( "PR_OpenSharedMemory: CreateFileMapping() failed: %s",
shm->ipcname ));
PR_SetError( PR_FILE_EXISTS_ERROR, ERROR_ALREADY_EXISTS );
_PR_MD_MAP_DEFAULT_ERROR( GetLastError());
PR_FREEIF( shm->ipcname )
PR_DELETE( shm );
return(NULL);
@@ -110,7 +138,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
}
}
} else {
shm->handle = OpenFileMapping( FILE_MAP_ALL_ACCESS, TRUE, shm->ipcname );
shm->handle = OpenFileMapping( FILE_MAP_WRITE, TRUE, shm->ipcname );
if ( NULL == shm->handle ) {
_PR_MD_MAP_DEFAULT_ERROR( GetLastError());
PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,

View File

@@ -24,9 +24,29 @@
#include "primpl.h"
#include <direct.h>
#include <mbstring.h>
struct _MDLock _pr_ioq_lock;
/*
* NSPR-to-NT access right mapping table for files.
*/
static DWORD fileAccessTable[] = {
FILE_GENERIC_READ,
FILE_GENERIC_WRITE,
FILE_GENERIC_EXECUTE
};
/*
* NSPR-to-NT access right mapping table for directories.
*/
static DWORD dirAccessTable[] = {
FILE_GENERIC_READ,
FILE_GENERIC_WRITE|FILE_DELETE_CHILD,
FILE_GENERIC_EXECUTE
};
/*
* The NSPR epoch (00:00:00 1 Jan 1970 UTC) in FILETIME.
* We store the value in a PRTime variable for convenience.
@@ -72,6 +92,8 @@ _PR_MD_INIT_IO()
PR_ASSERT(filetime.prt == _pr_filetime_offset);
}
#endif /* DEBUG */
_PR_NT_InitSids();
}
PRStatus
@@ -181,6 +203,67 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode)
return (PRInt32)file;
}
PRInt32
_PR_MD_OPEN_FILE(const char *name, PRIntn osflags, int mode)
{
HANDLE file;
PRInt32 access = 0;
PRInt32 flags = 0;
PRInt32 flag6 = 0;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
if (osflags & PR_CREATE_FILE) {
if (_PR_NT_MakeSecurityDescriptorACL(mode, fileAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
}
if (osflags & PR_SYNC) flag6 = FILE_FLAG_WRITE_THROUGH;
if (osflags & PR_RDONLY || osflags & PR_RDWR)
access |= GENERIC_READ;
if (osflags & PR_WRONLY || osflags & PR_RDWR)
access |= GENERIC_WRITE;
if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
flags = CREATE_NEW;
else if (osflags & PR_CREATE_FILE) {
if (osflags & PR_TRUNCATE)
flags = CREATE_ALWAYS;
else
flags = OPEN_ALWAYS;
} else {
if (osflags & PR_TRUNCATE)
flags = TRUNCATE_EXISTING;
else
flags = OPEN_EXISTING;
}
file = CreateFile(name,
access,
FILE_SHARE_READ|FILE_SHARE_WRITE,
lpSA,
flags,
flag6,
NULL);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if (file == INVALID_HANDLE_VALUE) {
_PR_MD_MAP_OPEN_ERROR(GetLastError());
return -1;
}
return (PRInt32)file;
}
PRInt32
_PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len)
{
@@ -353,12 +436,13 @@ _MD_CloseFile(PRInt32 osfd)
void FlipSlashes(char *cp, int len)
{
while (--len >= 0) {
if (cp[0] == '/') {
cp[0] = PR_DIRECTORY_SEPARATOR;
if (cp[0] == '/') {
cp[0] = PR_DIRECTORY_SEPARATOR;
}
cp = _mbsinc(cp);
}
cp++;
}
}
} /* end FlipSlashes() */
/*
**
@@ -661,7 +745,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
* FindFirstFile() expands wildcard characters. So
* we make sure the pathname contains no wildcard.
*/
if (NULL != strpbrk(fn, "?*")) {
if (NULL != _mbspbrk(fn, "?*")) {
PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0);
return -1;
}
@@ -683,7 +767,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
* If the pathname does not contain ., \, and /, it cannot be
* a root directory or a pathname that ends in a slash.
*/
if (NULL == strpbrk(fn, ".\\/")) {
if (NULL == _mbspbrk(fn, ".\\/")) {
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return -1;
}
@@ -865,6 +949,34 @@ _PR_MD_MKDIR(const char *name, PRIntn mode)
}
}
PRInt32
_PR_MD_MAKE_DIR(const char *name, PRIntn mode)
{
BOOL rv;
SECURITY_ATTRIBUTES sa;
LPSECURITY_ATTRIBUTES lpSA = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
if (_PR_NT_MakeSecurityDescriptorACL(mode, dirAccessTable,
&pSD, &pACL) == PR_SUCCESS) {
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = pSD;
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
rv = CreateDirectory(name, lpSA);
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
if (rv) {
return 0;
} else {
_PR_MD_MAP_MKDIR_ERROR(GetLastError());
return -1;
}
}
PRInt32
_PR_MD_RMDIR(const char *name)
{

View File

@@ -48,6 +48,8 @@ _PR_MD_EARLY_INIT()
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
{
_PR_NT_FreeSids();
WSACleanup();
#ifndef _PR_USE_STATIC_TLS

View File

@@ -142,6 +142,9 @@ void _MD_win32_map_default_error(PRInt32 err)
case ERROR_OPEN_FILES:
prError = PR_IO_ERROR;
break;
case ERROR_OPERATION_ABORTED:
prError = PR_OPERATION_ABORTED_ERROR;
break;
case ERROR_OUTOFMEMORY:
prError = PR_INSUFFICIENT_RESOURCES_ERROR;
break;

View File

@@ -88,7 +88,7 @@ static const struct PRErrorMessage text[] = {
{"PR_END_OF_FILE_ERROR", "Encountered end of file"},
{"PR_FILE_SEEK_ERROR", "Seek error"},
{"PR_FILE_IS_BUSY_ERROR", "The file is busy"},
{"PR_RESERVED_ERROR_5935", "Reserved Error Code -5935"},
{"PR_OPERATION_ABORTED_ERROR", "The I/O operation was aborted"},
{"PR_IN_PROGRESS_ERROR", "Operation is still in progress (probably a non-blocking connect)"},
{"PR_ALREADY_INITIATED_ERROR", "Operation has already been initiated (probably a non-blocking connect)"},
{"PR_GROUP_EMPTY_ERROR", "The wait group is empty"},

View File

@@ -99,7 +99,7 @@ ec PR_NO_MORE_FILES_ERROR, "No more entries in the directory"
ec PR_END_OF_FILE_ERROR, "Encountered end of file"
ec PR_FILE_SEEK_ERROR, "Seek error"
ec PR_FILE_IS_BUSY_ERROR, "The file is busy"
ec PR_RESERVED_ERROR_5935, "Reserved Error Code -5935"
ec PR_OPERATION_ABORTED_ERROR, "The I/O operation was aborted"
ec PR_IN_PROGRESS_ERROR,
"Operation is still in progress (probably a non-blocking connect)"
ec PR_ALREADY_INITIATED_ERROR,

View File

@@ -82,7 +82,7 @@ PR_NO_MORE_FILES_ERROR=No more entries in the directory
PR_END_OF_FILE_ERROR=Encountered end of file
PR_FILE_SEEK_ERROR=Seek error
PR_FILE_IS_BUSY_ERROR=The file is busy
PR_RESERVED_ERROR_5935=Reserved Error Code -5935
PR_OPERATION_ABORTED_ERROR=The I/O operation was aborted
PR_IN_PROGRESS_ERROR=Operation is still in progress (probably a non-blocking connect)
PR_ALREADY_INITIATED_ERROR=Operation has already been initiated (probably a non-blocking connect)
PR_GROUP_EMPTY_ERROR=The wait group is empty

View File

@@ -33,12 +33,6 @@ PR_IMPLEMENT(PRInt32) PR_GetOSError()
return thread->osErrorCode;
}
PR_IMPLEMENT(const char*) PR_GetErrorString()
{
PRThread *thread = PR_GetCurrentThread();
return thread->errorString;
}
PR_IMPLEMENT(void) PR_SetError(PRErrorCode code, PRInt32 osErr)
{
PRThread *thread = PR_GetCurrentThread();

View File

@@ -78,11 +78,11 @@ PR_IMPLEMENT(PRBool) PR_VersionCheck(const char *importedVersion)
/*
** This is the secret handshake algorithm.
**
** This release (3.1) is backward compatible with
** all the previous releases ("2.1 19980529", "3.0",
** "3.0.x"). It is not compatible with future
** releases or patches. So this release has a
** simple version compatibility check algorithm.
** This release has a simple version compatibility
** check algorithm. This release is not backward
** compatible with previous major releases. It is
** not compatible with future major, minor, or
** patch releases.
*/
int vmajor = 0, vminor = 0, vpatch = 0;
const char *ptr = importedVersion;
@@ -106,7 +106,7 @@ PR_IMPLEMENT(PRBool) PR_VersionCheck(const char *importedVersion)
}
}
if (vmajor > PR_VMAJOR) {
if (vmajor != PR_VMAJOR) {
return PR_FALSE;
}
if (vmajor == PR_VMAJOR && vminor > PR_VMINOR) {
@@ -144,6 +144,10 @@ static void _pr_SetNativeThreadsOnlyMode(void)
}
#endif
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
extern PRStatus _pr_init_ipv6();
#endif
static void _PR_InitStuff(void)
{
@@ -220,6 +224,10 @@ static void _PR_InitStuff(void)
nspr_InitializePRErrorTable();
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
_pr_init_ipv6();
#endif
_PR_MD_FINAL_INIT();
}

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,6 @@
* Reserved.
*/
#include "prtpool.h"
#include "nspr.h"
/*
@@ -84,10 +83,11 @@ struct PRThreadPool {
PRInt32 max_threads;
PRInt32 current_threads;
PRInt32 idle_threads;
PRInt32 stacksize;
PRUint32 stacksize;
tp_jobq jobq;
io_jobq ioq;
timer_jobq timerq;
PRLock *join_lock; /* used with jobp->join_cv */
PRCondVar *shutdown_cv;
PRBool shutdown;
};
@@ -95,12 +95,6 @@ struct PRThreadPool {
typedef enum io_op_type
{ JOB_IO_READ, JOB_IO_WRITE, JOB_IO_CONNECT, JOB_IO_ACCEPT } io_op_type;
typedef enum _PRJobStatus
{ JOB_ON_TIMERQ, JOB_ON_IOQ, JOB_QUEUED, JOB_RUNNING, JOB_COMPLETED,
JOB_CANCELED, JOB_FREED } _PRJobStatus;
typedef void (* Jobfn)(void *arg);
#ifdef OPT_WINNT
typedef struct NT_notifier {
OVERLAPPED overlapped; /* must be first */
@@ -110,12 +104,14 @@ typedef struct NT_notifier {
struct PRJob {
PRCList links; /* for linking jobs */
_PRJobStatus status;
PRBool joinable;
Jobfn job_func;
PRBool on_ioq; /* job on ioq */
PRBool on_timerq; /* job on timerq */
PRJobFn job_func;
void *job_arg;
PRLock *jlock;
PRCondVar *join_cv;
PRBool join_wait; /* == PR_TRUE, when waiting to join */
PRCondVar *cancel_cv; /* for cancelling IO jobs */
PRBool cancel_io; /* for cancelling IO jobs */
PRThreadPool *tpool; /* back pointer to thread pool */
PRJobIoDesc *iod;
io_op_type io_op;
@@ -134,12 +130,40 @@ struct PRJob {
#define WTHREAD_LINKS_PTR(_qp) \
((wthread *) ((char *) (_qp) - offsetof(wthread, links)))
#define JOINABLE_JOB(_jobp) (NULL != (_jobp)->join_cv)
#define JOIN_NOTIFY(_jobp) \
PR_BEGIN_MACRO \
PR_Lock(_jobp->tpool->join_lock); \
_jobp->join_wait = PR_FALSE; \
PR_NotifyCondVar(_jobp->join_cv); \
PR_Unlock(_jobp->tpool->join_lock); \
PR_END_MACRO
#define CANCEL_IO_JOB(jobp) \
PR_BEGIN_MACRO \
jobp->cancel_io = PR_FALSE; \
jobp->on_ioq = PR_FALSE; \
PR_REMOVE_AND_INIT_LINK(&jobp->links); \
tp->ioq.cnt--; \
PR_NotifyCondVar(jobp->cancel_cv); \
PR_END_MACRO
static void delete_job(PRJob *jobp);
static PRThreadPool * alloc_threadpool();
static PRJob * alloc_job(PRBool joinable);
static PRJob * alloc_job(PRBool joinable, PRThreadPool *tp);
static void notify_ioq(PRThreadPool *tp);
static void notify_timerq(PRThreadPool *tp);
/*
* locks are acquired in the following order
*
* tp->ioq.lock,tp->timerq.lock
* |
* V
* tp->jobq->lock
*/
/*
* worker thread function
*/
@@ -172,17 +196,14 @@ PRCList *head;
tp->idle_threads--;
tp->jobq.cnt--;
PR_Unlock(tp->jobq.lock);
PR_Lock(jobp->jlock);
jobp->status = JOB_RUNNING;
PR_Unlock(jobp->jlock);
#else
PR_Lock(tp->jobq.lock);
while (PR_CLIST_IS_EMPTY(&tp->jobq.list) && (!tp->shutdown)) {
tp->idle_threads++;
PR_WaitCondVar(tp->jobq.cv, PR_INTERVAL_NO_TIMEOUT);
tp->idle_threads--;
}
tp->idle_threads--;
if (tp->shutdown) {
PR_Unlock(tp->jobq.lock);
break;
@@ -194,20 +215,14 @@ PRCList *head;
PR_REMOVE_AND_INIT_LINK(head);
tp->jobq.cnt--;
jobp = JOB_LINKS_PTR(head);
PR_Lock(jobp->jlock);
jobp->status = JOB_RUNNING;
PR_Unlock(jobp->jlock);
PR_Unlock(tp->jobq.lock);
#endif
jobp->job_func(jobp->job_arg);
if (!jobp->joinable) {
if (!JOINABLE_JOB(jobp)) {
delete_job(jobp);
} else {
PR_Lock(jobp->jlock);
jobp->status = JOB_COMPLETED;
PR_NotifyCondVar(jobp->join_cv);
PR_Unlock(jobp->jlock);
JOIN_NOTIFY(jobp);
}
}
PR_Lock(tp->jobq.lock);
@@ -236,11 +251,9 @@ add_to_jobq(PRThreadPool *tp, PRJob *jobp)
#else
PR_Lock(tp->jobq.lock);
PR_APPEND_LINK(&jobp->links,&tp->jobq.list);
jobp->status = JOB_QUEUED;
tp->jobq.cnt++;
if ((tp->idle_threads < tp->jobq.cnt) &&
(tp->current_threads < tp->max_threads)) {
PRThread *thr;
wthread *wthrp;
/*
* increment thread count and unlock the jobq lock
@@ -248,15 +261,19 @@ add_to_jobq(PRThreadPool *tp, PRJob *jobp)
tp->current_threads++;
PR_Unlock(tp->jobq.lock);
/* create new worker thread */
thr = PR_CreateThread(PR_USER_THREAD, wstart,
wthrp = PR_NEWZAP(wthread);
if (wthrp) {
wthrp->thread = PR_CreateThread(PR_USER_THREAD, wstart,
tp, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,PR_JOINABLE_THREAD,tp->stacksize);
if (NULL == wthrp->thread) {
PR_DELETE(wthrp); /* this sets wthrp to NULL */
}
}
PR_Lock(tp->jobq.lock);
if (NULL == thr) {
if (NULL == wthrp) {
tp->current_threads--;
} else {
wthrp = PR_NEWZAP(wthread);
wthrp->thread = thr;
PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);
}
}
@@ -331,6 +348,10 @@ PRIntervalTime now;
PR_Lock(tp->ioq.lock);
for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = qp->next) {
jobp = JOB_LINKS_PTR(qp);
if (jobp->cancel_io) {
CANCEL_IO_JOB(jobp);
continue;
}
if (pollfds_used == (pollfd_cnt))
break;
pollfds[pollfds_used].fd = jobp->iod->socket;
@@ -391,11 +412,18 @@ PRIntervalTime now;
jobp = polljobs[index];
if ((revents & PR_POLL_NVAL) || /* busted in all cases */
(revents & PR_POLL_ERR) ||
((events & PR_POLL_WRITE) &&
(revents & PR_POLL_HUP))) { /* write op & hup */
PR_Lock(tp->ioq.lock);
if (jobp->cancel_io) {
CANCEL_IO_JOB(jobp);
PR_Unlock(tp->ioq.lock);
continue;
}
PR_REMOVE_AND_INIT_LINK(&jobp->links);
tp->ioq.cnt--;
jobp->on_ioq = PR_FALSE;
PR_Unlock(tp->ioq.lock);
/* set error */
@@ -403,21 +431,36 @@ PRIntervalTime now;
jobp->iod->error = PR_BAD_DESCRIPTOR_ERROR;
else if (PR_POLL_HUP & revents)
jobp->iod->error = PR_CONNECT_RESET_ERROR;
else
jobp->iod->error = PR_IO_ERROR;
/*
* add to jobq
*/
add_to_jobq(tp, jobp);
} else if (revents & events) {
} else if (revents) {
/*
* add to jobq
*/
PR_Lock(tp->ioq.lock);
if (jobp->cancel_io) {
CANCEL_IO_JOB(jobp);
PR_Unlock(tp->ioq.lock);
continue;
}
PR_REMOVE_AND_INIT_LINK(&jobp->links);
tp->ioq.cnt--;
jobp->on_ioq = PR_FALSE;
PR_Unlock(tp->ioq.lock);
jobp->iod->error = 0;
if (jobp->io_op == JOB_IO_CONNECT) {
if (PR_GetConnectStatus(&pollfds[index]) == PR_SUCCESS)
jobp->iod->error = 0;
else
jobp->iod->error = PR_GetError();
} else
jobp->iod->error = 0;
add_to_jobq(tp, jobp);
}
}
@@ -429,6 +472,10 @@ PRIntervalTime now;
PR_Lock(tp->ioq.lock);
for (qp = tp->ioq.list.next; qp != &tp->ioq.list; qp = qp->next) {
jobp = JOB_LINKS_PTR(qp);
if (jobp->cancel_io) {
CANCEL_IO_JOB(jobp);
continue;
}
if (PR_INTERVAL_NO_TIMEOUT == jobp->timeout)
break;
if ((PR_INTERVAL_NO_WAIT != jobp->timeout) &&
@@ -436,6 +483,7 @@ PRIntervalTime now;
break;
PR_REMOVE_AND_INIT_LINK(&jobp->links);
tp->ioq.cnt--;
jobp->on_ioq = PR_FALSE;
jobp->iod->error = PR_IO_TIMEOUT_ERROR;
add_to_jobq(tp, jobp);
}
@@ -494,6 +542,7 @@ PRIntervalTime now;
*/
PR_REMOVE_AND_INIT_LINK(&jobp->links);
tp->timerq.cnt--;
jobp->on_timerq = PR_FALSE;
add_to_jobq(tp, jobp);
}
PR_Unlock(tp->timerq.lock);
@@ -510,6 +559,8 @@ delete_threadpool(PRThreadPool *tp)
PR_DestroyCondVar(tp->jobq.cv);
if (NULL != tp->jobq.lock)
PR_DestroyLock(tp->jobq.lock);
if (NULL != tp->join_lock)
PR_DestroyLock(tp->join_lock);
#ifdef OPT_WINNT
if (NULL != tp->jobq.nt_completion_port)
CloseHandle(tp->jobq.nt_completion_port);
@@ -545,6 +596,9 @@ PRThreadPool *tp;
tp->jobq.cv = PR_NewCondVar(tp->jobq.lock);
if (NULL == tp->jobq.cv)
goto failed;
tp->join_lock = PR_NewLock();
if (NULL == tp->join_lock)
goto failed;
#ifdef OPT_WINNT
tp->jobq.nt_completion_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
NULL, 0, 0);
@@ -581,7 +635,7 @@ failed:
/* Create thread pool */
PR_IMPLEMENT(PRThreadPool *)
PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads,
PRSize stacksize)
PRUint32 stacksize)
{
PRThreadPool *tp;
PRThread *thr;
@@ -643,32 +697,29 @@ static void
delete_job(PRJob *jobp)
{
if (NULL != jobp) {
if (NULL != jobp->jlock) {
PR_DestroyLock(jobp->jlock);
jobp->jlock = NULL;
}
if (NULL != jobp->join_cv) {
PR_DestroyCondVar(jobp->join_cv);
jobp->join_cv = NULL;
}
jobp->status = JOB_FREED;
if (NULL != jobp->cancel_cv) {
PR_DestroyCondVar(jobp->cancel_cv);
jobp->cancel_cv = NULL;
}
PR_DELETE(jobp);
}
}
static PRJob *
alloc_job(PRBool joinable)
alloc_job(PRBool joinable, PRThreadPool *tp)
{
PRJob *jobp;
jobp = PR_NEWZAP(PRJob);
if (NULL == jobp)
goto failed;
jobp->jlock = PR_NewLock();
if (NULL == jobp->jlock)
goto failed;
if (joinable) {
jobp->join_cv = PR_NewCondVar(jobp->jlock);
jobp->join_cv = PR_NewCondVar(tp->join_lock);
jobp->join_wait = PR_TRUE;
if (NULL == jobp->join_cv)
goto failed;
} else {
@@ -686,32 +737,31 @@ failed:
/* queue a job */
PR_IMPLEMENT(PRJob *)
PR_QueueJob(PRThreadPool *tpool, JobFn fn, void *arg, PRBool joinable)
PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable)
{
PRJob *jobp;
jobp = alloc_job(joinable);
jobp = alloc_job(joinable, tpool);
if (NULL == jobp)
return NULL;
jobp->job_func = fn;
jobp->job_arg = arg;
jobp->tpool = tpool;
jobp->joinable = joinable;
add_to_jobq(tpool, jobp);
return jobp;
}
/* queue a job, when a socket is readable */
/* queue a job, when a socket is readable or writeable */
static PRJob *
queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, PRJobFn fn, void * arg,
PRBool joinable, io_op_type op)
{
PRJob *jobp;
PRIntervalTime now;
jobp = alloc_job(joinable);
jobp = alloc_job(joinable, tpool);
if (NULL == jobp) {
return NULL;
}
@@ -723,9 +773,7 @@ queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
jobp->job_func = fn;
jobp->job_arg = arg;
jobp->status = JOB_ON_IOQ;
jobp->tpool = tpool;
jobp->joinable = joinable;
jobp->iod = iod;
if (JOB_IO_READ == op) {
jobp->io_op = JOB_IO_READ;
@@ -738,7 +786,7 @@ queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
jobp->io_poll_flags = PR_POLL_READ;
} else if (JOB_IO_CONNECT == op) {
jobp->io_op = JOB_IO_CONNECT;
jobp->io_poll_flags = PR_POLL_WRITE;
jobp->io_poll_flags = PR_POLL_WRITE|PR_POLL_EXCEPT;
} else {
delete_job(jobp);
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
@@ -778,6 +826,7 @@ queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
PR_INSERT_AFTER(&jobp->links,qp);
}
jobp->on_ioq = PR_TRUE;
tpool->ioq.cnt++;
/*
* notify io worker thread(s)
@@ -789,7 +838,7 @@ queue_io_job(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
/* queue a job, when a socket is readable */
PR_IMPLEMENT(PRJob *)
PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, PRJobFn fn, void * arg,
PRBool joinable)
{
return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_READ));
@@ -797,7 +846,7 @@ PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
/* queue a job, when a socket is writeable */
PR_IMPLEMENT(PRJob *)
PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn,void * arg,
PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, PRJobFn fn,void * arg,
PRBool joinable)
{
return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_WRITE));
@@ -806,27 +855,40 @@ PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn,void * arg,
/* queue a job, when a socket has a pending connection */
PR_IMPLEMENT(PRJob *)
PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod, JobFn fn, void * arg,
PRBool joinable)
PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod, PRJobFn fn,
void * arg, PRBool joinable)
{
return (queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_ACCEPT));
}
/* queue a job, when a socket can be connected */
PR_IMPLEMENT(PRJob *)
PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod, PRNetAddr *addr,
JobFn fn, void * arg, PRBool joinable)
PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod,
const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable)
{
/*
* not implemented
*/
return NULL;
PRStatus rv;
PRErrorCode err;
rv = PR_Connect(iod->socket, addr, PR_INTERVAL_NO_WAIT);
if ((rv == PR_FAILURE) && ((err = PR_GetError()) == PR_IN_PROGRESS_ERROR)){
/* connection pending */
return(queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_CONNECT));
} else {
/*
* connection succeeded or failed; add to jobq right away
*/
if (rv == PR_FAILURE)
iod->error = err;
else
iod->error = 0;
return(PR_QueueJob(tpool, fn, arg, joinable));
}
}
/* queue a job, when a timer expires */
PR_IMPLEMENT(PRJob *)
PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
JobFn fn, void * arg, PRBool joinable)
PRJobFn fn, void * arg, PRBool joinable)
{
PRIntervalTime now;
PRJob *jobp;
@@ -841,7 +903,7 @@ PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
*/
return(PR_QueueJob(tpool, fn, arg, joinable));
}
jobp = alloc_job(joinable);
jobp = alloc_job(joinable, tpool);
if (NULL == jobp) {
return NULL;
}
@@ -853,9 +915,7 @@ PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
jobp->job_func = fn;
jobp->job_arg = arg;
jobp->status = JOB_ON_TIMERQ;
jobp->tpool = tpool;
jobp->joinable = joinable;
jobp->timeout = timeout;
now = PR_IntervalNow();
@@ -863,6 +923,7 @@ PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
PR_Lock(tpool->timerq.lock);
jobp->on_timerq = PR_TRUE;
if (PR_CLIST_IS_EMPTY(&tpool->timerq.list))
PR_APPEND_LINK(&jobp->links,&tpool->timerq.list);
else {
@@ -921,27 +982,64 @@ PR_CancelJob(PRJob *jobp) {
PRStatus rval = PR_FAILURE;
PRThreadPool *tp;
if (JOB_QUEUED == jobp->status) {
if (jobp->on_timerq) {
/*
* now, check again while holding thread pool lock
* now, check again while holding the timerq lock
*/
tp = jobp->tpool;
PR_Lock(tp->jobq.lock);
PR_Lock(jobp->jlock);
if (JOB_QUEUED == jobp->status) {
PR_Lock(tp->timerq.lock);
if (jobp->on_timerq) {
jobp->on_timerq = PR_FALSE;
PR_REMOVE_AND_INIT_LINK(&jobp->links);
if (!jobp->joinable) {
PR_Unlock(jobp->jlock);
tp->timerq.cnt--;
PR_Unlock(tp->timerq.lock);
if (!JOINABLE_JOB(jobp)) {
delete_job(jobp);
} else {
jobp->status = JOB_CANCELED;
PR_NotifyCondVar(jobp->join_cv);
PR_Unlock(jobp->jlock);
JOIN_NOTIFY(jobp);
}
rval = PR_SUCCESS;
}
PR_Unlock(tp->jobq.lock);
} else
PR_Unlock(tp->timerq.lock);
} else if (jobp->on_ioq) {
/*
* now, check again while holding the ioq lock
*/
tp = jobp->tpool;
PR_Lock(tp->ioq.lock);
if (jobp->on_ioq) {
jobp->cancel_cv = PR_NewCondVar(tp->ioq.lock);
if (NULL == jobp->cancel_cv) {
PR_Unlock(tp->ioq.lock);
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
return PR_FAILURE;
}
/*
* mark job 'cancelled' and notify io thread(s)
* XXXX:
* this assumes there is only one io thread; when there
* are multiple threads, the io thread processing this job
* must be notified.
*/
jobp->cancel_io = PR_TRUE;
PR_Unlock(tp->ioq.lock); /* release, reacquire ioq lock */
notify_ioq(tp);
PR_Lock(tp->ioq.lock);
while (jobp->cancel_io)
PR_WaitCondVar(jobp->cancel_cv, PR_INTERVAL_NO_TIMEOUT);
PR_Unlock(tp->ioq.lock);
PR_ASSERT(!jobp->on_ioq);
if (!JOINABLE_JOB(jobp)) {
delete_job(jobp);
} else {
JOIN_NOTIFY(jobp);
}
rval = PR_SUCCESS;
} else
PR_Unlock(tp->ioq.lock);
}
if (PR_FAILURE == rval)
PR_SetError(PR_INVALID_STATE_ERROR, 0);
return rval;
}
@@ -949,19 +1047,14 @@ PR_CancelJob(PRJob *jobp) {
PR_IMPLEMENT(PRStatus)
PR_JoinJob(PRJob *jobp)
{
/*
* No references to the thread pool
*/
if (!jobp->joinable) {
if (!JOINABLE_JOB(jobp)) {
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return PR_FAILURE;
}
PR_Lock(jobp->jlock);
while((JOB_COMPLETED != jobp->status) &&
(JOB_CANCELED != jobp->status))
PR_Lock(jobp->tpool->join_lock);
while(jobp->join_wait)
PR_WaitCondVar(jobp->join_cv, PR_INTERVAL_NO_TIMEOUT);
PR_Unlock(jobp->jlock);
PR_Unlock(jobp->tpool->join_lock);
delete_job(jobp);
return PR_SUCCESS;
}
@@ -1017,9 +1110,7 @@ PRStatus rval_status;
/*
* wakeup io thread(s)
*/
PR_Lock(tpool->ioq.lock);
notify_ioq(tpool);
PR_Unlock(tpool->ioq.lock);
/*
* wakeup timer thread(s)
@@ -1064,7 +1155,7 @@ PRStatus rval_status;
}
/*
* Delete unjoinable jobs; joinable jobs must be reclaimed by the user
* Delete queued jobs
*/
while (!PR_CLIST_IS_EMPTY(&tpool->jobq.list)) {
PRJob *jobp;
@@ -1073,17 +1164,10 @@ PRStatus rval_status;
PR_REMOVE_AND_INIT_LINK(head);
jobp = JOB_LINKS_PTR(head);
tpool->jobq.cnt--;
if (!jobp->joinable) {
delete_job(jobp);
} else {
PR_Lock(jobp->jlock);
jobp->status = JOB_CANCELED;
PR_NotifyCondVar(jobp->join_cv);
PR_Unlock(jobp->jlock);
}
delete_job(jobp);
}
/* delete io jobs */
while (!PR_CLIST_IS_EMPTY(&tpool->ioq.list)) {
PRJob *jobp;
@@ -1091,16 +1175,10 @@ PRStatus rval_status;
PR_REMOVE_AND_INIT_LINK(head);
tpool->ioq.cnt--;
jobp = JOB_LINKS_PTR(head);
if (!jobp->joinable) {
delete_job(jobp);
} else {
PR_Lock(jobp->jlock);
jobp->status = JOB_CANCELED;
PR_NotifyCondVar(jobp->join_cv);
PR_Unlock(jobp->jlock);
}
delete_job(jobp);
}
/* delete timer jobs */
while (!PR_CLIST_IS_EMPTY(&tpool->timerq.list)) {
PRJob *jobp;
@@ -1108,14 +1186,7 @@ PRStatus rval_status;
PR_REMOVE_AND_INIT_LINK(head);
tpool->timerq.cnt--;
jobp = JOB_LINKS_PTR(head);
if (!jobp->joinable) {
delete_job(jobp);
} else {
PR_Lock(jobp->jlock);
jobp->status = JOB_CANCELED;
PR_NotifyCondVar(jobp->join_cv);
PR_Unlock(jobp->jlock);
}
delete_job(jobp);
}
PR_ASSERT(0 == tpool->jobq.cnt);

View File

@@ -22,6 +22,10 @@
#define MY_LIBNAME "nspr"
#define MY_FILEDESCRIPTION "NSPR Library"
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
#ifdef _DEBUG
#define MY_DEBUG_STR " (debug)"
#define MY_FILEFLAGS_1 VS_FF_DEBUG
@@ -66,7 +70,7 @@ BEGIN
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
VALUE "FileVersion", PR_VERSION "\0"
VALUE "InternalName", MY_INTERNAL_NAME "\0"
VALUE "LegalCopyright", "Copyright \251 1996-1999 Netscape Communications Corporation\0"
VALUE "LegalCopyright", "Copyright \251 1996-2000 Netscape Communications Corporation\0"
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
VALUE "ProductName", "Netscape Portable Runtime\0"
VALUE "ProductVersion", PR_VERSION "\0"

View File

@@ -42,7 +42,14 @@
#define _DEBUG_STRING ""
#endif
PRVersionDescription prVersionDescription_libnspr3 =
/*
* A trick to expand the PR_VMAJOR macro before concatenation.
*/
#define CONCAT(x, y) x ## y
#define CONCAT2(x, y) CONCAT(x, y)
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libnspr, PR_VMAJOR)
PRVersionDescription VERSION_DESC_NAME =
{
/* version */ 2, /* this is the only one supported */
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
@@ -92,7 +99,7 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
dummy = rcsid;
dummy = sccsid;
#endif
return &prVersionDescription_libnspr3;
return &VERSION_DESC_NAME;
} /* versionEntryPointType */
/* prvrsion.c */

File diff suppressed because it is too large Load Diff

View File

@@ -761,7 +761,7 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name)
* From the semctl(2) man page in glibc 2.0
*/
#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
|| defined(FREEBSD) || defined(OPENBSD)
|| defined(FREEBSD) || defined(OPENBSD) || defined(BSDI)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */

View File

@@ -158,16 +158,6 @@ static void *_pt_root(void *arg)
/* unhook the thread from the runtime */
PR_Lock(pt_book.ml);
if (thred->state & PT_THREAD_SYSTEM)
pt_book.system -= 1;
else if (--pt_book.user == pt_book.this_many)
PR_NotifyAllCondVar(pt_book.cv);
thred->prev->next = thred->next;
if (NULL == thred->next)
pt_book.last = thred->prev;
else
thred->next->prev = thred->prev;
/*
* At this moment, PR_CreateThread() may not have set thred->id yet.
* It is safe for a detached thread to free thred only after
@@ -178,6 +168,16 @@ static void *_pt_root(void *arg)
while (!thred->okToDelete)
PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);
}
if (thred->state & PT_THREAD_SYSTEM)
pt_book.system -= 1;
else if (--pt_book.user == pt_book.this_many)
PR_NotifyAllCondVar(pt_book.cv);
thred->prev->next = thred->next;
if (NULL == thred->next)
pt_book.last = thred->prev;
else
thred->next->prev = thred->prev;
PR_Unlock(pt_book.ml);
/*
@@ -224,7 +224,6 @@ static PRThread* pt_AttachThread(void)
PR_ASSERT(0 == rv);
thred->state = PT_THREAD_GLOBAL | PT_THREAD_FOREIGN;
thred->io_tq_index = -1;
PR_Lock(pt_book.ml);
/* then put it into the list */
@@ -363,8 +362,6 @@ static PRThread* _PR_CreateThread(
thred->stack->stackSize = stackSize;
thred->stack->thr = thred;
thred->io_tq_index = -1;
#ifdef PT_NO_SIGTIMEDWAIT
pthread_mutex_init(&thred->suspendResumeMutex,NULL);
pthread_cond_init(&thred->suspendResumeCV,NULL);
@@ -740,8 +737,6 @@ static void _pt_thread_death(void *arg)
PR_Free(thred->privateData);
if (NULL != thred->errorString)
PR_Free(thred->errorString);
if (NULL != thred->io_cv)
PR_DestroyCondVar(thred->io_cv);
PR_Free(thred->stack);
#if defined(DEBUG)
memset(thred, 0xaf, sizeof(PRThread));
@@ -807,8 +802,6 @@ void _PR_InitThreads(
thred->stack->thr = thred;
_PR_InitializeStack(thred->stack);
thred->io_tq_index = -1;
/*
* Create a key for our use to store a backpointer in the pthread
* to our PRThread object. This object gets deleted when the thread

View File

@@ -39,6 +39,7 @@ endif
CSRCS = \
accept.c \
acceptread.c \
addrstr.c \
affinity.c \
alarm.c \
anonfm.c \
@@ -83,6 +84,8 @@ CSRCS = \
lock.c \
lockfile.c \
logger.c \
makedir.c \
mbcs.c \
multiacc.c \
multiwait.c \
many_cv.c \
@@ -91,12 +94,14 @@ CSRCS = \
nblayer.c \
nonblock.c \
ntioto.c \
ntoh.c \
op_2long.c \
op_excl.c \
op_filnf.c \
op_filok.c \
op_noacc.c \
op_nofil.c \
openfile.c \
parent.c \
perf.c \
pipeping.c \

Some files were not shown because too many files have changed in this diff Show More