Window CE patch NSPRPUB_WINCE_04122006_BRANCH
authordougt%meer.net
Wed, 12 Apr 2006 22:54:22 +0000
branchNSPRPUB_WINCE_04122006_BRANCH
changeset 3643 5cce8b47f5de34f559ce34aa05be62d7ffc59ea2
parent 3642 a1b74d1f5c803d0d336d72dd56c205848fbe69de
child 3656 9135ec8e9230974b347275aa0dacf9a34ba7d185
push idunknown
push userunknown
push dateunknown
Window CE patch
config/Makefile.in
config/rules.mk
configure
configure.in
pr/include/md/_win95.h
pr/include/md/_wince.cfg
pr/include/md/_wince.h
pr/include/md/prosdep.h
pr/include/prtypes.h
pr/src/io/prio.c
pr/src/io/prlog.c
pr/src/md/windows/Makefile.in
pr/src/md/windows/ntmisc.c
pr/src/md/windows/ntsec.c
pr/src/md/windows/objs.mk
pr/src/md/windows/w32rng.c
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -53,25 +53,28 @@ VISIBILITY_FLAGS =
 # autoconf.mk must be deleted last (from the top-level directory)
 # because it is included by every makefile.
 DIST_GARBAGE	= nsprincl.mk nsprincl.sh nspr-config
 
 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
 PROG_SUFFIX =
 endif
 
 # Temporary workaround to disable the generation of
 # library build time because now.c uses the 'long long'
@@ -111,27 +114,31 @@ endif
 
 ifeq ($(MOZ_OS2_TOOLS),PGCC)
 XCFLAGS = $(OS_CFLAGS)
 XLDOPTS = -Zlinker /PM:VIO
 endif
 
 include $(topsrcdir)/config/rules.mk
 
+ifneq ($(OS_TARGET),WINCE)
+
 PROGS	= $(OBJDIR)/now$(PROG_SUFFIX)
 
 ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
 TARGETS = $(PROGS)
 else
 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
 endif
 
 # Redefine MAKE_OBJDIR for just this directory
 define MAKE_OBJDIR
 if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -129,31 +129,44 @@ ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
 SHARED_LIBRARY	= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_shr.a
 else
 ifdef MKSHLIB
 SHARED_LIBRARY	= $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
 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
 
 ifndef TARGETS
 ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
 TARGETS		= $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
 ifndef BUILD_OPT
 ifdef MSC_VER
 ifneq (,$(filter-out 1100 1200,$(MSC_VER)))
 TARGETS		+= $(SHARED_LIB_PDB)
 endif
 endif
 endif
 else
 TARGETS		= $(LIBRARY) $(SHARED_LIBRARY)
 endif
+
+ifeq ($(OS_TARGET),WINCE)
+TARGETS		= $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
+endif
+
 endif
 
 #
 # OBJS is the list of object files.  It can be constructed by
 # specifying CSRCS (list of C source files) and ASFILES (list
 # of assembly language source files).
 #
 
--- a/configure
+++ b/configure
@@ -1079,17 +1079,17 @@ if test -n "$MOZ_DEBUG"; then
 EOF
 
     DEFINES="$DEFINES -UNDEBUG"
 
     case "${target_os}" in
     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'`"
         ;;
     *) 
         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
         ;;
     esac
 else
     cat >> confdefs.h <<\EOF
@@ -2901,17 +2901,17 @@ if test "$OS_TARGET" = "WIN16"; then
 fi
 OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
 
 
 case "$host" in
 *-mingw*)
     NSINSTALL=nsinstall
     ;;
-*-cygwin*|*-msvc*|*-mks*)
+*-cygwin*|*-msvc*|*-mks*|*-wince*)
     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
     if test `echo "${PATH}" | grep -c \;` = 0; then
         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
     fi
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
@@ -3912,16 +3912,55 @@ EOF
         ;;
     m68k)
         CFLAGS="$CFLAGS -m68020-60"
         CXXFLAGS="$CXXFLAGS -m68020-60"
         ;;
     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
 EOF
 
     cat >> confdefs.h <<\EOF
 #define WIN32 1
 EOF
@@ -4383,27 +4422,27 @@ EOF
     if test -z "$GNU_CC"; then
         CC="$CC -std1 -ieee_with_inexact"
         if test "$OS_RELEASE" != "V2.0"; then
             CC="$CC -readonly_strings"
         fi
         _OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
         ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4392: checking for machine/builtins.h" >&5
+echo "configure:4431: 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 4397 "configure"
+#line 4436 "configure"
 #include "confdefs.h"
 #include <machine/builtins.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4402: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4441: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -4955,63 +4994,63 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
 
 
 
 case $target in
 *-darwin*)
     ;;
 *)
     echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:4964: checking for dlopen in -ldl" >&5
+echo "configure:5003: 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
 else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4972 "configure"
+#line 5011 "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
     builtin and then its argument prototype would still apply.  */
 char dlopen();
 
 int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:4983: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5022: \"$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
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=no"
 fi
 rm -f conftest*
 LIBS="$ac_save_LIBS"
 
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:5000: checking for dlfcn.h" >&5
+echo "configure:5039: 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 5005 "configure"
+#line 5044 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5010: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
   eval "ac_cv_header_$ac_safe=yes"
 else
   echo "$ac_err" >&5
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
@@ -5034,23 +5073,23 @@ fi
     ;;
 esac
 
 
 
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5043: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5082: 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 5049 "configure"
+#line 5088 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5058,17 +5097,17 @@ else
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=no
 fi
 rm -f conftest*
 
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 5067 "configure"
+#line 5106 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
 EOF
 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   egrep "$ac_pattern" >/dev/null 2>&1; then
   rm -rf conftest*
   ac_cv_prog_gcc_traditional=yes
@@ -5082,22 +5121,22 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
 for ac_func in lchown strerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5091: checking for $ac_func" >&5
+echo "configure:5130: 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 5096 "configure"
+#line 5135 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
 #include <assert.h>
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
 char $ac_func();
@@ -5110,17 +5149,17 @@ int main() {
 #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
 choke me
 #else
 $ac_func();
 #endif
 
 ; return 0; }
 EOF
-if { (eval echo configure:5119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5158: \"$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
   echo "configure: failed program was:" >&5
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=no"
 fi
@@ -5151,17 +5190,17 @@ if test "${enable_strip+set}" = set; the
 fi
 
 
 case "${target_os}" in
 hpux*)
 if test -z "$GNU_CC"; then
 
     echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5160: checking for +Olit support" >&5
+echo "configure:5199: checking for +Olit support" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
                   ac_cv_hpux_usable_olit_option=no
         rm -f conftest*
         echo 'int main() { return 0; }' | cat > conftest.c
         ${CC-cc} ${CFLAGS} +Olit=all -o conftest conftest.c > conftest.out 2>&1
         if test $? -eq 0; then
@@ -5190,17 +5229,17 @@ esac
 
 case "$target_os" in
 darwin*)
     _HAVE_PTHREADS=1
     ;;
 *)
     
 echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5199: checking for pthread_create in -lpthreads" >&5
+echo "configure:5238: checking for pthread_create in -lpthreads" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5212,17 +5251,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthreads"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5221: checking for pthread_create in -lpthread" >&5
+echo "configure:5260: checking for pthread_create in -lpthread" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5234,17 +5273,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lpthread"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5243: checking for pthread_create in -lc_r" >&5
+echo "configure:5282: checking for pthread_create in -lc_r" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5256,17 +5295,17 @@ echo "
     rm -f dummy.c dummy${ac_exeext} ;
     if test "$_res" = "0"; then
         echo "$ac_t""yes" 1>&6
         _HAVE_PTHREADS=1 _PTHREAD_LDFLAGS="-lc_r"
     else
         echo "$ac_t""no" 1>&6
         
 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5265: checking for pthread_create in -lc" >&5
+echo "configure:5304: checking for pthread_create in -lc" >&5
 echo "
     #include <pthread.h> 
     void *foo(void *v) { return v; } 
     int main() { 
         pthread_t t;
         if (!pthread_create(&t, 0, &foo, 0)) {
             pthread_join(t, 0);
         }
@@ -5410,17 +5449,17 @@ EOF
     fi
 fi
 
 
 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:5419: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5458: checking whether ${CC-cc} accepts -pthread" >&5
    echo 'int main() { return 0; }' | cat > conftest.c
    ${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
    if test $? -eq 0; then
 	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthread`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 	    ac_cv_have_dash_pthread=yes
 		case "$target_os" in
 	    freebsd*)
 # Freebsd doesn't use -pthread for compiles, it uses them for linking
@@ -5433,17 +5472,17 @@ echo "configure:5419: checking whether $
 	fi
     fi
     rm -f conftest*
     echo "$ac_t""$ac_cv_have_dash_pthread" 1>&6
 
 			    ac_cv_have_dash_pthreads=no
     if test "$ac_cv_have_dash_pthread" = "no"; then
 	    echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5442: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5481: checking whether ${CC-cc} accepts -pthreads" >&5
     	echo 'int main() { return 0; }' | cat > conftest.c
 	    ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
     	if test $? -eq 0; then
 	    	if test -z "`egrep -i '(unrecognize|unknown)' conftest.out | grep pthreads`" && test -z "`egrep -i '(error|incorrect)' conftest.out`" ; then
 			    ac_cv_have_dash_pthreads=yes
 			    CFLAGS="$CFLAGS -pthreads"
 			    CXXFLAGS="$CXXFLAGS -pthreads"
 		    fi
@@ -5632,17 +5671,17 @@ EOF
 *-linux*)
     if test -n "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
 EOF
 
     fi
     ;;
-*-mingw*|*-cygwin*|*-msvc*|*-mks*)
+*-mingw*|*-cygwin*|*-msvc*|*-mks*|*-wince*)
         USE_PTHREADS=
     _PTHREAD_LDFLAGS=
     USE_USER_PTHREADS=
     ;;
 *-netbsd*|*-openbsd*)
     if test -n "$USE_NSPR_THREADS"; then
         cat >> confdefs.h <<\EOF
 #define _PR_LOCAL_THREADS_ONLY 1
@@ -5974,17 +6013,17 @@ trap 'rm -f $CONFIG_STATUS conftest*; ex
 # Protect against Makefile macro expansion.
 cat > conftest.defs <<\EOF
 s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
 s%[ 	`~#$^&*(){}\\|;'"<>?]%\\&%g
 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
 
 
 # Without the "./", some shells look in PATH for config.status.
 : ${CONFIG_STATUS=./config.status}
 
 echo creating $CONFIG_STATUS
 rm -f $CONFIG_STATUS
--- a/configure.in
+++ b/configure.in
@@ -361,17 +361,17 @@ fi
 if test -n "$MOZ_DEBUG"; then
     AC_DEFINE(DEBUG)
     DEFINES="$DEFINES -UNDEBUG"
 
     case "${target_os}" in
     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'`"
         ;;
     *) 
         DEFINES="$DEFINES -DDEBUG_`$WHOAMI`"
         ;;
     esac
 else
     AC_DEFINE(NDEBUG)
@@ -781,17 +781,17 @@ dnl ====================================
 
 dnl ========================================================
 dnl Override of system specific host options
 dnl ========================================================
 case "$host" in
 *-mingw*)
     NSINSTALL=nsinstall
     ;;
-*-cygwin*|*-msvc*|*-mks*)
+*-cygwin*|*-msvc*|*-mks*|*-wince*)
     NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
     if test `echo "${PATH}" | grep -c \;` = 0; then
         CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
     fi
     ;;
 *-beos*)
     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
     ;;
@@ -1442,16 +1442,43 @@ tools are selected during the Xcode/Deve
         ;;
     m68k)
         CFLAGS="$CFLAGS -m68020-60"
         CXXFLAGS="$CXXFLAGS -m68020-60"
         ;;
     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)
     PR_MD_ARCH_DIR=windows
     RESOLVE_LINK_SYMBOLS=1
 
     if test -n "$GNU_CC"; then
         CC="$CC -mno-cygwin"
@@ -2549,17 +2576,17 @@ case "$target" in
         fi
     fi
     ;;
 *-linux*)
     if test -n "$USE_NSPR_THREADS"; then
         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=
     USE_USER_PTHREADS=
     ;;
 *-netbsd*|*-openbsd*)
     if test -n "$USE_NSPR_THREADS"; then
         AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
--- a/pr/include/md/_win95.h
+++ b/pr/include/md/_win95.h
@@ -323,17 +323,21 @@ extern PRInt32 _MD_CloseSocket(PRInt32 o
 
 #define _MD_INIT_ATOMIC()
 #if defined(_M_IX86) || defined(_X86_)
 #define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT
 #define _MD_ATOMIC_ADD          	  _PR_MD_ATOMIC_ADD
 #define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT
 #else /* non-x86 processors */
 #define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)
+//#if defined(WINCE)
+//#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchange((PLONG)ptr, (*(PLONG)ptr) + (LONG)val) + val)
+//#else
 #define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)
+//#endif
 #define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)
 #endif /* x86 */
 #define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)
 
 #define _MD_INIT_IO                   _PR_MD_INIT_IO
 
 
 /* win95 doesn't have async IO */
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_wince.cfg
@@ -0,0 +1,418 @@
+     /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+     
+     /* 
+      * The contents of this file are subject to the Mozilla Public
+      * License Version 1.1 (the "License"); you may not use this file
+      * except in compliance with the License. You may obtain a copy of
+      * the License at http://www.mozilla.org/MPL/
+      * 
+      * Software distributed under the License is distributed on an "AS
+      * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+      * implied. See the License for the specific language governing
+      * rights and limitations under the License.
+      * 
+      * The Original Code is the Netscape Portable Runtime (NSPR).
+      * 
+      * The Initial Developer of the Original Code is Netscape
+      * Communications Corporation.  Portions created by Netscape are 
+      * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
+      * Rights Reserved.
+      * 
+      * Contributor(s):
+      *  Garrett Arch Blythe 01/15/2002
+      * 
+      * Alternatively, the contents of this file may be used under the
+      * terms of the GNU General Public License Version 2 or later (the
+      * "GPL"), in which case the provisions of the GPL are applicable 
+      * instead of those above.  If you wish to allow use of your 
+      * version of this file only under the terms of the GPL and not to
+      * allow others to use your version of this file under the MPL,
+      * indicate your decision by deleting the provisions above and
+      * replace them with the notice and other provisions required by
+      * the GPL.  If you do not delete the provisions above, a recipient
+      * may use your version of this file under either the MPL or the
+      * GPL.
+      */
+     #ifndef nspr_cpucfg___
+     #define nspr_cpucfg___
+     
+     #ifndef XP_PC
+     #define XP_PC
+     #endif
+     
+     #ifndef WIN32
+     #define WIN32
+     #endif
+     
+     #ifndef WINCE
+     #define WINCE
+     #endif
+     
+     /*
+      * Some needed types herein.
+      */
+     #include <windows.h>
+     #include <winnt.h>
+     #include <stdlib.h>
+     
+     #define PR_AF_INET6 (100) /* IPv6 not supported yet, use standard value. */
+     
+     #if defined(_M_IX86) || defined(_X86_)
+     
+     #define IS_LITTLE_ENDIAN 1
+     #undef  IS_BIG_ENDIAN
+     
+     #define PR_BYTES_PER_BYTE   1
+     #define PR_BYTES_PER_SHORT  2
+     #define PR_BYTES_PER_INT    4
+     #define PR_BYTES_PER_INT64  8
+     #define PR_BYTES_PER_LONG   4
+     #define PR_BYTES_PER_FLOAT  4
+     #define PR_BYTES_PER_WORD   4
+     #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    32
+     #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	5
+     #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    4
+     #define PR_ALIGN_OF_DWORD   8
+     #define PR_ALIGN_OF_DOUBLE  4
+     #define PR_ALIGN_OF_POINTER 4
+     
+     #define PR_BYTES_PER_WORD_LOG2  2
+     #define PR_BYTES_PER_DWORD_LOG2 2
+     
+     #elif defined(_ARM_)
+     
+     #define IS_LITTLE_ENDIAN 1
+     #undef  IS_BIG_ENDIAN
+     
+     #define PR_BYTES_PER_BYTE   1
+     #define PR_BYTES_PER_SHORT  2
+     #define PR_BYTES_PER_INT    4
+     #define PR_BYTES_PER_INT64  8
+     #define PR_BYTES_PER_LONG   4
+     #define PR_BYTES_PER_FLOAT  4
+     #define PR_BYTES_PER_WORD   4
+     #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    32
+     #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   5
+     #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    4
+     #define PR_ALIGN_OF_DWORD   8
+     #define PR_ALIGN_OF_DOUBLE  4
+     #define PR_ALIGN_OF_POINTER 4
+     
+     #define PR_BYTES_PER_WORD_LOG2  2
+     #define PR_BYTES_PER_DWORD_LOG2 2
+     
+     #else /* defined(_M_IX86) || defined(_X86_) */
+     
+     #error unknown processor architecture
+     
+     #endif /* defined(_M_IX86) || defined(_X86_) */
+     
+     #define HAVE_LONG_LONG
+     
+     #ifndef NO_NSPR_10_SUPPORT
+     
+     #define BYTES_PER_BYTE      PR_BYTES_PER_BYTE
+     #define BYTES_PER_SHORT     PR_BYTES_PER_SHORT
+     #define BYTES_PER_INT       PR_BYTES_PER_INT
+     #define BYTES_PER_INT64     PR_BYTES_PER_INT64
+     #define BYTES_PER_LONG      PR_BYTES_PER_LONG
+     #define BYTES_PER_FLOAT     PR_BYTES_PER_FLOAT
+     #define BYTES_PER_DOUBLE    PR_BYTES_PER_DOUBLE
+     #define BYTES_PER_WORD      PR_BYTES_PER_WORD
+     #define BYTES_PER_DWORD     PR_BYTES_PER_DWORD
+     
+     #define BITS_PER_BYTE       PR_BITS_PER_BYTE
+     #define BITS_PER_SHORT      PR_BITS_PER_SHORT
+     #define BITS_PER_INT        PR_BITS_PER_INT
+     #define BITS_PER_INT64      PR_BITS_PER_INT64
+     #define BITS_PER_LONG       PR_BITS_PER_LONG
+     #define BITS_PER_FLOAT      PR_BITS_PER_FLOAT
+     #define BITS_PER_DOUBLE     PR_BITS_PER_DOUBLE
+     #define BITS_PER_WORD       PR_BITS_PER_WORD
+     
+     #define BITS_PER_BYTE_LOG2  PR_BITS_PER_BYTE_LOG2
+     #define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
+     #define BITS_PER_INT_LOG2   PR_BITS_PER_INT_LOG2
+     #define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
+     #define BITS_PER_LONG_LOG2  PR_BITS_PER_LONG_LOG2
+     #define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
+     #define BITS_PER_DOUBLE_LOG2    PR_BITS_PER_DOUBLE_LOG2
+     #define BITS_PER_WORD_LOG2  PR_BITS_PER_WORD_LOG2
+     
+     #define ALIGN_OF_SHORT      PR_ALIGN_OF_SHORT
+     #define ALIGN_OF_INT        PR_ALIGN_OF_INT
+     #define ALIGN_OF_LONG       PR_ALIGN_OF_LONG
+     #define ALIGN_OF_INT64      PR_ALIGN_OF_INT64
+     #define ALIGN_OF_FLOAT      PR_ALIGN_OF_FLOAT
+     #define ALIGN_OF_DOUBLE     PR_ALIGN_OF_DOUBLE
+     #define ALIGN_OF_POINTER    PR_ALIGN_OF_POINTER
+     #define ALIGN_OF_WORD       PR_ALIGN_OF_WORD
+     
+     #define BYTES_PER_WORD_LOG2     PR_BYTES_PER_WORD_LOG2
+     #define BYTES_PER_DWORD_LOG2    PR_BYTES_PER_DWORD_LOG2
+     #define WORDS_PER_DWORD_LOG2    PR_WORDS_PER_DWORD_LOG2
+     
+     #endif /* NO_NSPR_10_SUPPORT */
+     
+     #endif /* nspr_cpucfg___ */
+     /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+     
+     /* 
+      * The contents of this file are subject to the Mozilla Public
+      * License Version 1.1 (the "License"); you may not use this file
+      * except in compliance with the License. You may obtain a copy of
+      * the License at http://www.mozilla.org/MPL/
+      * 
+      * Software distributed under the License is distributed on an "AS
+      * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+      * implied. See the License for the specific language governing
+      * rights and limitations under the License.
+      * 
+      * The Original Code is the Netscape Portable Runtime (NSPR).
+      * 
+      * The Initial Developer of the Original Code is Netscape
+      * Communications Corporation.  Portions created by Netscape are 
+      * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
+      * Rights Reserved.
+      * 
+      * Contributor(s):
+      *  Garrett Arch Blythe 01/15/2002
+      * 
+      * Alternatively, the contents of this file may be used under the
+      * terms of the GNU General Public License Version 2 or later (the
+      * "GPL"), in which case the provisions of the GPL are applicable 
+      * instead of those above.  If you wish to allow use of your 
+      * version of this file only under the terms of the GPL and not to
+      * allow others to use your version of this file under the MPL,
+      * indicate your decision by deleting the provisions above and
+      * replace them with the notice and other provisions required by
+      * the GPL.  If you do not delete the provisions above, a recipient
+      * may use your version of this file under either the MPL or the
+      * GPL.
+      */
+     #ifndef nspr_cpucfg___
+     #define nspr_cpucfg___
+     
+     #ifndef XP_PC
+     #define XP_PC
+     #endif
+     
+     #ifndef WIN32
+     #define WIN32
+     #endif
+     
+     #ifndef WINCE
+     #define WINCE
+     #endif
+     
+     /*
+      * Some needed types herein.
+      */
+     #include <windows.h>
+     #include <winnt.h>
+     #include <stdlib.h>
+     
+     #define PR_AF_INET6 (100) /* IPv6 not supported yet, use standard value. */
+     
+     #if defined(_M_IX86) || defined(_X86_)
+     
+     #define IS_LITTLE_ENDIAN 1
+     #undef  IS_BIG_ENDIAN
+     
+     #define PR_BYTES_PER_BYTE   1
+     #define PR_BYTES_PER_SHORT  2
+     #define PR_BYTES_PER_INT    4
+     #define PR_BYTES_PER_INT64  8
+     #define PR_BYTES_PER_LONG   4
+     #define PR_BYTES_PER_FLOAT  4
+     #define PR_BYTES_PER_WORD   4
+     #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    32
+     #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	5
+     #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    4
+     #define PR_ALIGN_OF_DWORD   8
+     #define PR_ALIGN_OF_DOUBLE  4
+     #define PR_ALIGN_OF_POINTER 4
+     
+     #define PR_BYTES_PER_WORD_LOG2  2
+     #define PR_BYTES_PER_DWORD_LOG2 2
+     
+     #elif defined(_ARM_)
+     
+     #define IS_LITTLE_ENDIAN 1
+     #undef  IS_BIG_ENDIAN
+     
+     #define PR_BYTES_PER_BYTE   1
+     #define PR_BYTES_PER_SHORT  2
+     #define PR_BYTES_PER_INT    4
+     #define PR_BYTES_PER_INT64  8
+     #define PR_BYTES_PER_LONG   4
+     #define PR_BYTES_PER_FLOAT  4
+     #define PR_BYTES_PER_WORD   4
+     #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    32
+     #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   5
+     #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    4
+     #define PR_ALIGN_OF_DWORD   8
+     #define PR_ALIGN_OF_DOUBLE  4
+     #define PR_ALIGN_OF_POINTER 4
+     
+     #define PR_BYTES_PER_WORD_LOG2  2
+     #define PR_BYTES_PER_DWORD_LOG2 2
+     
+     #else /* defined(_M_IX86) || defined(_X86_) */
+     
+     #error unknown processor architecture
+     
+     #endif /* defined(_M_IX86) || defined(_X86_) */
+     
+     #define HAVE_LONG_LONG
+     
+     #ifndef NO_NSPR_10_SUPPORT
+     
+     #define BYTES_PER_BYTE      PR_BYTES_PER_BYTE
+     #define BYTES_PER_SHORT     PR_BYTES_PER_SHORT
+     #define BYTES_PER_INT       PR_BYTES_PER_INT
+     #define BYTES_PER_INT64     PR_BYTES_PER_INT64
+     #define BYTES_PER_LONG      PR_BYTES_PER_LONG
+     #define BYTES_PER_FLOAT     PR_BYTES_PER_FLOAT
+     #define BYTES_PER_DOUBLE    PR_BYTES_PER_DOUBLE
+     #define BYTES_PER_WORD      PR_BYTES_PER_WORD
+     #define BYTES_PER_DWORD     PR_BYTES_PER_DWORD
+     
+     #define BITS_PER_BYTE       PR_BITS_PER_BYTE
+     #define BITS_PER_SHORT      PR_BITS_PER_SHORT
+     #define BITS_PER_INT        PR_BITS_PER_INT
+     #define BITS_PER_INT64      PR_BITS_PER_INT64
+     #define BITS_PER_LONG       PR_BITS_PER_LONG
+     #define BITS_PER_FLOAT      PR_BITS_PER_FLOAT
+     #define BITS_PER_DOUBLE     PR_BITS_PER_DOUBLE
+     #define BITS_PER_WORD       PR_BITS_PER_WORD
+     
+     #define BITS_PER_BYTE_LOG2  PR_BITS_PER_BYTE_LOG2
+     #define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
+     #define BITS_PER_INT_LOG2   PR_BITS_PER_INT_LOG2
+     #define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
+     #define BITS_PER_LONG_LOG2  PR_BITS_PER_LONG_LOG2
+     #define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
+     #define BITS_PER_DOUBLE_LOG2    PR_BITS_PER_DOUBLE_LOG2
+     #define BITS_PER_WORD_LOG2  PR_BITS_PER_WORD_LOG2
+     
+     #define ALIGN_OF_SHORT      PR_ALIGN_OF_SHORT
+     #define ALIGN_OF_INT        PR_ALIGN_OF_INT
+     #define ALIGN_OF_LONG       PR_ALIGN_OF_LONG
+     #define ALIGN_OF_INT64      PR_ALIGN_OF_INT64
+     #define ALIGN_OF_FLOAT      PR_ALIGN_OF_FLOAT
+     #define ALIGN_OF_DOUBLE     PR_ALIGN_OF_DOUBLE
+     #define ALIGN_OF_POINTER    PR_ALIGN_OF_POINTER
+     #define ALIGN_OF_WORD       PR_ALIGN_OF_WORD
+     
+     #define BYTES_PER_WORD_LOG2     PR_BYTES_PER_WORD_LOG2
+     #define BYTES_PER_DWORD_LOG2    PR_BYTES_PER_DWORD_LOG2
+     #define WORDS_PER_DWORD_LOG2    PR_WORDS_PER_DWORD_LOG2
+     
+     #endif /* NO_NSPR_10_SUPPORT */
+     
+     #endif /* nspr_cpucfg___ */
new file mode 100644
--- /dev/null
+++ b/pr/include/md/_wince.h
@@ -0,0 +1,507 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 
+ * The contents of this file are subject to the Mozilla Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ * 
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ * 
+ * The Original Code is the Netscape Portable Runtime (NSPR).
+ * 
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation.  Portions created by Netscape are 
+ * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
+ * Rights Reserved.
+ * 
+ * Contributor(s):
+ *  Garrett Arch Blythe 01/15/2002
+ * 
+ * Alternatively, the contents of this file may be used under the
+ * terms of the GNU General Public License Version 2 or later (the
+ * "GPL"), in which case the provisions of the GPL are applicable 
+ * instead of those above.  If you wish to allow use of your 
+ * version of this file only under the terms of the GPL and not to
+ * allow others to use your version of this file under the MPL,
+ * indicate your decision by deleting the provisions above and
+ * replace them with the notice and other provisions required by
+ * the GPL.  If you do not delete the provisions above, a recipient
+ * may use your version of this file under either the MPL or the
+ * GPL.
+ */
+
+#ifndef nspr_wince_defs_h___
+#define nspr_wince_defs_h___
+
+#include <windows.h>
+#include <winsock.h>
+#include <winnt.h>
+#include <stdlib.h>
+
+#include "_win32_time.h"
+#include "_win32_unicode.h"
+
+#include "prio.h"
+
+/*
+ * Internal configuration macros
+ */
+
+#define PR_LINKER_ARCH      "win32"
+#define _PR_SI_SYSNAME        "WINCE"
+
+/*
+ * Hardcoded for now.
+ */
+#if defined(_X86_)
+#define _PR_SI_ARCHITECTURE   "x86"
+#elif defined(_ARM_)
+#define _PR_SI_ARCHITECTURE   "ARM"
+#else
+#define _PR_SI_ARCHITECTURE   "XX"
+#endif
+
+#define HAVE_DLL
+#undef  HAVE_THREAD_AFFINITY
+#define _PR_HAVE_ATOMIC_OPS
+#define PR_HAVE_WIN32_NAMED_SHARED_MEMORY
+
+/* --- Common User-Thread/Native-Thread Definitions --------------------- */
+
+/* --- Globals --- */
+extern struct PRLock                      *_pr_schedLock;
+
+/* --- Typedefs --- */
+typedef void (*FiberFunc)(void *);
+
+#define PR_NUM_GCREGS           8
+typedef PRInt32	                PR_CONTEXT_TYPE[PR_NUM_GCREGS];
+#define GC_VMBASE               0x40000000
+#define GC_VMLIMIT              0x00FFFFFF
+
+#define _MD_MAGIC_THREAD	0x22222222
+#define _MD_MAGIC_THREADSTACK	0x33333333
+#define _MD_MAGIC_SEGMENT	0x44444444
+#define _MD_MAGIC_DIR		0x55555555
+#define _MD_MAGIC_CV        0x66666666
+
+struct _MDCPU {
+  int              unused;
+};
+
+struct _MDThread {
+  HANDLE           blocked_sema;      /* Threads block on this when waiting
+                                       * for IO or CondVar.
+                                       */
+  PRBool           inCVWaitQueue;     /* PR_TRUE if the thread is in the
+                                       * wait queue of some cond var.
+                                       * PR_FALSE otherwise.  */
+  HANDLE           handle;            /* Win32 thread handle */
+  PRBool           noCloseHandle;     /* Whether or not to CloseHandle */
+  PRUint32         id;
+  void            *sp;                /* only valid when suspended */
+  PRUint32         magic;             /* for debugging */
+  PR_CONTEXT_TYPE  gcContext;         /* Thread context for GC */
+  struct PRThread *prev, *next;       /* used by the cvar wait queue to
+                                       * chain the PRThread structures
+                                       * together */
+  void (*start)(void *);              /* used by _PR_MD_CREATE_THREAD to
+                                       * pass its 'start' argument to
+                                       * pr_root. */
+};
+
+struct _MDThreadStack {
+  PRUint32           magic;          /* for debugging */
+};
+
+struct _MDSegment {
+  PRUint32           magic;          /* for debugging */
+};
+
+#undef PROFILE_LOCKS
+
+struct _MDDir {
+  HANDLE           d_hdl;
+  WIN32_FIND_DATAW d_entry;
+  CHAR             cFileNameA[ MAX_PATH ];
+  PRBool           firstEntry;     /* Is this the entry returned
+                                    * by FindFirstFile()? */
+  PRUint32         magic;          /* for debugging */
+};
+
+struct _MDCVar {
+  PRUint32 magic;
+  struct PRThread *waitHead, *waitTail;  /* the wait queue: a doubly-
+                                          * linked list of threads
+                                          * waiting on this condition
+                                          * variable */
+  PRIntn nwait;                          /* number of threads in the
+                                          * wait queue */
+};
+
+#define _MD_CV_NOTIFIED_LENGTH 6
+typedef struct _MDNotified _MDNotified;
+struct _MDNotified {
+  PRIntn length;                     /* # of used entries in this
+                                      * structure */
+  struct {
+    struct _MDCVar *cv;            /* the condition variable notified */
+    PRIntn times;                  /* and the number of times notified */
+    struct PRThread *notifyHead;   /* list of threads to wake up */
+  } cv[_MD_CV_NOTIFIED_LENGTH];
+  _MDNotified *link;                 /* link to another of these, or NULL */
+};
+
+struct _MDLock {
+  CRITICAL_SECTION mutex;          /* this is recursive on NT */
+  
+  /*
+   * When notifying cvars, there is no point in actually
+   * waking up the threads waiting on the cvars until we've
+   * released the lock.  So, we temporarily record the cvars.
+   * When doing an unlock, we'll then wake up the waiting threads.
+   */
+  struct _MDNotified notified;     /* array of conditions notified */
+#ifdef PROFILE_LOCKS
+  PRInt32 hitcount;
+  PRInt32 misscount;
+#endif
+};
+
+struct _MDSemaphore {
+  HANDLE           sem;
+};
+
+struct _MDFileDesc {
+  PRInt32 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,
+                    *   which is a void*.
+                    * - For sockets, we are using Winsock SOCKET, which
+                    *   is a u_int.
+                    */
+};
+
+struct _MDProcess {
+  HANDLE handle;
+  DWORD id;
+};
+
+/* --- Misc stuff --- */
+#define _MD_GET_SP(thread)            (thread)->md.gcContext[6]
+
+/* --- NT security stuff --- */
+
+extern void _PR_NT_InitSids(void);
+extern void _PR_NT_FreeSids(void);
+extern PRStatus _PR_NT_MakeSecurityDescriptorACL(
+                                                 PRIntn mode,
+                                                 DWORD accessTable[],
+                                                 PSECURITY_DESCRIPTOR *resultSD,
+                                                 PACL *resultACL
+                                                 );
+extern void _PR_NT_FreeSecurityDescriptorACL(
+                                             PSECURITY_DESCRIPTOR pSD, PACL pACL);
+
+/* --- IO stuff --- */
+
+#define _MD_OPEN                      _PR_MD_OPEN
+#define _MD_OPEN_FILE                 _PR_MD_OPEN_FILE
+#define _MD_READ                      _PR_MD_READ
+#define _MD_WRITE                     _PR_MD_WRITE
+#define _MD_WRITEV                    _PR_MD_WRITEV
+#define _MD_LSEEK                     _PR_MD_LSEEK
+#define _MD_LSEEK64                   _PR_MD_LSEEK64
+extern PRInt32 _MD_CloseFile(PRInt32 osfd);
+#define _MD_CLOSE_FILE                _MD_CloseFile
+#define _MD_GETFILEINFO               _PR_MD_GETFILEINFO
+#define _MD_GETFILEINFO64             _PR_MD_GETFILEINFO64
+#define _MD_GETOPENFILEINFO           _PR_MD_GETOPENFILEINFO
+#define _MD_GETOPENFILEINFO64         _PR_MD_GETOPENFILEINFO64
+#define _MD_STAT                      _PR_MD_STAT
+#define _MD_RENAME                    _PR_MD_RENAME     
+#define _MD_ACCESS                    _PR_MD_ACCESS     
+#define _MD_DELETE                    _PR_MD_DELETE     
+#define _MD_MKDIR                     _PR_MD_MKDIR      
+#define _MD_MAKE_DIR                  _PR_MD_MAKE_DIR
+#define _MD_RMDIR                     _PR_MD_RMDIR      
+#define _MD_LOCKFILE                  _PR_MD_LOCKFILE
+#define _MD_TLOCKFILE                 _PR_MD_TLOCKFILE
+#define _MD_UNLOCKFILE                _PR_MD_UNLOCKFILE
+
+/* --- Socket IO stuff --- */
+#define _MD_EACCES                WSAEACCES
+#define _MD_EADDRINUSE            WSAEADDRINUSE
+#define _MD_EADDRNOTAVAIL         WSAEADDRNOTAVAIL
+#define _MD_EAFNOSUPPORT          WSAEAFNOSUPPORT
+#define _MD_EAGAIN                WSAEWOULDBLOCK
+#define _MD_EALREADY              WSAEALREADY
+#define _MD_EBADF                 WSAEBADF
+#define _MD_ECONNREFUSED          WSAECONNREFUSED
+#define _MD_ECONNRESET            WSAECONNRESET
+#define _MD_EFAULT                WSAEFAULT
+#define _MD_EINPROGRESS           WSAEINPROGRESS
+#define _MD_EINTR                 WSAEINTR
+#define _MD_EINVAL                EINVAL
+#define _MD_EISCONN               WSAEISCONN
+#define _MD_ENETUNREACH           WSAENETUNREACH
+#define _MD_ENOENT                ENOENT
+#define _MD_ENOTCONN              WSAENOTCONN
+#define _MD_ENOTSOCK              WSAENOTSOCK
+#define _MD_EOPNOTSUPP            WSAEOPNOTSUPP
+#define _MD_EWOULDBLOCK           WSAEWOULDBLOCK
+#define _MD_GET_SOCKET_ERROR()    WSAGetLastError()
+#define _MD_SET_SOCKET_ERROR(_err) WSASetLastError(_err)
+
+#define _MD_INIT_FILEDESC(fd)
+extern void _MD_MakeNonblock(PRFileDesc *f);
+#define _MD_MAKE_NONBLOCK             _MD_MakeNonblock
+#define _MD_INIT_FD_INHERITABLE       _PR_MD_INIT_FD_INHERITABLE
+#define _MD_QUERY_FD_INHERITABLE      _PR_MD_QUERY_FD_INHERITABLE
+#define _MD_SHUTDOWN                  _PR_MD_SHUTDOWN
+#define _MD_LISTEN                    _PR_MD_LISTEN
+extern PRInt32 _MD_CloseSocket(PRInt32 osfd);
+#define _MD_CLOSE_SOCKET              _MD_CloseSocket
+#define _MD_SENDTO                    _PR_MD_SENDTO
+#define _MD_RECVFROM                  _PR_MD_RECVFROM
+#define _MD_SOCKETPAIR(s, type, proto, sv) -1
+#define _MD_GETSOCKNAME               _PR_MD_GETSOCKNAME
+#define _MD_GETPEERNAME               _PR_MD_GETPEERNAME
+#define _MD_GETSOCKOPT                _PR_MD_GETSOCKOPT
+#define _MD_SETSOCKOPT                _PR_MD_SETSOCKOPT
+#define _MD_SET_FD_INHERITABLE        _PR_MD_SET_FD_INHERITABLE
+#define _MD_SELECT                    select
+#define _MD_FSYNC                     _PR_MD_FSYNC
+#define READ_FD                       1
+#define WRITE_FD                      2
+
+#define _MD_INIT_ATOMIC()
+#if defined(_M_IX86) || defined(_X86_)
+#define _MD_ATOMIC_INCREMENT          _PR_MD_ATOMIC_INCREMENT
+#define _MD_ATOMIC_ADD          	  _PR_MD_ATOMIC_ADD
+#define _MD_ATOMIC_DECREMENT          _PR_MD_ATOMIC_DECREMENT
+#else /* non-x86 processors */
+#define _MD_ATOMIC_INCREMENT(x)       InterlockedIncrement((PLONG)x)
+#if defined(WINCE)
+#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchange((PLONG)ptr, (*(PLONG)ptr) + (LONG)val) + val)
+#else
+#define _MD_ATOMIC_ADD(ptr,val)    (InterlockedExchangeAdd((PLONG)ptr, (LONG)val) + val)
+#endif
+#define _MD_ATOMIC_DECREMENT(x)       InterlockedDecrement((PLONG)x)
+#endif /* x86 */
+#define _MD_ATOMIC_SET(x,y)           InterlockedExchange((PLONG)x, (LONG)y)
+
+#define _MD_INIT_IO                   _PR_MD_INIT_IO
+
+
+/* wince doesn't have async IO */
+#define _MD_SOCKET                    _PR_MD_SOCKET
+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,
+                          PRIntervalTime timeout);
+#define _MD_ACCEPT                    _MD_Accept
+#define _MD_BIND                      _PR_MD_BIND
+#define _MD_RECV                      _PR_MD_RECV
+#define _MD_SEND                      _PR_MD_SEND
+#define _MD_PR_POLL                   _PR_MD_PR_POLL
+
+/* --- Scheduler stuff --- */
+// #define _MD_PAUSE_CPU                 _PR_MD_PAUSE_CPU
+#define _MD_PAUSE_CPU
+
+/* --- DIR stuff --- */
+#define PR_DIRECTORY_SEPARATOR        '\\'
+#define PR_DIRECTORY_SEPARATOR_STR    "\\"
+#define PR_PATH_SEPARATOR		';'
+#define PR_PATH_SEPARATOR_STR		";"
+#define _MD_ERRNO()                   GetLastError()
+#define _MD_OPEN_DIR                  _PR_MD_OPEN_DIR
+#define _MD_CLOSE_DIR                 _PR_MD_CLOSE_DIR
+#define _MD_READ_DIR                  _PR_MD_READ_DIR
+
+/* --- Segment stuff --- */
+#define _MD_INIT_SEGS()
+#define _MD_ALLOC_SEGMENT(seg, size, vaddr)   0
+#define _MD_FREE_SEGMENT(seg)
+
+/* --- Environment Stuff --- */
+#define _MD_GET_ENV                 _PR_MD_GET_ENV
+#define _MD_PUT_ENV                 _PR_MD_PUT_ENV
+
+/* --- Threading Stuff --- */
+#define _MD_DEFAULT_STACK_SIZE            0
+#define _MD_INIT_THREAD             _PR_MD_INIT_THREAD
+#define _MD_INIT_ATTACHED_THREAD    _PR_MD_INIT_THREAD
+#define _MD_CREATE_THREAD           _PR_MD_CREATE_THREAD
+#define _MD_YIELD                   _PR_MD_YIELD
+#define _MD_SET_PRIORITY            _PR_MD_SET_PRIORITY
+#define _MD_CLEAN_THREAD            _PR_MD_CLEAN_THREAD
+#define _MD_SETTHREADAFFINITYMASK   _PR_MD_SETTHREADAFFINITYMASK
+#define _MD_GETTHREADAFFINITYMASK   _PR_MD_GETTHREADAFFINITYMASK
+#define _MD_EXIT_THREAD             _PR_MD_EXIT_THREAD
+#define _MD_EXIT                    _PR_MD_EXIT
+#define _MD_SUSPEND_THREAD          _PR_MD_SUSPEND_THREAD
+#define _MD_RESUME_THREAD           _PR_MD_RESUME_THREAD
+#define _MD_SUSPEND_CPU             _PR_MD_SUSPEND_CPU
+#define _MD_RESUME_CPU              _PR_MD_RESUME_CPU
+#define _MD_BEGIN_SUSPEND_ALL()
+#define _MD_BEGIN_RESUME_ALL()
+#define _MD_END_SUSPEND_ALL()
+#define _MD_END_RESUME_ALL()
+
+/* --- Lock stuff --- */
+#define _PR_LOCK                      _MD_LOCK
+#define _PR_UNLOCK					  _MD_UNLOCK
+
+#define _MD_NEW_LOCK(lock)            (InitializeCriticalSection(&((lock)->mutex)),(lock)->notified.length=0,(lock)->notified.link=NULL,PR_SUCCESS)
+#define _MD_FREE_LOCK(lock)           DeleteCriticalSection(&((lock)->mutex))
+#define _MD_LOCK(lock)                EnterCriticalSection(&((lock)->mutex))
+#define _MD_TEST_AND_LOCK(lock)       (EnterCriticalSection(&((lock)->mutex)),0)
+#define _MD_UNLOCK                    _PR_MD_UNLOCK
+
+/* --- lock and cv waiting --- */
+#define _MD_WAIT                      _PR_MD_WAIT
+#define _MD_WAKEUP_WAITER             _PR_MD_WAKEUP_WAITER
+
+/* --- CVar ------------------- */
+#define _MD_WAIT_CV					  _PR_MD_WAIT_CV
+#define _MD_NEW_CV					  _PR_MD_NEW_CV
+#define _MD_FREE_CV					  _PR_MD_FREE_CV
+#define _MD_NOTIFY_CV				  _PR_MD_NOTIFY_CV	
+#define _MD_NOTIFYALL_CV			  _PR_MD_NOTIFYALL_CV
+
+/* XXXMB- the IOQ stuff is certainly not working correctly yet. */
+// extern  struct _MDLock              _pr_ioq_lock;
+#define _MD_IOQ_LOCK()                
+#define _MD_IOQ_UNLOCK()              
+
+
+/* --- Initialization stuff --- */
+#define _MD_START_INTERRUPTS()
+#define _MD_STOP_INTERRUPTS()
+#define _MD_DISABLE_CLOCK_INTERRUPTS()
+#define _MD_ENABLE_CLOCK_INTERRUPTS()
+#define _MD_BLOCK_CLOCK_INTERRUPTS()
+#define _MD_UNBLOCK_CLOCK_INTERRUPTS()
+#define _MD_EARLY_INIT                _PR_MD_EARLY_INIT
+#define _MD_FINAL_INIT()
+#define _MD_INIT_CPUS()
+#define _MD_INIT_RUNNING_CPU(cpu)
+
+struct PRProcess;
+struct PRProcessAttr;
+
+#define _MD_CREATE_PROCESS _PR_CreateWindowsProcess
+extern struct PRProcess * _PR_CreateWindowsProcess(
+                                                   const char *path,
+                                                   char *const *argv,
+                                                   char *const *envp,
+                                                   const struct PRProcessAttr *attr
+                                                   );
+
+#define _MD_DETACH_PROCESS _PR_DetachWindowsProcess
+extern PRStatus _PR_DetachWindowsProcess(struct PRProcess *process);
+
+/* --- Wait for a child process to terminate --- */
+#define _MD_WAIT_PROCESS _PR_WaitWindowsProcess
+extern PRStatus _PR_WaitWindowsProcess(struct PRProcess *process, 
+                                       PRInt32 *exitCode);
+
+#define _MD_KILL_PROCESS _PR_KillWindowsProcess
+extern PRStatus _PR_KillWindowsProcess(struct PRProcess *process);
+
+#define _MD_CLEANUP_BEFORE_EXIT           _PR_MD_CLEANUP_BEFORE_EXIT
+#define _MD_INIT_CONTEXT
+#define _MD_SWITCH_CONTEXT
+#define _MD_RESTORE_CONTEXT
+
+/* --- Intervals --- */
+#define _MD_INTERVAL_INIT                 _PR_MD_INTERVAL_INIT
+#define _MD_GET_INTERVAL                  _PR_MD_GET_INTERVAL
+#define _MD_INTERVAL_PER_SEC              _PR_MD_INTERVAL_PER_SEC
+#define _MD_INTERVAL_PER_MILLISEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000)
+#define _MD_INTERVAL_PER_MICROSEC()       (_PR_MD_INTERVAL_PER_SEC() / 1000000)
+
+/* --- Native-Thread Specific Definitions ------------------------------- */
+
+extern struct PRThread * _MD_CURRENT_THREAD(void);
+
+#ifdef _PR_USE_STATIC_TLS
+extern __declspec(thread) struct PRThread *_pr_currentThread;
+#define _MD_GET_ATTACHED_THREAD() _pr_currentThread
+#define _MD_SET_CURRENT_THREAD(_thread) (_pr_currentThread = (_thread))
+
+extern __declspec(thread) struct PRThread *_pr_thread_last_run;
+#define _MD_LAST_THREAD() _pr_thread_last_run
+#define _MD_SET_LAST_THREAD(_thread) (_pr_thread_last_run = 0)
+
+extern __declspec(thread) struct _PRCPU *_pr_currentCPU;
+#define _MD_CURRENT_CPU() _pr_currentCPU
+#define _MD_SET_CURRENT_CPU(_cpu) (_pr_currentCPU = 0)
+#else /* _PR_USE_STATIC_TLS */
+extern DWORD _pr_currentThreadIndex;
+#define _MD_GET_ATTACHED_THREAD() ((PRThread *) TlsGetValue(_pr_currentThreadIndex))
+#define _MD_SET_CURRENT_THREAD(_thread) TlsSetValue(_pr_currentThreadIndex, (_thread))
+
+extern DWORD _pr_lastThreadIndex;
+#define _MD_LAST_THREAD() ((PRThread *) TlsGetValue(_pr_lastThreadIndex))
+#define _MD_SET_LAST_THREAD(_thread) TlsSetValue(_pr_lastThreadIndex, 0)
+
+extern DWORD _pr_currentCPUIndex;
+#define _MD_CURRENT_CPU() ((struct _PRCPU *) TlsGetValue(_pr_currentCPUIndex))
+#define _MD_SET_CURRENT_CPU(_cpu) TlsSetValue(_pr_currentCPUIndex, 0)
+#endif /* _PR_USE_STATIC_TLS */
+
+/* --- Scheduler stuff --- */
+#define LOCK_SCHEDULER()                 0
+#define UNLOCK_SCHEDULER()               0
+#define _PR_LockSched()                	 0
+#define _PR_UnlockSched()                0
+
+/* --- Initialization stuff --- */
+#define _MD_INIT_LOCKS()
+
+/* --- Stack stuff --- */
+#define _MD_INIT_STACK(stack, redzone)
+#define _MD_CLEAR_STACK(stack)
+
+/* --- Memory-mapped files stuff --- */
+
+struct _MDFileMap {
+  HANDLE hFileMap;
+  DWORD dwAccess;
+};
+
+extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
+#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
+
+extern PRInt32 _MD_GetMemMapAlignment(void);
+#define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
+
+extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
+                         PRUint32 len);
+#define _MD_MEM_MAP _MD_MemMap
+
+extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
+#define _MD_MEM_UNMAP _MD_MemUnmap
+
+extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
+#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
+
+/* --- Named semaphores stuff --- */
+#define _PR_HAVE_NAMED_SEMAPHORES
+#define _MD_OPEN_SEMAPHORE            _PR_MD_OPEN_SEMAPHORE
+#define _MD_WAIT_SEMAPHORE            _PR_MD_WAIT_SEMAPHORE
+#define _MD_POST_SEMAPHORE            _PR_MD_POST_SEMAPHORE
+#define _MD_CLOSE_SEMAPHORE           _PR_MD_CLOSE_SEMAPHORE
+#define _MD_DELETE_SEMAPHORE(name)    PR_SUCCESS  /* no op */
+
+
+#endif /* nspr_wince_defs_h___ */
--- a/pr/include/md/prosdep.h
+++ b/pr/include/md/prosdep.h
@@ -46,17 +46,17 @@
 PR_BEGIN_EXTERN_C
 
 #ifdef XP_PC
 
 #include "md/_pcos.h"
 #ifdef WINNT
 #include "md/_winnt.h"
 #include "md/_win32_errors.h"
-#elif defined(WIN95)
+#elif defined(WIN95) || defined(WINCE)
 #include "md/_win95.h"
 #include "md/_win32_errors.h"
 #elif defined(WIN16)
 #include "md/_win16.h"
 #elif defined(OS2)
 #include "md/_os2.h"
 #include "md/_os2_errors.h"
 #else
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -75,16 +75,17 @@
 ** Example:
 **   in dowhim.h
 **     PR_EXTERN( void ) DoWhatIMean( void );
 **   in dowhim.c
 **     PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
 **
 **
 ***********************************************************************/
+
 #if defined(WIN32)
 
 #define PR_EXPORT(__type) extern __declspec(dllexport) __type
 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
 #define PR_IMPORT(__type) __declspec(dllimport) __type
 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
 
 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
@@ -199,16 +200,17 @@
 #define PR_CALLBACK_DECL
 #define PR_STATIC_CALLBACK(__x) static __x
 
 #endif
 
 #if defined(_NSPR_BUILD_)
 #define NSPR_API(__type) PR_EXPORT(__type)
 #define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
+
 #else
 #define NSPR_API(__type) PR_IMPORT(__type)
 #define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
 #endif
 
 /***********************************************************************
 ** MACROS:      PR_BEGIN_MACRO
 **              PR_END_MACRO
--- a/pr/src/io/prio.c
+++ b/pr/src/io/prio.c
@@ -49,17 +49,17 @@ void _PR_InitIO(void)
 {
     const PRIOMethods *methods = PR_GetFileMethods();
 
     _PR_InitFdCache();
 
     _pr_flock_lock = PR_NewLock();
     _pr_flock_cv = PR_NewCondVar(_pr_flock_lock);
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(WINCE)
     _pr_stdin = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_INPUT_HANDLE),
             methods);
     _pr_stdout = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_OUTPUT_HANDLE),
             methods);
     _pr_stderr = PR_AllocFileDesc((PRInt32)GetStdHandle(STD_ERROR_HANDLE),
             methods);
 #ifdef WINNT
     _pr_stdin->secret->md.sync_file_io = PR_TRUE;
--- a/pr/src/io/prlog.c
+++ b/pr/src/io/prlog.c
@@ -381,18 +381,20 @@ PR_IMPLEMENT(PRBool) PR_SetLogFile(const
     }
     else
 #endif
     {
         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
         && logFile != stderr
 #ifdef XP_PC
         && logFile != WIN32_DEBUG_FILE
 #endif
         ) {
--- a/pr/src/md/windows/Makefile.in
+++ b/pr/src/md/windows/Makefile.in
@@ -57,17 +57,17 @@ CSRCS = \
     w16io.c  \
     w16gc.c  \
     w16error.c  \
     w16stdio.c  \
     w16callb.c \
     ntinrval.c \
     $(NULL)
 else
-ifeq ($(OS_TARGET), WIN95)
+ifneq ($(OS_TARGET), WINNT)
 CSRCS =          \
     ntmisc.c \
     ntsec.c   \
     ntsem.c   \
     ntinrval.c \
     ntgc.c \
 	w95thred.c \
 	w95io.c \
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -314,16 +314,17 @@ PRProcess * _PR_CreateWindowsProcess(
         goto errorExit;
     }
 
     if (assembleCmdLine(argv, &cmdLine) == -1) {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
         goto errorExit;
     }
 
+#ifndef WINCE
     /*
      * If attr->fdInheritBuffer is not NULL, we need to insert
      * it into the envp array, so envp cannot be NULL.
      */
     if ((envp == NULL) && attr && attr->fdInheritBuffer) {
         envp = environ;
     }
 
@@ -382,16 +383,17 @@ PRProcess * _PR_CreateWindowsProcess(
             startupInfo.hStdError = (HANDLE) attr->stderrFd->secret->md.osfd;
             redirected = PR_TRUE;
         }
         if (redirected) {
             startupInfo.dwFlags |= STARTF_USESTDHANDLES;
         }
         cwd = attr->currentDirectory;
     }
+#endif
 
     retVal = CreateProcess(NULL,
                            cmdLine,
                            NULL,  /* security attributes for the new
                                    * process */
                            NULL,  /* security attributes for the primary
                                    * thread in the new process */
                            TRUE,  /* inherit handles */
@@ -592,19 +594,24 @@ PRStatus _MD_CreateFileMap(PRFileMap *fm
 
     if (fmap->prot == PR_PROT_READONLY) {
         flProtect = PAGE_READONLY;
         fmap->md.dwAccess = FILE_MAP_READ;
     } else if (fmap->prot == PR_PROT_READWRITE) {
         flProtect = PAGE_READWRITE;
         fmap->md.dwAccess = FILE_MAP_WRITE;
     } else {
+#ifdef WINCE
+        // WINCE does not have MAP COPY
+      return PR_FAILURE;
+#else
         PR_ASSERT(fmap->prot == PR_PROT_WRITECOPY);
         flProtect = PAGE_WRITECOPY;
         fmap->md.dwAccess = FILE_MAP_COPY;
+#endif
     }
 
     fmap->md.hFileMap = CreateFileMapping(
         (HANDLE) osfd,
         NULL,
         flProtect,
         dwHi,
         dwLo,
--- a/pr/src/md/windows/ntsec.c
+++ b/pr/src/md/windows/ntsec.c
@@ -64,16 +64,17 @@ static struct {
 /*
  * Initialize the SIDs for owner, primary group, and the Everyone
  * group in the _pr_nt_sids structure.
  *
  * This function needs to be called by NSPR initialization.
  */
 void _PR_NT_InitSids(void)
 {
+#ifndef WINCE
     SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
     HANDLE hToken = NULL; /* initialized to an arbitrary value to
                            * silence a Purify UMR warning */
     UCHAR infoBuffer[1024];
     PTOKEN_OWNER pTokenOwner = (PTOKEN_OWNER) infoBuffer;
     PTOKEN_PRIMARY_GROUP pTokenPrimaryGroup
             = (PTOKEN_PRIMARY_GROUP) infoBuffer;
     DWORD dwLength;
@@ -123,36 +124,39 @@ void _PR_NT_InitSids(void)
     PR_ASSERT(rv != 0);
 
     /* Create a well-known SID for the Everyone group. */
     rv = AllocateAndInitializeSid(&SIDAuthWorld, 1,
             SECURITY_WORLD_RID,
             0, 0, 0, 0, 0, 0, 0,
             &_pr_nt_sids.everyone);
     PR_ASSERT(rv != 0);
+#endif
 }
 
 /*
  * Free the SIDs for owner, primary group, and the Everyone group
  * in the _pr_nt_sids structure.
  *
  * This function needs to be called by NSPR cleanup.
  */
 void
 _PR_NT_FreeSids(void)
 {
+#ifndef WINCE
     if (_pr_nt_sids.owner) {
         PR_Free(_pr_nt_sids.owner);
     }
     if (_pr_nt_sids.group) {
         PR_Free(_pr_nt_sids.group);
     }
     if (_pr_nt_sids.everyone) {
         FreeSid(_pr_nt_sids.everyone);
     }
+#endif
 }
 
 /*
  * Construct a security descriptor whose discretionary access-control
  * list implements the specified mode bits.  The SIDs for owner, group,
  * and everyone are obtained from the global _pr_nt_sids structure.
  * Both the security descriptor and access-control list are returned
  * and should be freed by a _PR_NT_FreeSecurityDescriptorACL call.
@@ -163,16 +167,20 @@ void
  */
 PRStatus
 _PR_NT_MakeSecurityDescriptorACL(
     PRIntn mode,
     DWORD accessTable[],
     PSECURITY_DESCRIPTOR *resultSD,
     PACL *resultACL)
 {
+#ifdef WINCE
+  PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
+ return PR_FAILURE;
+#else
     PSECURITY_DESCRIPTOR pSD = NULL;
     PACL pACL = NULL;
     DWORD cbACL;  /* size of ACL */
     DWORD accessMask;
 
     if (_pr_nt_sids.owner == NULL) {
         PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
         return PR_FAILURE;
@@ -256,24 +264,27 @@ PRStatus
 failed:
     if (pSD) {
         PR_Free(pSD);
     }
     if (pACL) {
         PR_Free(pACL);
     }
     return PR_FAILURE;
+#endif
 }
 
 /*
  * Free the specified security descriptor and access-control list
  * previously created by _PR_NT_MakeSecurityDescriptorACL.
  */
 void
 _PR_NT_FreeSecurityDescriptorACL(PSECURITY_DESCRIPTOR pSD, PACL pACL)
 {
+#ifndef WINCE
     if (pSD) {
         PR_Free(pSD);
     }
     if (pACL) {
         PR_Free(pACL);
     }
+#endif
 }
--- a/pr/src/md/windows/objs.mk
+++ b/pr/src/md/windows/objs.mk
@@ -46,17 +46,18 @@ CSRCS = ntmisc.c \
 	ntthread.c \
 	ntdllmn.c \
 	win32_errors.c \
 	w32ipcsem.c \
 	w32poll.c \
 	w32rng.c \
 	w32shm.c
 else
-ifeq ($(OS_TARGET),WIN95)
+#same as win16
+ifeq ($(OS_TARGET),WINCE) 
 CSRCS =	ntmisc.c \
 	ntsec.c \
 	ntsem.c \
 	ntinrval.c \
 	ntgc.c \
 	w95thred.c \
 	w95io.c \
 	w95cv.c \
@@ -77,17 +78,17 @@ CSRCS =	w16null.c \
 	w16mem.c \
 	w16io.c \
 	w16gc.c \
 	w16error.c \
 	w16stdio.c \
 	w16callb.c \
 	ntinrval.c
 endif # win16
-endif # win95
+endif # win95 || wince
 endif # winnt
 
 CSRCS	+= $(PR_MD_CSRCS)
 ASFILES += $(PR_MD_ASFILES)
 
 OBJS += $(addprefix md/windows/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)))  \
 	$(addprefix md/windows/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
 
--- a/pr/src/md/windows/w32rng.c
+++ b/pr/src/md/windows/w32rng.c
@@ -91,17 +91,18 @@ extern PRSize _PR_MD_GetRandomNoise( voi
     nBytes = sizeof(dwVal) > size ? size : sizeof(dwVal);
     memcpy(((char *)buf) + n, &dwVal, nBytes);
     n += nBytes;
     size -= nBytes;
 
     if (size <= 0)
         return n;
 
+#ifndef WINCE
     // get the time in seconds since midnight Jan 1, 1970
     time(&sTime);
     nBytes = sizeof(sTime) > size ? size : sizeof(sTime);
     memcpy(((char *)buf) + n, &sTime, nBytes);
     n += nBytes;
-
+#endif
     return n;
 }