diff options
author | wtc%netscape.com <devnull@localhost> | 2003-03-26 01:36:20 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2003-03-26 01:36:20 +0000 |
commit | 121b06591deb962cffe147b91e427d212ab8dbca (patch) | |
tree | 49d65cb760bfbdf4d2e9c6f0854cfad826d1823a | |
parent | 372d4f43f488cc078c9d30d7b503b2fac94e1740 (diff) | |
download | nspr-hg-121b06591deb962cffe147b91e427d212ab8dbca.tar.gz |
Bug 188246: support building NSPR with gcc 3.x on OS/2. also fixed the
tests. The patch is contributed by Javier Pedemonte <pedemont@us.ibm.com>.
Modified Files: configure configure.in rules.mk lib/ds/Makefile.in
lib/libc/src/Makefile.in _os2.h pr/src/Makefile.in prlink.c
pr/src/md/os2/Makefile.in pr/src/md/os2/objs.mk os2cv.c os2misc.c
os2poll.c os2sock.c os2thred.c pr/tests/Makefile.in attach.c runtests.sh
Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
Added Files: os2emx.s
-rw-r--r-- | config/rules.mk | 33 | ||||
-rwxr-xr-x | configure | 87 | ||||
-rw-r--r-- | configure.in | 49 | ||||
-rw-r--r-- | lib/ds/Makefile.in | 6 | ||||
-rw-r--r-- | lib/libc/src/Makefile.in | 6 | ||||
-rw-r--r-- | pr/include/md/_os2.h | 8 | ||||
-rw-r--r-- | pr/src/Makefile.in | 6 | ||||
-rw-r--r-- | pr/src/linking/prlink.c | 4 | ||||
-rw-r--r-- | pr/src/md/os2/Makefile.in | 4 | ||||
-rw-r--r-- | pr/src/md/os2/objs.mk | 6 | ||||
-rw-r--r-- | pr/src/md/os2/os2cv.c | 4 | ||||
-rw-r--r-- | pr/src/md/os2/os2emx.s | 111 | ||||
-rw-r--r-- | pr/src/md/os2/os2misc.c | 40 | ||||
-rw-r--r-- | pr/src/md/os2/os2poll.c | 6 | ||||
-rw-r--r-- | pr/src/md/os2/os2sock.c | 32 | ||||
-rw-r--r-- | pr/src/md/os2/os2thred.c | 8 | ||||
-rw-r--r-- | pr/tests/Makefile.in | 7 | ||||
-rw-r--r-- | pr/tests/attach.c | 20 | ||||
-rwxr-xr-x | pr/tests/runtests.sh | 2 |
19 files changed, 275 insertions, 164 deletions
diff --git a/config/rules.mk b/config/rules.mk index 3cecd88d..29f6d663 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -311,8 +311,9 @@ endif $(RANLIB) $@ ifeq ($(OS_TARGET), OS2) -$(IMPORT_LIBRARY): $(SHARED_LIBRARY) - $(IMPLIB) $@ $(SHARED_LIBRARY).def +$(IMPORT_LIBRARY): $(MAPFILE) + rm -f $@ + $(IMPLIB) $@ $(MAPFILE) endif $(SHARED_LIBRARY): $(OBJS) $(MAPFILE) @@ -330,16 +331,9 @@ else # AIX 4.1 ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) $(LINK_DLL) -MAP $(DLLBASE) $(DLL_LIBS) $(EXTRA_LIBS) $(OBJS) else -ifeq ($(OS_ARCH),OS2) -# append ( >> ) doesn't seem to be working under OS/2 gmake. Run through OS/2 shell instead. - @cmd /C "echo LIBRARY $(notdir $(basename $(SHARED_LIBRARY))) INITINSTANCE TERMINSTANCE >$@.def" - @cmd /C "echo PROTMODE >>$@.def" - @cmd /C "echo CODE LOADONCALL MOVEABLE DISCARDABLE >>$@.def" - @cmd /C "echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >>$@.def" - @cmd /C "echo EXPORTS >>$@.def" - @cmd /C "$(FILTER) $(LIBRARY) | grep -v _DLL_InitTerm >>$@.def" - $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $@.def -else # OS2 +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $(MAPFILE) +else # !os2 vacpp ifeq ($(OS_TARGET), OpenVMS) @if test ! -f $(VMS_SYMVEC_FILE); then \ if test -f $(VMS_SYMVEC_FILE_MODULE); then \ @@ -349,7 +343,7 @@ ifeq ($(OS_TARGET), OpenVMS) fi endif # OpenVMS $(MKSHLIB) $(OBJS) $(EXTRA_LIBS) -endif # OS2 +endif # OS2 vacpp endif # WINNT endif # AIX 4.1 ifdef ENABLE_STRIP @@ -372,13 +366,24 @@ endif @echo $(RES) finished endif +ifeq ($(OS_ARCH),SunOS) $(MAPFILE): $(LIBRARY_NAME).def @$(MAKE_OBJDIR) -ifeq ($(OS_ARCH),SunOS) grep -v ';-' $< | \ sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@ endif +ifeq ($(OS_ARCH),OS2) +$(MAPFILE): $(LIBRARY) + rm -f $@ + echo LIBRARY $(LIBRARY_NAME)$(LIBRARY_VERSION) INITINSTANCE TERMINSTANCE > $@ + echo PROTMODE >> $@ + echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@ + echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ + echo EXPORTS >> $@ + $(FILTER) $(LIBRARY) >> $@ +endif + $(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp @$(MAKE_OBJDIR) ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) @@ -1063,7 +1063,7 @@ EOF beos*) DEFINES="$DEFINES -DDEBUG_${USER}" ;; - msvc*|mksnt*|cygwin*|mingw*) + msvc*|mksnt*|cygwin*|mingw*|os2*) DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" ;; *) @@ -2529,7 +2529,7 @@ fi if test "$GXX" = "yes"; then GNU_CXX=1 fi -if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then GNU_AS=1 fi rm -f a.out @@ -4607,10 +4607,8 @@ EOF #define _PR_GLOBAL_THREADS_ONLY 1 EOF - OBJ_SUFFIX=obj LIB_SUFFIX=lib DLL_SUFFIX=dll - ASM_SUFFIX=asm RC=rc.exe PR_MD_ARCH_DIR=os2 PROG_SUFFIX=.exe @@ -4619,7 +4617,7 @@ EOF RESOLVE_LINK_SYMBOLS=1 # EMX/GCC build - if test "$GNU_CC"; then + if test -n "$GNU_CC"; then cat >> confdefs.h <<\EOF #define XP_OS2_EMX 1 EOF @@ -4630,29 +4628,30 @@ EOF AR=emxomfar AR_FLAGS='-p256 r $@' - CFLAGS="-Zmtd -Zomf" - HOST_CFLAGS="$CFLAGS" - CXXFLAGS="-Zmtd -Zomf" + CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll -Zmtd' + _OPTIMIZE_FLAGS=-O3 + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi OS_LIBS="-lsocket -lemxio" - LD='$(CC)' IMPLIB='emximp -o' - FILTER='emxexp' - OS_DLLFLAGS='$(DSO_LDOPTS) -o $@' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS=-g - if test -n "$MOZ_DEBUG"; then - DLLFLAGS='-g' - EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@' - DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' - else - DLLFLAGS= - EXEFLAGS='-Zmtd -o $@' - DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' + FILTER='emxexp -o' + + if test -z "$EMXOMFLD_LINKER"; then + # using LINK386.EXE + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" fi - fi - + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + # Visual Age C++ build - if test "$VACPP" = "yes"; then + elif test "$VACPP" = "yes"; then cat >> confdefs.h <<\EOF #define XP_OS2_VACPP 1 EOF @@ -4669,8 +4668,10 @@ EOF #define _X86_ 1 EOF + OBJ_SUFFIX=obj AS=alp ASFLAGS='-Mb' + ASM_SUFFIX=asm AR=-ilib AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' @@ -4715,12 +4716,12 @@ esac if test -z "$SKIP_LIBRARY_CHECKS"; then echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4719: checking for dlopen" >&5 +echo "configure:4720: checking for dlopen" >&5 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4724 "configure" +#line 4725 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen(); below. */ @@ -4743,7 +4744,7 @@ dlopen(); ; return 0; } EOF -if { (eval echo configure:4747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_dlopen=yes" else @@ -4762,7 +4763,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4766: checking for dlopen in -ldl" >&5 +echo "configure:4767: 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 @@ -4770,7 +4771,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4774 "configure" +#line 4775 "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 @@ -4781,7 +4782,7 @@ int main() { dlopen() ; return 0; } EOF -if { (eval echo configure:4785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4786: \"$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 @@ -4809,13 +4810,13 @@ fi if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4813: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:4814: 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 4819 "configure" +#line 4820 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -4833,7 +4834,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 4837 "configure" +#line 4838 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -4857,12 +4858,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4861: checking for $ac_func" >&5 +echo "configure:4862: 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 4866 "configure" +#line 4867 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4885,7 +4886,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4890: \"$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 @@ -4924,7 +4925,7 @@ hpux*) if test -z "$GNU_CC"; then echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 -echo "configure:4928: checking for +Olit support" >&5 +echo "configure:4929: 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 @@ -4958,7 +4959,7 @@ esac echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:4962: checking for pthread_create in -lpthreads" >&5 +echo "configure:4963: checking for pthread_create in -lpthreads" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -4980,7 +4981,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:4984: checking for pthread_create in -lpthread" >&5 +echo "configure:4985: checking for pthread_create in -lpthread" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5002,7 +5003,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:5006: checking for pthread_create in -lc_r" >&5 +echo "configure:5007: checking for pthread_create in -lc_r" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5024,7 +5025,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:5028: checking for pthread_create in -lc" >&5 +echo "configure:5029: checking for pthread_create in -lc" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5176,7 +5177,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:5180: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5181: 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 @@ -5199,7 +5200,7 @@ echo "configure:5180: 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:5203: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5204: checking whether ${CC-cc} accepts -pthreads" >&5 echo 'int main() { return 0; }' | cat > conftest.c ${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1 if test $? -eq 0; then diff --git a/configure.in b/configure.in index 91e0d4ee..9737dcd7 100644 --- a/configure.in +++ b/configure.in @@ -342,7 +342,7 @@ if test -n "$MOZ_DEBUG"; then beos*) DEFINES="$DEFINES -DDEBUG_${USER}" ;; - msvc*|mksnt*|cygwin*|mingw*) + msvc*|mksnt*|cygwin*|mingw*|os2*) DEFINES="$DEFINES -DDEBUG_`echo ${USERNAME} | sed -e 's| |_|g'`" ;; *) @@ -451,7 +451,7 @@ fi if test "$GXX" = "yes"; then GNU_CXX=1 fi -if test "`echo | $AS -V 2>&1 | grep -c GNU`" != "0"; then +if test "`echo | $AS -v 2>&1 | grep -c GNU`" != "0"; then GNU_AS=1 fi rm -f a.out @@ -1770,10 +1770,8 @@ mips-sony-newsos*) AC_DEFINE(XP_PC) AC_DEFINE(BSD_SELECT) AC_DEFINE(_PR_GLOBAL_THREADS_ONLY) - OBJ_SUFFIX=obj LIB_SUFFIX=lib DLL_SUFFIX=dll - ASM_SUFFIX=asm RC=rc.exe PR_MD_ARCH_DIR=os2 PROG_SUFFIX=.exe @@ -1782,40 +1780,43 @@ mips-sony-newsos*) RESOLVE_LINK_SYMBOLS=1 # EMX/GCC build - if test "$GNU_CC"; then + if test -n "$GNU_CC"; then AC_DEFINE(XP_OS2_EMX) AC_DEFINE(OS2) AR=emxomfar AR_FLAGS='-p256 r $@' - CFLAGS="-Zmtd -Zomf" - HOST_CFLAGS="$CFLAGS" - CXXFLAGS="-Zmtd -Zomf" + CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' + DSO_CFLAGS= + DSO_LDOPTS='-Zomf -Zdll -Zmtd' + _OPTIMIZE_FLAGS=-O3 + _DEBUG_FLAGS="-g -fno-inline" + if test -n "$MOZ_OPTIMIZE"; then + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA" + fi OS_LIBS="-lsocket -lemxio" - LD='$(CC)' IMPLIB='emximp -o' - FILTER='emxexp' - OS_DLLFLAGS='$(DSO_LDOPTS) -o $@' - _OPTIMIZE_FLAGS=-O3 - _DEBUG_FLAGS=-g - if test -n "$MOZ_DEBUG"; then - DLLFLAGS='-g' - EXEFLAGS='-g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@' - DSO_LDOPTS='-g -Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' - else - DLLFLAGS= - EXEFLAGS='-Zmtd -o $@' - DSO_LDOPTS='-Zomf -Zdll -Zmt -Zcrtdll -Zlinker /NOO' + FILTER='emxexp -o' + + if test -z "$EMXOMFLD_LINKER"; then + # using LINK386.EXE + DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" fi - fi - + + # GCC for OS/2 currently predefines these, but we don't want them + DEFINES="$DEFINES -Uunix -U__unix -U__unix__" + # Visual Age C++ build - if test "$VACPP" = "yes"; then + elif test "$VACPP" = "yes"; then AC_DEFINE(XP_OS2_VACPP) AC_DEFINE(OS2,4) AC_DEFINE(TCPV40HDRS) AC_DEFINE(_X86_) + OBJ_SUFFIX=obj AS=alp ASFLAGS='-Mb' + ASM_SUFFIX=asm AR=-ilib AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)' CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl9' diff --git a/lib/ds/Makefile.in b/lib/ds/Makefile.in index 08b4dd3d..3a1cf40e 100644 --- a/lib/ds/Makefile.in +++ b/lib/ds/Makefile.in @@ -95,6 +95,12 @@ MKSHLIB += -M $(MAPFILE) endif endif +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/plds.def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + EXTRA_LIBS = $(LIBNSPR) # On NCR and SCOOS, we can't link with extra libraries when diff --git a/lib/libc/src/Makefile.in b/lib/libc/src/Makefile.in index 39f71a3c..d3502ecf 100644 --- a/lib/libc/src/Makefile.in +++ b/lib/libc/src/Makefile.in @@ -105,6 +105,12 @@ MKSHLIB += -M $(MAPFILE) endif endif +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/plc.def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + EXTRA_LIBS = $(LIBNSPR) # On NCR and SCOOS, we can't link with extra libraries when diff --git a/pr/include/md/_os2.h b/pr/include/md/_os2.h index 22fddd20..dc50982a 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -47,7 +47,10 @@ #include <errno.h> +#ifdef XP_OS2_VACPP +/* TODO RAMSEMs need to be written for GCC/EMX */ #define USE_RAMSEM +#endif #ifdef USE_RAMSEM #pragma pack(4) @@ -75,15 +78,14 @@ APIRET _Optlink SemReleasex86(PRAMSEM, ULONG); #ifdef XP_OS2_EMX /* * EMX-specific tweaks: - * o Use stricmp instead of strcmpi. * o Use errno rather than sock_errno() * o Use close rather than soclose * o Ignore sock_init calls. */ -#define strcmpi stricmp #define sock_errno() errno #define soclose close #define sock_init() +#include <string.h> #endif /* @@ -308,11 +310,13 @@ extern PRInt32 _MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, #define _MD_FSYNC _PR_MD_FSYNC #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) +#ifdef _PR_HAVE_ATOMIC_OPS #define _MD_INIT_ATOMIC() #define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT #define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD #define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT #define _MD_ATOMIC_SET _PR_MD_ATOMIC_SET +#endif #define _MD_INIT_IO (_PR_MD_INIT_IO) #define _MD_PR_POLL (_PR_MD_PR_POLL) diff --git a/pr/src/Makefile.in b/pr/src/Makefile.in index 7118c97f..fa472fdd 100644 --- a/pr/src/Makefile.in +++ b/pr/src/Makefile.in @@ -141,6 +141,12 @@ endif endif endif +ifeq ($(OS_ARCH),OS2) +MAPFILE = $(OBJDIR)/nspr.def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) +endif + ifeq ($(OS_ARCH),OSF1) ifeq ($(USE_PTHREADS), 1) OS_LIBS = -lpthread -lrt diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index c70f1065..d42ad219 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -580,9 +580,11 @@ pr_UnlockedFindLibrary(const char *name) while (lm) { const char* cp = strrchr(lm->name, PR_DIRECTORY_SEPARATOR); cp = cp ? cp + 1 : lm->name; -#ifdef XP_PC +#ifdef WIN32 /* Windows DLL names are case insensitive... */ if (strcmpi(np, cp) == 0) +#elif defined(XP_OS2) + if (stricmp(np, cp) == 0) #else if (strcmp(np, cp) == 0) #endif diff --git a/pr/src/md/os2/Makefile.in b/pr/src/md/os2/Makefile.in index 9898c88f..7db0b44b 100644 --- a/pr/src/md/os2/Makefile.in +++ b/pr/src/md/os2/Makefile.in @@ -62,6 +62,10 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP) ASFILES = os2vacpp.asm endif +ifeq ($(MOZ_OS2_TOOLS),EMX) +ASFILES = os2emx.s +endif + TARGETS = $(OBJS) INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private diff --git a/pr/src/md/os2/objs.mk b/pr/src/md/os2/objs.mk index 7c0bb943..3339a538 100644 --- a/pr/src/md/os2/objs.mk +++ b/pr/src/md/os2/objs.mk @@ -52,6 +52,10 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP) ASFILES = os2vacpp.asm endif +ifeq ($(MOZ_OS2_TOOLS),EMX) +ASFILES = os2emx.s +endif + OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ - $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.asm=.$(OBJ_SUFFIX))) + $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX))) diff --git a/pr/src/md/os2/os2cv.c b/pr/src/md/os2/os2cv.c index 76c96330..44e1e68b 100644 --- a/pr/src/md/os2/os2cv.c +++ b/pr/src/md/os2/os2cv.c @@ -51,6 +51,10 @@ #ifdef USE_RAMSEM ULONG _Far16 _Pascal Dos16GetInfoSeg(PSEL pselGlobal, PSEL pselLocal); +#ifdef XP_OS2_EMX +typedef unsigned short BOOL16; +#endif + typedef struct _LINFOSEG { USHORT pidCurrent; diff --git a/pr/src/md/os2/os2emx.s b/pr/src/md/os2/os2emx.s new file mode 100644 index 00000000..4dd81e39 --- /dev/null +++ b/pr/src/md/os2/os2emx.s @@ -0,0 +1,111 @@ +/ -*- 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) 2000 Netscape Communications Corporation. All +/ Rights Reserved. +/ +/ Contributor(s): +/ +/ 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. +/ + +/ PRInt32 __PR_MD_ATOMIC_INCREMENT(PRInt32 *val) +/ +/ Atomically increment the integer pointed to by 'val' and return +/ the result of the increment. +/ + .text + .globl __PR_MD_ATOMIC_INCREMENT + .align 4 +__PR_MD_ATOMIC_INCREMENT: + movl 4(%esp), %ecx + movl $1, %eax + lock + xaddl %eax, (%ecx) + incl %eax + ret + +/ PRInt32 __PR_MD_ATOMIC_DECREMENT(PRInt32 *val) +/ +/ Atomically decrement the integer pointed to by 'val' and return +/ the result of the decrement. +/ + .text + .globl __PR_MD_ATOMIC_DECREMENT + .align 4 +__PR_MD_ATOMIC_DECREMENT: + movl 4(%esp), %ecx + movl $-1, %eax + lock + xaddl %eax, (%ecx) + decl %eax + ret + +/ PRInt32 __PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) +/ +/ Atomically set the integer pointed to by 'val' to the new +/ value 'newval' and return the old value. +/ +/ An alternative implementation: +/ .text +/ .globl __PR_MD_ATOMIC_SET +/ .align 4 +/__PR_MD_ATOMIC_SET: +/ movl 4(%esp), %ecx +/ movl 8(%esp), %edx +/ movl (%ecx), %eax +/retry: +/ lock +/ cmpxchgl %edx, (%ecx) +/ jne retry +/ ret +/ + .text + .globl __PR_MD_ATOMIC_SET + .align 4 +__PR_MD_ATOMIC_SET: + movl 4(%esp), %ecx + movl 8(%esp), %eax + lock + xchgl %eax, (%ecx) + ret + +/ PRInt32 __PR_MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val) +/ +/ Atomically add 'val' to the integer pointed to by 'ptr' +/ and return the result of the addition. +/ + .text + .globl __PR_MD_ATOMIC_ADD + .align 4 +__PR_MD_ATOMIC_ADD: + movl 4(%esp), %ecx + movl 8(%esp), %eax + movl %eax, %edx + lock + xaddl %eax, (%ecx) + addl %edx, %eax + ret diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c index 3b7717f6..d14972c6 100644 --- a/pr/src/md/os2/os2misc.c +++ b/pr/src/md/os2/os2misc.c @@ -518,43 +518,3 @@ unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long fla return rc; } -#ifndef XP_OS2_VACPP - -PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *intp, PRInt32 val) -{ - PRInt32 result; - asm volatile ("lock ; xchg %0, %1" - : "=r"(result), "=m"(intp) - : "0"(val), "m"(intp)); - return result; -} - -PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *intp, PRInt32 val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(intp) - : "0"(val), "m"(intp)); - return result + val; -} - -PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(*val) - : "0"(1), "m"(*val)); - return result + 1; -} - -PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *val) -{ - PRInt32 result; - asm volatile ("lock ; xadd %0, %1" - : "=r"(result), "=m"(*val) - : "0"(1), "m"(*val)); - return result - 1; -} - -#endif - diff --git a/pr/src/md/os2/os2poll.c b/pr/src/md/os2/os2poll.c index 0b9c0de6..3b087e11 100644 --- a/pr/src/md/os2/os2poll.c +++ b/pr/src/md/os2/os2poll.c @@ -265,7 +265,7 @@ retry: ready = _MD_SELECT(socks, rd, wt, ex, msecs); #endif - if (ready == -1 && errno == SOCEINTR) + if (ready == -1 && errno == EINTR) { if (timeout == PR_INTERVAL_NO_TIMEOUT) goto retry; @@ -357,8 +357,8 @@ retry: if (getsockopt(bottom->secret->md.osfd, SOL_SOCKET, SO_TYPE, (char *) &optval, &optlen) == -1) { - PR_ASSERT(sock_errno() == SOCENOTSOCK); - if (sock_errno() == SOCENOTSOCK) + PR_ASSERT(sock_errno() == ENOTSOCK); + if (sock_errno() == ENOTSOCK) { pd->out_flags = PR_POLL_NVAL; ready++; diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c index ecdb31ff..b9c812ba 100644 --- a/pr/src/md/os2/os2sock.c +++ b/pr/src/md/os2/os2sock.c @@ -151,7 +151,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) else rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); #endif - if (rv == -1 && (syserror = sock_errno()) != SOCEINTR) { + if (rv == -1 && (syserror = sock_errno()) != EINTR) { _PR_MD_MAP_SELECT_ERROR(syserror); break; } @@ -209,7 +209,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) /* * we don't consider EINTR a real error */ - if (rv == -1 && (syserror = sock_errno()) != SOCEINTR) { + if (rv == -1 && (syserror = sock_errno()) != EINTR) { _PR_MD_MAP_SELECT_ERROR(syserror); break; } @@ -223,7 +223,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) * We loop again if _MD_SELECT timed out or got interrupted * by a signal, and the timeout deadline has not passed yet. */ - if (rv == 0 || (rv == -1 && syserror == SOCEINTR)) { + if (rv == 0 || (rv == -1 && syserror == EINTR)) { /* * If _MD_SELECT timed out, we know how much time * we spent in blocking, so we can avoid a @@ -252,7 +252,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) remaining = timeout - elapsed; } } - } while (rv == 0 || (rv == -1 && syserror == SOCEINTR)); + } while (rv == 0 || (rv == -1 && syserror == EINTR)); break; } return(rv); @@ -269,14 +269,14 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *addr, while ((rv = accept(osfd, (struct sockaddr*) addr, (int*)addrlen)) == -1) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK) || (err == SOCECONNABORTED)) + if ((err == EWOULDBLOCK) || (err == ECONNABORTED)) { if (fd->secret->nonblocking) { break; } if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) goto done; - } else if ((err == SOCEINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ continue; } else { break; @@ -314,7 +314,7 @@ retry: { err = sock_errno(); - if (err == SOCEINTR) { + if (err == EINTR) { if (_PR_PENDING_INTERRUPT(me)) { me->flags &= ~_PR_INTERRUPT; PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); @@ -323,7 +323,7 @@ retry: goto retry; } - if (!fd->secret->nonblocking && (err == SOCEINPROGRESS)) + if (!fd->secret->nonblocking && (err == EINPROGRESS)) { /* * socket_io_wait() may return -1 or 1. @@ -391,13 +391,13 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, while ((rv = recv(osfd,buf,amount,flags)) == -1) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK)) { + if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; } if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) goto done; - } else if ((err == SOCEINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ continue; } else { break; @@ -421,13 +421,13 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, while ((rv = send(osfd,buf,amount,flags)) == -1) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK)) { + if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; } if ((rv = socket_io_wait(osfd, WRITE_FD, timeout)) < 0) goto done; - } else if ((err == SOCEINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ continue; } else { break; @@ -465,7 +465,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, (struct sockaddr *) addr, addrlen)) == -1) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK)) + if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; @@ -498,13 +498,13 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, (struct sockaddr *) addr, (int *)addrlen)) == -1)) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK)) { + if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; } if ((rv = socket_io_wait(osfd, READ_FD, timeout)) < 0) goto done; - } else if ((err == SOCEINTR) && (!_PR_PENDING_INTERRUPT(me))){ + } else if ((err == EINTR) && (!_PR_PENDING_INTERRUPT(me))){ continue; } else { break; @@ -541,7 +541,7 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) { err = sock_errno(); - if ((err == SOCEWOULDBLOCK)) { + if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { break; } diff --git a/pr/src/md/os2/os2thred.c b/pr/src/md/os2/os2thred.c index 7c06126f..735856bd 100644 --- a/pr/src/md/os2/os2thred.c +++ b/pr/src/md/os2/os2thred.c @@ -93,14 +93,6 @@ PRStatus _PR_MD_INIT_THREAD(PRThread *thread) { APIRET rv; -#ifdef XP_OS2_EMX - /* disable SIGPIPE */ - struct sigaction sa; - sa.sa_handler = SIG_IGN; - sa.sa_flags = 0; - sigemptyset( &sa.sa_mask); - sigaction( SIGPIPE, &sa, NULL); -#endif if (thread->flags & (_PR_PRIMORDIAL | _PR_ATTACHED)) { _pr_SetThreadMDHandle(thread); diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index a1b7c686..17105b4e 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -233,9 +233,8 @@ ifeq ($(OS_ARCH),OS2) ifeq ($(MOZ_OS2_TOOLS),VACPP) LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO else -ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) - LDOPTS = -Zlinker /PM:VIO -endif + EXTRA_LIBS = $(OS_LIBS) + LDOPTS = -Zmtd -Zomf -Zlinker /PM:VIO -Zlinker /ST:0x30000 endif endif @@ -487,7 +486,7 @@ $(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX) ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT) link $(LDOPTS) $(EXTRA_LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -out:$@ else -ifeq ($(OS_ARCH),OS2) +ifeq ($(MOZ_OS2_TOOLS),VACPP) $(LD) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBNSPR) $(OS_LIBS) $(EXTRA_LIBS) else $(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBNSPR) $(EXTRA_LIBS) -o $@ diff --git a/pr/tests/attach.c b/pr/tests/attach.c index f13d7f3f..a17b31f5 100644 --- a/pr/tests/attach.c +++ b/pr/tests/attach.c @@ -329,19 +329,25 @@ int main(int argc, char **argv) #elif defined(OS2) +# ifdef __EMX__ + threadID = (TID) _beginthread((void *)threadStartFunc, NULL, + 32768, NULL); +# else threadID = (TID) _beginthread((void(* _Optlink)(void*))threadStartFunc, NULL, 32768, NULL); +# endif if (threadID == -1) { fprintf(stderr, "thread creation failed: error code %d\n", errno); - failed_already=1; - goto exit_now; + failed_already=1; + goto exit_now; } rv = DosWaitThread(&threadID, DCWW_WAIT); - if (debug_mode)PR_ASSERT(rv == NO_ERROR); - else if (rv == NO_ERROR) { - failed_already=1; - goto exit_now; - } + if (debug_mode) { + PR_ASSERT(rv == NO_ERROR); + } else if (rv != NO_ERROR) { + failed_already=1; + goto exit_now; + } #elif defined(XP_BEOS) diff --git a/pr/tests/runtests.sh b/pr/tests/runtests.sh index 4024e9cb..4ce755cb 100755 --- a/pr/tests/runtests.sh +++ b/pr/tests/runtests.sh @@ -225,7 +225,7 @@ printf "\nNSPR Test Results - $OBJDIR\n\n" printf "BEGIN\t\t\t`date`\n" printf "NSPR_TEST_LOGFILE\t${LOGFILE}\n\n" printf "Test\t\t\tResult\n\n" -if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] ; then +if [ $OS_PLATFORM = "Windows_95" ] || [ $OS_PLATFORM = "Windows_98" ] || [ $OS_PLATFORM = "Windows_NT" ] || [ $OS_PLATFORM = "OS/2" ] ; then for prog in $TESTS do printf "$prog" |