summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordougt%meer.net <devnull@localhost>2005-04-20 23:26:16 +0000
committerdougt%meer.net <devnull@localhost>2005-04-20 23:26:16 +0000
commit87b7d11632a6c60f53622a03778917ff6b9d3d73 (patch)
tree2a41158ce68caa5504eb898d6b90ed998c3379c7
parent8a498d688ccdfa4df9dc0ba58805bea4bfbb0b77 (diff)
downloadnspr-hg-NSPR_PRE_4_2_WINCE_BRANCH.tar.gz
Creating branch tag and allowing WINCE code to live there.NSPR_PRE_4_2_WINCE_BRANCH
-rw-r--r--config/Makefile.in10
-rw-r--r--config/rules.mk12
-rwxr-xr-xconfigure94
-rw-r--r--configure.in38
-rw-r--r--gmakefile.win10
-rw-r--r--lib/ds/Makefile.in3
-rw-r--r--lib/tests/windows/winevent.c4
-rw-r--r--pr/include/md/prosdep.h4
-rw-r--r--pr/include/private/pprthred.h6
-rw-r--r--pr/src/io/prfile.c2
-rw-r--r--pr/src/io/prio.c12
-rw-r--r--pr/src/io/priometh.c2
-rw-r--r--pr/src/io/prlog.c3
-rw-r--r--pr/src/io/prsocket.c2
-rw-r--r--pr/src/linking/prlink.c4
-rw-r--r--pr/src/md/windows/Makefile.in22
-rw-r--r--pr/src/md/windows/ntgc.c6
-rw-r--r--pr/src/md/windows/ntmisc.c83
-rw-r--r--pr/src/md/windows/ntsec.c9
-rw-r--r--pr/src/md/windows/objs.mk20
-rw-r--r--pr/src/md/windows/w32ipcsem.c32
-rw-r--r--pr/src/md/windows/w32rng.c4
-rw-r--r--pr/src/md/windows/w32shm.c70
-rw-r--r--pr/src/md/windows/w95io.c191
-rw-r--r--pr/src/md/windows/w95thred.c63
-rw-r--r--pr/src/misc/prerror.c6
-rw-r--r--pr/src/misc/prerrortable.c4
-rw-r--r--pr/src/misc/prnetdb.c6
-rw-r--r--pr/src/threads/combined/prucv.c2
-rw-r--r--pr/src/threads/combined/prulock.c2
-rw-r--r--pr/src/threads/combined/pruthr.c2
-rw-r--r--pr/src/threads/prcthr.c2
-rw-r--r--pr/src/threads/prdump.c2
-rw-r--r--pr/src/threads/prtpd.c2
34 files changed, 656 insertions, 78 deletions
diff --git a/config/Makefile.in b/config/Makefile.in
index 7a1ccbd9..14b3f913 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -58,15 +58,18 @@ RELEASE_BINS = nspr-config
include $(topsrcdir)/config/config.mk
+ifneq ($(OS_TARGET),WINCE)
CSRCS = now.c
# This version hasn't been ported for us; the one in mozilla/config has
ifneq ($(OS_ARCH),OS2)
CSRCS += nsinstall.c
-
+
PLSRCS = nfspwd.pl
endif
+endif
+
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH)))
PROG_SUFFIX = .exe
else
@@ -116,6 +119,7 @@ endif
include $(topsrcdir)/config/rules.mk
+ifneq ($(OS_TARGET),WINCE)
PROGS = $(OBJDIR)/now$(PROG_SUFFIX)
ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
@@ -125,8 +129,10 @@ PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX)
TARGETS = $(PROGS) $(PLSRCS:.pl=)
endif
+endif
+
OUTOPTION = -o # end of the line
-ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET)))
+ifeq (,$(filter-out WINNT WIN95 WINCE,$(OS_TARGET)))
ifndef NS_USE_GCC
OUTOPTION = /Fe
endif
diff --git a/config/rules.mk b/config/rules.mk
index 492e0aeb..0e8b49f3 100644
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -133,8 +133,16 @@ endif
endif
endif
+
+ifeq ($(OS_TARGET),WINCE)
+LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
+SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
+IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
+SHARED_LIB_PDB = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
endif
+endif # LIBRARY_NAME
+
ifndef TARGETS
ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
@@ -148,6 +156,10 @@ endif
else
TARGETS = $(LIBRARY) $(SHARED_LIBRARY)
endif
+
+ifeq ($(OS_TARGET),WINCE)
+TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
+endif
endif
#
diff --git a/configure b/configure
index caccf83d..3549ca39 100755
--- a/configure
+++ b/configure
@@ -1067,7 +1067,7 @@ EOF
beos*)
DEFINES="$DEFINES -DDEBUG_${USER}"
;;
- msvc*|mks*|cygwin*|mingw*|os2*)
+ msvc*|mks*|cygwin*|mingw*|os2*|wince*)
DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
;;
*)
@@ -2852,7 +2852,7 @@ OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
case "$host" in
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-wince*)
NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
if test `echo "${PATH}" | grep -c \;` = 0; then
CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
@@ -3806,6 +3806,46 @@ EOF
esac
;;
+*-wince*)
+ cat >> confdefs.h <<\EOF
+#define XP_PC 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define WIN32 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define WINCE 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define _PR_GLOBAL_THREADS_ONLY 1
+EOF
+
+
+ AR='lib -NOLOGO -OUT:"$@"'
+ AR_FLAGS=
+
+ OBJ_SUFFIX=obj
+ LIB_SUFFIX=lib
+ DLL_SUFFIX=dll
+ MKSHLIB='$(LD) -DLL $(DSO_LDOPTS) -OUT:$@'
+
+ PR_MD_ARCH_DIR=windows
+ RESOLVE_LINK_SYMBOLS=1
+ DEFINES="$DEFINES -UWINNT"
+
+ MDCPUCFG_H=_wince.cfg
+ LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
+ LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
+
+ DLLFLAGS='-OUT:"$@"'
+ _DEBUG_FLAGS=-Z7
+
+;;
+
+
*-mingw*|*-cygwin*|*-msvc*|*-mks*)
cat >> confdefs.h <<\EOF
#define XP_PC 1
@@ -4277,17 +4317,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:4281: checking for machine/builtins.h" >&5
+echo "configure:4321: 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 4286 "configure"
+#line 4326 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4291: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4331: \"$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*
@@ -4829,7 +4869,7 @@ case $target in
;;
*)
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4833: checking for dlopen in -ldl" >&5
+echo "configure:4873: 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
@@ -4837,7 +4877,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4841 "configure"
+#line 4881 "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
@@ -4848,7 +4888,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:4852: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4892: \"$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
@@ -4865,17 +4905,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:4869: checking for dlfcn.h" >&5
+echo "configure:4909: 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 4874 "configure"
+#line 4914 "configure"
#include "confdefs.h"
#include <dlfcn.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4879: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4919: \"$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,13 +4948,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:4912: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:4952: 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 4918 "configure"
+#line 4958 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -4932,7 +4972,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 4936 "configure"
+#line 4976 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -4956,12 +4996,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4960: checking for $ac_func" >&5
+echo "configure:5000: 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 4965 "configure"
+#line 5005 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -4984,7 +5024,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:4988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5028: \"$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
@@ -5025,7 +5065,7 @@ hpux*)
if test -z "$GNU_CC"; then
echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5029: checking for +Olit support" >&5
+echo "configure:5069: 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
@@ -5059,7 +5099,7 @@ esac
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5063: checking for pthread_create in -lpthreads" >&5
+echo "configure:5103: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5081,7 +5121,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5085: checking for pthread_create in -lpthread" >&5
+echo "configure:5125: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5103,7 +5143,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5107: checking for pthread_create in -lc_r" >&5
+echo "configure:5147: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5125,7 +5165,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5129: checking for pthread_create in -lc" >&5
+echo "configure:5169: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5277,7 +5317,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:5281: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5321: 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
@@ -5300,7 +5340,7 @@ echo "configure:5281: 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:5304: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5344: 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
@@ -5499,7 +5539,7 @@ EOF
fi
;;
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-wince*)
USE_PTHREADS=
_PTHREAD_LDFLAGS=
USE_USER_PTHREADS=
@@ -5610,7 +5650,7 @@ fi
RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}.${OBJDIR_SUFFIX}"
case "$target_os" in
-mingw*|cygwin*|msvc*|mks*)
+mingw*|cygwin*|msvc*|mks*|wince*)
CC="\$(CYGWIN_WRAPPER) $CC"
CXX="\$(CYGWIN_WRAPPER) $CXX"
RC="\$(CYGWIN_WRAPPER) $RC"
@@ -5832,7 +5872,7 @@ s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
diff --git a/configure.in b/configure.in
index d91fc4a6..f1fb0020 100644
--- a/configure.in
+++ b/configure.in
@@ -14,7 +14,7 @@ dnl The Original Code is the Netscape Portable Runtime (NSPR).
dnl
dnl The Initial Developer of the Original Code is Netscape
dnl Communications Corporation. Portions created by Netscape are
-dnl Copyright (C) 1998o-2000 Netscape Communications Corporation. All
+dnl Copyright (C) 1998-2000 Netscape Communications Corporation. All
dnl Rights Reserved.
dnl
dnl Contributor(s):
@@ -346,7 +346,7 @@ if test -n "$MOZ_DEBUG"; then
beos*)
DEFINES="$DEFINES -DDEBUG_${USER}"
;;
- msvc*|mks*|cygwin*|mingw*|os2*)
+ msvc*|mks*|cygwin*|mingw*|os2*|wince*)
DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`"
;;
*)
@@ -720,7 +720,7 @@ dnl ========================================================
dnl Override of system specific host options
dnl ========================================================
case "$host" in
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-wince*)
NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
if test `echo "${PATH}" | grep -c \;` = 0; then
CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
@@ -1280,6 +1280,34 @@ case "$target" in
esac
;;
+*-wince*)
+ AC_DEFINE(XP_PC)
+ AC_DEFINE(WIN32)
+ AC_DEFINE(WINCE)
+ AC_DEFINE(_PR_GLOBAL_THREADS_ONLY)
+
+ AR='lib -NOLOGO -OUT:"$@"'
+ AR_FLAGS=
+
+ OBJ_SUFFIX=obj
+ LIB_SUFFIX=lib
+ DLL_SUFFIX=dll
+ MKSHLIB='$(LD) -DLL $(DSO_LDOPTS) -OUT:$@'
+
+ PR_MD_ARCH_DIR=windows
+ RESOLVE_LINK_SYMBOLS=1
+ DEFINES="$DEFINES -UWINNT"
+
+ MDCPUCFG_H=_wince.cfg
+ LIBNSPR='$(dist_libdir)/nspr$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
+ LIBPLC='$(dist_libdir)/plc$(MOD_MAJOR_VERSION).$(LIB_SUFFIX)'
+
+ DLLFLAGS='-OUT:"$@"'
+ _DEBUG_FLAGS=-Z7
+
+;;
+
+
*-mingw*|*-cygwin*|*-msvc*|*-mks*)
AC_DEFINE(XP_PC)
AC_DEFINE(WIN32)
@@ -2367,7 +2395,7 @@ case "$target" in
AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
fi
;;
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-wince*)
dnl win32 does not use pthreads
USE_PTHREADS=
_PTHREAD_LDFLAGS=
@@ -2457,7 +2485,7 @@ dnl ========================================================
dnl Use cygwin wrapper for win32 builds
dnl ========================================================
case "$target_os" in
-mingw*|cygwin*|msvc*|mks*)
+mingw*|cygwin*|msvc*|mks*|wince*)
CC="\$(CYGWIN_WRAPPER) $CC"
CXX="\$(CYGWIN_WRAPPER) $CXX"
RC="\$(CYGWIN_WRAPPER) $RC"
diff --git a/gmakefile.win b/gmakefile.win
index 80e8809a..c57e9d57 100644
--- a/gmakefile.win
+++ b/gmakefile.win
@@ -48,11 +48,19 @@ endif
MOZ_DIST_FLIPPED = $(MOZ_SRC_FLIPPED)/mozilla/dist
+ifeq ($(OS_TARGET),WINCE)
+ifdef MOZ_DEBUG
+MOZ_OBJDIR = $(OSVERSION)$(TARGETCPU)_D.OBJ
+else
+MOZ_OBJDIR = $(OSVERSION)$(TARGETCPU)_O.OBJ
+endif
+else
ifdef MOZ_DEBUG
MOZ_OBJDIR = WIN32_D.OBJ
else
MOZ_OBJDIR = WIN32_O.OBJ
endif
+endif
NSPR_CONFIGURE := ../configure \
--with-mozilla \
@@ -87,7 +95,7 @@ clobber_all: $(MOZ_OBJDIR)/config.status check_old
gmake -C $(MOZ_OBJDIR) clobber_all
distclean: check_old
- rm -rf WIN32_D.OBJ WIN32_O.OBJ
+ rm -rf WIN32_D.OBJ WIN32_O.OBJ WINCE_D.OBJ WINCE_O.OBJ
check_old:
@if test -f Makefile; then gmake distclean; fi
diff --git a/lib/ds/Makefile.in b/lib/ds/Makefile.in
index 516e1a37..25fb1763 100644
--- a/lib/ds/Makefile.in
+++ b/lib/ds/Makefile.in
@@ -70,6 +70,9 @@ DLLBASE=/BASE:0x30000000
endif # GCC
RES=$(OBJDIR)/plds.res
RESNAME=plds.rc
+ifneq ($(OS_TARGET), WINCE)
+OS_LIBS = user32.lib
+endif
endif # WINNT
ifeq ($(OS_ARCH), AIX)
diff --git a/lib/tests/windows/winevent.c b/lib/tests/windows/winevent.c
index d571aed7..f9bc462f 100644
--- a/lib/tests/windows/winevent.c
+++ b/lib/tests/windows/winevent.c
@@ -123,7 +123,11 @@ int WINAPI WinMain(
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
+#if !defined(WINCE)
wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION );
+#else
+ wndclass.hIcon = NULL;
+#endif
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
wndclass.lpszMenuName = NULL;
diff --git a/pr/include/md/prosdep.h b/pr/include/md/prosdep.h
index 93496520..24edb164 100644
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -37,7 +37,6 @@
#ifndef prosdep_h___
#define prosdep_h___
-
/*
** Get OS specific header information
*/
@@ -54,6 +53,9 @@ PR_BEGIN_EXTERN_C
#elif defined(WIN95)
#include "md/_win95.h"
#include "md/_win32_errors.h"
+#elif defined(WINCE)
+#include "md/_wince.h"
+#include "md/_win32_errors.h"
#elif defined(WIN16)
#include "md/_win16.h"
#elif defined(OS2)
diff --git a/pr/include/private/pprthred.h b/pr/include/private/pprthred.h
index c9413396..e6f48dcd 100644
--- a/pr/include/private/pprthred.h
+++ b/pr/include/private/pprthred.h
@@ -135,6 +135,12 @@ NSPR_API(void) PR_ShowStatus(void);
*/
NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
+/*
+** Return the address of thread's last os error variable.
+** Used to implement errno on platforms that lack it.
+*/
+NSPR_API(PRInt32 *) PR_GetOSErrorAddress(void);
+
/*---------------------------------------------------------------------------
** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS
diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c
index d91bffa2..a6633934 100644
--- a/pr/src/io/prfile.c
+++ b/pr/src/io/prfile.c
@@ -720,7 +720,7 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe(
#pragma unused (readPipe, writePipe)
#endif
-#ifdef WIN32
+#if defined(WIN32) && !defined(WINCE)
HANDLE readEnd, writeEnd;
SECURITY_ATTRIBUTES pipeAttributes;
diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c
index 908bfd61..8468c76f 100644
--- a/pr/src/io/prio.c
+++ b/pr/src/io/prio.c
@@ -55,6 +55,7 @@ void _PR_InitIO(void)
_pr_flock_cv = PR_NewCondVar(_pr_flock_lock);
#ifdef WIN32
+#if !defined(WINCE)
_pr_stdin = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_INPUT_HANDLE),
methods);
_pr_stdout = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_OUTPUT_HANDLE),
@@ -67,6 +68,17 @@ void _PR_InitIO(void)
_pr_stderr->secret->md.sync_file_io = PR_TRUE;
#endif
#else
+ /*
+ * WINCE has some oddity of _getstdfilex to determine stdin, et. al.
+ * As unsure what that code actually does, just get fileno here.
+ *
+ * How odd, _fileno returns a void*, so cast it...
+ */
+ _pr_stdin = PR_AllocFileDesc((PRInt32)_fileno(stdin), methods);
+ _pr_stdout = PR_AllocFileDesc((PRInt32)_fileno(stdout), methods);
+ _pr_stderr = PR_AllocFileDesc((PRInt32)_fileno(stderr), methods);
+#endif
+#else
_pr_stdin = PR_AllocFileDesc(0, methods);
_pr_stdout = PR_AllocFileDesc(1, methods);
_pr_stderr = PR_AllocFileDesc(2, methods);
diff --git a/pr/src/io/priometh.c b/pr/src/io/priometh.c
index 1ca474f0..b1606fce 100644
--- a/pr/src/io/priometh.c
+++ b/pr/src/io/priometh.c
@@ -365,7 +365,7 @@ PR_IMPLEMENT(PRInt32) PR_EmulateSendFile(
goto done;
}
if (sfd->file_nbytes &&
- (info.size < (sfd->file_offset + sfd->file_nbytes))) {
+ ((PRUint32)info.size < (sfd->file_offset + sfd->file_nbytes))) {
/*
* there are fewer bytes in file to send than specified
*/
diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c
index ab348d4f..4b46fed7 100644
--- a/pr/src/io/prlog.c
+++ b/pr/src/io/prlog.c
@@ -385,9 +385,10 @@ PR_IMPLEMENT(PRBool) PR_SetLogFile(const char *file)
newLogFile = fopen(file, "w");
if (!newLogFile)
return PR_FALSE;
-
+#ifndef WINCE
/* We do buffering ourselves. */
setvbuf(newLogFile, NULL, _IONBF, 0);
+#endif
}
if (logFile
&& logFile != stdout
diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c
index 8be198fa..1c308da0 100644
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -67,7 +67,7 @@ static PRBool IsValidNetAddrLen(const PRNetAddr *addr, PRInt32 addr_len)
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
&& (addr->raw.family != AF_UNIX)
#endif
- && (PR_NETADDR_SIZE(addr) != addr_len)) {
+ && (PR_NETADDR_SIZE(addr) != (PRUintn)addr_len)) {
#if defined(LINUX) && __GLIBC__ == 2 && __GLIBC_MINOR__ == 1
/*
* In glibc 2.1, struct sockaddr_in6 is 24 bytes. In glibc 2.2
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index 325decb5..f32d887d 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -953,7 +953,11 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags)
HINSTANCE h;
h = LoadLibrary(name);
+#ifndef WINCE
if (h < (HINSTANCE)HINSTANCE_ERROR) {
+#else
+ if (h < (HINSTANCE)0) {
+#endif
oserr = _MD_ERRNO();
PR_DELETE(lm);
goto unlock;
diff --git a/pr/src/md/windows/Makefile.in b/pr/src/md/windows/Makefile.in
index c97c9821..230d1ca1 100644
--- a/pr/src/md/windows/Makefile.in
+++ b/pr/src/md/windows/Makefile.in
@@ -62,6 +62,27 @@ CSRCS = \
ntinrval.c \
$(NULL)
else
+ifeq ($(OS_TARGET), WINCE)
+CSRCS = \
+ ntmisc.c \
+ ntsec.c \
+ ntsem.c \
+ ntinrval.c \
+ ntgc.c \
+ w95thred.c \
+ w95io.c \
+ w95cv.c \
+ w32rng.c \
+ w95sock.c \
+ win32_errors.c \
+ w32ipcsem.c \
+ w32poll.c \
+ w32shm.c \
+ w95dllmain.c \
+ w32unicode.c \
+ w32netdb.c \
+ $(NULL)
+else
ifeq ($(OS_TARGET), WIN95)
CSRCS = \
ntmisc.c \
@@ -98,6 +119,7 @@ CSRCS = \
$(NULL)
endif
endif
+endif
TARGETS = $(OBJS)
diff --git a/pr/src/md/windows/ntgc.c b/pr/src/md/windows/ntgc.c
index 12af4846..afdd5cc8 100644
--- a/pr/src/md/windows/ntgc.c
+++ b/pr/src/md/windows/ntgc.c
@@ -72,7 +72,7 @@ PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */
-#if !defined WIN95 // Win95 does not have fibers
+#if !defined(WIN95) && !defined(WINCE) /* Win95/WinCE does not have fibers */
int *fiberData = t->md.fiber_id;
/* I found these offsets by disassembling SwitchToFiber().
@@ -97,6 +97,8 @@ PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
}
return (PRWord *)&t->md.gcContext;
#elif defined(_ALPHA_)
+#elif defined(_ARM_)
+ return NULL;
#endif /* defined(_X86_) */
}
@@ -122,5 +124,7 @@ GetMyFiberID()
return fiberData;
#elif defined(_ALPHA_)
+#elif defined(_ARM_)
+ return NULL;
#endif /* defined(_X86_) */
}
diff --git a/pr/src/md/windows/ntmisc.c b/pr/src/md/windows/ntmisc.c
index 849bbbe0..30949fa7 100644
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -87,12 +87,24 @@ PRIntn _PR_MD_PUT_ENV(const char *name)
PR_IMPLEMENT(PRTime)
PR_Now(void)
{
- PRTime prt;
- FILETIME ft;
-
- GetSystemTimeAsFileTime(&ft);
- _PR_FileTimeToPRTime(&ft, &prt);
- return prt;
+ PRInt64 s;
+#if !defined(WINCE)
+ PRInt64 ms, ms2us, s2us;
+ struct timeb b;
+ ftime(&b);
+ LL_I2L(ms2us, PR_USEC_PER_MSEC);
+ LL_I2L(s2us, PR_USEC_PER_SEC);
+ LL_I2L(s, b.time);
+ LL_I2L(ms, b.millitm);
+ LL_MUL(ms, ms, ms2us);
+ LL_MUL(s, s, s2us);
+ LL_ADD(s, s, ms);
+#else
+ SYSTEMTIME sysTime;
+ GetSystemTime(&sysTime);
+ _MD_SYSTEMTIME_2_PRTime(s, sysTime);
+#endif
+ return s;
}
/*
@@ -118,6 +130,7 @@ PR_Now(void)
void
_PR_Win32InitTimeZone(void)
{
+#if !defined(WINCE)
OSVERSIONINFO version;
TIME_ZONE_INFORMATION tzinfo;
@@ -158,6 +171,7 @@ _PR_Win32InitTimeZone(void)
_timezone = tzinfo.Bias * 60;
_daylight = tzinfo.DaylightBias ? 1 : 0;
return;
+#endif
}
/*
@@ -366,6 +380,7 @@ PRProcess * _PR_CreateWindowsProcess(
char *const *envp,
const PRProcessAttr *attr)
{
+#if !defined(WINCE)
STARTUPINFO startupInfo;
PROCESS_INFORMATION procInfo;
BOOL retVal;
@@ -506,6 +521,57 @@ errorExit:
PR_DELETE(proc);
}
return NULL;
+#else
+ PROCESS_INFORMATION procInfo;
+ BOOL retVal;
+ char *cmdLine = NULL;
+ PRProcess *proc = NULL;
+
+ proc = PR_NEW(PRProcess);
+ if (!proc) {
+ PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
+ goto errorExit;
+ }
+
+ if (assembleCmdLine(argv, &cmdLine) == -1) {
+ PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
+ goto errorExit;
+ }
+
+ retVal =
+ CreateProcess(path,
+ cmdLine,
+ NULL, /* not supported */
+ NULL, /* not supported */
+ FALSE, /* not supported */
+ 0, /* creation flags */
+ NULL, /* not supported */
+ NULL, /* not supported */
+ NULL, /* not supported */
+ &procInfo
+ );
+ if (retVal == FALSE) {
+ /* XXX what error code? */
+ PR_SetError(PR_UNKNOWN_ERROR, GetLastError());
+ goto errorExit;
+ }
+
+ CloseHandle(procInfo.hThread);
+ proc->md.handle = procInfo.hProcess;
+ proc->md.id = procInfo.dwProcessId;
+
+ PR_DELETE(cmdLine);
+ return proc;
+
+errorExit:
+ if (cmdLine) {
+ PR_DELETE(cmdLine);
+ }
+ if (proc) {
+ PR_DELETE(proc);
+ }
+ return NULL;
+#endif
} /* _PR_CreateWindowsProcess */
PRStatus _PR_DetachWindowsProcess(PRProcess *process)
@@ -665,8 +731,13 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size)
fmap->md.dwAccess = FILE_MAP_WRITE;
} else {
PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);
+#if !defined(WINCE)
flProtect = PAGE_WRITECOPY;
fmap->md.dwAccess = FILE_MAP_COPY;
+#else
+ PR_SetError(PR_OPERATION_NOT_SUPPORTED_ERROR, GetLastError());
+ return PR_FAILURE;
+#endif
}
fmap->md.hFileMap = CreateFileMapping(
diff --git a/pr/src/md/windows/ntsec.c b/pr/src/md/windows/ntsec.c
index 89ac1dfb..d78c13b7 100644
--- a/pr/src/md/windows/ntsec.c
+++ b/pr/src/md/windows/ntsec.c
@@ -69,6 +69,7 @@ static struct {
*/
void _PR_NT_InitSids(void)
{
+#if !defined(WINCE)
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
HANDLE hToken = NULL; /* initialized to an arbitrary value to
* silence a Purify UMR warning */
@@ -128,6 +129,7 @@ void _PR_NT_InitSids(void)
0, 0, 0, 0, 0, 0, 0,
&_pr_nt_sids.everyone);
PR_ASSERT(rv != 0);
+#endif /* !WINCE */
}
/*
@@ -145,9 +147,11 @@ _PR_NT_FreeSids(void)
if (_pr_nt_sids.group) {
PR_Free(_pr_nt_sids.group);
}
+#if !defined(WINCE)
if (_pr_nt_sids.everyone) {
FreeSid(_pr_nt_sids.everyone);
}
+#endif
}
/*
@@ -168,6 +172,7 @@ _PR_NT_MakeSecurityDescriptorACL(
PSECURITY_DESCRIPTOR *resultSD,
PACL *resultACL)
{
+#if !defined(WINCE)
PSECURITY_DESCRIPTOR pSD = NULL;
PACL pACL = NULL;
DWORD cbACL; /* size of ACL */
@@ -261,6 +266,10 @@ failed:
PR_Free(pACL);
}
return PR_FAILURE;
+#else
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return PR_FAILURE;
+#endif /* !WINCE */
}
/*
diff --git a/pr/src/md/windows/objs.mk b/pr/src/md/windows/objs.mk
index 36f21a44..2586ab57 100644
--- a/pr/src/md/windows/objs.mk
+++ b/pr/src/md/windows/objs.mk
@@ -51,6 +51,25 @@ CSRCS = ntmisc.c \
w32rng.c \
w32shm.c
else
+ifeq ($(OS_TARGET),WINCE)
+CSRCS = ntmisc.c \
+ ntsec.c \
+ ntsem.c \
+ ntinrval.c \
+ ntgc.c \
+ w95thred.c \
+ w95io.c \
+ w95cv.c \
+ w95sock.c \
+ win32_errors.c \
+ w32ipcsem.c \
+ w32poll.c \
+ w32rng.c \
+ w32shm.c \
+ w95dllmain.c \
+ w32unicode.c \
+ w32netdb.c
+else
ifeq ($(OS_TARGET),WIN95)
CSRCS = ntmisc.c \
ntsec.c \
@@ -83,6 +102,7 @@ CSRCS = w16null.c \
ntinrval.c
endif # win16
endif # win95
+endif # wince
endif # winnt
CSRCS += $(PR_MD_CSRCS)
diff --git a/pr/src/md/windows/w32ipcsem.c b/pr/src/md/windows/w32ipcsem.c
index 82201a80..0f240ae9 100644
--- a/pr/src/md/windows/w32ipcsem.c
+++ b/pr/src/md/windows/w32ipcsem.c
@@ -148,6 +148,7 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
lpSA = &sa;
}
sem->sem = CreateSemaphore(lpSA, value, 0x7fffffff, osname);
+
if (lpSA != NULL) {
_PR_NT_FreeSecurityDescriptorACL(pSD, pACL);
}
@@ -163,6 +164,7 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
return NULL;
}
} else {
+#if !defined(WINCE)
sem->sem = OpenSemaphore(
SEMAPHORE_MODIFY_STATE|SYNCHRONIZE, FALSE, osname);
if (sem->sem == NULL) {
@@ -181,6 +183,36 @@ PRSem *_PR_MD_OPEN_SEMAPHORE(
PR_DELETE(sem);
return NULL;
}
+#else
+ /*
+ * WinCE has odd sematics regarding opening a semaphore.
+ * We create the semaphore. If it existed previouisly, the
+ * state is signaled by GetLastError....
+ */
+ sem->sem = CreateSemaphoreA(lpSA, 0, 0x7fffffff, osname);
+ if(NULL != sem->sem)
+ {
+ DWORD lastErr = GetLastError();
+
+ if(ERROR_ALREADY_EXISTS != lastErr)
+ {
+ /*
+ * We created, not opened.
+ * Fail....
+ */
+ CloseHandle(sem->sem);
+ PR_DELETE(sem);
+ PR_SetError(PR_FILE_NOT_FOUND_ERROR, 0);
+ return NULL;
+ }
+ }
+ else
+ {
+ _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
+ PR_DELETE(sem);
+ return NULL;
+ }
+#endif
}
return sem;
}
diff --git a/pr/src/md/windows/w32rng.c b/pr/src/md/windows/w32rng.c
index 2ad6ed86..3e92ea1b 100644
--- a/pr/src/md/windows/w32rng.c
+++ b/pr/src/md/windows/w32rng.c
@@ -97,7 +97,11 @@ extern PRSize _PR_MD_GetRandomNoise( void *buf, PRSize size )
return n;
// get the time in seconds since midnight Jan 1, 1970
+#if !defined(WINCE)
time(&sTime);
+#else
+ sTime = (time_t)(PR_Now() / PR_MSEC_PER_SEC);
+#endif
nBytes = sizeof(sTime) > size ? size : sizeof(sTime);
memcpy(((char *)buf) + n, &sTime, nBytes);
n += nBytes;
diff --git a/pr/src/md/windows/w32shm.c b/pr/src/md/windows/w32shm.c
index 705f62f1..21eff71a 100644
--- a/pr/src/md/windows/w32shm.c
+++ b/pr/src/md/windows/w32shm.c
@@ -120,7 +120,9 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
sa.bInheritHandle = FALSE;
lpSA = &sa;
}
- shm->handle = CreateFileMapping(
+ shm->handle =
+ CreateFileMapping
+ (
(HANDLE)-1 ,
lpSA,
flProtect,
@@ -157,6 +159,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
}
}
} else {
+#if !defined(WINCE)
shm->handle = OpenFileMapping( FILE_MAP_WRITE, TRUE, shm->ipcname );
if ( NULL == shm->handle ) {
_PR_MD_MAP_DEFAULT_ERROR( GetLastError());
@@ -172,6 +175,62 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
shm->ipcname, shm->handle ));
return(shm);
}
+#else
+ dwHi = 0;
+ dwLo = shm->size;
+
+ /*
+ * WinCE has odd sematics regarding opening of an existing file
+ * mapping. We use CreateFileMapping and must use GetLastError
+ * to determine if the the mapping already existed.
+ */
+ shm->handle = CreateFileMappingA(
+ (HANDLE)INVALID_HANDLE_VALUE,
+ NULL,
+ flProtect,
+ dwHi,
+ dwLo,
+ shm->ipcname);
+
+ if(NULL == shm->handle)
+ {
+ PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,
+ ( "PR_OpenSharedMemory: CreateFileMapping() failed: %s",
+ shm->ipcname ));
+ _PR_MD_MAP_DEFAULT_ERROR(GetLastError());
+ PR_FREEIF(shm->ipcname);
+ PR_DELETE(shm);
+ return NULL;
+ }
+ else
+ {
+ DWORD dwError = GetLastError();
+
+ /*
+ * Must have existed previously.
+ */
+ if(ERROR_ALREADY_EXISTS != dwError)
+ {
+ CloseHandle(shm->handle);
+ shm->handle = NULL;
+
+ PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,
+ ( "PR_OpenSharedMemory: CreateFileMapping() failed: %s",
+ shm->ipcname ));
+ _PR_MD_MAP_DEFAULT_ERROR(dwError);
+ PR_FREEIF(shm->ipcname);
+ PR_DELETE(shm);
+ return NULL;
+ }
+ else
+ {
+ PR_LOG(_pr_shm_lm, PR_LOG_DEBUG,
+ ( "PR_OpenSharedMemory: CreateFileMapping() success: %s, handle: %d",
+ shm->ipcname, shm->handle ));
+ return shm;
+ }
+ }
+#endif
}
/* returns from separate paths */
}
@@ -259,6 +318,7 @@ extern PRFileMap* _md_OpenAnonFileMap(
PRFileMapProtect prot
)
{
+#if !defined(WINCE)
PRFileMap *fm;
HANDLE hFileMap;
@@ -291,6 +351,14 @@ extern PRFileMap* _md_OpenAnonFileMap(
Finished:
return(fm);
+#else
+ /*
+ ** WinCE does not have inheritable handles.
+ ** Unsure if this should fail, but here it is....
+ */
+ PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return NULL;
+#endif
} /* end md_OpenAnonFileMap() */
/*
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index 5d483cea..0c8886c7 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -218,13 +218,14 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode)
flags = OPEN_EXISTING;
}
- file = CreateFile(name,
- access,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- flags,
- flag6,
- NULL);
+ 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;
@@ -460,7 +461,18 @@ _MD_CloseFile(PRInt32 osfd)
/* --- DIR IO ------------------------------------------------------------ */
+#if !defined(WINCE)
#define GetFileFromDIR(d) (d)->d_entry.cFileName
+#else
+char* GetFileFromDIR(_MDDir* d)
+{
+ char* retval = NULL;
+
+ retval = _PR_MD_W2A(d->d_entry.cFileName, d->cFileNameA, sizeof(d->cFileNameA));
+
+ return retval;
+}
+#endif
#define FileIsHidden(d) ((d)->d_entry.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
void FlipSlashes(char *cp, int len)
@@ -485,6 +497,16 @@ PRStatus
_PR_MD_CLOSE_DIR(_MDDir *d)
{
if ( d ) {
+#if defined(WINCE)
+ /*
+ ** Handle case where we faked no more files.
+ ** FindFirstFile likes to return ERROR_NO_MORE_FILES itself.
+ */
+ if (NULL == d->d_hdl) {
+ d->magic = (PRUint32)-1;
+ return PR_SUCCESS;
+ } else
+#endif /* WINCE */
if (FindClose(d->d_hdl)) {
d->magic = (PRUint32)-1;
return PR_SUCCESS;
@@ -522,12 +544,49 @@ _PR_MD_OPEN_DIR(_MDDir *d, const char *name)
strcpy(&filename[len], "\\*.*");
FlipSlashes( filename, strlen(filename) );
+#if !defined(WINCE)
d->d_hdl = FindFirstFile( filename, &(d->d_entry) );
+#else
+ {
+ WCHAR ceFileName[MAX_PATH];
+ LPWSTR ceResult = _PR_MD_A2W(filename, ceFileName, MAX_PATH);
+
+ if(NULL != ceResult)
+ {
+ d->d_hdl = FindFirstFile( ceFileName, &(d->d_entry) );
+
+ /*
+ ** WINCE likes to report no files on the first call....
+ */
+ if(INVALID_HANDLE_VALUE == d->d_hdl && ERROR_NO_MORE_FILES == GetLastError())
+ {
+ d->d_hdl = NULL;
+ SetLastError(NO_ERROR);
+ }
+ }
+ else
+ {
+ d->d_hdl = INVALID_HANDLE_VALUE;
+ }
+ }
+#endif
if ( d->d_hdl == INVALID_HANDLE_VALUE ) {
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return PR_FAILURE;
}
+#if !defined(WINCE)
d->firstEntry = PR_TRUE;
+#else /* WINCE */
+ /*
+ ** If we are having to fake ERROR_NO_MORE_FILES on wince, make sure we
+ ** have _PR_MD_READ_DIR act correctly.
+ */
+ if (NULL != d->d_hdl) {
+ d->firstEntry = PR_TRUE;
+ } else {
+ d->firstEntry = PR_FALSE;
+ }
+#endif /* WINCE */
d->magic = _MD_MAGIC_DIR;
return PR_SUCCESS;
}
@@ -545,11 +604,28 @@ _PR_MD_READ_DIR(_MDDir *d, PRIntn flags)
d->firstEntry = PR_FALSE;
rv = 1;
} else {
+#if !defined(WINCE)
rv = FindNextFile(d->d_hdl, &(d->d_entry));
+#else /* WINCE */
+ if (NULL != d->d_hdl) {
+ rv = FindNextFile(d->d_hdl, &(d->d_entry));
+ } else {
+ /*
+ ** Fake the no more files we'd normally expect.
+ ** All of this magic started by setting d_hdl to NULL
+ ** in _PR_MD_OPEN_DIR because FindFirstFile likes to
+ ** return ERROR_NO_MORE_FILES itself.
+ */
+ rv = 0;
+ SetLastError(ERROR_NO_MORE_FILES);
+ }
+#endif /* WINCE */
}
if (rv == 0) {
break;
}
+ if ( (flags & PR_SKIP_HIDDEN) && FileIsHidden(d))
+ continue;
fileName = GetFileFromDIR(d);
if ( (flags & PR_SKIP_DOT) &&
(fileName[0] == '.') && (fileName[1] == '\0'))
@@ -558,8 +634,6 @@ _PR_MD_READ_DIR(_MDDir *d, PRIntn flags)
(fileName[0] == '.') && (fileName[1] == '.') &&
(fileName[2] == '\0'))
continue;
- if ( (flags & PR_SKIP_HIDDEN) && FileIsHidden(d))
- continue;
return fileName;
}
err = GetLastError();
@@ -666,6 +740,7 @@ _PR_MD_STAT(const char *fn, struct stat *info)
if (-1 == rv) {
_PR_MD_MAP_STAT_ERROR(errno);
}
+
return rv;
}
@@ -700,11 +775,13 @@ IsRootDirectory(char *fn, size_t buflen)
return PR_TRUE;
}
+#if !defined(WINCE)
if (isalpha(fn[0]) && fn[1] == ':' && _PR_IS_SLASH(fn[2])
&& fn[3] == '\0') {
rv = GetDriveType(fn) > 1 ? PR_TRUE : PR_FALSE;
return rv;
}
+#endif
/* The UNC root directory */
@@ -736,6 +813,7 @@ IsRootDirectory(char *fn, size_t buflen)
if (_PR_IS_SLASH(*p) && p[1] != '\0') {
return PR_FALSE;
}
+#if !defined(WINCE)
if (*p == '\0') {
/*
* GetDriveType() doesn't work correctly if the
@@ -755,6 +833,12 @@ IsRootDirectory(char *fn, size_t buflen)
if (slashAdded) {
*--p = '\0';
}
+#else
+ /*
+ * Assume the path as root.
+ */
+ rv = PR_TRUE;
+#endif
}
return rv;
}
@@ -780,10 +864,28 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
return -1;
}
+#if !defined(WINCE)
hFindFile = FindFirstFile(fn, &findFileData);
+#else
+ {
+ WCHAR ceFileName[MAX_PATH + 1];
+ LPWSTR ceResult = _PR_MD_A2W(fn, ceFileName, sizeof(ceFileName) / sizeof(WCHAR));
+
+ if(NULL != ceResult)
+ {
+ hFindFile = FindFirstFile(ceFileName, &findFileData);
+ }
+ else
+ {
+ hFindFile = INVALID_HANDLE_VALUE;
+ }
+ }
+#endif
if (INVALID_HANDLE_VALUE == hFindFile) {
DWORD len;
+#if !defined(WINCE)
char *filePart;
+#endif
/*
* FindFirstFile() does not work correctly on root directories.
@@ -801,8 +903,13 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return -1;
}
+#if !defined(WINCE)
len = GetFullPathName(fn, sizeof(pathbuf), pathbuf,
&filePart);
+#else
+ strncpy(pathbuf, fn, sizeof(pathbuf));
+ len = strlen(pathbuf);
+#endif
if (0 == len) {
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return -1;
@@ -826,7 +933,23 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
return -1;
} else {
pathbuf[len - 1] = '\0';
+#if !defined(WINCE)
hFindFile = FindFirstFile(pathbuf, &findFileData);
+#else
+ {
+ WCHAR ceFileName[MAX_PATH + 1];
+ LPWSTR ceResult = _PR_MD_A2W(pathbuf, ceFileName, sizeof(ceFileName) / sizeof(WCHAR));
+
+ if(NULL != ceResult)
+ {
+ hFindFile = FindFirstFile(ceFileName, &findFileData);
+ }
+ else
+ {
+ hFindFile = INVALID_HANDLE_VALUE;
+ }
+ }
+#endif
if (INVALID_HANDLE_VALUE == hFindFile) {
_PR_MD_MAP_OPENDIR_ERROR(GetLastError());
return -1;
@@ -918,6 +1041,7 @@ _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info)
PRStatus
_PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
{
+#if !defined(WINCE)
BOOL rv;
/*
@@ -933,6 +1057,10 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
return PR_FAILURE;
}
return PR_SUCCESS;
+#else
+ _PR_MD_MAP_DEFAULT_ERROR(ERROR_CALL_NOT_IMPLEMENTED);
+ return PR_FAILURE;
+#endif
}
void
@@ -948,6 +1076,7 @@ _PR_MD_INIT_FD_INHERITABLE(PRFileDesc *fd, PRBool imported)
void
_PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd)
{
+#if !defined(WINCE)
DWORD flags;
PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);
@@ -958,6 +1087,9 @@ _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd)
fd->secret->inheritable = _PR_TRI_FALSE;
}
}
+#else
+ fd->secret->inheritable = _PR_TRI_FALSE;
+#endif
}
PRInt32
@@ -975,7 +1107,9 @@ _PR_MD_RENAME(const char *from, const char *to)
PRInt32
_PR_MD_ACCESS(const char *name, PRAccessHow how)
{
-PRInt32 rv;
+ PRInt32 rv = -1;
+
+#if !defined(WINCE)
switch (how) {
case PR_ACCESS_WRITE_OK:
rv = _access(name, 02);
@@ -992,6 +1126,33 @@ PRInt32 rv;
}
if (rv < 0)
_PR_MD_MAP_ACCESS_ERROR(errno);
+#else
+ DWORD attribs = 0;
+
+ attribs = GetFileAttributes(name);
+ if((DWORD)-1 != attribs)
+ {
+ switch(how)
+ {
+ case PR_ACCESS_WRITE_OK:
+ if(FILE_ATTRIBUTE_READONLY & attribs)
+ {
+ rv = 0;
+ }
+ break;
+ case PR_ACCESS_READ_OK:
+ rv = 0;
+ break;
+ case PR_ACCESS_EXISTS:
+ rv = 0;
+ break;
+ default:
+ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
+ break;
+ }
+ }
+#endif
+
return rv;
}
@@ -1049,6 +1210,7 @@ _PR_MD_RMDIR(const char *name)
PRStatus
_PR_MD_LOCKFILE(PRInt32 f)
{
+#if !defined(WINCE)
PRStatus rc = PR_SUCCESS;
DWORD rv;
@@ -1063,6 +1225,10 @@ _PR_MD_LOCKFILE(PRInt32 f)
}
return rc;
+#else
+ PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
+ return PR_FAILURE;
+#endif
} /* end _PR_MD_LOCKFILE() */
PRStatus
@@ -1076,6 +1242,7 @@ _PR_MD_TLOCKFILE(PRInt32 f)
PRStatus
_PR_MD_UNLOCKFILE(PRInt32 f)
{
+#if !defined(WINCE)
PRInt32 rv;
rv = UnlockFile( (HANDLE) f,
@@ -1091,6 +1258,10 @@ _PR_MD_UNLOCKFILE(PRInt32 f)
_PR_MD_MAP_DEFAULT_ERROR(GetLastError());
return PR_FAILURE;
}
+#else
+ PR_SetError( PR_NOT_IMPLEMENTED_ERROR, 0 );
+ return PR_FAILURE;
+#endif
} /* end _PR_MD_UNLOCKFILE() */
PRInt32
diff --git a/pr/src/md/windows/w95thred.c b/pr/src/md/windows/w95thred.c
index 8671d825..674e3623 100644
--- a/pr/src/md/windows/w95thred.c
+++ b/pr/src/md/windows/w95thred.c
@@ -91,6 +91,7 @@ _PR_MD_INIT_THREAD(PRThread *thread)
** suspending). Therefore, get a real handle from
** the pseudo handle via DuplicateHandle(...)
*/
+#if !defined(WINCE)
DuplicateHandle(
GetCurrentProcess(), /* Process of source handle */
GetCurrentThread(), /* Pseudo Handle to dup */
@@ -99,6 +100,13 @@ _PR_MD_INIT_THREAD(PRThread *thread)
0L, /* access flags */
FALSE, /* Inheritable */
DUPLICATE_SAME_ACCESS); /* Options */
+#else
+ /*
+ ** On WinCE the thread ID is the same as the real thread handle.
+ */
+ thread->md.handle = (HANDLE)GetCurrentThreadId();
+ thread->md.noCloseHandle = PR_TRUE;
+#endif
}
/* Create the blocking IO semaphore */
@@ -126,14 +134,23 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
PRUint32 stackSize)
{
- thread->md.start = start;
- thread->md.handle = (HANDLE) _beginthreadex(
- NULL,
- thread->stack->stackSize,
- pr_root,
- (void *)thread,
- CREATE_SUSPENDED,
- &(thread->id));
+#if !defined(WINCE)
+ thread->md.start = start;
+ thread->md.handle = (HANDLE) _beginthreadex(NULL,
+ thread->stack->stackSize,
+ pr_root,
+ (void *)thread,
+ CREATE_SUSPENDED,
+ &(thread->id));
+#else
+ thread->md.handle = CreateThread(NULL,
+ (DWORD)thread->stack->stackSize,
+ (LPTHREAD_START_ROUTINE)start,
+ (LPVOID)thread,
+ (DWORD)CREATE_SUSPENDED,
+ (LPDWORD)&(thread->id));
+#endif /* !WINCE */
+
if(!thread->md.handle) {
return PR_FAILURE;
}
@@ -144,13 +161,13 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
* THREAD_PRIORITY_NORMAL.
*/
if (priority != PR_PRIORITY_NORMAL) {
- _PR_MD_SET_PRIORITY(&(thread->md), priority);
+ _PR_MD_SET_PRIORITY(&(thread->md), priority);
}
-
+
/* Activate the thread */
if ( ResumeThread( thread->md.handle ) != -1)
- return PR_SUCCESS;
-
+ return PR_SUCCESS;
+
return PR_FAILURE;
}
@@ -206,8 +223,18 @@ _PR_MD_CLEAN_THREAD(PRThread *thread)
}
if (thread->md.handle) {
+#if !defined(WINCE)
rv = CloseHandle(thread->md.handle);
PR_ASSERT(rv);
+#else
+ if(PR_FALSE == thread->md.noCloseHandle) {
+ rv = CloseHandle(thread->md.handle);
+ PR_ASSERT(rv);
+ }
+ else {
+ thread->md.noCloseHandle = PR_FALSE; /* reused? insurance.... */
+ }
+#endif
thread->md.handle = 0;
}
}
@@ -223,25 +250,37 @@ _PR_MD_EXIT_THREAD(PRThread *thread)
void
_PR_MD_EXIT(PRIntn status)
{
+#if !defined(WINCE)
_exit(status);
+#else
+ TerminateProcess(GetCurrentProcess(), status);
+#endif
}
PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask )
{
+#if !defined(WINCE)
int rv;
rv = SetThreadAffinityMask(thread->md.handle, mask);
return rv?0:-1;
+#else
+ return -1;
+#endif
}
PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask)
{
+#if !defined(WINCE)
PRInt32 rv, system_mask;
rv = GetProcessAffinityMask(GetCurrentProcess(), mask, &system_mask);
return rv?0:-1;
+#else
+ return -1;
+#endif
}
void
diff --git a/pr/src/misc/prerror.c b/pr/src/misc/prerror.c
index f578f2d2..aea90e92 100644
--- a/pr/src/misc/prerror.c
+++ b/pr/src/misc/prerror.c
@@ -52,6 +52,12 @@ PR_IMPLEMENT(PRInt32) PR_GetOSError(void)
return thread->osErrorCode;
}
+PR_IMPLEMENT(PRInt32 *) PR_GetOSErrorAddress(void)
+{
+ PRThread *thread = PR_GetCurrentThread();
+ return &thread->osErrorCode;
+}
+
PR_IMPLEMENT(void) PR_SetError(PRErrorCode code, PRInt32 osErr)
{
PRThread *thread = PR_GetCurrentThread();
diff --git a/pr/src/misc/prerrortable.c b/pr/src/misc/prerrortable.c
index a51b4e8f..50b956a2 100644
--- a/pr/src/misc/prerrortable.c
+++ b/pr/src/misc/prerrortable.c
@@ -148,7 +148,7 @@ PR_ErrorToString(PRErrorCode code, PRLanguageCode language)
}
if (code >= 0 && code < 256) {
- return strerror(code);
+ return strerror(code);
}
offset = (int) (code & ((1<<ERRCODE_RANGE)-1));
@@ -204,7 +204,7 @@ PR_ErrorInstallTable(const struct PRErrorTable *table)
new_et = (struct PRErrorTableList *)
PR_Malloc(sizeof(struct PRErrorTableList));
if (!new_et)
- return errno; /* oops */
+ return errno; /* oops */
new_et->table = table;
if (callback_newtable) {
new_et->table_private = callback_newtable(table, callback_private);
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index edccde85..ca647fd8 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -1183,6 +1183,8 @@ static struct protoent *getprotobyname_r(const char* name)
{
#ifdef XP_OS2_VACPP
return getprotobyname((char *)name);
+#elif defined(WINCE)
+ return Wingetprotobyname(name);
#else
return getprotobyname(name);
#endif
@@ -1190,7 +1192,11 @@ static struct protoent *getprotobyname_r(const char* name)
static struct protoent *getprotobynumber_r(PRInt32 number)
{
+#if !defined(WINCE)
return getprotobynumber(number);
+#else
+ return Wingetprotobynumber(number);
+#endif
} /* getprotobynumber_r */
#endif /* !defined(_PR_HAVE_GETPROTO_R) */
diff --git a/pr/src/threads/combined/prucv.c b/pr/src/threads/combined/prucv.c
index 80d919b8..e17c67bd 100644
--- a/pr/src/threads/combined/prucv.c
+++ b/pr/src/threads/combined/prucv.c
@@ -43,7 +43,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/
diff --git a/pr/src/threads/combined/prulock.c b/pr/src/threads/combined/prulock.c
index 5ede1c7b..0fef63e9 100644
--- a/pr/src/threads/combined/prulock.c
+++ b/pr/src/threads/combined/prulock.c
@@ -40,7 +40,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/
diff --git a/pr/src/threads/combined/pruthr.c b/pr/src/threads/combined/pruthr.c
index 7e31b56b..793e8379 100644
--- a/pr/src/threads/combined/pruthr.c
+++ b/pr/src/threads/combined/pruthr.c
@@ -42,7 +42,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/
diff --git a/pr/src/threads/prcthr.c b/pr/src/threads/prcthr.c
index 1e2f469c..6579869a 100644
--- a/pr/src/threads/prcthr.c
+++ b/pr/src/threads/prcthr.c
@@ -40,7 +40,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/
diff --git a/pr/src/threads/prdump.c b/pr/src/threads/prdump.c
index 3ea884d2..8c9e6f06 100644
--- a/pr/src/threads/prdump.c
+++ b/pr/src/threads/prdump.c
@@ -40,7 +40,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/
diff --git a/pr/src/threads/prtpd.c b/pr/src/threads/prtpd.c
index 168c6601..203e8d39 100644
--- a/pr/src/threads/prtpd.c
+++ b/pr/src/threads/prtpd.c
@@ -73,7 +73,7 @@
#if defined(WIN95)
/*
** Some local variables report warnings on Win95 because the code paths
-** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
+** using them are conditioned on HAVE_CUSTOM_USER_THREADS.
** The pragma suppresses the warning.
**
*/