diff options
author | wtc%netscape.com <devnull@localhost> | 2003-09-16 02:01:24 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2003-09-16 02:01:24 +0000 |
commit | ac763e319c9c55b1b1eb89d746e57a6e21d227d7 (patch) | |
tree | 2a27e20f50d251e679e794d1ff4c242f3d84d466 | |
parent | 35fd11ed50d9b9478048adbb23ac4e8a127aea01 (diff) | |
download | nspr-hg-ac763e319c9c55b1b1eb89d746e57a6e21d227d7.tar.gz |
Bugzilla bug 215581: build with GCC 3.2.2 for OS/2. The patch is
contributed by Javier Pedemonte <pedemont@us.ibm.com>. r=wtc.
Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r-- | config/rules.mk | 4 | ||||
-rwxr-xr-x | configure | 57 | ||||
-rw-r--r-- | configure.in | 16 | ||||
-rw-r--r-- | pr/include/md/_os2.h | 22 | ||||
-rw-r--r-- | pr/include/md/_os2_errors.h | 3 | ||||
-rw-r--r-- | pr/include/prio.h | 2 | ||||
-rw-r--r-- | pr/include/private/primpl.h | 4 | ||||
-rw-r--r-- | pr/src/Makefile.in | 1 | ||||
-rw-r--r-- | pr/src/io/prlog.c | 3 | ||||
-rw-r--r-- | pr/src/io/prsocket.c | 6 | ||||
-rw-r--r-- | pr/src/linking/prlink.c | 20 | ||||
-rw-r--r-- | pr/src/md/os2/Makefile.in | 2 | ||||
-rw-r--r-- | pr/src/md/os2/objs.mk | 2 | ||||
-rw-r--r-- | pr/src/md/os2/os2_errors.c | 24 | ||||
-rw-r--r-- | pr/src/md/os2/os2poll.c | 152 | ||||
-rw-r--r-- | pr/src/md/os2/os2sock.c | 42 | ||||
-rw-r--r-- | pr/src/md/os2/os2thred.c | 9 | ||||
-rw-r--r-- | pr/src/misc/prnetdb.c | 2 | ||||
-rw-r--r-- | pr/tests/Makefile.in | 2 | ||||
-rw-r--r-- | pr/tests/dll/Makefile.in | 9 |
20 files changed, 131 insertions, 251 deletions
diff --git a/config/rules.mk b/config/rules.mk index 6aad726e..beb3072a 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -379,7 +379,9 @@ ifeq ($(OS_ARCH),OS2) echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@ echo EXPORTS >> $@ grep -v ';+' $< | grep -v ';-' | \ - sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' >> $@ + sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,\([\t ]*\),\1_,' | \ + awk 'BEGIN {ord=1;} { print($$0 " @" ord " RESIDENTNAME"); ord++;}' >> $@ + $(ADD_TO_DEF_FILE) endif # @@ -4651,27 +4651,26 @@ EOF #define OS2 1 EOF + cat >> confdefs.h <<\EOF +#define TCPV40HDRS 1 +EOF + AR=emxomfar - AR_FLAGS='-p256 r $@' - CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" - CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + AR_FLAGS='r $@' + CFLAGS="$CFLAGS -Wall -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zomf" MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' DSO_CFLAGS= - DSO_LDOPTS='-Zomf -Zdll -Zmtd' + DSO_LDOPTS='-Zomf -Zdll' _OPTIMIZE_FLAGS="-O2 -s" _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" + OS_LIBS="-lsocket" IMPLIB='emximp -o' FILTER='emxexp -o' - if test -z "$EMXOMFLD_LINKER"; then - # using LINK386.EXE - DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" - fi - # GCC for OS/2 currently predefines these, but we don't want them DEFINES="$DEFINES -Uunix -U__unix -U__unix__" @@ -4747,7 +4746,7 @@ case $target in ;; *) echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4751: checking for dlopen in -ldl" >&5 +echo "configure:4750: 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 @@ -4755,7 +4754,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4759 "configure" +#line 4758 "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 @@ -4766,7 +4765,7 @@ int main() { dlopen() ; return 0; } EOF -if { (eval echo configure:4770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4769: \"$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 @@ -4783,17 +4782,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6 -echo "configure:4787: checking for dlfcn.h" >&5 +echo "configure:4786: 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 4792 "configure" +#line 4791 "configure" #include "confdefs.h" #include <dlfcn.h> EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4797: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4796: \"$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* @@ -4826,13 +4825,13 @@ esac if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4830: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:4829: 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 4836 "configure" +#line 4835 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -4850,7 +4849,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 4854 "configure" +#line 4853 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -4874,12 +4873,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4878: checking for $ac_func" >&5 +echo "configure:4877: 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 4883 "configure" +#line 4882 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4902,7 +4901,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4905: \"$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 @@ -4941,7 +4940,7 @@ hpux*) if test -z "$GNU_CC"; then echo $ac_n "checking for +Olit support""... $ac_c" 1>&6 -echo "configure:4945: checking for +Olit support" >&5 +echo "configure:4944: 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 @@ -4975,7 +4974,7 @@ esac echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:4979: checking for pthread_create in -lpthreads" >&5 +echo "configure:4978: checking for pthread_create in -lpthreads" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -4997,7 +4996,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:5001: checking for pthread_create in -lpthread" >&5 +echo "configure:5000: checking for pthread_create in -lpthread" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5019,7 +5018,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:5023: checking for pthread_create in -lc_r" >&5 +echo "configure:5022: checking for pthread_create in -lc_r" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5041,7 +5040,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:5045: checking for pthread_create in -lc" >&5 +echo "configure:5044: checking for pthread_create in -lc" >&5 echo " #include <pthread.h> void *foo(void *v) { return v; } @@ -5193,7 +5192,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:5197: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:5196: 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 @@ -5216,7 +5215,7 @@ echo "configure:5197: 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:5220: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:5219: 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 745eedcc..7bc24119 100644 --- a/configure.in +++ b/configure.in @@ -1802,27 +1802,23 @@ mips-sony-newsos*) if test -n "$GNU_CC"; then AC_DEFINE(XP_OS2_EMX) AC_DEFINE(OS2) + AC_DEFINE(TCPV40HDRS) AR=emxomfar - AR_FLAGS='-p256 r $@' - CFLAGS="$CFLAGS -Wall -Zmtd -Zomf" - CXXFLAGS="$CFLAGS -Wall -Zmtd -Zomf" + AR_FLAGS='r $@' + CFLAGS="$CFLAGS -Wall -Zomf" + CXXFLAGS="$CFLAGS -Wall -Zomf" MKSHLIB='$(CC) $(DSO_LDOPTS) -o $@' DSO_CFLAGS= - DSO_LDOPTS='-Zomf -Zdll -Zmtd' + DSO_LDOPTS='-Zomf -Zdll' _OPTIMIZE_FLAGS="-O2 -s" _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" + OS_LIBS="-lsocket" IMPLIB='emximp -o' FILTER='emxexp -o' - if test -z "$EMXOMFLD_LINKER"; then - # using LINK386.EXE - DSO_LDOPTS="$DSO_LDOPTS -Zlinker /NOO" - fi - # GCC for OS/2 currently predefines these, but we don't want them DEFINES="$DEFINES -Uunix -U__unix -U__unix__" diff --git a/pr/include/md/_os2.h b/pr/include/md/_os2.h index dc50982a..43395e06 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -75,19 +75,6 @@ APIRET _Optlink SemRequest486(PRAMSEM, ULONG); APIRET _Optlink SemReleasex86(PRAMSEM, ULONG); #endif -#ifdef XP_OS2_EMX -/* - * EMX-specific tweaks: - * o Use errno rather than sock_errno() - * o Use close rather than soclose - * o Ignore sock_init calls. - */ -#define sock_errno() errno -#define soclose close -#define sock_init() -#include <string.h> -#endif - /* * Internal configuration macros */ @@ -294,19 +281,12 @@ 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_SOCKETPAIR (_PR_MD_SOCKETPAIR) #define _MD_GETSOCKNAME (_PR_MD_GETSOCKNAME) #define _MD_GETPEERNAME (_PR_MD_GETPEERNAME) #define _MD_GETSOCKOPT (_PR_MD_GETSOCKOPT) #define _MD_SETSOCKOPT (_PR_MD_SETSOCKOPT) -#ifdef XP_OS2_EMX -extern PRInt32 _MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout); -#else -#define _MD_SELECT select -#endif - #define _MD_FSYNC _PR_MD_FSYNC #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) diff --git a/pr/include/md/_os2_errors.h b/pr/include/md/_os2_errors.h index f196a201..b872fac8 100644 --- a/pr/include/md/_os2_errors.h +++ b/pr/include/md/_os2_errors.h @@ -127,6 +127,9 @@ NSPR_API(void) _MD_os2_map_listen_error(PRInt32 err); NSPR_API(void) _MD_os2_map_shutdown_error(PRInt32 err); #define _PR_MD_MAP_SHUTDOWN_ERROR _MD_os2_map_shutdown_error +NSPR_API(void) _MD_os2_map_socketpair_error(int err); +#define _PR_MD_MAP_SOCKETPAIR_ERROR _MD_os2_map_socketpair_error + NSPR_API(void) _MD_os2_map_getsockname_error(PRInt32 err); #define _PR_MD_MAP_GETSOCKNAME_ERROR _MD_os2_map_getsockname_error diff --git a/pr/include/prio.h b/pr/include/prio.h index bb96c296..d9843dc3 100644 --- a/pr/include/prio.h +++ b/pr/include/prio.h @@ -194,7 +194,7 @@ union PRNetAddr { PRIPv6Addr ip; /* the actual 128 bits of address */ PRUint32 scope_id; /* set of interfaces for a scope */ } ipv6; -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_OS2) struct { /* Unix domain socket address */ PRUint16 family; /* address family (AF_UNIX) */ char path[104]; /* null-terminated pathname */ diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h index 351781bf..04f9d4c5 100644 --- a/pr/include/private/primpl.h +++ b/pr/include/private/primpl.h @@ -1395,7 +1395,7 @@ extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr); ** struct sockaddr_in6. */ -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_OS2) #define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ @@ -1411,7 +1411,7 @@ extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr); #else -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_OS2) #define PR_NETADDR_SIZE(_addr) \ ((_addr)->raw.family == PR_AF_INET \ ? sizeof((_addr)->inet) \ diff --git a/pr/src/Makefile.in b/pr/src/Makefile.in index fdf10cf1..0969b816 100644 --- a/pr/src/Makefile.in +++ b/pr/src/Makefile.in @@ -143,6 +143,7 @@ endif ifeq ($(OS_ARCH),OS2) MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def +ADD_TO_DEF_FILE = cat $(srcdir)/os2extra.def >> $(MAPFILE) GARBAGE += $(MAPFILE) MKSHLIB += $(MAPFILE) endif diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c index ac1c5492..9cec9150 100644 --- a/pr/src/io/prlog.c +++ b/pr/src/io/prlog.c @@ -493,8 +493,7 @@ PR_IMPLEMENT(void) PR_Abort(void) #include <builtin.h> static void DebugBreak(void) { _interrupt(3); } #elif defined(XP_OS2_EMX) -/* Force a trap */ -static void DebugBreak(void) { int *pTrap=NULL; *pTrap = 1; } +static void DebugBreak(void) { asm("int $3"); } #else static void DebugBreak(void) { } #endif diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c index 652632fc..999fc03d 100644 --- a/pr/src/io/prsocket.c +++ b/pr/src/io/prsocket.c @@ -44,7 +44,7 @@ PRBool IsValidNetAddr(const PRNetAddr *addr) { if ((addr != NULL) -#ifdef XP_UNIX +#if defined(XP_UNIX) || defined(XP_OS2) && (addr->raw.family != PR_AF_LOCAL) #endif && (addr->raw.family != PR_AF_INET6) @@ -61,7 +61,7 @@ static PRBool IsValidNetAddrLen(const PRNetAddr *addr, PRInt32 addr_len) * is not uniform, so we don't check it. */ if ((addr != NULL) -#ifdef XP_UNIX +#if defined(XP_UNIX) || defined(XP_OS2) && (addr->raw.family != AF_UNIX) #endif && (PR_NETADDR_SIZE(addr) != addr_len)) { @@ -1273,7 +1273,7 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto) if (!_pr_initialized) _PR_ImplicitInitialization(); if (PR_AF_INET != domain && PR_AF_INET6 != domain -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_OS2) && PR_AF_LOCAL != domain #endif ) { diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c index e980b649..7c583639 100644 --- a/pr/src/linking/prlink.c +++ b/pr/src/linking/prlink.c @@ -162,7 +162,7 @@ struct _imcb *IAC$GL_IMAGE_LIST = NULL; * On these platforms, symbols have a leading '_'. */ #if defined(SUNOS4) || defined(DARWIN) || defined(NEXTSTEP) \ - || defined(WIN16) \ + || defined(WIN16) || defined(XP_OS2) \ || ((defined(OPENBSD) || defined(NETBSD)) && !defined(__ELF__)) #define NEED_LEADING_UNDERSCORE #endif @@ -939,8 +939,7 @@ pr_LoadLibraryByPathname(const char *name, PRIntn flags) UCHAR pszError[_MAX_PATH]; ULONG ulRc = NO_ERROR; - retry: - ulRc = DosLoadModule(pszError, _MAX_PATH, (PSZ) name, &h); + ulRc = DosLoadModule(pszError, _MAX_PATH, (PSZ) name, &h); if (ulRc != NO_ERROR) { oserr = ulRc; PR_DELETE(lm); @@ -1432,6 +1431,9 @@ static void* pr_FindSymbolInLib(PRLibrary *lm, const char *name) { void *f = NULL; +#ifdef XP_OS2 + int rc; +#endif if (lm->staticTable != NULL) { const PRStaticLinkTable* tp; @@ -1451,7 +1453,17 @@ pr_FindSymbolInLib(PRLibrary *lm, const char *name) } #ifdef XP_OS2 - DosQueryProcAddr(lm->dlh, 0, (PSZ) name, (PFN *) &f); + rc = DosQueryProcAddr(lm->dlh, 0, (PSZ) name, (PFN *) &f); +#if defined(NEED_LEADING_UNDERSCORE) + /* + * Older plugins (not built using GCC) will have symbols that are not + * underscore prefixed. We check for that here. + */ + if (rc != NO_ERROR) { + name++; + DosQueryProcAddr(lm->dlh, 0, (PSZ) name, (PFN *) &f); + } +#endif #endif /* XP_OS2 */ #if defined(WIN32) || defined(WIN16) diff --git a/pr/src/md/os2/Makefile.in b/pr/src/md/os2/Makefile.in index 7db0b44b..7f56eb23 100644 --- a/pr/src/md/os2/Makefile.in +++ b/pr/src/md/os2/Makefile.in @@ -63,7 +63,7 @@ ASFILES = os2vacpp.asm endif ifeq ($(MOZ_OS2_TOOLS),EMX) -ASFILES = os2emx.s +ASFILES = os2emx.s os2vaclegacy.s endif TARGETS = $(OBJS) diff --git a/pr/src/md/os2/objs.mk b/pr/src/md/os2/objs.mk index 3339a538..05fe4658 100644 --- a/pr/src/md/os2/objs.mk +++ b/pr/src/md/os2/objs.mk @@ -53,7 +53,7 @@ ASFILES = os2vacpp.asm endif ifeq ($(MOZ_OS2_TOOLS),EMX) -ASFILES = os2emx.s +ASFILES = os2emx.s os2vaclegacy.s endif OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ diff --git a/pr/src/md/os2/os2_errors.c b/pr/src/md/os2/os2_errors.c index 5efd2c16..7c270c4d 100644 --- a/pr/src/md/os2/os2_errors.c +++ b/pr/src/md/os2/os2_errors.c @@ -875,6 +875,30 @@ void _MD_os2_map_shutdown_error(PRInt32 err) } } +void _MD_os2_map_socketpair_error(PRInt32 err) +{ + switch (err) { + case ENOMEM: + PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, err); + break; + case EAFNOSUPPORT: + PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); + break; + case EPROTONOSUPPORT: + PR_SetError(PR_PROTOCOL_NOT_SUPPORTED_ERROR, err); + break; + case EOPNOTSUPP: + PR_SetError(PR_NOT_TCP_SOCKET_ERROR, err); + break; + case EPROTOTYPE: + PR_SetError(PR_ADDRESS_NOT_SUPPORTED_ERROR, err); + break; + default: + _MD_os2_map_default_error(err); + return; + } +} + void _MD_os2_map_getsockname_error(PRInt32 err) { switch (err) { diff --git a/pr/src/md/os2/os2poll.c b/pr/src/md/os2/os2poll.c index 3b087e11..5bf84e3b 100644 --- a/pr/src/md/os2/os2poll.c +++ b/pr/src/md/os2/os2poll.c @@ -242,7 +242,7 @@ retry: tvp = &tv; } - ready = _MD_SELECT(maxfd + 1, &rd, &wt, &ex, tvp); + ready = bsdselect(maxfd + 1, &rd, &wt, &ex, tvp); #else switch (timeout) { @@ -262,7 +262,7 @@ retry: for( i = rd+wt, j = npds*2; j < npds*2+ex; i++,j++ ) socks[i] = socks[j]; - ready = _MD_SELECT(socks, rd, wt, ex, msecs); + ready = os2_select(socks, rd, wt, ex, msecs); #endif if (ready == -1 && errno == EINTR) @@ -378,151 +378,3 @@ retry: return ready; } -#ifdef XP_OS2_EMX -HMTX thread_select_mutex = 0; /* because EMX's select is not thread safe - duh! */ - -typedef struct _thread_select_st { - int nfds; - int isrdfds; - struct _fd_set *readfds; - int iswrfds; - struct _fd_set *writefds; - int isexfds; - struct _fd_set *exceptfds; - int istimeout; - struct timeval timeout; - volatile HEV event; - int result; - int select_errno; - volatile int done; -} *pthread_select_t; - -void _thread_select(void * arg) -{ - pthread_select_t self = arg; - int result, chkstdin; - struct _fd_set readfds; - struct _fd_set writefds; - struct _fd_set exceptfds; - HEV event = self->event; - - chkstdin = (self->isrdfds && FD_ISSET(0,self->readfds))?1:0; - - do { - struct timeval timeout = {0L,0L}; - - - if (self->isrdfds) readfds = *self->readfds; - if (self->iswrfds) writefds = *self->writefds; - if (self->isexfds) exceptfds = *self->exceptfds; - - if (chkstdin) FD_CLR(0,&readfds); - - if (!thread_select_mutex) - DosCreateMutexSem(NULL,&thread_select_mutex,0,1); - else - DosRequestMutexSem(thread_select_mutex,SEM_INDEFINITE_WAIT); - result = select( - self->nfds, - self->isrdfds?&readfds:NULL, - self->iswrfds?&writefds:NULL, - self->isexfds?&exceptfds:NULL, - &timeout); - DosReleaseMutexSem(thread_select_mutex); - - if (chkstdin) { - int charcount = 0, res; - res = ioctl(0,FIONREAD,&charcount); - if (res==0 && charcount>0) FD_SET(0,&readfds); - } - - if (result>0) { - self->done++; - if (self->isrdfds) *self->readfds = readfds; - if (self->iswrfds) *self->writefds = writefds; - if (self->isexfds) *self->exceptfds = exceptfds; - } else - if (result) self->done++; - else DosSleep(1); - - } while (self->event!=0 && self->done==0); - - if (self->event) { - self->select_errno = (result < 0)?errno:0; - self->result = result; - self->done = 3; - DosPostEventSem(event); - } else { - self->done = 3; - free(self); - } - -} - -PRInt32 -_MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - pthread_select_t sel; - HEV ev = 0; - HTIMER timer = 0; - int result = 0; - APIRET rc; - unsigned long msecs = SEM_INDEFINITE_WAIT; - - if (timeout) { - if (timeout->tv_sec != 0 || timeout->tv_usec != 0) - msecs = (timeout->tv_sec * 1000L) + (timeout->tv_usec / 1000L); - else - msecs = SEM_IMMEDIATE_RETURN; - }; - - if (!(sel = (pthread_select_t) malloc(sizeof(struct _thread_select_st)))) { - result = -1; - errno = ENOMEM; - } else { - sel->nfds = nfds; - sel->isrdfds = readfds?1:0; - if (sel->isrdfds) sel->readfds = readfds; - sel->iswrfds = writefds?1:0; - if (sel->iswrfds) sel->writefds = writefds; - sel->isexfds = exceptfds?1:0; - if (sel->isexfds) sel->exceptfds = exceptfds; - sel->istimeout = timeout?1:0; - if (sel->istimeout) sel->timeout = *timeout; - - rc = DosCreateEventSem(NULL,&ev,0,FALSE); - - sel->event = ev; - if (msecs == SEM_IMMEDIATE_RETURN) - sel->done = 1; - else - sel->done = 0; - - if (_beginthread(_thread_select,NULL,65536,(void *)sel) == -1) { - result = -1; sel->event = 0; - DosCloseEventSem(ev); - } else { - rc = DosWaitEventSem(ev,msecs); - if ((!sel->done) && (msecs != SEM_IMMEDIATE_RETURN)) { /* Interrupted by other thread or timeout */ - sel->event = 0; - result = 0; - errno = ETIMEDOUT; - - } else { - while (sel->done && sel->done != 3) { - DosSleep(1); - } - sel->event = 0; - result = sel->result; - if (sel->select_errno) errno = sel->select_errno; - free(sel); - } - rc = DosCloseEventSem(ev); - } - } - - return (result); -} - -#endif diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c index b9c812ba..8830a675 100644 --- a/pr/src/md/os2/os2sock.c +++ b/pr/src/md/os2/os2sock.c @@ -100,7 +100,7 @@ _MD_SocketAvailable(PRFileDesc *fd) { PRInt32 result; - if (ioctl(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) { + if (so_ioctl(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) { PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno()); return -1; } @@ -139,17 +139,17 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) do { FD_SET(osfd, &rd_wr); if (fd_type == READ_FD) - rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv); + rv = bsdselect(osfd + 1, &rd_wr, NULL, NULL, &tv); else - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv); + rv = bsdselect(osfd + 1, NULL, &rd_wr, NULL, &tv); #else lTimeout = _PR_INTERRUPT_CHECK_INTERVAL_SECS * 1000; do { socks[0] = osfd; if (fd_type == READ_FD) - rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); + rv = os2_select(socks, 1, 0, 0, lTimeout); else - rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); + rv = os2_select(socks, 0, 1, 0, lTimeout); #endif if (rv == -1 && (syserror = sock_errno()) != EINTR) { _PR_MD_MAP_SELECT_ERROR(syserror); @@ -171,7 +171,7 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) #endif do { /* - * We block in _MD_SELECT for at most + * We block in select for at most * _PR_INTERRUPT_CHECK_INTERVAL_SECS seconds, * so that there is an upper limit on the delay * before the interrupt bit is checked. @@ -190,9 +190,9 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) } FD_SET(osfd, &rd_wr); if (fd_type == READ_FD) - rv = _MD_SELECT(osfd + 1, &rd_wr, NULL, NULL, &tv); + rv = bsdselect(osfd + 1, &rd_wr, NULL, NULL, &tv); else - rv = _MD_SELECT(osfd + 1, NULL, &rd_wr, NULL, &tv); + rv = bsdselect(osfd + 1, NULL, &rd_wr, NULL, &tv); #else wait_for_remaining = PR_TRUE; lTimeout = PR_IntervalToMilliseconds(remaining); @@ -202,9 +202,9 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) } socks[0] = osfd; if (fd_type == READ_FD) - rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); + rv = os2_select(socks, 1, 0, 0, lTimeout); else - rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); + rv = os2_select(socks, 0, 1, 0, lTimeout); #endif /* * we don't consider EINTR a real error @@ -220,12 +220,12 @@ socket_io_wait( PRInt32 osfd, PRInt32 fd_type, PRIntervalTime timeout ) break; } /* - * We loop again if _MD_SELECT timed out or got interrupted + * We loop again if select timed out or got interrupted * by a signal, and the timeout deadline has not passed yet. */ if (rv == 0 || (rv == -1 && syserror == EINTR)) { /* - * If _MD_SELECT timed out, we know how much time + * If select timed out, we know how much time * we spent in blocking, so we can avoid a * PR_IntervalNow() call. */ @@ -539,7 +539,7 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, } } - while ((rv = writev(osfd, (const struct iovec*)iov, iov_size)) == -1) { + while ((rv = so_writev(osfd, (const struct iovec*)iov, iov_size)) == -1) { err = sock_errno(); if ((err == EWOULDBLOCK)) { if (fd->secret->nonblocking) { @@ -584,6 +584,20 @@ _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how) return rv; } +PRInt32 +_PR_MD_SOCKETPAIR(int af, int type, int flags, PRInt32 *osfd) +{ + PRInt32 rv, err; + + rv = socketpair(af, type, flags, osfd); + if (rv < 0) { + err = _MD_ERRNO(); + _PR_MD_MAP_SOCKETPAIR_ERROR(err); + } + return rv; +} + + PRStatus _PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen) { @@ -652,7 +666,7 @@ _MD_MakeNonblock(PRFileDesc *fd) return; } - err = ioctl( osfd, FIONBIO, (char *) &one, sizeof(one)); + err = so_ioctl( osfd, FIONBIO, (char *) &one, sizeof(one)); if ( err != 0 ) { err = sock_errno(); diff --git a/pr/src/md/os2/os2thred.c b/pr/src/md/os2/os2thred.c index 735856bd..6b83869f 100644 --- a/pr/src/md/os2/os2thred.c +++ b/pr/src/md/os2/os2thred.c @@ -111,11 +111,10 @@ _PR_MD_CREATE_THREAD(PRThread *thread, PRThreadState state, PRUint32 stackSize) { - thread->md.handle = thread->id = (TID) _beginthread( - (void(* _Optlink)(void*))start, - NULL, - thread->stack->stackSize, - thread); + thread->md.handle = thread->id = (TID) _beginthread(start, + NULL, + thread->stack->stackSize, + thread); if(thread->md.handle == -1) { return PR_FAILURE; } diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c index 9396f2fa..0b8f99f7 100644 --- a/pr/src/misc/prnetdb.c +++ b/pr/src/misc/prnetdb.c @@ -1373,7 +1373,7 @@ PRUintn _PR_NetAddrSize(const PRNetAddr* addr) #else addrsize = sizeof(addr->ipv6); #endif -#if defined(XP_UNIX) +#if defined(XP_UNIX) || defined(XP_OS2) else if (AF_UNIX == addr->raw.family) addrsize = sizeof(addr->local); #endif diff --git a/pr/tests/Makefile.in b/pr/tests/Makefile.in index d765b256..62e7e18c 100644 --- a/pr/tests/Makefile.in +++ b/pr/tests/Makefile.in @@ -235,7 +235,7 @@ ifeq ($(MOZ_OS2_TOOLS),VACPP) LDOPTS = -NOE -DEBUG -nologo -PMTYPE:VIO else EXTRA_LIBS = $(OS_LIBS) - LDOPTS = -Zmtd -Zomf -Zlinker /PM:VIO -Zlinker /ST:0x30000 + LDOPTS = -Zomf -Zlinker /PM:VIO -Zlinker /ST:0x64000 endif endif diff --git a/pr/tests/dll/Makefile.in b/pr/tests/dll/Makefile.in index 38ad5b8e..2d86a4ac 100644 --- a/pr/tests/dll/Makefile.in +++ b/pr/tests/dll/Makefile.in @@ -78,12 +78,11 @@ ifeq (,$(filter-out WINNT OS2,$(OS_ARCH))) IMPORT_LIBRARY = $(OBJDIR)/my.$(LIB_SUFFIX) SHARED_LIBRARY = $(OBJDIR)/my.dll 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) -else -TARGETS = $(SHARED_LIBRARY) $(IMPORT_LIBRARY) +MAPFILE = $(OBJDIR)/my.def +GARBAGE += $(MAPFILE) +MKSHLIB += $(MAPFILE) endif +TARGETS = $(SHARED_LIBRARY) $(IMPORT_LIBRARY) else ifdef MKSHLIB SHARED_LIBRARY = $(OBJDIR)/libmy.$(DLL_SUFFIX) |