diff options
author | wtchang%redhat.com <devnull@localhost> | 2005-10-21 18:15:48 +0000 |
---|---|---|
committer | wtchang%redhat.com <devnull@localhost> | 2005-10-21 18:15:48 +0000 |
commit | 00ce86c1602198b1d3942e1d7f8daf0960bbd9b9 (patch) | |
tree | 438beac46131c87938155af3336022e5887e63a4 | |
parent | 7386bbaaf9f88d6cd0f6b81fc83638a2cefaac0a (diff) | |
download | nspr-hg-00ce86c1602198b1d3942e1d7f8daf0960bbd9b9.tar.gz |
Bugzilla Bug 225859: added 64-bit Windows support. Peter Armistead
contributed the first 64-bit Windows patch (for IA64) in 2001. Portions
of this checkin are based on the patch contributed by Makoto Kato
<m_kato@ga2.so-net.ne.jp>. r=wtc.
Modified Files: configure configure.in prtypes.h _win95.cfg _win95.h
_winnt.cfg _winnt.h probslet.h pprio.h primpl.h
pr/src/Makefile.in prfile.c prio.c prsocket.c ntgc.c ntio.c
ntmisc.c w32rng.c w32shm.c w95io.c w95sock.c w95thred.c
prinit.c pr/tests/prpoll.c
Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rwxr-xr-x | configure | 73 | ||||
-rw-r--r-- | configure.in | 14 | ||||
-rw-r--r-- | pr/include/md/_win95.cfg | 98 | ||||
-rw-r--r-- | pr/include/md/_win95.h | 18 | ||||
-rw-r--r-- | pr/include/md/_winnt.cfg | 98 | ||||
-rw-r--r-- | pr/include/md/_winnt.h | 16 | ||||
-rw-r--r-- | pr/include/obsolete/probslet.h | 9 | ||||
-rw-r--r-- | pr/include/private/pprio.h | 22 | ||||
-rw-r--r-- | pr/include/private/primpl.h | 42 | ||||
-rw-r--r-- | pr/include/prtypes.h | 9 | ||||
-rw-r--r-- | pr/src/Makefile.in | 2 | ||||
-rw-r--r-- | pr/src/io/prfile.c | 14 | ||||
-rw-r--r-- | pr/src/io/prio.c | 8 | ||||
-rw-r--r-- | pr/src/io/prsocket.c | 39 | ||||
-rw-r--r-- | pr/src/md/windows/ntgc.c | 8 | ||||
-rw-r--r-- | pr/src/md/windows/ntio.c | 94 | ||||
-rw-r--r-- | pr/src/md/windows/ntmisc.c | 10 | ||||
-rw-r--r-- | pr/src/md/windows/w32rng.c | 4 | ||||
-rw-r--r-- | pr/src/md/windows/w32shm.c | 19 | ||||
-rw-r--r-- | pr/src/md/windows/w95io.c | 34 | ||||
-rw-r--r-- | pr/src/md/windows/w95sock.c | 45 | ||||
-rw-r--r-- | pr/src/md/windows/w95thred.c | 21 | ||||
-rw-r--r-- | pr/src/misc/prinit.c | 14 | ||||
-rw-r--r-- | pr/tests/prpoll.c | 7 |
24 files changed, 514 insertions, 204 deletions
@@ -4033,6 +4033,28 @@ EOF EOF ;; + x86_64) + cat >> confdefs.h <<\EOF +#define _AMD64_ 1 +EOF + + cat >> confdefs.h <<\EOF +#define _M_AMD64 1 +EOF + + USE_64=1 + ;; + ia64) + cat >> confdefs.h <<\EOF +#define _IA64_ 1 +EOF + + cat >> confdefs.h <<\EOF +#define _M_IA64 1 +EOF + + USE_64=1 + ;; *) cat >> confdefs.h <<\EOF #define _CPU_ARCH_NOT_DEFINED 1 @@ -4041,6 +4063,13 @@ EOF ;; esac + if test "$USE_64"; then + cat >> confdefs.h <<\EOF +#define _WIN64 1 +EOF + + fi + ;; *-ncr-sysv*) @@ -4336,17 +4365,17 @@ EOF _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000" ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6 -echo "configure:4340: checking for machine/builtins.h" >&5 +echo "configure:4369: checking for machine/builtins.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4345 "configure" +#line 4374 "configure" #include "confdefs.h" #include <machine/builtins.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4350: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4379: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4908,7 +4937,7 @@ case $target in ;; *) echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4912: checking for dlopen in -ldl" >&5 +echo "configure:4941: 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 @@ -4916,7 +4945,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4920 "configure" +#line 4949 "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 @@ -4927,7 +4956,7 @@ int main() { dlopen() ; return 0; } EOF -if { (eval echo configure:4931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4960: \"$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 @@ -4944,17 +4973,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 -echo "configure:4948: checking for dlfcn.h" >&5 +echo "configure:4977: checking for dlfcn.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4953 "configure" +#line 4982 "configure" #include "confdefs.h" #include <dlfcn.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4958: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4987: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -4987,13 +5016,13 @@ esac if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4991: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:5020: 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 4997 "configure" +#line 5026 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -5011,7 +5040,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 5015 "configure" +#line 5044 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -5035,12 +5064,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5039: checking for $ac_func" >&5 +echo "configure:5068: 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 5044 "configure" +#line 5073 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -5063,7 +5092,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:5067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5096: \"$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 @@ -5104,7 +5133,7 @@ hpux*) if test -z "$GNU_CC"; then echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 -echo "configure:5108: checking for +Olit support" >&5 +echo "configure:5137: checking for +Olit support" >&5 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5143,7 +5172,7 @@ darwin*) *) echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:5147: checking for pthread_create in -lpthreads" >&5 +echo "configure:5176: checking for pthread_create in -lpthreads" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5165,7 +5194,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:5169: checking for pthread_create in -lpthread" >&5 +echo "configure:5198: checking for pthread_create in -lpthread" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5187,7 +5216,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:5191: checking for pthread_create in -lc_r" >&5 +echo "configure:5220: checking for pthread_create in -lc_r" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5209,7 +5238,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:5213: checking for pthread_create in -lc" >&5 +echo "configure:5242: checking for pthread_create in -lc" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5363,7 +5392,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:5367: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5396: 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 @@ -5386,7 +5415,7 @@ echo "configure:5367: checking whether ${CC-cc} accepts -pthread" >&5 ac_cv_have_dash_pthreads=no if test "$ac_cv_have_dash_pthread" = "no"; then echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6 -echo "configure:5390: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5419: checking whether ${CC-cc} accepts -pthreads" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then diff --git a/configure.in b/configure.in index c91ca2da..f0c5d3be 100644 --- a/configure.in +++ b/configure.in @@ -1492,11 +1492,25 @@ case "$target" in mips) AC_DEFINE(_MIPS_) ;; + x86_64) + AC_DEFINE(_AMD64_) + AC_DEFINE(_M_AMD64) + USE_64=1 + ;; + ia64) + AC_DEFINE(_IA64_) + AC_DEFINE(_M_IA64) + USE_64=1 + ;; *) AC_DEFINE(_CPU_ARCH_NOT_DEFINED) ;; esac + if test "$USE_64"; then + AC_DEFINE(_WIN64) + fi + ;; *-ncr-sysv*) diff --git a/pr/include/md/_win95.cfg b/pr/include/md/_win95.cfg index 310fff89..de25ce24 100644 --- a/pr/include/md/_win95.cfg +++ b/pr/include/md/_win95.cfg @@ -144,6 +144,104 @@ #define PR_ALIGN_OF_DOUBLE 8 #define PR_ALIGN_OF_POINTER 4 +#elif defined(_AMD64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_IA64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + #else /* defined(_M_IX86) || defined(_X86_) */ #error unknown processor architecture diff --git a/pr/include/md/_win95.h b/pr/include/md/_win95.h index cd26bd63..083d0200 100644 --- a/pr/include/md/_win95.h +++ b/pr/include/md/_win95.h @@ -50,7 +50,15 @@ #define PR_LINKER_ARCH "win32" #define _PR_SI_SYSNAME "WIN95" -#define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */ +#if defined(_M_IX86) || defined(_X86_) +#define _PR_SI_ARCHITECTURE "x86" +#elif defined(_AMD64_) +#define _PR_SI_ARCHITECTURE "x86-64" +#elif defined(_IA64_) +#define _PR_SI_ARCHITECTURE "ia64" +#else +#error unknown processor architecture +#endif #define HAVE_DLL #undef HAVE_THREAD_AFFINITY @@ -208,7 +216,7 @@ struct _MDSemaphore { }; struct _MDFileDesc { - PRInt32 osfd; /* The osfd can come from one of three spaces: + PROsfd osfd; /* The osfd can come from one of three spaces: * - For stdin, stdout, and stderr, we are using * the libc file handle (0, 1, 2), which is an int. * - For files and pipes, we are using Win32 HANDLE, @@ -248,7 +256,7 @@ extern void _PR_NT_FreeSecurityDescriptorACL( #define _MD_WRITEV _PR_MD_WRITEV #define _MD_LSEEK _PR_MD_LSEEK #define _MD_LSEEK64 _PR_MD_LSEEK64 -extern PRInt32 _MD_CloseFile(PRInt32 osfd); +extern PRInt32 _MD_CloseFile(PROsfd osfd); #define _MD_CLOSE_FILE _MD_CloseFile #define _MD_GETFILEINFO _PR_MD_GETFILEINFO #define _MD_GETFILEINFO64 _PR_MD_GETFILEINFO64 @@ -305,7 +313,7 @@ extern void _MD_MakeNonblock(PRFileDesc *f); #define _MD_QUERY_FD_INHERITABLE _PR_MD_QUERY_FD_INHERITABLE #define _MD_SHUTDOWN _PR_MD_SHUTDOWN #define _MD_LISTEN _PR_MD_LISTEN -extern PRInt32 _MD_CloseSocket(PRInt32 osfd); +extern PRInt32 _MD_CloseSocket(PROsfd osfd); #define _MD_CLOSE_SOCKET _MD_CloseSocket #define _MD_SENDTO _PR_MD_SENDTO #define _MD_RECVFROM _PR_MD_RECVFROM @@ -341,7 +349,7 @@ extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd); #define _MD_SOCKETAVAILABLE _MD_SocketAvailable #define _MD_PIPEAVAILABLE _PR_MD_PIPEAVAILABLE #define _MD_CONNECT _PR_MD_CONNECT -extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, +extern PROsfd _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, PRIntervalTime timeout); #define _MD_ACCEPT _MD_Accept #define _MD_BIND _PR_MD_BIND diff --git a/pr/include/md/_winnt.cfg b/pr/include/md/_winnt.cfg index ce077d33..fb71b8a9 100644 --- a/pr/include/md/_winnt.cfg +++ b/pr/include/md/_winnt.cfg @@ -144,6 +144,104 @@ #define PR_ALIGN_OF_DOUBLE 8 #define PR_ALIGN_OF_POINTER 4 +#elif defined(_AMD64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_IA64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + #else /* defined(_M_IX86) || defined(_X86_) */ #error unknown processor architecture diff --git a/pr/include/md/_winnt.h b/pr/include/md/_winnt.h index 0e6ce819..da349cd0 100644 --- a/pr/include/md/_winnt.h +++ b/pr/include/md/_winnt.h @@ -64,7 +64,15 @@ #define PR_LINKER_ARCH "win32" #define _PR_SI_SYSNAME "WINNT" -#define _PR_SI_ARCHITECTURE "x86" /* XXXMB hardcode for now */ +#if defined(_M_IX86) || defined(_X86_) +#define _PR_SI_ARCHITECTURE "x86" +#elif defined(_AMD64_) +#define _PR_SI_ARCHITECTURE "x86-64" +#elif defined(_IA64_) +#define _PR_SI_ARCHITECTURE "ia64" +#else +#error unknown processor architecture +#endif #define HAVE_DLL #define HAVE_CUSTOM_USER_THREADS @@ -106,7 +114,9 @@ struct _md_sockaddr_in6 { #endif #define _PR_HAVE_THREADSAFE_GETHOST #define _PR_HAVE_ATOMIC_OPS +#if defined(_M_IX86) || defined(_X86_) #define _PR_HAVE_ATOMIC_CAS +#endif #define PR_HAVE_WIN32_NAMED_SHARED_MEMORY #define _PR_HAVE_PEEK_BUFFER #define _PR_PEEK_BUFFER_MAX (32 * 1024) @@ -231,7 +241,7 @@ struct _MDSemaphore { }; struct _MDFileDesc { - PRInt32 osfd; /* The osfd can come from one of three spaces: + PROsfd osfd; /* The osfd can come from one of three spaces: * - For stdin, stdout, and stderr, we are using * the libc file handle (0, 1, 2), which is an int. * - For files and pipes, we are using Win32 HANDLE, @@ -281,7 +291,7 @@ extern void _PR_NT_FreeSecurityDescriptorACL( /* --- IO stuff --- */ extern PRInt32 _md_Associate(HANDLE); -extern PRInt32 _PR_MD_CLOSE(PRInt32 osfd, PRBool socket); +extern PRInt32 _PR_MD_CLOSE(PROsfd osfd, PRBool socket); #define _MD_OPEN _PR_MD_OPEN #define _MD_OPEN_FILE _PR_MD_OPEN_FILE diff --git a/pr/include/obsolete/probslet.h b/pr/include/obsolete/probslet.h index 374e696c..efc67f61 100644 --- a/pr/include/obsolete/probslet.h +++ b/pr/include/obsolete/probslet.h @@ -44,6 +44,7 @@ #define PROBSLET_H #include "prio.h" +#include "private/pprio.h" /* for PROsfd */ PR_BEGIN_EXTERN_C @@ -70,7 +71,7 @@ typedef struct PR_fd_set { PRUint32 hsize; PRFileDesc *harray[PR_MAX_SELECT_DESC]; PRUint32 nsize; - PRInt32 narray[PR_MAX_SELECT_DESC]; + PROsfd narray[PR_MAX_SELECT_DESC]; } PR_fd_set; /* @@ -154,9 +155,9 @@ NSPR_API(void) PR_FD_ZERO(PR_fd_set *set); NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set); NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set); NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set); -NSPR_API(void) PR_FD_NSET(PRInt32 osfd, PR_fd_set *set); -NSPR_API(void) PR_FD_NCLR(PRInt32 osfd, PR_fd_set *set); -NSPR_API(PRInt32) PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set); +NSPR_API(void) PR_FD_NSET(PROsfd osfd, PR_fd_set *set); +NSPR_API(void) PR_FD_NCLR(PROsfd osfd, PR_fd_set *set); +NSPR_API(PRInt32) PR_FD_NISSET(PROsfd osfd, PR_fd_set *set); #ifndef NO_NSPR_10_SUPPORT #ifdef XP_MAC diff --git a/pr/include/private/pprio.h b/pr/include/private/pprio.h index 55417cf2..63e063cf 100644 --- a/pr/include/private/pprio.h +++ b/pr/include/private/pprio.h @@ -52,6 +52,12 @@ PR_BEGIN_EXTERN_C /************************************************************************/ /************************************************************************/ +#ifdef _WIN64 +typedef __int64 PROsfd; +#else +typedef PRInt32 PROsfd; +#endif + /* Return the method tables for files, tcp sockets and udp sockets */ NSPR_API(const PRIOMethods*) PR_GetFileMethods(void); NSPR_API(const PRIOMethods*) PR_GetTCPMethods(void); @@ -62,18 +68,18 @@ NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void); ** Convert a NSPR Socket Handle to a Native Socket handle. ** This function will be obsoleted with the next release; avoid using it. */ -NSPR_API(PRInt32) PR_FileDesc2NativeHandle(PRFileDesc *); -NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PRInt32); -NSPR_API(PRFileDesc*) PR_AllocFileDesc(PRInt32 osfd, +NSPR_API(PROsfd) PR_FileDesc2NativeHandle(PRFileDesc *); +NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PROsfd); +NSPR_API(PRFileDesc*) PR_AllocFileDesc(PROsfd osfd, const PRIOMethods *methods); NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd); /* ** Import an existing OS file to NSPR. */ -NSPR_API(PRFileDesc*) PR_ImportFile(PRInt32 osfd); -NSPR_API(PRFileDesc*) PR_ImportPipe(PRInt32 osfd); -NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd); -NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PRInt32 osfd); +NSPR_API(PRFileDesc*) PR_ImportFile(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportPipe(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PROsfd osfd); +NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PROsfd osfd); /* @@ -94,7 +100,7 @@ NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PRInt32 osfd); ************************************************************************** */ -NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd); +NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd); /* ************************************************************************* diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index eebcb841..1565d184 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -1098,13 +1098,13 @@ extern void _PR_MD_MAKE_NONBLOCK(PRFileDesc *fd); #define _PR_MD_MAKE_NONBLOCK _MD_MAKE_NONBLOCK /* File I/O related */ -extern PRInt32 _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode); +extern PROsfd _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); +extern PROsfd _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); +extern PRInt32 _PR_MD_CLOSE_FILE(PROsfd osfd); #define _PR_MD_CLOSE_FILE _MD_CLOSE_FILE extern PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 amount); @@ -1147,7 +1147,7 @@ extern PRInt32 _PR_MD_RMDIR(const char *name); extern PRStatus _PR_MD_OPEN_DIR_UTF16(_MDDirUTF16 *md, const PRUnichar *name); #define _PR_MD_OPEN_DIR_UTF16 _MD_OPEN_DIR_UTF16 -extern PRInt32 _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, PRIntn mode); +extern PROsfd _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, PRIntn mode); #define _PR_MD_OPEN_FILE_UTF16 _MD_OPEN_FILE_UTF16 extern PRUnichar * _PR_MD_READ_DIR_UTF16(_MDDirUTF16 *md, PRIntn flags); @@ -1164,7 +1164,7 @@ extern PRInt32 _PR_MD_GETFILEINFO64_UTF16(const PRUnichar *fn, PRFileInfo64 *inf extern void _PR_MD_INIT_IO(void); #define _PR_MD_INIT_IO _MD_INIT_IO -extern PRInt32 _PR_MD_CLOSE_SOCKET(PRInt32 osfd); +extern PRInt32 _PR_MD_CLOSE_SOCKET(PROsfd osfd); #define _PR_MD_CLOSE_SOCKET _MD_CLOSE_SOCKET extern PRInt32 _PR_MD_CONNECT( @@ -1172,7 +1172,7 @@ extern PRInt32 _PR_MD_CONNECT( PRUint32 addrlen, PRIntervalTime timeout); #define _PR_MD_CONNECT _MD_CONNECT -extern PRInt32 _PR_MD_ACCEPT( +extern PROsfd _PR_MD_ACCEPT( PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout); #define _PR_MD_ACCEPT _MD_ACCEPT @@ -1195,25 +1195,25 @@ extern PRInt32 _PR_MD_SEND( PRIntervalTime timeout); #define _PR_MD_SEND _MD_SEND -extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, +extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout); #define _PR_MD_ACCEPT_READ _MD_ACCEPT_READ #ifdef WIN32 -extern PRInt32 _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr, +extern PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg); -extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, +extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg); -extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PRInt32 s, PRInt32 ls); +extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd s, PROsfd ls); #define _PR_MD_UPDATE_ACCEPT_CONTEXT _MD_UPDATE_ACCEPT_CONTEXT #endif /* WIN32 */ @@ -1255,10 +1255,10 @@ extern PRInt32 _PR_MD_SENDTO( const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout); #define _PR_MD_SENDTO _MD_SENDTO -extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PRInt32 *osfd); +extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PROsfd *osfd); #define _PR_MD_SOCKETPAIR _MD_SOCKETPAIR -extern PRInt32 _PR_MD_SOCKET(int af, int type, int flags); +extern PROsfd _PR_MD_SOCKET(int af, int type, int flags); #define _PR_MD_SOCKET _MD_SOCKET extern PRInt32 _PR_MD_SOCKETAVAILABLE(PRFileDesc *fd); @@ -1754,6 +1754,18 @@ struct PRFilePrivate { #endif }; +#ifdef _WIN64 +#define PR_PRIdOSFD "lld" /* for printing PROsfd */ +#define PR_PRIxOSFD "llx" +#define PR_SCNdOSFD "lld" /* for scanning PROsfd */ +#define PR_SCNxOSFD "llx" +#else +#define PR_PRIdOSFD "ld" /* for printing PROsfd */ +#define PR_PRIxOSFD "lx" +#define PR_SCNdOSFD "ld" /* for scanning PROsfd */ +#define PR_SCNxOSFD "lx" +#endif + struct PRDir { PRDirEntry d; _MDDir md; @@ -1964,13 +1976,13 @@ extern PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask); /* File locking */ -extern PRStatus _PR_MD_LOCKFILE(PRInt32 osfd); +extern PRStatus _PR_MD_LOCKFILE(PROsfd osfd); #define _PR_MD_LOCKFILE _MD_LOCKFILE -extern PRStatus _PR_MD_TLOCKFILE(PRInt32 osfd); +extern PRStatus _PR_MD_TLOCKFILE(PROsfd osfd); #define _PR_MD_TLOCKFILE _MD_TLOCKFILE -extern PRStatus _PR_MD_UNLOCKFILE(PRInt32 osfd); +extern PRStatus _PR_MD_UNLOCKFILE(PROsfd osfd); #define _PR_MD_UNLOCKFILE _MD_UNLOCKFILE /* Memory-mapped files */ diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index 1ed9f995..157da93a 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -442,7 +442,11 @@ typedef ptrdiff_t PRPtrdiff; ** A type for pointer difference. Variables of this type are suitable ** for storing a pointer or pointer sutraction. ************************************************************************/ +#ifdef _WIN64 +typedef unsigned __int64 PRUptrdiff; +#else typedef unsigned long PRUptrdiff; +#endif /************************************************************************ ** TYPES: PRBool @@ -495,8 +499,13 @@ typedef PRUint16 PRUnichar; ** Specification, Addison-Wesley, September 1996. ** http://java.sun.com/docs/books/vmspec/index.html.) */ +#ifdef _WIN64 +typedef __int64 PRWord; +typedef unsigned __int64 PRUword; +#else typedef long PRWord; typedef unsigned long PRUword; +#endif #if defined(NO_NSPR_10_SUPPORT) #else diff --git a/pr/src/Makefile.in b/pr/src/Makefile.in index cf2f5229..4a3ac42a 100644 --- a/pr/src/Makefile.in +++ b/pr/src/Makefile.in @@ -316,11 +316,13 @@ OBJS += memory/$(OBJDIR)/prgcleak.$(OBJ_SUFFIX) endif ifeq ($(OS_ARCH), WINNT) +ifndef USE_64 ifdef NS_USE_GCC DLLBASE=-Wl,--image-base -Wl,0x30000000 else DLLBASE=-BASE:0x30000000 endif # GCC +endif # !USE_64 RES=$(OBJDIR)/nspr.res RESNAME=nspr.rc endif # WINNT diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c index d91bffa2..6aa736d4 100644 --- a/pr/src/io/prfile.c +++ b/pr/src/io/prfile.c @@ -359,7 +359,7 @@ PR_IMPLEMENT(const PRIOMethods*) PR_GetPipeMethods(void) PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd = 0; #if !defined(_PR_HAVE_O_APPEND) PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE; @@ -387,7 +387,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode) PR_IMPLEMENT(PRFileDesc*) PR_OpenFile( const char *name, PRIntn flags, PRIntn mode) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd = 0; #if !defined(_PR_HAVE_O_APPEND) PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE; @@ -558,7 +558,7 @@ PRInt32 rv; /* ** Import an existing OS file to NSPR */ -PR_IMPLEMENT(PRFileDesc*) PR_ImportFile(PRInt32 osfd) +PR_IMPLEMENT(PRFileDesc*) PR_ImportFile(PROsfd osfd) { PRFileDesc *fd = NULL; @@ -577,7 +577,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_ImportFile(PRInt32 osfd) /* ** Import an existing OS pipe to NSPR */ -PR_IMPLEMENT(PRFileDesc*) PR_ImportPipe(PRInt32 osfd) +PR_IMPLEMENT(PRFileDesc*) PR_ImportPipe(PROsfd osfd) { PRFileDesc *fd = NULL; @@ -733,13 +733,13 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe( PR_SetError(PR_UNKNOWN_ERROR, GetLastError()); return PR_FAILURE; } - *readPipe = PR_AllocFileDesc((PRInt32)readEnd, &_pr_pipeMethods); + *readPipe = PR_AllocFileDesc((PROsfd)readEnd, &_pr_pipeMethods); if (NULL == *readPipe) { CloseHandle(readEnd); CloseHandle(writeEnd); return PR_FAILURE; } - *writePipe = PR_AllocFileDesc((PRInt32)writeEnd, &_pr_pipeMethods); + *writePipe = PR_AllocFileDesc((PROsfd)writeEnd, &_pr_pipeMethods); if (NULL == *writePipe) { PR_Close(*readPipe); CloseHandle(writeEnd); @@ -802,7 +802,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe( PR_IMPLEMENT(PRFileDesc*) PR_OpenFileUTF16( const PRUnichar *name, PRIntn flags, PRIntn mode) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd = 0; #if !defined(_PR_HAVE_O_APPEND) PRBool appendMode = ( PR_APPEND & flags )? PR_TRUE : PR_FALSE; diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c index 908bfd61..be187756 100644 --- a/pr/src/io/prio.c +++ b/pr/src/io/prio.c @@ -55,11 +55,11 @@ void _PR_InitIO(void) _pr_flock_cv = PR_NewCondVar(_pr_flock_lock); #ifdef WIN32 - _pr_stdin = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_INPUT_HANDLE), + _pr_stdin = PR_AllocFileDesc((PROsfd)GetStdHandle(STD_INPUT_HANDLE), methods); - _pr_stdout = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_OUTPUT_HANDLE), + _pr_stdout = PR_AllocFileDesc((PROsfd)GetStdHandle(STD_OUTPUT_HANDLE), methods); - _pr_stderr = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_ERROR_HANDLE), + _pr_stderr = PR_AllocFileDesc((PROsfd)GetStdHandle(STD_ERROR_HANDLE), methods); #ifdef WINNT _pr_stdin->secret->md.sync_file_io = PR_TRUE; @@ -118,7 +118,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD osfd) } PR_IMPLEMENT(PRFileDesc*) PR_AllocFileDesc( - PRInt32 osfd, const PRIOMethods *methods) + PROsfd osfd, const PRIOMethods *methods) { PRFileDesc *fd; diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index 8be198fa..535e1c7a 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -190,7 +190,7 @@ PRInt32 iov_size, PRIntervalTime timeout) /************************************************************************/ -PR_IMPLEMENT(PRFileDesc *) PR_ImportTCPSocket(PRInt32 osfd) +PR_IMPLEMENT(PRFileDesc *) PR_ImportTCPSocket(PROsfd osfd) { PRFileDesc *fd; @@ -204,7 +204,7 @@ PRFileDesc *fd; return(fd); } -PR_IMPLEMENT(PRFileDesc *) PR_ImportUDPSocket(PRInt32 osfd) +PR_IMPLEMENT(PRFileDesc *) PR_ImportUDPSocket(PROsfd osfd) { PRFileDesc *fd; @@ -221,7 +221,7 @@ PRFileDesc *fd; static const PRIOMethods* PR_GetSocketPollFdMethods(void); -PR_IMPLEMENT(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd) +PR_IMPLEMENT(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd) { PRFileDesc *fd; @@ -287,7 +287,7 @@ static PRStatus PR_CALLBACK SocketConnect( static PRStatus PR_CALLBACK SocketConnectContinue( PRFileDesc *fd, PRInt16 out_flags) { - PRInt32 osfd; + PROsfd osfd; int err; if (out_flags & PR_POLL_NVAL) { @@ -397,7 +397,7 @@ PR_IMPLEMENT(PRStatus) PR_GetConnectStatus(const PRPollDesc *pd) static PRFileDesc* PR_CALLBACK SocketAccept(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd2; PRUint32 al; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -476,7 +476,7 @@ PRIntervalTime timeout) PR_IMPLEMENT(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd2; PRIntn al; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -596,8 +596,9 @@ PRIntervalTime timeout) return -1; } - PR_LOG(_pr_io_lm, PR_LOG_MAX, ("recv: fd=%p osfd=%d buf=%p amount=%d flags=%d", - fd, fd->secret->md.osfd, buf, amount, flags)); + PR_LOG(_pr_io_lm, PR_LOG_MAX, + ("recv: fd=%p osfd=%" PR_PRIdOSFD " buf=%p amount=%d flags=%d", + fd, fd->secret->md.osfd, buf, amount, flags)); #ifdef _PR_HAVE_PEEK_BUFFER if (fd->secret->peekBytes != 0) { @@ -678,7 +679,7 @@ PRIntn flags, PRIntervalTime timeout) count = 0; while (amount > 0) { PR_LOG(_pr_io_lm, PR_LOG_MAX, - ("send: fd=%p osfd=%d buf=%p amount=%d", + ("send: fd=%p osfd=%" PR_PRIdOSFD " buf=%p amount=%d", fd, fd->secret->md.osfd, buf, amount)); temp = _PR_MD_SEND(fd, buf, amount, flags, timeout); if (temp < 0) { @@ -865,7 +866,7 @@ PRIntervalTime timeout) #if defined(WINNT) { - PRInt32 newSock; + PROsfd newSock; PRNetAddr *raddrCopy; if (raddr == NULL) { @@ -905,7 +906,7 @@ PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout) { PRInt32 rv; - PRInt32 newSock; + PROsfd newSock; PRThread *me = _PR_MD_CURRENT_THREAD(); PRNetAddr *raddrCopy; @@ -956,7 +957,7 @@ _PR_AcceptTimeoutCallback callback, void *callbackArg) { PRInt32 rv; - PRInt32 newSock; + PROsfd newSock; PRThread *me = _PR_MD_CURRENT_THREAD(); PRNetAddr *raddrCopy; @@ -1254,7 +1255,7 @@ PR_EXTERN(PRBool) _pr_ipv6_is_present; PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket() { -PRInt32 osfd; + PROsfd osfd; osfd = _PR_MD_SOCKET(AF_INET6, SOCK_STREAM, 0); if (osfd != -1) { @@ -1269,7 +1270,7 @@ PRInt32 osfd; PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) { - PRInt32 osfd; + PROsfd osfd; PRFileDesc *fd; PRInt32 tmp_domain = domain; @@ -1579,7 +1580,7 @@ failed: #endif } -PR_IMPLEMENT(PRInt32) +PR_IMPLEMENT(PROsfd) PR_FileDesc2NativeHandle(PRFileDesc *fd) { if (fd) { @@ -1593,7 +1594,7 @@ PR_FileDesc2NativeHandle(PRFileDesc *fd) } PR_IMPLEMENT(void) -PR_ChangeFileDescNativeHandle(PRFileDesc *fd, PRInt32 handle) +PR_ChangeFileDescNativeHandle(PRFileDesc *fd, PROsfd handle) { if (fd) fd->secret->md.osfd = handle; @@ -1640,14 +1641,14 @@ PR_IMPLEMENT(PRInt32) PR_FD_ISSET(PRFileDesc *fh, PR_fd_set *set) return 0; } -PR_IMPLEMENT(void) PR_FD_NSET(PRInt32 fd, PR_fd_set *set) +PR_IMPLEMENT(void) PR_FD_NSET(PROsfd fd, PR_fd_set *set) { PR_ASSERT( set->nsize < PR_MAX_SELECT_DESC ); set->narray[set->nsize++] = fd; } -PR_IMPLEMENT(void) PR_FD_NCLR(PRInt32 fd, PR_fd_set *set) +PR_IMPLEMENT(void) PR_FD_NCLR(PROsfd fd, PR_fd_set *set) { PRUint32 index, index2; @@ -1661,7 +1662,7 @@ PR_IMPLEMENT(void) PR_FD_NCLR(PRInt32 fd, PR_fd_set *set) } } -PR_IMPLEMENT(PRInt32) PR_FD_NISSET(PRInt32 fd, PR_fd_set *set) +PR_IMPLEMENT(PRInt32) PR_FD_NISSET(PROsfd fd, PR_fd_set *set) { PRUint32 index; for (index = 0; index<set->nsize; index++) diff --git a/pr/src/md/windows/ntgc.c b/pr/src/md/windows/ntgc.c index 12af4846..e12b30d6 100644 --- a/pr/src/md/windows/ntgc.c +++ b/pr/src/md/windows/ntgc.c @@ -96,7 +96,9 @@ PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) #endif } return (PRWord *)&t->md.gcContext; -#elif defined(_ALPHA_) +#else + PR_NOT_REACHED("not implemented"); + return NULL; #endif /* defined(_X86_) */ } @@ -121,6 +123,8 @@ GetMyFiberID() } return fiberData; -#elif defined(_ALPHA_) +#else + PR_NOT_REACHED("not implemented"); + return NULL; #endif /* defined(_X86_) */ } diff --git a/pr/src/md/windows/ntio.c b/pr/src/md/windows/ntio.c index defaae4d..d70cc949 100644 --- a/pr/src/md/windows/ntio.c +++ b/pr/src/md/windows/ntio.c @@ -118,7 +118,7 @@ PRInt32 IsFileLocal(HANDLE hFile); static PRInt32 _md_MakeNonblock(HANDLE); -static PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *addrlen, PRIntervalTime); +static PROsfd _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *addrlen, PRIntervalTime); static PRInt32 _nt_nonblock_connect(PRFileDesc *fd, struct sockaddr *addr, int addrlen, PRIntervalTime); static PRInt32 _nt_nonblock_recv(PRFileDesc *fd, char *buf, int len, int flags, PRIntervalTime); static PRInt32 _nt_nonblock_send(PRFileDesc *fd, char *buf, int len, PRIntervalTime); @@ -1045,7 +1045,7 @@ static int missing_completions = 0; static int max_wait_loops = 0; static PRInt32 -_NT_IO_ABORT(PRInt32 sock) +_NT_IO_ABORT(PROsfd sock) { PRThread *me = _PR_MD_CURRENT_THREAD(); PRBool fWait; @@ -1136,7 +1136,7 @@ _NT_IO_ABORT(PRInt32 sock) } -PRInt32 +PROsfd _PR_MD_SOCKET(int af, int type, int flags) { SOCKET sock; @@ -1147,13 +1147,13 @@ _PR_MD_SOCKET(int af, int type, int flags) _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError()); } - return (PRInt32)sock; + return (PROsfd)sock; } struct connect_data_s { PRInt32 status; PRInt32 error; - PRInt32 osfd; + PROsfd osfd; struct sockaddr *addr; PRUint32 addrlen; PRIntervalTime timeout; @@ -1177,7 +1177,7 @@ PRInt32 _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; u_long nbio; PRInt32 rc; @@ -1245,7 +1245,7 @@ _PR_MD_BIND(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen) return 0; } -void _PR_MD_UPDATE_ACCEPT_CONTEXT(PRInt32 accept_sock, PRInt32 listen_sock) +void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd accept_sock, PROsfd listen_sock) { /* Sockets accept()'d with AcceptEx need to call this setsockopt before * calling anything other than ReadFile(), WriteFile(), send(), recv(), @@ -1268,12 +1268,12 @@ void _PR_MD_UPDATE_ACCEPT_CONTEXT(PRInt32 accept_sock, PRInt32 listen_sock) } #define INET_ADDR_PADDED (sizeof(PRNetAddr) + 16) -PRInt32 +PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRThread *me = _PR_MD_CURRENT_THREAD(); SOCKET accept_sock; int bytes; @@ -1420,12 +1420,12 @@ _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, } PRInt32 -_PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, +_PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg) { - PRInt32 sock = sd->secret->md.osfd; + PROsfd sock = sd->secret->md.osfd; PRThread *me = _PR_MD_CURRENT_THREAD(); int bytes; PRNetAddr *Laddr; @@ -1707,7 +1707,7 @@ PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRThread *me = _PR_MD_CURRENT_THREAD(); int bytes; int rv, err; @@ -1806,7 +1806,7 @@ PRInt32 _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRThread *me = _PR_MD_CURRENT_THREAD(); int bytes; int rv, err; @@ -1901,7 +1901,7 @@ PRInt32 _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv; if (!fd->secret->md.io_model_committed) { @@ -1919,7 +1919,7 @@ PRInt32 _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv; if (!fd->secret->md.io_model_committed) { @@ -1937,7 +1937,7 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRInt32 _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; int index; int sent = 0; int rv; @@ -2082,7 +2082,7 @@ _PR_MD_SETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* op /* --- FILE IO ----------------------------------------------------------- */ -PRInt32 +PROsfd _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode) { HANDLE file; @@ -2125,10 +2125,10 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, PRIntn mode) } } - return (PRInt32)file; + return (PROsfd)file; } -PRInt32 +PROsfd _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode) { HANDLE file; @@ -2187,13 +2187,13 @@ _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, PRIntn mode) } } - return (PRInt32)file; + return (PROsfd)file; } PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) { - PRInt32 f = fd->secret->md.osfd; + PROsfd f = fd->secret->md.osfd; PRUint32 bytes; int rv, err; LONG hiOffset = 0; @@ -2344,7 +2344,7 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { - PRInt32 f = fd->secret->md.osfd; + PROsfd f = fd->secret->md.osfd; PRInt32 bytes; int rv, err; LONG hiOffset = 0; @@ -2613,7 +2613,7 @@ _PR_MD_FSYNC(PRFileDesc *fd) } PRInt32 -_PR_MD_CLOSE(PRInt32 osfd, PRBool socket) +_PR_MD_CLOSE(PROsfd osfd, PRBool socket) { PRInt32 rv; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -3268,7 +3268,7 @@ _PR_MD_RMDIR(const char *name) } PRStatus -_PR_MD_LOCKFILE(PRInt32 f) +_PR_MD_LOCKFILE(PROsfd f) { PRInt32 rv, err; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -3387,7 +3387,7 @@ _PR_MD_LOCKFILE(PRInt32 f) } PRStatus -_PR_MD_TLOCKFILE(PRInt32 f) +_PR_MD_TLOCKFILE(PROsfd f) { PRInt32 rv, err; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -3500,7 +3500,7 @@ _PR_MD_TLOCKFILE(PRInt32 f) PRStatus -_PR_MD_UNLOCKFILE(PRInt32 f) +_PR_MD_UNLOCKFILE(PROsfd f) { PRInt32 rv; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -3792,9 +3792,10 @@ PR_IMPLEMENT(PRStatus) PR_NT_CancelIo(PRFileDesc *fd) return PR_SUCCESS; } -static PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *addrlen, PRIntervalTime timeout) +static PROsfd _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; + SOCKET sock; PRInt32 rv, err; fd_set rd; struct timeval tv, *tvp; @@ -3802,10 +3803,10 @@ static PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *a FD_ZERO(&rd); FD_SET((SOCKET)osfd, &rd); if (timeout == PR_INTERVAL_NO_TIMEOUT) { - while ((rv = accept(osfd, addr, addrlen)) == -1) { + while ((sock = accept(osfd, addr, addrlen)) == -1) { if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) { - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, &rd, NULL, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, NULL)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); break; @@ -3816,7 +3817,7 @@ static PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *a } } } else if (timeout == PR_INTERVAL_NO_WAIT) { - if ((rv = accept(osfd, addr, addrlen)) == -1) { + if ((sock = accept(osfd, addr, addrlen)) == -1) { if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) { PR_SetError(PR_IO_TIMEOUT_ERROR, 0); @@ -3826,7 +3827,7 @@ static PRInt32 _nt_nonblock_accept(PRFileDesc *fd, struct sockaddr *addr, int *a } } else { retry: - if ((rv = accept(osfd, addr, addrlen)) == -1) { + if ((sock = accept(osfd, addr, addrlen)) == -1) { if (((err = WSAGetLastError()) == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) { tv.tv_sec = PR_IntervalToSeconds(timeout); @@ -3834,12 +3835,11 @@ retry: timeout - PR_SecondsToInterval(tv.tv_sec)); tvp = &tv; - rv = _PR_NTFiberSafeSelect(osfd + 1, &rd, NULL, NULL, tvp); + rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp); if (rv > 0) { goto retry; } else if (rv == 0) { PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - rv = -1; } else { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); } @@ -3848,12 +3848,12 @@ retry: } } } - return(rv); + return (PROsfd)sock; } static PRInt32 _nt_nonblock_connect(PRFileDesc *fd, struct sockaddr *addr, int addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv; int err; fd_set wr, ex; @@ -3874,7 +3874,7 @@ static PRInt32 _nt_nonblock_connect(PRFileDesc *fd, struct sockaddr *addr, int a FD_ZERO(&ex); FD_SET((SOCKET)osfd, &wr); FD_SET((SOCKET)osfd, &ex); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, NULL, &wr, &ex, + if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wr, &ex, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); return rv; @@ -3906,7 +3906,7 @@ static PRInt32 _nt_nonblock_connect(PRFileDesc *fd, struct sockaddr *addr, int a static PRInt32 _nt_nonblock_recv(PRFileDesc *fd, char *buf, int len, int flags, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; struct timeval tv, *tvp; fd_set rd; @@ -3931,7 +3931,7 @@ static PRInt32 _nt_nonblock_recv(PRFileDesc *fd, char *buf, int len, int flags, timeout - PR_SecondsToInterval(tv.tv_sec)); tvp = &tv; } - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, &rd, NULL, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); break; @@ -3950,7 +3950,7 @@ static PRInt32 _nt_nonblock_recv(PRFileDesc *fd, char *buf, int len, int flags, static PRInt32 _nt_nonblock_send(PRFileDesc *fd, char *buf, int len, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; struct timeval tv, *tvp; fd_set wd; @@ -3970,7 +3970,7 @@ static PRInt32 _nt_nonblock_send(PRFileDesc *fd, char *buf, int len, PRIntervalT } FD_ZERO(&wd); FD_SET((SOCKET)osfd, &wd); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, NULL, &wd, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); return -1; @@ -3999,7 +3999,7 @@ static PRInt32 _nt_nonblock_send(PRFileDesc *fd, char *buf, int len, PRIntervalT } FD_ZERO(&wd); FD_SET((SOCKET)osfd, &wd); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, NULL, &wd, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); return -1; @@ -4046,7 +4046,7 @@ static PRInt32 _nt_nonblock_sendto( PRFileDesc *fd, const char *buf, int len, const struct sockaddr *addr, int addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; struct timeval tv, *tvp; fd_set wd; @@ -4066,7 +4066,7 @@ static PRInt32 _nt_nonblock_sendto( } FD_ZERO(&wd); FD_SET((SOCKET)osfd, &wd); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, NULL, &wd, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); return -1; @@ -4095,7 +4095,7 @@ static PRInt32 _nt_nonblock_sendto( } FD_ZERO(&wd); FD_SET((SOCKET)osfd, &wd); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, NULL, &wd, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, NULL, &wd, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); return -1; @@ -4111,7 +4111,7 @@ static PRInt32 _nt_nonblock_sendto( static PRInt32 _nt_nonblock_recvfrom(PRFileDesc *fd, char *buf, int len, struct sockaddr *addr, int *addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; struct timeval tv, *tvp; fd_set rd; @@ -4129,7 +4129,7 @@ static PRInt32 _nt_nonblock_recvfrom(PRFileDesc *fd, char *buf, int len, struct } FD_ZERO(&rd); FD_SET((SOCKET)osfd, &rd); - if ((rv = _PR_NTFiberSafeSelect(osfd + 1, &rd, NULL, NULL, + if ((rv = _PR_NTFiberSafeSelect(0, &rd, NULL, NULL, tvp)) == -1) { _PR_MD_MAP_SELECT_ERROR(WSAGetLastError()); break; diff --git a/pr/src/md/windows/ntmisc.c b/pr/src/md/windows/ntmisc.c index 8433da02..f2255d90 100644 --- a/pr/src/md/windows/ntmisc.c +++ b/pr/src/md/windows/ntmisc.c @@ -112,7 +112,7 @@ static int assembleCmdLine(char *const *argv, char **cmdLine) { char *const *arg; char *p, *q; - int cmdLineSize; + size_t cmdLineSize; int numBackslashes; int i; int argNeedQuotes; @@ -133,7 +133,7 @@ static int assembleCmdLine(char *const *argv, char **cmdLine) + 2 /* we quote every argument */ + 1; /* space in between, or final null */ } - p = *cmdLine = PR_MALLOC(cmdLineSize); + p = *cmdLine = PR_MALLOC((PRUint32) cmdLineSize); if (p == NULL) { return -1; } @@ -226,7 +226,7 @@ static int assembleEnvBlock(char **envp, char **envBlock) char **env; char *curEnv; char *cwdStart, *cwdEnd; - int envBlockSize; + size_t envBlockSize; if (envp == NULL) { *envBlock = NULL; @@ -261,7 +261,7 @@ static int assembleEnvBlock(char **envp, char **envBlock) } envBlockSize++; - p = *envBlock = PR_MALLOC(envBlockSize); + p = *envBlock = PR_MALLOC((PRUint32) envBlockSize); if (p == NULL) { FreeEnvironmentStrings(curEnv); return -1; @@ -583,7 +583,7 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size) { DWORD dwHi, dwLo; DWORD flProtect; - PRUint32 osfd; + PROsfd osfd; osfd = ( fmap->fd == (PRFileDesc*)-1 )? -1 : fmap->fd->secret->md.osfd; diff --git a/pr/src/md/windows/w32rng.c b/pr/src/md/windows/w32rng.c index 2ad6ed86..5232b5fa 100644 --- a/pr/src/md/windows/w32rng.c +++ b/pr/src/md/windows/w32rng.c @@ -59,8 +59,8 @@ CurrentClockTickTime(LPDWORD lpdwHigh, LPDWORD lpdwLow) extern PRSize _PR_MD_GetRandomNoise( void *buf, PRSize size ) { DWORD dwHigh, dwLow, dwVal; - int n = 0; - int nBytes; + size_t n = 0; + size_t nBytes; time_t sTime; if (size <= 0) diff --git a/pr/src/md/windows/w32shm.c b/pr/src/md/windows/w32shm.c index 705f62f1..136b20d2 100644 --- a/pr/src/md/windows/w32shm.c +++ b/pr/src/md/windows/w32shm.c @@ -92,7 +92,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory( return(NULL); } - shm->ipcname = PR_MALLOC( strlen( ipcname ) + 1 ); + shm->ipcname = PR_MALLOC( (PRUint32) (strlen( ipcname ) + 1) ); if ( NULL == shm->ipcname ) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 ); @@ -109,9 +109,8 @@ extern PRSharedMemory * _MD_OpenSharedMemory( shm->ident = _PR_SHM_IDENT; if (flags & PR_SHM_CREATE ) { - /* XXX: Not 64bit safe. Fix when WinNT goes 64bit. */ - dwHi = 0; - dwLo = shm->size; + dwHi = (DWORD) (((PRUint64) shm->size >> 32) & 0xffffffff); + dwLo = (DWORD) (shm->size & 0xffffffff); if (_PR_NT_MakeSecurityDescriptorACL(mode, filemapAccessTable, &pSD, &pACL) == PR_SUCCESS) { @@ -305,9 +304,8 @@ extern PRStatus _md_ExportFileMapAsString( { PRIntn written; - written = PR_snprintf( buf, bufSize, "%d:%ld:%ld", - (PRIntn)fm->prot, (PRInt32)fm->md.hFileMap, (PRInt32)fm->md.dwAccess ); - /* Watch out on the above snprintf(). Windows HANDLE assumes 32bits; windows calls it void* */ + written = PR_snprintf( buf, (PRUint32) bufSize, "%d:%" PR_PRIdOSFD ":%ld", + (PRIntn)fm->prot, (PROsfd)fm->md.hFileMap, (PRInt32)fm->md.dwAccess ); PR_LOG( _pr_shma_lm, PR_LOG_DEBUG, ("_md_ExportFileMapAsString(): prot: %x, hFileMap: %x, dwAccess: %x", @@ -326,11 +324,12 @@ extern PRFileMap * _md_ImportFileMapFromString( ) { PRIntn prot; - PRInt32 hFileMap; + PROsfd hFileMap; PRInt32 dwAccess; PRFileMap *fm = NULL; - PR_sscanf( fmstring, "%d:%ld:%ld", &prot, &hFileMap, &dwAccess ); + PR_sscanf( fmstring, "%d:%" PR_SCNdOSFD ":%ld", + &prot, &hFileMap, &dwAccess ); fm = PR_NEWZAP(PRFileMap); if ( NULL == fm ) { @@ -340,7 +339,7 @@ extern PRFileMap * _md_ImportFileMapFromString( } fm->prot = (PRFileMapProtect)prot; - fm->md.hFileMap = (HANDLE)hFileMap; /* Assumes HANDLE is 32bit */ + fm->md.hFileMap = (HANDLE)hFileMap; fm->md.dwAccess = (DWORD)dwAccess; fm->fd = (PRFileDesc*)-1; diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c index 5d483cea..52032214 100644 --- a/pr/src/md/windows/w95io.c +++ b/pr/src/md/windows/w95io.c @@ -189,7 +189,7 @@ _PR_MD_WAKEUP_WAITER(PRThread *thread) * as in 0666, in the case of opening the logFile. * */ -PRInt32 +PROsfd _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) { HANDLE file; @@ -230,10 +230,10 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) return -1; } - return (PRInt32)file; + return (PROsfd)file; } -PRInt32 +PROsfd _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, int mode) { HANDLE file; @@ -291,7 +291,7 @@ _PR_MD_OPEN_FILE(const char *name, PRIntn osflags, int mode) return -1; } - return (PRInt32)file; + return (PROsfd)file; } PRInt32 @@ -324,7 +324,7 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { - PRInt32 f = fd->secret->md.osfd; + PROsfd f = fd->secret->md.osfd; PRInt32 bytes; int rv; PRThread *me = _PR_MD_CURRENT_THREAD(); @@ -448,7 +448,7 @@ _PR_MD_FSYNC(PRFileDesc *fd) } PRInt32 -_MD_CloseFile(PRInt32 osfd) +_MD_CloseFile(PROsfd osfd) { PRInt32 rv; @@ -463,9 +463,9 @@ _MD_CloseFile(PRInt32 osfd) #define GetFileFromDIR(d) (d)->d_entry.cFileName #define FileIsHidden(d) ((d)->d_entry.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) -void FlipSlashes(char *cp, int len) +void FlipSlashes(char *cp, size_t len) { - while (--len >= 0) { + while (len-- > 0) { if (cp[0] == '/') { cp[0] = PR_DIRECTORY_SEPARATOR; } @@ -502,7 +502,7 @@ PRStatus _PR_MD_OPEN_DIR(_MDDir *d, const char *name) { char filename[ MAX_PATH ]; - int len; + size_t len; len = strlen(name); /* Need 5 bytes for \*.* and the trailing null byte. */ @@ -652,7 +652,7 @@ _PR_MD_STAT(const char *fn, struct stat *info) * try again. */ - int len = strlen(fn); + size_t len = strlen(fn); if (len > 0 && len <= _MAX_PATH && (fn[len - 1] == '\\' || fn[len - 1] == '/')) { char newfn[_MAX_PATH + 1]; @@ -1047,7 +1047,7 @@ _PR_MD_RMDIR(const char *name) } PRStatus -_PR_MD_LOCKFILE(PRInt32 f) +_PR_MD_LOCKFILE(PROsfd f) { PRStatus rc = PR_SUCCESS; DWORD rv; @@ -1066,7 +1066,7 @@ _PR_MD_LOCKFILE(PRInt32 f) } /* end _PR_MD_LOCKFILE() */ PRStatus -_PR_MD_TLOCKFILE(PRInt32 f) +_PR_MD_TLOCKFILE(PROsfd f) { PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 ); return PR_FAILURE; @@ -1074,7 +1074,7 @@ _PR_MD_TLOCKFILE(PRInt32 f) PRStatus -_PR_MD_UNLOCKFILE(PRInt32 f) +_PR_MD_UNLOCKFILE(PROsfd f) { PRInt32 rv; @@ -1139,9 +1139,9 @@ static void InitUnicodeSupport(void) } /* ================ UTF16 Interfaces ================================ */ -void FlipSlashesW(PRUnichar *cp, int len) +void FlipSlashesW(PRUnichar *cp, size_t len) { - while (--len >= 0) { + while (len-- > 0) { if (cp[0] == L'/') { cp[0] = L'\\'; } @@ -1149,7 +1149,7 @@ void FlipSlashesW(PRUnichar *cp, int len) } } /* end FlipSlashesW() */ -PRInt32 +PROsfd _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, int mode) { HANDLE file; @@ -1212,7 +1212,7 @@ _PR_MD_OPEN_FILE_UTF16(const PRUnichar *name, PRIntn osflags, int mode) return -1; } - return (PRInt32)file; + return (PROsfd)file; } PRStatus diff --git a/pr/src/md/windows/w95sock.c b/pr/src/md/windows/w95sock.c index 01c25258..58d6f6a0 100644 --- a/pr/src/md/windows/w95sock.c +++ b/pr/src/md/windows/w95sock.c @@ -46,7 +46,7 @@ #define CONNECT_FD 3 static PRInt32 socket_io_wait( - PRInt32 osfd, + PROsfd osfd, PRInt32 fd_type, PRIntervalTime timeout); @@ -54,7 +54,7 @@ static PRInt32 socket_io_wait( /* --- SOCKET IO --------------------------------------------------------- */ -PRInt32 +PROsfd _PR_MD_SOCKET(int af, int type, int flags) { SOCKET sock; @@ -65,7 +65,7 @@ _PR_MD_SOCKET(int af, int type, int flags) if (sock == INVALID_SOCKET ) { _PR_MD_MAP_SOCKET_ERROR(WSAGetLastError()); - return (PRInt32)sock; + return (PROsfd)sock; } /* @@ -78,7 +78,7 @@ _PR_MD_SOCKET(int af, int type, int flags) return -1; } - return (PRInt32)sock; + return (PROsfd)sock; } /* @@ -86,7 +86,7 @@ _PR_MD_SOCKET(int af, int type, int flags) ** */ PRInt32 -_MD_CloseSocket(PRInt32 osfd) +_MD_CloseSocket(PROsfd osfd) { PRInt32 rv; @@ -109,23 +109,24 @@ _MD_SocketAvailable(PRFileDesc *fd) return result; } -PRInt32 _MD_Accept( +PROsfd _MD_Accept( PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, PRIntervalTime timeout ) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; + SOCKET sock; PRInt32 rv, err; - while ((rv = accept(osfd, (struct sockaddr *) raddr, rlen)) == -1) + while ((sock = accept(osfd, (struct sockaddr *) raddr, rlen)) == -1) { err = WSAGetLastError(); if ((err == WSAEWOULDBLOCK) && (!fd->secret->nonblocking)) { if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) { - return(-1); + break; } } else @@ -134,14 +135,14 @@ PRInt32 _MD_Accept( break; } } - return(rv); + return(sock); } /* end _MD_accept() */ PRInt32 _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv; int err; @@ -201,7 +202,7 @@ PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; int osflags; @@ -235,7 +236,7 @@ PRInt32 _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; PRInt32 bytesSent = 0; @@ -279,7 +280,7 @@ PRInt32 _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; PRInt32 bytesSent = 0; @@ -324,7 +325,7 @@ PRInt32 _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout) { - PRInt32 osfd = fd->secret->md.osfd; + PROsfd osfd = fd->secret->md.osfd; PRInt32 rv, err; while ((rv = recvfrom( osfd, buf, amount, 0, (struct sockaddr *) addr, @@ -469,7 +470,7 @@ _MD_MakeNonblock(PRFileDesc *f) #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5 static PRInt32 socket_io_wait( - PRInt32 osfd, + PROsfd osfd, PRInt32 fd_type, PRIntervalTime timeout) { @@ -500,13 +501,13 @@ static PRInt32 socket_io_wait( switch( fd_type ) { case READ_FD: - rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv); + rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv); break; case WRITE_FD: - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv); + rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv); break; case CONNECT_FD: - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, &ex, &tv); + rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv); break; default: PR_ASSERT(0); @@ -580,13 +581,13 @@ static PRInt32 socket_io_wait( switch( fd_type ) { case READ_FD: - rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv); + rv = _MD_SELECT(0, &rd_wr, NULL, NULL, &tv); break; case WRITE_FD: - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv); + rv = _MD_SELECT(0, NULL, &rd_wr, NULL, &tv); break; case CONNECT_FD: - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, &ex, &tv); + rv = _MD_SELECT(0, NULL, &rd_wr, &ex, &tv); break; default: PR_ASSERT(0); diff --git a/pr/src/md/windows/w95thred.c b/pr/src/md/windows/w95thred.c index a8d5f068..89cd39ab 100644 --- a/pr/src/md/windows/w95thred.c +++ b/pr/src/md/windows/w95thred.c @@ -38,6 +38,14 @@ #include "primpl.h" #include <process.h> /* for _beginthreadex() */ +#if _MSC_VER <= 1200 +/* + * VC++ 6.0 doesn't have DWORD_PTR. + */ + +typedef DWORD DWORD_PTR; +#endif /* _MSC_VER <= 1200 */ + /* --- globals ------------------------------------------------ */ #ifdef _PR_USE_STATIC_TLS __declspec(thread) struct PRThread *_pr_thread_last_run; @@ -224,7 +232,7 @@ _PR_MD_EXIT(PRIntn status) PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask ) { - int rv; + DWORD_PTR rv; rv = SetThreadAffinityMask(thread->md.handle, mask); @@ -233,10 +241,15 @@ PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask ) PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask) { - PRInt32 rv, system_mask; + BOOL rv; + DWORD_PTR process_mask; + DWORD_PTR system_mask; + + rv = GetProcessAffinityMask(GetCurrentProcess(), + &process_mask, &system_mask); + if (rv) + *mask = (PRUint32)process_mask; - rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask); - return rv?0:-1; } diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c index 1ecfb3d1..3fb92f18 100644 --- a/pr/src/misc/prinit.c +++ b/pr/src/misc/prinit.c @@ -587,8 +587,12 @@ PR_ProcessAttrSetInheritableFD( #define FD_INHERIT_BUFFER_INCR 128 /* The length of "NSPR_INHERIT_FDS=" */ #define NSPR_INHERIT_FDS_STRLEN 17 - /* The length of osfd (PRInt32) printed in hexadecimal with 0x prefix */ + /* The length of osfd (PROsfd) printed in hexadecimal with 0x prefix */ +#ifdef _WIN64 +#define OSFD_STRLEN 18 +#else #define OSFD_STRLEN 10 +#endif /* The length of fd type (PRDescType) printed in decimal */ #define FD_TYPE_STRLEN 1 PRSize newSize; @@ -645,10 +649,10 @@ PR_ProcessAttrSetInheritableFD( freeSize = attr->fdInheritBufferSize - attr->fdInheritBufferUsed; if (0 == attr->fdInheritBufferUsed) { nwritten = PR_snprintf(cur, freeSize, - "NSPR_INHERIT_FDS=%s:%d:0x%lx", + "NSPR_INHERIT_FDS=%s:%d:0x%" PR_PRIxOSFD, name, (PRIntn)fd->methods->file_type, fd->secret->md.osfd); } else { - nwritten = PR_snprintf(cur, freeSize, ":%s:%d:0x%lx", + nwritten = PR_snprintf(cur, freeSize, ":%s:%d:0x%" PR_PRIxOSFD, name, (PRIntn)fd->methods->file_type, fd->secret->md.osfd); } attr->fdInheritBufferUsed += nwritten; @@ -662,7 +666,7 @@ PR_IMPLEMENT(PRFileDesc *) PR_GetInheritedFD( const char *envVar; const char *ptr; int len = strlen(name); - PRInt32 osfd; + PROsfd osfd; int nColons; PRIntn fileType; @@ -676,7 +680,7 @@ PR_IMPLEMENT(PRFileDesc *) PR_GetInheritedFD( while (1) { if ((ptr[len] == ':') && (strncmp(ptr, name, len) == 0)) { ptr += len + 1; - PR_sscanf(ptr, "%d:0x%lx", &fileType, &osfd); + PR_sscanf(ptr, "%d:0x%" PR_SCNxOSFD, &fileType, &osfd); switch ((PRDescType)fileType) { case PR_DESC_FILE: fd = PR_ImportFile(osfd); diff --git a/pr/tests/prpoll.c b/pr/tests/prpoll.c index 9058981b..1dfdb074 100644 --- a/pr/tests/prpoll.c +++ b/pr/tests/prpoll.c @@ -100,8 +100,9 @@ int main(int argc, char **argv) PRPollDesc pds0[10], pds1[10], *pds, *other_pds; PRIntn npds; PRInt32 retVal; - PRInt32 sd, rv; - struct sockaddr_in saddr; + PRInt32 rv; + PROsfd sd; + struct sockaddr_in saddr; PRIntn saddr_len; PRUint16 listenPort3; PRFileDesc *socket_poll_fd; @@ -286,7 +287,7 @@ int main(int argc, char **argv) nEvents++; if (j == 2) { - int newsd; + PROsfd newsd; newsd = accept(PR_FileDesc2NativeHandle(pds[j].fd), NULL, 0); if (newsd == -1) { fprintf(stderr, "accept() failed\n"); |