diff options
author | srinivas%netscape.com <devnull@localhost> | 2000-01-10 21:08:45 +0000 |
---|---|---|
committer | srinivas%netscape.com <devnull@localhost> | 2000-01-10 21:08:45 +0000 |
commit | 694a6d2b62f2d6a42c8983ddbe4549255b778e65 (patch) | |
tree | 88e555b19dfbe38747fd424e3fc24a36d448f859 | |
parent | 9f4864cbf70f2839d272775ef6c8d64536cd3417 (diff) | |
download | nspr-hg-694a6d2b62f2d6a42c8983ddbe4549255b778e65.tar.gz |
Update to OS/2 port; the build now uses OS_ARCH=OS2, in place of WINNT.
Checkin for sobotka@axess.com. Bugzilla 23544.
47 files changed, 535 insertions, 220 deletions
diff --git a/config/Makefile b/config/Makefile index 4625ce73..e4ffc4d2 100644 --- a/config/Makefile +++ b/config/Makefile @@ -24,11 +24,16 @@ INTERNAL_TOOLS = 1 include $(MOD_DEPTH)/config/config.mk -CSRCS = nsinstall.c now.c +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 -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -64,7 +69,14 @@ ifeq ($(OS_ARCH), HP-UX) endif endif -ifdef XP_OS2_EMX +ifeq ($(MOZ_OS2_TOOLS),EMX) +XCFLAGS = $(OS_EXE_CFLAGS) +ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) +XLDOPTS = -Zlinker /PM:VIO +endif +endif + +ifeq ($(MOZ_OS2_TOOLS),PGCC) XCFLAGS = $(OS_EXE_CFLAGS) XLDOPTS = -Zlinker /PM:VIO endif @@ -77,7 +89,7 @@ include $(MOD_DEPTH)/config/rules.mk PROGS = $(OBJDIR)/now$(PROG_SUFFIX) -ifeq ($(OS_ARCH),WINNT) +ifeq (,$(filter-out OS2 WINNT,$(OS_ARCH))) TARGETS = $(PROGS) else PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX) diff --git a/config/OS2.mk b/config/OS2.mk index cf2d53dd..3f008cb9 100644 --- a/config/OS2.mk +++ b/config/OS2.mk @@ -38,6 +38,10 @@ XP_OS2_EMX = 1 endif endif +ifeq ($(XP_OS2_EMX),1) +MOZ_EMXTAG = $(subst .,,$(MOZ_OS2_EMX_OBJECTFORMAT)) +endif + # # On OS/2 we proudly support gbash... # @@ -46,7 +50,7 @@ SHELL = GBASH.EXE CC = icc -q -DXP_OS2 -N10 CCC = icc -q -DXP_OS2 -DOS2=4 -N10 LINK = ilink -AR = ilib /noignorecase /nologo $(subst /,\\,$@) +AR = ilib /noignorecase /nologo /Out:$(subst /,\\,$@) RANLIB = @echo RANLIB BSDECHO = @echo BSDECHO NSINSTALL = nsinstall @@ -65,7 +69,7 @@ OBJ_SUFFIX = obj OS_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -ge- OS_EXE_CFLAGS = -W3 -Wcnd- -gm -gd+ -sd- -su4 -AR_EXTRA_ARGS = ,, +AR_EXTRA_ARGS = ifdef BUILD_OPT OPTIMIZER = -O+ -Oi @@ -88,9 +92,9 @@ DEFINES += -D_PR_GLOBAL_THREADS_ONLY -DBSD_SELECT # Name of the binary code directories ifdef MOZ_LITE -OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))_$(MOZ_OS2_TOOLS)$(OBJDIR_TAG).OBJ +OBJDIR_NAME = $(subst OS2,NAV,$(OS_CONFIG))_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ else -OBJDIR_NAME = $(OS_CONFIG)_$(MOZ_OS2_TOOLS)$(OBJDIR_TAG).OBJ +OBJDIR_NAME = $(OS_CONFIG)_$(MOZ_OS2_TOOLS)$(MOZ_EMXTAG)$(OBJDIR_TAG).OBJ endif OS_DLLFLAGS = -nologo -DLL -FREE -NOE @@ -99,7 +103,7 @@ ifdef XP_OS2_VACPP OS_LIBS = so32dll.lib tcp32dll.lib -DEFINES += -DXP_OS2_VACPP +DEFINES += -DXP_OS2_VACPP -DTCPV40HDRS else CC = gcc @@ -122,20 +126,26 @@ endif OS_LIBS = -lsocket -lemxio -DEFINES += -DXP_OS2 -DXP_OS2_EMX -DHAVE_SIGNED_CHAR +DEFINES += -DXP_OS2 -DXP_OS2_EMX -DOS2EMX_PLAIN_CHAR OS_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd OS_EXE_CFLAGS = $(OMF_FLAG) -Wall -Wno-unused -Zmtd OS_DLLFLAGS = $(OMF_FLAG) -Zmt -Zdll -Zcrtdll -o $@ +ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) +EXEFLAGS += -Zlinker /DE +endif ifdef BUILD_OPT OPTIMIZER = -O3 DLLFLAGS = EXEFLAGS = -Zmtd -o $@ else -OPTIMIZER = -g -DLLFLAGS = -g -EXEFLAGS = -g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@ +OPTIMIZER = -g #-s +DLLFLAGS = -g #-s +EXEFLAGS = -g $(OMF_FLAG) -Zmtd -L$(DIST)/lib -o $@ # -s +ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) +EXEFLAGS += -Zlinker /DE +endif endif AR_EXTRA_ARGS = diff --git a/config/arch.mk b/config/arch.mk index 10dfc6a9..67734e44 100644 --- a/config/arch.mk +++ b/config/arch.mk @@ -164,7 +164,7 @@ ifeq ($(OS_ARCH),CYGWIN_95-4.0) OS_TARGET := WIN95 endif ifeq ($(OS_ARCH),OS2) - OS_ARCH := WINNT + OS_ARCH := OS2 OS_TARGET := OS2 endif diff --git a/config/rules.mk b/config/rules.mk index 31bd759b..ed2a5f9f 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -81,7 +81,7 @@ endif # ifdef LIBRARY_NAME -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) # # Win95, Win16, and OS/2 require library names conforming to the 8.3 rule. @@ -112,7 +112,7 @@ endif endif ifndef TARGETS -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) else TARGETS = $(LIBRARY) $(SHARED_LIBRARY) @@ -146,11 +146,9 @@ endif ifeq ($(OS_ARCH), WINNT) ifneq ($(OS_TARGET), WIN16) -ifneq ($(OS_TARGET), OS2) OBJS += $(RES) endif endif -endif ALL_TRASH = $(TARGETS) $(OBJS) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAGE) \ $(NOSUCHFILE) \ @@ -184,7 +182,7 @@ install:: +$(LOOP_OVER_DIRS) clean:: - rm -rf $(OBJS) so_locations $(NOSUCHFILE) + rm -rf $(OBJS) so_locations $(NOSUCHFILE) $(GARBAGE) +$(LOOP_OVER_DIRS) clobber:: @@ -259,13 +257,17 @@ $(PROGRAM): $(OBJS) ifeq ($(OS_ARCH),WINNT) $(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) else +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(CC) $(OBJS) -Fe$@ $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) +else $(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS) endif +endif $(LIBRARY): $(OBJS) @$(MAKE_OBJDIR) rm -f $@ -ifdef XP_OS2_VACPP +ifneq ($(MOZ_OS2_TOOLS),VACPP) $(AR) $(subst /,\\,$(OBJS)) $(AR_EXTRA_ARGS) else ifdef USE_AUTOCONF @@ -319,20 +321,19 @@ ifeq ($(OS_TARGET), WIN16) $(LINK) @w16link. rm w16link else # WIN16 -ifeq ($(OS_TARGET), OS2) + $(LINK_DLL) -MAP $(DLLBASE) $(OS_LIBS) $(EXTRA_LIBS) $(OBJS) +endif # WINNT +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) >> $@.def" + @cmd /C "$(FILTER) $(LIBRARY) | grep -v _DLL_InitTerm >>$@.def" $(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $@.def -else - $(LINK_DLL) -MAP $(DLLBASE) $(OS_LIBS) $(EXTRA_LIBS) $(OBJS) -endif # OS2 -endif # WIN16 -else # WINNT +else # OS2 ifeq ($(OS_TARGET), OpenVMS) @if test ! -f $(OBJDIR)/VMSuni.opt; then \ echo "Creating universal symbol option file $(OBJDIR)/VMSuni.opt";\ @@ -344,11 +345,13 @@ ifeq ($(OS_TARGET), OpenVMS) else # OpenVMS $(MKSHLIB) -o $@ $(OBJS) $(EXTRA_LIBS) $(OS_LIBS) endif # OpenVMS +endif # OS2 endif # WINNT endif # AIX 4.1 endif # USE_AUTOCONF -ifeq ($(OS_ARCH), WINNT) + +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) $(RES): $(RESNAME) @$(MAKE_OBJDIR) ifeq ($(OS_TARGET),OS2) @@ -363,14 +366,14 @@ endif $(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp @$(MAKE_OBJDIR) ifeq ($(OS_ARCH), WINNT) -ifndef XP_OS2_EMX $(CCC) -Fo$@ -c $(CCCFLAGS) $< else - $(CCC) -o $@ -c $(CCCFLAGS) $< -endif +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(CCC) -Fo$@ -c $(CCCFLAGS) $< else $(CCC) -o $@ -c $(CCCFLAGS) $< endif +endif WCCFLAGS1 = $(subst /,\\,$(CFLAGS)) WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1)) @@ -384,15 +387,16 @@ ifeq ($(OS_TARGET), WIN16) $(CC) -zq -fo$(OBJDIR)\\$*.$(OBJ_SUFFIX) @w16wccf $*.c rm w16wccf else -ifndef XP_OS2_EMX $(CC) -Fo$@ -c $(CFLAGS) $< -else - $(CC) -o $@ -c $(CFLAGS) $< -endif endif else +ifeq ($(MOZ_OS2_TOOLS),VACPP) + $(CC) -Fo$@ -c $(CFLAGS) $< +else $(CC) -o $@ -c $(CFLAGS) $< endif +endif + $(OBJDIR)/%.$(OBJ_SUFFIX): %.s @$(MAKE_OBJDIR) diff --git a/lib/ds/Makefile b/lib/ds/Makefile index f01741ec..b3076f3c 100644 --- a/lib/ds/Makefile +++ b/lib/ds/Makefile @@ -45,13 +45,9 @@ HEADERS = \ $(NULL) ifeq ($(OS_ARCH), WINNT) -ifeq (,$(filter-out WIN16 OS2,$(OS_TARGET))) +ifeq ($(OS_TARGET), WIN16) # OS_CFLAGS = $(OS_EXE_CFLAGS) -ifdef XP_OS2_EMX -EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) -else EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX) -endif else DLLBASE=/BASE:0x30000000 RES=$(OBJDIR)/plds.res @@ -68,8 +64,12 @@ ifdef GLOWCODE EXTRA_LIBS += $(GLOWDIR)/glowcode.lib endif endif - endif + +else +ifeq ($(MOZ_OS2_TOOLS),VACPP) +EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX) + else ifeq ($(OS_ARCH), AIX) ifeq ($(CLASSIC_NSPR),1) @@ -84,6 +84,7 @@ else EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) endif endif +endif # On NCR and SCOOS, we can't link with extra libraries when # we build a shared library. If we do so, the linker doesn't @@ -116,11 +117,7 @@ SH_DATE = $(shell date) SH_NOW = $(shell $(NOW)) ifeq ($(OS_ARCH), WINNT) -ifeq ($(OS_TARGET),OS2) - SUF = -else SUF = i64 -endif else SUF = LL endif @@ -138,14 +135,14 @@ $(TINC): $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC) ifeq ($(OS_ARCH), WINNT) -ifdef XP_OS2_EMX - $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c + $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c else +ifeq ($(MOZ_OS2_TOOLS), VACPP) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c -endif else $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c endif +endif # # Version information generation (end) # diff --git a/lib/ds/plevent.c b/lib/ds/plevent.c index 362b5461..ba7deedf 100644 --- a/lib/ds/plevent.c +++ b/lib/ds/plevent.c @@ -980,10 +980,6 @@ static PRStatus InitEventLib( void ) #endif /* Win16, Win32, OS2 */ -#if defined(_WIN32) || defined(WIN16) || defined(XP_OS2) - -#endif - #if defined(_WIN32) || defined(WIN16) /* ** _md_CreateEventQueue() -- ModelDependent initializer diff --git a/lib/ds/plevent.h b/lib/ds/plevent.h index 82f5d0fa..38871055 100644 --- a/lib/ds/plevent.h +++ b/lib/ds/plevent.h @@ -176,6 +176,7 @@ and to ensure that no more events will be delivered for that owner. #elif defined(WIN16) || defined(__MINGW32__) #include <windows.h> #elif defined(XP_OS2) +#define INCL_DOSPROCESS #include <os2.h> #endif diff --git a/lib/libc/src/Makefile b/lib/libc/src/Makefile index 265a74be..9fb0a22a 100644 --- a/lib/libc/src/Makefile +++ b/lib/libc/src/Makefile @@ -53,12 +53,8 @@ LIBRARY_VERSION = $(MOD_VERSION) RELEASE_LIBS = $(TARGETS) ifeq ($(OS_ARCH),WINNT) -ifeq (,$(filter-out WIN16 OS2,$(OS_TARGET))) -ifdef XP_OS2_EMX -EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) -else +ifeq ($(OS_TARGET), WIN16) EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib -endif else DLLBASE=/BASE:0x30000000 RES=$(OBJDIR)/plc.res @@ -74,8 +70,12 @@ ifdef GLOWCODE EXTRA_LIBS += $(GLOWDIR)/glowcode.lib endif endif - endif + +else +ifeq ($(MOZ_OS2_TOOLS),VACPP) +EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX) + else ifeq ($(OS_ARCH), AIX) ifeq ($(CLASSIC_NSPR),1) @@ -90,6 +90,7 @@ else EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) endif endif +endif # On NCR and SCOOS, we can't link with extra libraries when # we build a shared library. If we do so, the linker doesn't @@ -115,15 +116,13 @@ SH_DATE = $(shell date) SH_NOW = $(shell $(NOW)) ifeq ($(OS_ARCH), WINNT) -ifeq ($(OS_TARGET),OS2) - SUF = -else SUF = i64 -endif else SUF = LL endif +GARBAGE += $(TINC) + $(TINC): @$(MAKE_OBJDIR) @$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC) @@ -137,14 +136,14 @@ $(TINC): $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC) ifeq ($(OS_ARCH), WINNT) -ifdef XP_OS2_EMX - $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c + $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c else +ifeq ($(MOZ_OS2_TOOLS), VACPP) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c -endif else $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c endif +endif # # Version information generation (end) # diff --git a/lib/msgc/src/Makefile b/lib/msgc/src/Makefile index c4073f5b..bf1b2d93 100644 --- a/lib/msgc/src/Makefile +++ b/lib/msgc/src/Makefile @@ -36,20 +36,20 @@ ifeq ($(OS_ARCH),WINNT) ifeq ($(OS_TARGET),WIN16) CSRCS += win16gc.c else -ifeq ($(OS_TARGET),OS2) -CSRCS += os2gc.c -else CSRCS += win32gc.c endif -endif +else +ifeq ($(OS_ARCH),OS2) +CSRCS += os2gc.c else CSRCS += unixgc.c endif +endif NSPR_VERSION = $(MOD_VERSION) ifeq ($(OS_ARCH), WINNT) -ifeq (,$(filter-out WIN16 OS2,$(OS_TARGET))) +ifeq ($(OS_TARGET), WIN16) EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).lib else DLLBASE=/BASE:0x30000000 @@ -63,8 +63,12 @@ ifdef GLOWCODE EXTRA_LIBS += $(GLOWDIR)/glowcode.lib endif endif - endif + +else +ifeq ($(MOZ_OS2_TOOLS),VACPP) +EXTRA_LIBS = $(DIST)/lib/nspr$(NSPR_VERSION).$(LIB_SUFFIX) + else ifeq ($(OS_ARCH), AIX) ifeq ($(CLASSIC_NSPR),1) @@ -79,6 +83,7 @@ else EXTRA_LIBS = -L$(DIST)/lib -lnspr$(NSPR_VERSION) endif endif +endif # On NCR and SCOOS, we can't link with extra libraries when # we build a shared library. If we do so, the linker doesn't diff --git a/lib/msgc/tests/Makefile b/lib/msgc/tests/Makefile index b07f4851..6716ead8 100644 --- a/lib/msgc/tests/Makefile +++ b/lib/msgc/tests/Makefile @@ -32,7 +32,7 @@ endif CSRCS = gc1.c thrashgc.c -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -59,18 +59,22 @@ ifeq ($(OS_TARGET), WIN16) LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib else -ifeq ($(OS_TARGET),OS2) - LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO - LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib - LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib - LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib -else LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO LIBPR = $(DIST)/lib/libnspr$(NSPR_VERSION).$(LIB_SUFFIX) LIBPLC = $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX) LIBGC= $(DIST)/lib/libmsgc$(GC_VERSION).$(LIB_SUFFIX) endif endif + +ifeq ($(OS_ARCH),OS2) +ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO + LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib + LIBPLC = $(DIST)/lib/plc$(NSPR_VERSION).lib + LIBGC= $(DIST)/lib/msgc$(GC_VERSION).lib +else + LDOPTS += -Zomf -Zlinker /PM:VIO +endif endif ifneq ($(OS_ARCH), WINNT) @@ -270,16 +274,14 @@ ifeq ($(OS_TARGET),WIN16) echo winsock.lib >>w16link wlink @w16link. else -ifeq ($(OS_TARGET),OS2) - $(LINK) $(LDOPTS) $< $(LIBGC) $(LIBPLC) $(LIBPR) so32dll.lib tcp32dll.lib -MAP:$(@:.exe=.map) -out:$@ -else link $(LDOPTS) $< $(LIBGC) $(LIBPLC) $(LIBPR) wsock32.lib -out:$@ -endif -endif +else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(LDOPTS) $< $(LIBGC) $(LIBPLC) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS) -o $@ else $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBGC) $(LIBPLC) $(LIBPR) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) diff --git a/lib/prstreams/Makefile b/lib/prstreams/Makefile index 1c60d8d6..a4718ed1 100644 --- a/lib/prstreams/Makefile +++ b/lib/prstreams/Makefile @@ -50,7 +50,7 @@ endif INCLUDES = -I$(DIST)/include -HEADERS = *.h +HEADERS = $(wildcard *.h) CSRCS = \ plvrsion.c \ @@ -63,7 +63,7 @@ CXXSRCS = \ OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX)) $(CXXSRCS:.cpp=.$(OBJ_SUFFIX))) ifeq ($(OS_ARCH), WINNT) - ifeq (,$(filter-out WIN16 OS2,$(OS_TARGET))) + ifeq ($(OS_TARGET), WIN16) EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).lib else DLLBASE=/BASE:0x30000000 @@ -77,6 +77,13 @@ ifeq ($(OS_ARCH), WINNT) endif endif else + ifeq ($(OS_ARCH),OS2) + ifeq ($(MOZ_OS2_TOOLS),VACPP) + EXTRA_LIBS = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX) + else + EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) -lstdcpp + endif + else ifeq ($(OS_ARCH), AIX) ifeq ($(OS_RELEASE), 4.1) ifeq ($(CLASSIC_NSPR),1) @@ -101,6 +108,7 @@ else EXTRA_LIBS = -L$(DIST)/lib -lnspr$(MOD_VERSION) endif endif +endif # On NCR and SCOOS, we can't link with extra libraries when # we build a shared library. If we do so, the linker doesn't @@ -140,11 +148,7 @@ SH_DATE = $(shell date) SH_NOW = $(shell $(NOW)) ifeq ($(OS_ARCH), WINNT) -ifeq ($(OS_TARGET),OS2) - SUF = -else SUF = i64 -endif else SUF = LL endif @@ -162,14 +166,14 @@ $(TINC): $(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC) ifeq ($(OS_ARCH), WINNT) -ifdef XP_OS2_EMX - $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c + $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c else +ifeq ($(MOZ_OS2_TOOLS), VACPP) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c -endif else $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) plvrsion.c endif +endif # # Version information generation (end) # @@ -177,6 +181,9 @@ endif export:: $(TARGETS) $(HEADERS) $(INSTALL) -m 444 $(HEADERS) $(DIST)/include $(INSTALL) -m 444 $(TARGETS) $(DIST)/lib +ifeq ($(OS_ARCH),OS2) + $(INSTALL) -m 444 $(TARGETS) $(DIST)/bin +endif ifeq ($(OS_ARCH),HP-UX) ifdef SHARED_LIBRARY $(INSTALL) -m 755 $(SHARED_LIBRARY) $(DIST)/lib diff --git a/lib/prstreams/tests/testprstrm/Makefile b/lib/prstreams/tests/testprstrm/Makefile index 98c37ba8..a14e1878 100644 --- a/lib/prstreams/tests/testprstrm/Makefile +++ b/lib/prstreams/tests/testprstrm/Makefile @@ -31,7 +31,7 @@ CXXSRCS = \ OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX))) -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -65,6 +65,16 @@ else endif endif +ifeq ($(OS_ARCH),OS2) + ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768 + LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib + LIBPRSTRMS = $(DIST)/lib/prstrms$(MOD_VERSION).$(LIB_SUFFIX) + else + LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp + endif +endif + ifneq ($(OS_ARCH), WINNT) PWD = $(shell pwd) endif @@ -203,12 +213,18 @@ else link $(LDOPTS) $< $(LIBPR) $(LIBPRSTRMS) wsock32.lib -out:$@ endif else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPR) $(LIBPRSTRMS) $(OS_LIBS) $(EXTRA_LIBS) +else $(CCC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPRSTRMS) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) install:: export clean:: rm -f $(TARGETS) + +testlinker: + echo $(LINK) diff --git a/lib/prstreams/tests/testprstrm/testprstrm.cpp b/lib/prstreams/tests/testprstrm/testprstrm.cpp index b6047a9b..2f2c8574 100644 --- a/lib/prstreams/tests/testprstrm/testprstrm.cpp +++ b/lib/prstreams/tests/testprstrm/testprstrm.cpp @@ -21,7 +21,7 @@ #include "prio.h" #include <string.h> #include <stdio.h> -#ifdef XP_UNIX +#if defined(XP_UNIX) || defined(XP_OS2_EMX) #include <sys/types.h> #include <sys/stat.h> #endif @@ -36,6 +36,9 @@ typedef struct threadarg { } threadarg; void +#ifdef XP_OS2_VACPP +_Optlink +#endif threadmain(void *mytag) { threadarg arg; diff --git a/lib/tests/Makefile b/lib/tests/Makefile index e1c9e8b9..5cafffa3 100644 --- a/lib/tests/Makefile +++ b/lib/tests/Makefile @@ -34,7 +34,11 @@ CSRCS = \ event.c \ base64t.c -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +CSRCS += arena.c +endif + +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -72,6 +76,17 @@ else endif endif +ifeq ($(OS_ARCH),OS2) + ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO /S:32768 + LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib + LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib + LIBPLDS= $(DIST)/lib/plds$(MOD_VERSION).$(LIB_SUFFIX) + else + LDOPTS += -Zomf -Zlinker /PM:VIO + endif +endif + ifneq ($(OS_ARCH), WINNT) PWD = $(shell pwd) endif @@ -203,9 +218,12 @@ else link $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) wsock32.lib -out:$@ endif else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBPLDS) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS) +else $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPLDS) $(LIBPR) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) diff --git a/pr/include/md/Makefile b/pr/include/md/Makefile index 8aae21f7..08b0efc7 100644 --- a/pr/include/md/Makefile +++ b/pr/include/md/Makefile @@ -38,13 +38,13 @@ else ifeq ($(OS_TARGET), WIN16) MDCPUCFG_H = _win16.cfg else -ifeq ($(OS_TARGET),OS2) -MDCPUCFG_H = _os2.cfg -else MDCPUCFG_H = _winnt.cfg endif endif endif + +ifeq ($(OS_ARCH),OS2) +MDCPUCFG_H = _os2.cfg endif ifeq ($(OS_ARCH),AIX) diff --git a/pr/include/md/_os2.cfg b/pr/include/md/_os2.cfg index 517b8355..f72eab69 100644 --- a/pr/include/md/_os2.cfg +++ b/pr/include/md/_os2.cfg @@ -33,7 +33,11 @@ #define IS_LITTLE_ENDIAN 1 #undef IS_BIG_ENDIAN +#ifdef NO_LONG_LONG #undef HAVE_LONG_LONG +#else +#define HAVE_LONG_LONG 1 +#endif #define PR_BYTES_PER_BYTE 1 #define PR_BYTES_PER_SHORT 2 @@ -42,7 +46,6 @@ #define PR_BYTES_PER_LONG 4 #define PR_BYTES_PER_FLOAT 4 #define PR_BYTES_PER_DOUBLE 8 -#define PR_BYTES_PER_WORD_LOG2 2 #define PR_BYTES_PER_WORD 4 #define PR_BYTES_PER_DWORD 8 diff --git a/pr/include/md/_os2.h b/pr/include/md/_os2.h index 3ab0d399..9fb935c2 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -251,6 +251,7 @@ extern PRInt32 _MD_CloseSocket(PRInt32 osfd); #define _MD_SETSOCKOPT (_PR_MD_SETSOCKOPT) #define _MD_SELECT select #define _MD_FSYNC _PR_MD_FSYNC +#define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) #define _MD_INIT_ATOMIC _PR_MD_INIT_ATOMIC #define _MD_ATOMIC_INCREMENT(x) _PR_MD_ATOMIC_INCREMENT(x) @@ -265,6 +266,7 @@ extern PRInt32 _MD_CloseSocket(PRInt32 osfd); #define _MD_SOCKET (_PR_MD_SOCKET) extern PRInt32 _MD_SocketAvailable(PRFileDesc *fd); #define _MD_SOCKETAVAILABLE _MD_SocketAvailable +#define _MD_PIPEAVAILABLE _MD_SocketAvailable #define _MD_CONNECT (_PR_MD_CONNECT) extern PRInt32 _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, PRIntervalTime timeout); @@ -492,6 +494,7 @@ typedef struct _CONTEXTRECORD { #endif extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD); +unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long flag); /* #define _pr_tid (((PTIB2)_getTIBvalue(offsetof(TIB, tib_ptib2)))->tib2_ultid) @@ -502,7 +505,7 @@ extern APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD); * little bit easier. Only add one here if it is a DIRECT mapping. We are * not emulating anything. Just mapping. */ -#define FreeLibrary(x) DosFreeModule(x) +#define FreeLibrary(x) DosFreeModule((HMODULE)x) #define OutputDebugString(x) #endif /* nspr_os2_defs_h___ */ diff --git a/pr/include/prlong.h b/pr/include/prlong.h index 8310a77e..1f2ad727 100644 --- a/pr/include/prlong.h +++ b/pr/include/prlong.h @@ -97,7 +97,7 @@ NSPR_API(PRInt64) LL_Zero(void); ** LL_OR Logical or ** LL_XOR Logical exclusion ** LL_OR2 A disgusting deviation -** LL_NOT Negation (one's compliment) +** LL_NOT Negation (one's complement) ***********************************************************************/ #define LL_AND(r, a, b) ((r) = (a) & (b)) #define LL_OR(r, a, b) ((r) = (a) | (b)) @@ -108,9 +108,9 @@ NSPR_API(PRInt64) LL_Zero(void); /*********************************************************************** ** MACROS: LL_<mathematical operators> ** -** LL_NEG Negation (two's compliment) -** LL_ADD Summation (two's compliment) -** LL_SUB Difference (two's compliment) +** LL_NEG Negation (two's complement) +** LL_ADD Summation (two's complement) +** LL_SUB Difference (two's complement) ***********************************************************************/ #define LL_NEG(r, a) ((r) = -(a)) #define LL_ADD(r, a, b) ((r) = (a) + (b)) @@ -119,9 +119,9 @@ NSPR_API(PRInt64) LL_Zero(void); /*********************************************************************** ** MACROS: LL_<mathematical operators> ** -** LL_MUL Product (two's compliment) -** LL_DIV Quotient (two's compliment) -** LL_MOD Modulus (two's compliment) +** LL_MUL Product (two's complement) +** LL_DIV Quotient (two's complement) +** LL_MOD Modulus (two's complement) ***********************************************************************/ #define LL_MUL(r, a, b) ((r) = (a) * (b)) #define LL_DIV(r, a, b) ((r) = (a) / (b)) diff --git a/pr/include/prtime.h b/pr/include/prtime.h index 11f7be15..9f1f6ae0 100644 --- a/pr/include/prtime.h +++ b/pr/include/prtime.h @@ -253,7 +253,7 @@ NSPR_API(PRStatus) PR_ParseTimeString ( /* * FIXME: should we also have a formatting function, such as asctime, ctime, * and strftime in standard C library? But this would involve - * internationalization issues. Might want to provide a US Engligh version. + * internationalization issues. Might want to provide a US English version. */ /**********************************************************************/ diff --git a/pr/include/prtypes.h b/pr/include/prtypes.h index 81cb9b30..02ea6412 100644 --- a/pr/include/prtypes.h +++ b/pr/include/prtypes.h @@ -147,7 +147,7 @@ #define PR_CALLBACK_DECL #define PR_STATIC_CALLBACK(__x) static __x -#elif defined(XP_OS2) +#elif defined(XP_OS2_VACPP) #define PR_EXPORT(__type) extern __type #define PR_EXPORT_DATA(__type) extern __type diff --git a/pr/src/Makefile b/pr/src/Makefile index c064e7ad..f93aba82 100644 --- a/pr/src/Makefile +++ b/pr/src/Makefile @@ -23,6 +23,11 @@ include $(MOD_DEPTH)/config/config.mk DIRS = io linking malloc md memory misc threads +# For VAC++ 4 geticcdata rule in config/OS2.mk +ifeq ($(MOZ_OS2_TOOLS),VACPP) +CSRCS = prvrsion.c +endif + ifeq ($(USE_PTHREADS), 1) DIRS += pthreads endif @@ -135,14 +140,10 @@ OS_LIBS = -lsocket -lnsl -lgen -lresolv endif ifeq ($(OS_ARCH),WINNT) -ifeq ($(OS_TARGET),OS2) -# We define this in os2.mk. -else ifneq ($(OS_TARGET),WIN16) OS_LIBS = wsock32.lib winmm.lib endif endif -endif # # Define platform-dependent OBJS @@ -165,7 +166,6 @@ OBJS = \ threads/$(OBJDIR)/prrwlock.$(OBJ_SUFFIX) \ threads/$(OBJDIR)/prtpd.$(OBJ_SUFFIX) \ linking/$(OBJDIR)/prlink.$(OBJ_SUFFIX) \ - malloc/$(OBJDIR)/prmalloc.$(OBJ_SUFFIX) \ malloc/$(OBJDIR)/prmem.$(OBJ_SUFFIX) \ md/$(OBJDIR)/prosdep.$(OBJ_SUFFIX) \ memory/$(OBJDIR)/prshm.$(OBJ_SUFFIX) \ @@ -192,6 +192,11 @@ OBJS = \ misc/$(OBJDIR)/prtrace.$(OBJ_SUFFIX) \ misc/$(OBJDIR)/prtime.$(OBJ_SUFFIX) +# ilib now rejects empty objects +ifneq ($(MOZ_OS2_TOOLS),VACPP) +OBJS += malloc/$(OBJDIR)/prmalloc.$(OBJ_SUFFIX) +endif + ifdef USE_PTHREADS OBJS += \ pthreads/$(OBJDIR)/ptsynch.$(OBJ_SUFFIX) \ @@ -240,7 +245,7 @@ OBJS += \ endif ifeq ($(OS_ARCH), WINNT) -ifneq (,$(filter-out WIN16 OS2,$(OS_TARGET))) +ifneq ($(OS_TARGET),WIN16) DLLBASE=/BASE:0x30000000 RES=$(OBJDIR)/nspr.res RESNAME=nspr.rc @@ -291,18 +296,6 @@ OBJS += md/windows/$(OBJDIR)/w95io.$(OBJ_SUFFIX) \ md/windows/$(OBJDIR)/w32shm.$(OBJ_SUFFIX) \ md/windows/$(OBJDIR)/w95dllmain.$(OBJ_SUFFIX) else -ifeq ($(OS_TARGET),OS2) -OBJS += md/os2/$(OBJDIR)/os2io.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2sock.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2thred.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2cv.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2gc.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2misc.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2inrval.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2sem.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2_errors.$(OBJ_SUFFIX) \ - md/os2/$(OBJDIR)/os2poll.$(OBJ_SUFFIX) -else OBJS += md/windows/$(OBJDIR)/ntdllmn.$(OBJ_SUFFIX) \ md/windows/$(OBJDIR)/ntio.$(OBJ_SUFFIX) \ md/windows/$(OBJDIR)/ntgc.$(OBJ_SUFFIX) \ @@ -317,10 +310,23 @@ OBJS += md/windows/$(OBJDIR)/ntdllmn.$(OBJ_SUFFIX) \ md/windows/$(OBJDIR)/w32poll.$(OBJ_SUFFIX) endif endif -endif else +ifeq ($(OS_ARCH),OS2) +OBJS += md/os2/$(OBJDIR)/os2io.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2sock.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2thred.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2cv.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2gc.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2misc.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2inrval.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2sem.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2_errors.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2poll.$(OBJ_SUFFIX) \ + md/os2/$(OBJDIR)/os2rng.$(OBJ_SUFFIX) +else + ifeq ($(OS_ARCH), BeOS) include md/beos/objs.mk include bthreads/objs.mk @@ -328,7 +334,7 @@ else # Unix include md/unix/objs.mk endif - +endif endif LIBRARY_NAME = nspr @@ -349,17 +355,19 @@ endif ECHO = echo INCLUDES = -I$(DIST)/include TINC = $(OBJDIR)/_pr_bld.h + +ifeq ($(OS_TARGET),OS2) +PROD = nspr$(MOD_VERSION).$(DLL_SUFFIX) +else PROD = $(notdir $(SHARED_LIBRARY)) +endif + NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now SH_DATE = $(shell date) SH_NOW = $(shell $(NOW)) ifeq ($(OS_ARCH), WINNT) -ifeq ($(OS_TARGET),OS2) - SUF = -else SUF = i64 -endif else SUF = LL endif @@ -379,14 +387,14 @@ $(TINC): $(OBJDIR)/prvrsion.$(OBJ_SUFFIX): prvrsion.c $(TINC) ifeq ($(OS_ARCH), WINNT) -ifdef XP_OS2_EMX - $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c + $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c else +ifeq ($(MOZ_OS2_TOOLS), VACPP) $(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c -endif else $(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) prvrsion.c endif +endif # # Version information generation (end) # diff --git a/pr/src/cplus/Makefile b/pr/src/cplus/Makefile index 35c9df7b..fc75f115 100644 --- a/pr/src/cplus/Makefile +++ b/pr/src/cplus/Makefile @@ -44,7 +44,7 @@ DEFINES += -D_NSPR_BUILD_ include $(MOD_DEPTH)/config/rules.mk -HEADERS = *.h +HEADERS = $(wildcard *.h) export:: $(TARGETS) diff --git a/pr/src/cplus/tests/Makefile b/pr/src/cplus/tests/Makefile index 7ba24d22..b7e658d7 100644 --- a/pr/src/cplus/tests/Makefile +++ b/pr/src/cplus/tests/Makefile @@ -37,7 +37,7 @@ CXXSRCS = \ OBJS = $(addprefix $(OBJDIR)/,$(CXXSRCS:.cpp=.$(OBJ_SUFFIX))) -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -112,6 +112,16 @@ else endif endif +ifeq ($(OS_ARCH),OS2) + ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO + LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib + LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib + else + LDOPTS += -Zomf -Zlinker /PM:VIO -lstdcpp + endif +endif + ifneq ($(OS_ARCH), WINNT) PWD = $(shell pwd) endif @@ -238,9 +248,12 @@ else link $(LDOPTS) $< $(LIBPR) $(LIBPL) wsock32.lib -out:$@ endif else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(LDOPTS) $< $(LIBGC) $(LIBPLC) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS) -o $@ +else $(CCC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPL) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) diff --git a/pr/src/io/prfile.c b/pr/src/io/prfile.c index ab16e27a..70baeebf 100644 --- a/pr/src/io/prfile.c +++ b/pr/src/io/prfile.c @@ -638,12 +638,20 @@ PR_IMPLEMENT(PRStatus) PR_CreatePipe( (*readPipe)->secret->inheritable = PR_TRUE; (*writePipe)->secret->inheritable = PR_TRUE; return PR_SUCCESS; -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) || defined(XP_OS2) +#ifdef XP_OS2 + HFILE pipefd[2]; +#else int pipefd[2]; +#endif if (!_pr_initialized) _PR_ImplicitInitialization(); +#ifdef XP_OS2 + if (DosCreatePipe(&pipefd[0], &pipefd[1], 4096) != 0) { +#else if (pipe(pipefd) == -1) { +#endif /* XXX map pipe error */ PR_SetError(PR_UNKNOWN_ERROR, errno); return PR_FAILURE; diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c index 6e940096..84da9988 100644 --- a/pr/src/io/prio.c +++ b/pr/src/io/prio.c @@ -122,7 +122,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable( PRFileDesc *fd, PRBool inheritable) { -#if defined(XP_UNIX) || defined(WIN32) +#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2) /* * Only a non-layered, NSPR file descriptor can be inherited * by a child process. diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index 5b0a4ab4..69c61bb2 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -190,7 +190,7 @@ PRFileDesc *fd; } -static const PRIOMethods* PR_GetSocketPollFdMethods(); +static const PRIOMethods* PR_GetSocketPollFdMethods(void); PR_IMPLEMENT(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd) { diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index d9c59b6e..998e6378 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -82,8 +82,13 @@ struct PRLibrary { const PRStaticLinkTable* staticTable; #ifdef XP_PC +#ifdef XP_OS2 + HMODULE dlh; +#else HINSTANCE dlh; #endif +#endif + #ifdef XP_MAC CFragConnectionID dlh; #endif diff --git a/pr/src/md/Makefile b/pr/src/md/Makefile index 765d0f62..cb047e20 100644 --- a/pr/src/md/Makefile +++ b/pr/src/md/Makefile @@ -22,16 +22,16 @@ MOD_DEPTH = ../../.. include $(MOD_DEPTH)/config/config.mk ifeq ($(OS_ARCH),WINNT) - ifeq ($(OS_TARGET),OS2) - DIRS = os2 - else DIRS = windows - endif else + ifeq ($(OS_ARCH),OS2) + DIRS = os2 + else ifeq ($(OS_ARCH),BeOS) DIRS = beos else DIRS = unix + endif endif endif diff --git a/pr/src/md/os2/Makefile b/pr/src/md/os2/Makefile index 6e9390dc..03e4c863 100644 --- a/pr/src/md/os2/Makefile +++ b/pr/src/md/os2/Makefile @@ -33,6 +33,7 @@ CSRCS = \ os2sock.c \ os2_errors.c \ os2poll.c \ + os2rng.c \ $(NULL) endif diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c index 8b200aab..e6977ff7 100644 --- a/pr/src/md/os2/os2io.c +++ b/pr/src/md/os2/os2io.c @@ -28,6 +28,7 @@ #ifdef XP_OS2_VACPP #include <direct.h> #else +#include <limits.h> #include <dirent.h> #include <fcntl.h> #include <io.h> @@ -153,7 +154,7 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode) PRInt32 _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) { - PRUword bytes; + ULONG bytes; int rv; rv = DosRead((HFILE)fd->secret->md.osfd, @@ -172,13 +173,13 @@ _PR_MD_READ(PRFileDesc *fd, void *buf, PRInt32 len) return -1; } } - return bytes; + return (PRInt32)bytes; } PRInt32 _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) { - PRUword bytes; + PRInt32 bytes; int rv; /* No longer using DosWrite since it doesn't convert \n to \n\r like C runtime does */ @@ -195,7 +196,7 @@ _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len) } #else bytes = write(fd->secret->md.osfd, buf, len); - if (rv == -1) + if (bytes == -1) _PR_MD_MAP_WRITE_ERROR(errno); #endif @@ -220,6 +221,7 @@ _PR_MD_LSEEK(PRFileDesc *fd, PRInt32 offset, PRSeekWhence whence) PRInt64 _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) { +#ifdef NO_LONG_LONG PRInt64 result; PRInt32 rv, low = offset.lo, hi = offset.hi; PRUword newLocation; @@ -235,6 +237,45 @@ _PR_MD_LSEEK64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence) result.lo = newLocation; result.hi = hi; return result; + +#else + PRInt32 where, rc, lo = (PRInt32)offset, hi = (PRInt32)(offset >> 32); + PRUint64 rv; + PRUint32 newLocation, uhi; + + switch (whence) + { + case PR_SEEK_SET: + where = FILE_BEGIN; + break; + case PR_SEEK_CUR: + where = FILE_CURRENT; + break; + case PR_SEEK_END: + where = FILE_END; + break; + default: + PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); + return -1; +} + + rc = DosSetFilePtr((HFILE)fd->secret->md.osfd, lo, where, (PULONG)&newLocation); + + if (rc != NO_ERROR) { + _PR_MD_MAP_LSEEK_ERROR(rc); + return -1; + } + + uhi = (PRUint32)hi; + PR_ASSERT((PRInt32)uhi >= 0); + rv = uhi; + PR_ASSERT((PRInt64)rv >= 0); + rv = (rv << 32); + PR_ASSERT((PRInt64)rv >= 0); + rv += newLocation; + PR_ASSERT((PRInt64)rv >= 0); + return (PRInt64)rv; +#endif } PRInt32 @@ -443,6 +484,7 @@ _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info) { struct stat sb; PRInt32 rv; + PRInt64 s, s2us; if ( (rv = _PR_MD_STAT(fn, &sb)) == 0 ) { if (info) { @@ -453,8 +495,13 @@ _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info) else info->type = PR_FILE_OTHER; info->size = sb.st_size; - info->modifyTime.lo = sb.st_mtime; - info->creationTime.lo = sb.st_ctime; + LL_I2L(s2us, PR_USEC_PER_SEC); + LL_I2L(s, sb.st_mtime); + LL_MUL(s, s, s2us); + info->modifyTime = s; + LL_I2L(s, sb.st_ctime); + LL_MUL(s, s, s2us); + info->creationTime = s; } } return rv; @@ -468,7 +515,7 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info) if (0 == rv) { info->type = info32.type; - info->size.lo = info32.size; + LL_UI2L(info->size,info32.size); info->modifyTime = info32.modifyTime; info->creationTime = info32.creationTime; } @@ -493,6 +540,7 @@ _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) * point is now moot. */ struct stat hinfo; + PRInt64 s, s2us; _setmode(fd->secret->md.osfd, O_BINARY); if(fstat((int)fd->secret->md.osfd, &hinfo) != NO_ERROR) { @@ -506,8 +554,13 @@ _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info) info->type = PR_FILE_FILE; info->size = hinfo.st_size; - info->modifyTime.lo = hinfo.st_mtime; - info->creationTime.lo = hinfo.st_ctime; + LL_I2L(s2us, PR_USEC_PER_SEC); + LL_I2L(s, hinfo.st_mtime); + LL_MUL(s, s, s2us); + info->modifyTime = s; + LL_I2L(s, hinfo.st_ctime); + LL_MUL(s, s, s2us); + info->creationTime = s; return 0; } @@ -520,7 +573,8 @@ _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info) if (0 == rv) { info->type = info32.type; - info->size.lo = info32.size; + LL_UI2L(info->size,info32.size); + info->modifyTime = info32.modifyTime; info->creationTime = info32.creationTime; } @@ -651,3 +705,28 @@ _PR_MD_UNLOCKFILE(PRInt32 f) } } /* end _PR_MD_UNLOCKFILE() */ +PRStatus +_PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable) +{ + int rv = 0; + ULONG flags; + + rv = DosQueryFHState((HFILE)fd->secret->md.osfd, &flags); + if (rv != 0) { + PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO()); + return PR_FAILURE; + } + + if (inheritable) + flags &= OPEN_FLAGS_NOINHERIT; + else + flags |= OPEN_FLAGS_NOINHERIT; + + rv = DosSetFHState((HFILE)fd->secret->md.osfd, flags); + if (rv != 0) { + PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO()); + return PR_FAILURE; + } + return PR_SUCCESS; +} + diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c index de675e43..27277e68 100644 --- a/pr/src/md/os2/os2misc.c +++ b/pr/src/md/os2/os2misc.c @@ -23,6 +23,11 @@ #include <string.h> #include "primpl.h" +extern int _CRT_init(void); +extern void _CRT_term(void); +extern void __ctordtorInit(int flag); +extern void __ctordtorTerm(int flag); + char * _PR_MD_GET_ENV(const char *name) { @@ -303,7 +308,9 @@ PRProcess * _PR_CreateOS2Process( HFILE hStdIn = 0, hStdOut = 0, hStdErr = 0; - + HFILE hStdInSave = -1, + hStdOutSave = -1, + hStdErrSave = -1; proc = PR_NEW(PRProcess); if (!proc) { @@ -343,16 +350,19 @@ PRProcess * _PR_CreateOS2Process( * and gross I know. If you know a better way, please use it. */ if (attr->stdinFd) { - hStdIn = (HFILE) attr->stdinFd->secret->md.osfd; - DosDupHandle(0, &hStdIn); + hStdIn = 0; + DosDupHandle(hStdIn, &hStdInSave); + DosDupHandle((HFILE) attr->stdinFd->secret->md.osfd, &hStdIn); } if (attr->stdoutFd) { - hStdOut = (HFILE) attr->stdoutFd->secret->md.osfd; - DosDupHandle(1, &hStdOut); + hStdOut = 1; + DosDupHandle(hStdOut, &hStdOutSave); + DosDupHandle((HFILE) attr->stdoutFd->secret->md.osfd, &hStdOut); } if (attr->stderrFd) { - hStdErr = (HFILE) attr->stderrFd->secret->md.osfd; - DosDupHandle(2, &hStdErr); + hStdErr = 2; + DosDupHandle(hStdErr, &hStdErrSave); + DosDupHandle((HFILE) attr->stderrFd->secret->md.osfd, &hStdErr); } } @@ -365,17 +375,17 @@ PRProcess * _PR_CreateOS2Process( argv[0]); /* Restore our old values. Hope this works */ - if(hStdIn){ - hStdIn = 0; - DosDupHandle(0, &hStdIn); + if(hStdInSave != -1){ + DosDupHandle(hStdInSave, &hStdIn); + DosClose(hStdInSave); } - if(hStdOut){ - hStdOut = 1; - DosDupHandle(1, &hStdOut); + if(hStdOutSave != -1){ + DosDupHandle(hStdOutSave, &hStdOut); + DosClose(hStdOutSave); } - if(hStdErr){ - hStdErr = 1; - DosDupHandle(0, &hStdErr); + if(hStdErrSave != -1){ + DosDupHandle(hStdErrSave, &hStdErr); + DosClose(hStdErrSave); } if (retVal != NO_ERROR) { @@ -509,3 +519,37 @@ PRStatus _MD_CloseFileMap(PRFileMap *fmap) return PR_FAILURE; } +/* + * Automatically set apptype switch for interactive and other + * tests that create an invisible plevent window. + */ +unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long flag) +{ + unsigned long rc = 0; /* failure */ + + if( !flag) + { + /* init */ + if( _CRT_init() == 0) + { + PPIB pPib; + PTIB pTib; + + /* probably superfluous, but can't hurt */ + __ctordtorInit(0); + + DosGetInfoBlocks( &pTib, &pPib); + pPib->pib_ultype = 3; /* PM */ + + rc = 1; + } + } + else + { + __ctordtorTerm(0); + _CRT_term(); + rc = 1; + } + + return rc; +} diff --git a/pr/src/md/os2/os2rng.c b/pr/src/md/os2/os2rng.c index 18a4c729..c98fe3ad 100644 --- a/pr/src/md/os2/os2rng.c +++ b/pr/src/md/os2/os2rng.c @@ -20,9 +20,9 @@ #define INCL_DOS #define INCL_DOSERRORS #include <os2.h> -#include <secrng.h> #include <stdlib.h> -#include <primpl.h> +#include <time.h> +#include "primpl.h" static BOOL clockTickTime(unsigned long *phigh, unsigned long *plow) { @@ -39,7 +39,7 @@ static BOOL clockTickTime(unsigned long *phigh, unsigned long *plow) return TRUE; } -extern PRSize _PR_MD_GetRandomNoise( buf, size ) +extern PRSize _PR_MD_GetRandomNoise(void *buf, PRSize size ) { unsigned long high = 0; unsigned long low = 0; diff --git a/pr/src/md/os2/os2thred.c b/pr/src/md/os2/os2thred.c index 6d4c3ddc..b6c1615b 100644 --- a/pr/src/md/os2/os2thred.c +++ b/pr/src/md/os2/os2thred.c @@ -23,6 +23,10 @@ #include <time.h> /* for _tzset() */ #endif +#ifdef XP_OS2_EMX +#include <signal.h> +#endif + /* --- Declare these to avoid "implicit" warnings --- */ PR_EXTERN(void) _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value); PR_EXTERN(void) _PR_MD_DESTROY_SEM(_MDSemaphore *md); @@ -51,7 +55,7 @@ _PR_MD_EARLY_INIT() { HMODULE hmod; - if (DosLoadModule(NULL, 0, "DOSCALL1.DLL", &hmod) == 0) + if (DosLoadModule(NULL, 0, "DOSCALL1", &hmod) == 0) DosQueryProcAddr(hmod, 877, "DOSQUERYTHREADCONTEXT", (PFN *)&QueryThreadContext); @@ -76,6 +80,15 @@ _pr_SetThreadMDHandle(PRThread *thread) PR_IMPLEMENT(PRStatus) _PR_MD_INIT_THREAD(PRThread *thread) { +#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/src/misc/pratom.c b/pr/src/misc/pratom.c index 103eb213..5c26670a 100644 --- a/pr/src/misc/pratom.c +++ b/pr/src/misc/pratom.c @@ -34,7 +34,7 @@ * compiled in. */ -#ifndef _PR_HAVE_ATOMIC_OPS +#if !defined(_PR_HAVE_ATOMIC_OPS) #if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) /* @@ -207,7 +207,7 @@ _PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) * The lock contention should be acceptable. */ static PRLock *atomic_lock = NULL; -void _PR_MD_INIT_ATOMIC() +void _PR_MD_INIT_ATOMIC(void) { if (atomic_lock == NULL) { atomic_lock = PR_NewLock(); diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c index 574791d3..4c74b3b4 100644 --- a/pr/src/misc/prsystem.c +++ b/pr/src/misc/prsystem.c @@ -87,14 +87,17 @@ PR_IMPLEMENT(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 bufle ULONG os2ver[2] = {0}; DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_REVISION, &os2ver, sizeof(os2ver)); - /* Formatting for normal usage (2.11, 3.0, 4.0); officially, - Warp 4 is version 2.40.00 */ + /* Formatting for normal usage (2.11, 3.0, 4.0, 4.5); officially, + Warp 4 is version 2.40.00, WSeB 2.45.00 */ if (os2ver[0] < 30) (void)PR_snprintf(buf, buflen, "%s%lu", "2.", os2ver[0]); - else + else if (os2ver[0] < 45) (void)PR_snprintf(buf, buflen, "%lu%s%lu", os2ver[0]/10, ".", os2ver[1]); + else + (void)PR_snprintf(buf, buflen, "%.1f", + os2ver[0]/10.0); } #endif /* OS2 */ break; diff --git a/pr/tests/Makefile b/pr/tests/Makefile index b3138a06..2fd2c0cd 100644 --- a/pr/tests/Makefile +++ b/pr/tests/Makefile @@ -175,7 +175,7 @@ CSRCS += \ $(NULL) endif -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -198,15 +198,6 @@ ifeq ($(OS_TARGET), WIN16) LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib else -ifeq ($(OS_TARGET), OS2) -ifdef XP_OS2_VACPP - LDOPTS = - LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib - LIBPLC= $(DIST)/lib/plc$(MOD_VERSION).lib -else - LDOPTS = -Zlinker /PM:VIO -endif -else LDOPTS = -NOLOGO -DEBUG -DEBUGTYPE:CV -INCREMENTAL:NO ifeq ($(OS_TARGET), WIN95) LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).$(LIB_SUFFIX) @@ -220,6 +211,17 @@ else endif # profile endif endif + +ifeq ($(OS_ARCH),OS2) +ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO + LIBPR = $(DIST)/lib/nspr$(MOD_VERSION).lib + LIBPLC = $(DIST)/lib/plc$(MOD_VERSION).lib +else +ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF) + LDOPTS = -Zlinker /PM:VIO +endif +endif endif ifneq ($(OS_ARCH), WINNT) @@ -479,16 +481,15 @@ ifeq ($(OS_TARGET),WIN16) echo winsock.lib >>w16link wlink @w16link. else -ifeq ($(OS_TARGET),OS2) - $(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS) -else link $(LDOPTS) $(EXTRA_LDOPTS) $< $(LIBPLC) $(LIBPR) $(EXTRA_LIBS) wsock32.lib -out:$@ endif -endif +else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(EXEFLAGS) $(LDOPTS) $< $(LIBPLC) $(LIBPR) $(OS_LIBS) $(EXTRA_LIBS) else $(PURE) $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPLC) $(LIBPR) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) @@ -529,7 +530,7 @@ PROGRAMS = $(notdir $(PROGS)) ifdef NSPR_TEST_LOGFILE LOGFILE = $(NSPR_TEST_LOGFILE) else -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) LOGFILE = nul else LOGFILE = /dev/null diff --git a/pr/tests/bigfile.c b/pr/tests/bigfile.c index 0ac78c64..b3173dc4 100644 --- a/pr/tests/bigfile.c +++ b/pr/tests/bigfile.c @@ -190,24 +190,24 @@ PRIntn main(PRIntn argc, char **argv) if (!LL_IS_ZERO(big_answer)) return Error("empty available64()", filename); LL_SUB(big_size, filesize64, one_meg); - VERBOSE(v_whisper, "Creating sparce big file by seeking to end"); + VERBOSE(v_whisper, "Creating sparse big file by seeking to end"); big_answer = file->methods->seek64(file, big_size, PR_SEEK_SET); if (!LL_EQ(big_answer, big_size)) return Error("seek", filename); - VERBOSE(v_whisper, "Writing block at end of sparce file"); + VERBOSE(v_whisper, "Writing block at end of sparse file"); bytes = file->methods->write(file, buffer, BUFFER_SIZE); if (bytes != BUFFER_SIZE) return Error("write", filename); - VERBOSE(v_whisper, "Testing available space at end of sparce file"); + VERBOSE(v_whisper, "Testing available space at end of sparse file"); big_answer = file->methods->available64(file); if (!LL_IS_ZERO(big_answer)) return Error("eof available64()", filename); - VERBOSE(v_whisper, "Getting big info on sparce big file"); + VERBOSE(v_whisper, "Getting big info on sparse big file"); rv = file->methods->fileInfo64(file, &big_info); if (PR_FAILURE == rv) return Error("fileInfo64()", filename); if (v_shout <= verbose) PrintInfo(&big_info, filename); - VERBOSE(v_whisper, "Getting small info on sparce big file"); + VERBOSE(v_whisper, "Getting small info on sparse big file"); rv = file->methods->fileInfo(file, &small_info); if (LL_CMP(sevenFox, <, filesize64) && (PR_SUCCESS == rv)) { diff --git a/pr/tests/bigfile2.c b/pr/tests/bigfile2.c index 5dfc091f..9b0a9cae 100644 --- a/pr/tests/bigfile2.c +++ b/pr/tests/bigfile2.c @@ -24,7 +24,7 @@ #include <windows.h> #endif -#define TEST_FILE_NAME "m:\\bigfile2.txt" +#define TEST_FILE_NAME "bigfile2.txt" #define MESSAGE "Hello world!" #define MESSAGE_SIZE 13 diff --git a/pr/tests/bigfile3.c b/pr/tests/bigfile3.c index 996d5434..3ff8b5d5 100644 --- a/pr/tests/bigfile3.c +++ b/pr/tests/bigfile3.c @@ -24,7 +24,7 @@ #include <windows.h> #endif -#define TEST_FILE_NAME "m:\\bigfile3.txt" +#define TEST_FILE_NAME "bigfile3.txt" #define MESSAGE "Hello world!" #define MESSAGE_SIZE 13 diff --git a/pr/tests/dll/Makefile b/pr/tests/dll/Makefile index 68360c50..66acab4a 100644 --- a/pr/tests/dll/Makefile +++ b/pr/tests/dll/Makefile @@ -28,6 +28,8 @@ OPTIMIZER = endif endif +CSRCS = mygetval.c mysetval.c + INCLUDES = -I$(DIST)/include OBJS = $(OBJDIR)/mygetval.$(OBJ_SUFFIX) \ @@ -38,7 +40,7 @@ W16OBJS = $(subst $(space),$(comma)$(space),$(OBJS)) endif ifeq ($(OS_ARCH), WINNT) -ifeq (,$(filter-out WIN16 OS2,$(OS_TARGET))) +ifeq ($(OS_TARGET), WIN16) # do nothing else DLLBASE=/BASE:0x30000000 @@ -47,10 +49,10 @@ RESNAME=../../../pr/src/nspr.rc endif endif -ifeq ($(OS_ARCH), WINNT) -IMPORT_LIBRARY = $(OBJDIR)/my.lib +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) +IMPORT_LIBRARY = $(OBJDIR)/my.$(LIB_SUFFIX) SHARED_LIBRARY = $(OBJDIR)/my.dll -ifeq ($(OS_TARGET), OS2) +ifeq ($(OS_ARCH), OS2) LIBRARY = $(OBJDIR)/my_s.lib # XXX $(LIBRARY) probably doesn't need to be added to TARGETS. TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY) diff --git a/pr/tests/ipv6.c b/pr/tests/ipv6.c index 478d59ae..7e92f3e2 100644 --- a/pr/tests/ipv6.c +++ b/pr/tests/ipv6.c @@ -74,6 +74,7 @@ static PRStatus PrintAddress(const PRNetAddr* address) PRNetAddr translation; char buffer[ADDR_BUFFER]; PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer)); + memset(&translation, 0, sizeof(PRNetAddr)); if (PR_FAILURE == rv) PL_FPrintError(err, "PR_NetAddrToString"); else { diff --git a/pr/tests/pipeping.c b/pr/tests/pipeping.c index 7c51cf11..570c5929 100644 --- a/pr/tests/pipeping.c +++ b/pr/tests/pipeping.c @@ -39,7 +39,11 @@ #include <stdlib.h> #include <string.h> +#ifdef XP_OS2 +static char *child_argv[] = { "pipepong.exe", NULL }; +#else static char *child_argv[] = { "pipepong", NULL }; +#endif #define NUM_ITERATIONS 10 diff --git a/pr/tests/prpoll.c b/pr/tests/prpoll.c index 88662181..4dc09092 100644 --- a/pr/tests/prpoll.c +++ b/pr/tests/prpoll.c @@ -20,6 +20,10 @@ #include <windows.h> #endif +#ifdef XP_OS2_VACPP +#include <io.h> /* for close() */ +#endif + #include "prinit.h" #include "prio.h" #include "prlog.h" diff --git a/pr/tests/sigpipe.c b/pr/tests/sigpipe.c index b0d267ad..42c061f7 100644 --- a/pr/tests/sigpipe.c +++ b/pr/tests/sigpipe.c @@ -26,32 +26,51 @@ ************************************************************************* */ -#if !defined(XP_UNIX) +#if !defined(XP_UNIX) && !defined(XP_OS2) -int main() +int main(void) { - /* This test applies to Unix only. */ + /* This test applies to Unix and OS/2 (emx build). */ return 0; } -#else /* XP_UNIX */ +#else /* XP_UNIX && OS/2 */ #include "nspr.h" +#ifdef XP_OS2 +#define INCL_DOSQUEUES +#define INCL_DOSERRORS +#include <os2.h> +#endif + #include <stdio.h> +#ifdef XP_OS2_VACPP +#define EPIPE EBADF /* IBM's write() doesn't return EPIPE */ +#include <io.h> +#else #include <unistd.h> +#endif #include <errno.h> -int main() +int main(void) { +#ifdef XP_OS2 + HFILE pipefd[2]; +#else int pipefd[2]; +#endif int rv; char c = '\0'; /* This initializes NSPR. */ PR_SetError(0, 0); +#ifdef XP_OS2 + if (DosCreatePipe(&pipefd[0], &pipefd[1], 4096) != 0) { +#else if (pipe(pipefd) == -1) { +#endif fprintf(stderr, "cannot create pipe: %d\n", errno); exit(1); } diff --git a/pr/tests/testfile.c b/pr/tests/testfile.c index b6b03882..794ea5ed 100644 --- a/pr/tests/testfile.c +++ b/pr/tests/testfile.c @@ -35,6 +35,7 @@ #include <os2.h> #ifdef XP_OS2_EMX #include <getopt.h> +#include <errno.h> #endif /* XP_OS2_EMX */ #endif /* XP_OS2 */ @@ -48,7 +49,7 @@ static int _debug_on = 0; extern void SetupMacPrintfLog(char *logFile); #endif -#ifdef XP_PC +#ifdef XP_WIN #define mode_t int #endif @@ -111,7 +112,9 @@ PRThread* create_new_thread(PRThreadType type, PRInt32 native_thread = 0; PR_ASSERT(state == PR_UNJOINABLE_THREAD); -#if (defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)) || defined(WIN32) + +#if (defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)) || defined(WIN32) || defined(XP_OS2) + switch(index % 4) { case 0: scope = (PR_LOCAL_THREAD); @@ -136,6 +139,17 @@ PRInt32 native_thread = 0; return((PRThread *) tid); else return (NULL); +#elif defined(XP_OS2) + TID tid; + + tid = (TID)_beginthread((void(* _Optlink)(void*))start, + NULL, 32768, arg); + if (tid == -1) { + printf("_beginthread failed. errno %d\n", errno); + return (NULL); + } + else + return((PRThread *) tid); #else HANDLE thandle; unsigned tid; diff --git a/pr/tests/yield.c b/pr/tests/yield.c index 33ab416b..80e04bd9 100644 --- a/pr/tests/yield.c +++ b/pr/tests/yield.c @@ -19,6 +19,13 @@ #include <stdio.h> #include "prthread.h" #include "prinit.h" +#ifndef XP_OS2 +#include "private/pprmisc.h" +#include <windows.h> +#else +#include "primpl.h" +#include <os2.h> +#endif #define THREADS 10 diff --git a/tools/Makefile b/tools/Makefile index 527ca57f..6effac67 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -33,7 +33,7 @@ CSRCS = \ tail.c \ $(NULL) -ifeq ($(OS_ARCH), WINNT) +ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) PROG_SUFFIX = .exe else PROG_SUFFIX = @@ -64,6 +64,16 @@ LIBPLC= $(DIST)/lib/libplc$(NSPR_VERSION).$(LIB_SUFFIX) endif endif +ifeq ($(OS_ARCH),OS2) + ifeq ($(MOZ_OS2_TOOLS),VACPP) + LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO + LIBPR = $(DIST)/lib/nspr$(NSPR_VERSION).lib + LIBPLC= $(DIST)/lib/plc$(NSPR_VERSION).lib + else + LDOPTS += -Zomf -Zlinker /PM:VIO + endif +endif + ifneq ($(OS_ARCH), WINNT) PWD = $(shell pwd) endif @@ -200,9 +210,12 @@ else link $(LDOPTS) $< $(LIBPR) $(LIBPLC) wsock32.lib -out:$@ endif else +ifeq ($(OS_ARCH),OS2) + $(LINK) $(LDOPTS) $< $(LIBPR) $(LIBPLC) $(OS_LIBS) $(EXTRA_LIBS) -o $@ +else $(CC) $(XCFLAGS) $< $(LDOPTS) $(LIBPR) $(LIBPLC) $(EXTRA_LIBS) -o $@ endif - +endif endif export:: $(TARGETS) |