summaryrefslogtreecommitdiff
path: root/pr/src/md
diff options
context:
space:
mode:
authorcvs2hg <devnull@localhost>2001-04-20 01:25:00 +0000
committercvs2hg <devnull@localhost>2001-04-20 01:25:00 +0000
commitc24dc97185327dc82f0839025b3e947ec71a4438 (patch)
tree51862c188244197ebfdb4d8c3cd1ef74d8b02253 /pr/src/md
parentc946b6be47b3c83eef19f3347c17af256a08ef50 (diff)
downloadnspr-hg-c24dc97185327dc82f0839025b3e947ec71a4438.tar.gz
fixup commit for branch 'Accessible_042501_Branch3'Accessible_042501_Branch3
Diffstat (limited to 'pr/src/md')
-rw-r--r--pr/src/md/.cvsignore1
-rw-r--r--pr/src/md/Makefile59
-rw-r--r--pr/src/md/Makefile.in26
-rw-r--r--pr/src/md/beos/.cvsignore1
-rw-r--r--pr/src/md/beos/Makefile30
-rw-r--r--pr/src/md/beos/Makefile.in3
-rw-r--r--pr/src/md/mac/macdll.c9
-rw-r--r--pr/src/md/mac/macsockotpt.c240
-rw-r--r--pr/src/md/mac/macthr.c2
-rw-r--r--pr/src/md/mac/mdmac.c4
-rw-r--r--pr/src/md/mac/prcpucfg.h2
-rw-r--r--pr/src/md/os2/.cvsignore1
-rw-r--r--pr/src/md/os2/Makefile.in4
-rw-r--r--pr/src/md/os2/objs.mk (renamed from pr/src/md/os2/Makefile)54
-rw-r--r--pr/src/md/os2/os2cv.c12
-rw-r--r--pr/src/md/os2/os2inrval.c6
-rw-r--r--pr/src/md/os2/os2io.c59
-rw-r--r--pr/src/md/os2/os2misc.c2
-rw-r--r--pr/src/md/os2/os2poll.c154
-rw-r--r--pr/src/md/os2/os2sem.c10
-rw-r--r--pr/src/md/os2/os2sock.c268
-rw-r--r--pr/src/md/os2/os2thred.c26
-rw-r--r--pr/src/md/unix/.cvsignore1
-rw-r--r--pr/src/md/unix/Makefile316
-rw-r--r--pr/src/md/unix/Makefile.in261
-rw-r--r--pr/src/md/unix/darwin.c27
-rw-r--r--pr/src/md/unix/objs.mk217
-rw-r--r--pr/src/md/unix/os_Linux_x86.s95
-rw-r--r--pr/src/md/unix/rhapsody.c27
-rw-r--r--pr/src/md/unix/uxproces.c108
-rw-r--r--pr/src/md/unix/uxrng.c3
-rw-r--r--pr/src/md/unix/uxshm.c2
-rw-r--r--pr/src/md/windows/.cvsignore1
-rw-r--r--pr/src/md/windows/Makefile87
-rw-r--r--pr/src/md/windows/Makefile.in9
-rw-r--r--pr/src/md/windows/ntinrval.c2
-rw-r--r--pr/src/md/windows/ntio.c9
-rw-r--r--pr/src/md/windows/objs.mk16
-rw-r--r--pr/src/md/windows/w95io.c5
39 files changed, 863 insertions, 1296 deletions
diff --git a/pr/src/md/.cvsignore b/pr/src/md/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/pr/src/md/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/pr/src/md/Makefile b/pr/src/md/Makefile
deleted file mode 100644
index cb047e20..00000000
--- a/pr/src/md/Makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# The contents of this file are subject to the Netscape Public License
-# Version 1.1 (the "NPL"); you may not use this file except in
-# compliance with the NPL. You may obtain a copy of the NPL at
-# http://www.mozilla.org/NPL/
-#
-# Software distributed under the NPL is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
-# for the specific language governing rights and limitations under the
-# NPL.
-#
-# The Initial Developer of this code under the NPL is Netscape
-# Communications Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All Rights
-# Reserved.
-#
-
-#! gmake
-
-MOD_DEPTH = ../../..
-
-include $(MOD_DEPTH)/config/config.mk
-
-ifeq ($(OS_ARCH),WINNT)
- DIRS = windows
-else
- ifeq ($(OS_ARCH),OS2)
- DIRS = os2
- else
- ifeq ($(OS_ARCH),BeOS)
- DIRS = beos
- else
- DIRS = unix
- endif
- endif
-endif
-
-# Disable optimization of the nspr on SunOS4.1.3
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-OPTIMIZER =
-endif
-endif
-
-CSRCS = \
- prosdep.c \
- $(NULL)
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(MOD_DEPTH)/config/rules.mk
-
-export:: $(TARGETS)
-
-install:: export
diff --git a/pr/src/md/Makefile.in b/pr/src/md/Makefile.in
index 5e78b60b..f9157722 100644
--- a/pr/src/md/Makefile.in
+++ b/pr/src/md/Makefile.in
@@ -26,30 +26,7 @@ include $(MOD_DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
-ifdef USE_AUTOCONF
DIRS = $(PR_MD_ARCH_DIR)
-else
-ifeq ($(OS_ARCH),WINNT)
- ifeq ($(OS_TARGET),OS2)
- DIRS = os2
- else
- DIRS = windows
- endif
-else
- ifeq ($(OS_ARCH),BeOS)
- DIRS = beos
- else
- DIRS = unix
- endif
-endif
-
-# Disable optimization of the nspr on SunOS4.1.3
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-OPTIMIZER =
-endif
-endif
-endif # USE_AUTOCONF
CSRCS = \
prosdep.c \
@@ -57,7 +34,7 @@ CSRCS = \
TARGETS = $(OBJS)
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include
+INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include
DEFINES += -D_NSPR_BUILD_
@@ -65,4 +42,3 @@ include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)
-install:: export
diff --git a/pr/src/md/beos/.cvsignore b/pr/src/md/beos/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/pr/src/md/beos/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/pr/src/md/beos/Makefile b/pr/src/md/beos/Makefile
deleted file mode 100644
index ce21aece..00000000
--- a/pr/src/md/beos/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# The contents of this file are subject to the Mozilla Public License
-# Version 1.1 (the "MPL"); you may not use this file except in
-# compliance with the MPL. You may obtain a copy of the MPL at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
-# for the specific language governing rights and limitations under the
-# MPL.
-#
-
-MOD_DEPTH = ../../../..
-
-include $(MOD_DEPTH)/config/config.mk
-
-include bsrcs.mk
-CSRCS += $(MDCSRCS)
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(MOD_DEPTH)/config/rules.mk
-
-export:: $(TARGETS)
-
-install:: export
diff --git a/pr/src/md/beos/Makefile.in b/pr/src/md/beos/Makefile.in
index 9e407a95..024bde8b 100644
--- a/pr/src/md/beos/Makefile.in
+++ b/pr/src/md/beos/Makefile.in
@@ -24,7 +24,7 @@ CSRCS += $(MDCSRCS)
TARGETS = $(OBJS)
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
DEFINES += -D_NSPR_BUILD_
@@ -32,4 +32,3 @@ include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)
-install:: export
diff --git a/pr/src/md/mac/macdll.c b/pr/src/md/mac/macdll.c
index bebf2356..ba9465d0 100644
--- a/pr/src/md/mac/macdll.c
+++ b/pr/src/md/mac/macdll.c
@@ -530,6 +530,15 @@ OSErr NSLoadIndexedFragment(const FSSpec *fileSpec, PRUint32 fragmentIndex,
err = GetIndexedFragmentOffsets(fileSpec, fragmentIndex, &fragOffset, &fragLength, &fragNameBlock);
if (err != noErr) return err;
+ if (fragNameBlock)
+ {
+ UInt32 nameLen = strlen(fragNameBlock);
+ if (nameLen > 63)
+ nameLen = 63;
+ BlockMoveData(fragNameBlock, &fragName[1], nameLen);
+ fragName[0] = nameLen;
+ }
+
err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName,
kLoadCFrag, outConnectionID, &main, errName);
if (err != noErr)
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c
index 7b6e4441..910803c6 100644
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -29,6 +29,12 @@
#define GESTALT_OPEN_TPT_TCP_PRESENT gestaltOpenTptTCPPresentMask
#include <OpenTptInternet.h> // All the internet typedefs
+
+#if (UNIVERSAL_INTERFACES_VERSION >= 0x0330)
+// for some reason Apple removed this typedef.
+typedef struct OTConfiguration OTConfiguration;
+#endif
+
#include "primpl.h"
typedef enum SndRcvOpCode {
@@ -45,11 +51,10 @@ static struct {
void * cookie;
} dnsContext;
-static PRBool gOTInitialized;
static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
-static pascal void NotifierRoutine(void * contextPtr, OTEventCode code,
- OTResult result, void * cookie);
+static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
+static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady);
@@ -59,24 +64,20 @@ extern void DoneWaitingOnThisThread(PRThread *thread);
#if TARGET_CARBON
OTClientContextPtr clientContext = NULL;
-OTNotifyUPP DNSNotifierRoutineUPP;
-OTNotifyUPP notifierRoutineUPP;
-
-#define DNS_NOTIFIER_ROUTINE DNSNotifierRoutineUPP
-#define NOTIFIER_ROUTINE notifierRoutineUPP
-#define INIT_OPEN_TRANSPORT() InitOpenTransport(clientContext, kInitOTForExtensionMask)
-#define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServices(config, flags, err, clientContext)
-#define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpoint(config, flags, info, err, clientContext)
+#define INIT_OPEN_TRANSPORT() InitOpenTransportInContext(kInitOTForExtensionMask, &clientContext)
+#define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServicesInContext(config, flags, err, clientContext)
+#define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpointInContext(config, flags, info, err, clientContext)
#else
-#define DNS_NOTIFIER_ROUTINE DNSNotifierRoutine
-#define NOTIFIER_ROUTINE NotifierRoutine
#define INIT_OPEN_TRANSPORT() InitOpenTransport()
#define OT_OPEN_INTERNET_SERVICES(config, flags, err) OTOpenInternetServices(config, flags, err)
#define OT_OPEN_ENDPOINT(config, flags, info, err) OTOpenEndpoint(config, flags, info, err)
#endif /* TARGET_CARBON */
+static OTNotifyUPP DNSNotifierRoutineUPP;
+static OTNotifyUPP NotifierRoutineUPP;
+static OTNotifyUPP RawEndpointNotifierRoutineUPP;
void _MD_InitNetAccess()
{
@@ -97,26 +98,20 @@ void _MD_InitNetAccess()
PR_ASSERT(hasOTTCPIP == PR_TRUE);
-#if TARGET_CARBON
DNSNotifierRoutineUPP = NewOTNotifyUPP(DNSNotifierRoutine);
- notifierRoutineUPP = NewOTNotifyUPP(NotifierRoutine);
-
- errOT = OTAllocClientContext((UInt32)0, &clientContext);
- PR_ASSERT(err == kOTNoError);
-#endif
-
+ NotifierRoutineUPP = NewOTNotifyUPP(NotifierRoutine);
+ RawEndpointNotifierRoutineUPP = NewOTNotifyUPP(RawEndpointNotifierRoutine);
errOT = INIT_OPEN_TRANSPORT();
PR_ASSERT(err == kOTNoError);
+ dnsContext.serviceRef = NULL;
dnsContext.lock = PR_NewLock();
PR_ASSERT(dnsContext.lock != NULL);
dnsContext.thread = _PR_MD_CURRENT_THREAD();
dnsContext.cookie = NULL;
- gOTInitialized = PR_FALSE;
-
/* XXX Does not handle absence of open tpt and tcp yet! */
}
@@ -124,36 +119,65 @@ static void _MD_FinishInitNetAccess()
{
OSStatus errOT;
+ if (dnsContext.serviceRef)
+ return;
+
dnsContext.serviceRef = OT_OPEN_INTERNET_SERVICES(kDefaultInternetServicesPath, NULL, &errOT);
- if (errOT != kOTNoError) return; /* no network -- oh well */
+ if (errOT != kOTNoError) {
+ dnsContext.serviceRef = NULL;
+ return; /* no network -- oh well */
+ }
+
PR_ASSERT((dnsContext.serviceRef != NULL) && (errOT == kOTNoError));
/* Install notify function for DNR Address To String completion */
- errOT = OTInstallNotifier(dnsContext.serviceRef, DNS_NOTIFIER_ROUTINE, &dnsContext);
+ errOT = OTInstallNotifier(dnsContext.serviceRef, DNSNotifierRoutineUPP, &dnsContext);
PR_ASSERT(errOT == kOTNoError);
/* Put us into async mode */
errOT = OTSetAsynchronous(dnsContext.serviceRef);
PR_ASSERT(errOT == kOTNoError);
-
- gOTInitialized = PR_TRUE;
}
-pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode otEvent, OTResult result, void * cookie)
{
#pragma unused(contextPtr)
_PRCPU * cpu = _PR_MD_CURRENT_CPU();
-
- if (code == T_DNRSTRINGTOADDRCOMPLETE) {
+ OSStatus errOT;
+
dnsContext.thread->md.osErrCode = result;
dnsContext.cookie = cookie;
- if (_PR_MD_GET_INTSOFF()) {
- cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
- dnsContext.thread->md.missedIONotify = PR_TRUE;
- return;
- }
- DoneWaitingOnThisThread(dnsContext.thread);
+
+ switch (otEvent) {
+ case T_DNRSTRINGTOADDRCOMPLETE:
+ if (_PR_MD_GET_INTSOFF()) {
+ cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
+ dnsContext.thread->md.missedIONotify = PR_TRUE;
+ return;
+ }
+ DoneWaitingOnThisThread(dnsContext.thread);
+ break;
+
+ case kOTProviderWillClose:
+ errOT = OTSetSynchronous(dnsContext.serviceRef);
+ // fall through to kOTProviderIsClosed case
+
+ case kOTProviderIsClosed:
+ errOT = OTCloseProvider((ProviderRef)dnsContext.serviceRef);
+ dnsContext.serviceRef = nil;
+
+ if (_PR_MD_GET_INTSOFF()) {
+ cpu->u.missed[cpu->where] |= _PR_MISSED_IO;
+ dnsContext.thread->md.missedIONotify = PR_TRUE;
+ return;
+ }
+ DoneWaitingOnThisThread(dnsContext.thread);
+ break;
+
+ default: // or else we don't handle the event
+ PR_ASSERT(otEvent==NULL);
+
}
// or else we don't handle the event
}
@@ -262,12 +286,13 @@ WakeUpNotifiedThread(PRThread *thread, OTResult result)
// Notification routine
// Async callback routine.
// A5 is OK. Cannot allocate memory here
-pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
{
PRFilePrivate *secret = (PRFilePrivate *) contextPtr;
_MDFileDesc * md = &(secret->md);
EndpointRef endpoint = (EndpointRef)secret->md.osfd;
PRThread * thread = NULL;
+ PRThread * pollThread = md->poll.thread;
OSStatus err;
OTResult resultOT;
TDiscon discon;
@@ -301,7 +326,6 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
thread = secret->md.write.thread;
secret->md.write.thread = NULL;
secret->md.write.cookie = cookie;
- secret->md.connectionOpen = PR_TRUE;
break;
case T_DATA: // Standard data is available
@@ -323,7 +347,6 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
err = OTRcvDisconnect(endpoint, &discon);
PR_ASSERT(err == kOTNoError);
secret->md.exceptReady = PR_TRUE;
- secret->md.connectionOpen = PR_FALSE;
// wake up waiting threads, if any
result = -3199 - discon.reason; // obtain the negative error code
@@ -356,7 +379,7 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
PR_ASSERT(err == kOTNoError);
secret->md.readReady = PR_TRUE; // mark readable (to emulate bsd sockets)
// remember connection is closed, so we can return 0 on read or receive
- secret->md.connectionOpen = PR_FALSE;
+ secret->md.orderlyDisconnect = PR_TRUE;
thread = secret->md.read.thread;
secret->md.read.thread = NULL;
@@ -430,7 +453,11 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul
return;
}
- WakeUpNotifiedThread(thread, result);
+ if (pollThread)
+ WakeUpNotifiedThread(pollThread, kOTNoError);
+
+ if (thread && (thread != pollThread))
+ WakeUpNotifiedThread(thread, result);
}
@@ -473,7 +500,6 @@ PRInt32 _MD_socket(int domain, int type, int protocol)
OSStatus err;
EndpointRef endpoint;
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
// We only deal with internet domain
@@ -1037,7 +1063,7 @@ typedef struct RawEndpointAndThread
// Notification routine for raw endpoints not yet attached to a PRFileDesc.
// Async callback routine.
// A5 is OK. Cannot allocate memory here
-pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
{
RawEndpointAndThread *endthr = (RawEndpointAndThread *) contextPtr;
PRThread * thread = endthr->thread;
@@ -1194,7 +1220,7 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRInterva
endthr->thread = me;
endthr->endpoint = (EndpointRef) newosfd;
- err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutine, endthr);
+ err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutineUPP, endthr);
PR_ASSERT(err == kOTNoError);
err = OTSetAsynchronous((EndpointRef) newosfd);
@@ -1350,6 +1376,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
PRInt32 bytesLeft = amount;
PR_ASSERT(flags == 0);
+ PR_ASSERT(opCode == kSTREAM_SEND || opCode == kSTREAM_RECEIVE);
if (endpoint == NULL) {
err = kEBADFErr;
@@ -1361,11 +1388,6 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
goto ErrorExit;
}
- if (opCode != kSTREAM_SEND && opCode != kSTREAM_RECEIVE) {
- err = kEINVALErr;
- goto ErrorExit;
- }
-
while (bytesLeft > 0) {
PrepareForAsyncCompletion(me, fd->secret->md.osfd);
@@ -1434,6 +1456,10 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
}
me->io_pending = PR_FALSE;
+ if (opCode == kSTREAM_SEND)
+ fd->secret->md.write.thread = nil;
+ else
+ fd->secret->md.read.thread = nil;
if (result > 0) {
buf = (void *) ( (UInt32) buf + (UInt32)result );
@@ -1442,9 +1468,6 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
return result;
} else {
switch (result) {
- case kOTOutStateErr: // it has been closed
- return 0;
-
case kOTLookErr:
PR_ASSERT(!"call to OTLook() required after all.");
break;
@@ -1464,6 +1487,9 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
goto ErrorExit;
break;
+ case kOTOutStateErr: // if provider already closed, fall through to handle error
+ if (fd->secret->md.orderlyDisconnect)
+ return 0;
default:
err = result;
goto ErrorExit;
@@ -1471,9 +1497,13 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount,
}
}
+ PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
+ fd->secret->md.read.thread == nil);
return amount;
ErrorExit:
+ PR_ASSERT(opCode == kSTREAM_SEND ? fd->secret->md.write.thread == nil :
+ fd->secret->md.read.thread == nil);
macsock_map_error(err);
return -1;
}
@@ -1633,8 +1663,13 @@ PRInt32 _MD_writev(PRFileDesc *fd, const struct PRIOVec *iov, PRInt32 iov_size,
static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady)
{
OTResult resultOT;
-
- *readReady = fd->secret->md.readReady;
+ // hack to emulate BSD sockets; say that a socket that has disconnected
+ // is still readable.
+ size_t availableData = 1;
+ if (!fd->secret->md.orderlyDisconnect)
+ OTCountDataBytes((EndpointRef)fd->secret->md.osfd, &availableData);
+
+ *readReady = fd->secret->md.readReady && (availableData > 0);
*exceptReady = fd->secret->md.exceptReady;
resultOT = OTGetEndpointState((EndpointRef)fd->secret->md.osfd);
@@ -1650,22 +1685,13 @@ static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PR
return *readReady || *writeReady || *exceptReady;
}
-
-PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
+// check to see if any of the poll descriptors have data available
+// for reading or writing.
+static PRInt32 CheckPollDescs(PRPollDesc *pds, PRIntn npds)
{
PRInt32 ready = 0;
PRPollDesc *pd, *epd;
- PRIntervalTime sleepTime, timein;
- sleepTime = PR_MillisecondsToInterval(5UL);
- if (PR_INTERVAL_NO_TIMEOUT != timeout)
- {
- if (sleepTime > timeout) sleepTime = timeout;
- timein = PR_IntervalNow();
- }
-
- do
- {
for (pd = pds, epd = pd + npds; pd < epd; pd++)
{
PRInt16 in_flags_read = 0, in_flags_write = 0;
@@ -1697,8 +1723,9 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
pd->out_flags = 0; /* pre-condition */
bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
PR_ASSERT(NULL != bottomFD);
- if ((NULL != bottomFD) && (_PR_FILEDESC_OPEN == bottomFD->secret->state))
- {
+
+ if (bottomFD && (_PR_FILEDESC_OPEN == bottomFD->secret->state))
+ {
if (GetState(bottomFD, &readReady, &writeReady, &exceptReady))
{
if (readReady)
@@ -1722,7 +1749,7 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
if (0 != pd->out_flags) ready++;
}
}
- else
+ else /* bad state */
{
ready += 1; /* this will cause an abrupt return */
pd->out_flags = PR_POLL_NVAL; /* bogii */
@@ -1730,14 +1757,69 @@ PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
}
}
- if (ready > 0) return ready;
+ return ready;
+}
+
+// set or clear md.poll.thread on the poll descriptors
+static void SetDescPollThread(PRPollDesc *pds, PRIntn npds, PRThread* thread)
+{
+ PRInt32 ready = 0;
+ PRPollDesc *pd, *epd;
+
+ for (pd = pds, epd = pd + npds; pd < epd; pd++)
+ {
+ if (pd->fd)
+ {
+ PRFileDesc *bottomFD = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
+ PR_ASSERT(NULL != bottomFD);
+ if (bottomFD && (_PR_FILEDESC_OPEN == bottomFD->secret->state))
+ {
+ bottomFD->secret->md.poll.thread = thread;
+ }
+ }
+ }
+}
+
+PRInt32 _MD_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
+{
+ PRThread *thread = _PR_MD_CURRENT_THREAD();
+ intn is;
+ PRInt32 ready;
+ OSErr result;
+
+ if (timeout == PR_INTERVAL_NO_WAIT) {
+ return CheckPollDescs(pds, npds);
+ }
+
+ _PR_INTSOFF(is);
+ PR_Lock(thread->md.asyncIOLock);
- (void) PR_Sleep(sleepTime);
+ // ensure that we don't miss the firing of the notifier while checking socket status
+ // need to set up the thread
+ PrepareForAsyncCompletion(thread, 0);
- } while ((timeout == PR_INTERVAL_NO_TIMEOUT) ||
- (((PRIntervalTime)(PR_IntervalNow() - timein)) < timeout));
+ SetDescPollThread(pds, npds, thread);
+ ready = CheckPollDescs(pds, npds);
- return 0; /* timed out */
+ PR_Unlock(thread->md.asyncIOLock);
+ _PR_FAST_INTSON(is);
+
+ if (ready == 0) {
+ WaitOnThisThread(thread, timeout);
+ result = thread->md.osErrCode;
+ if (result != noErr && result != kETIMEDOUTErr) {
+ PR_ASSERT(0); /* debug: catch unexpected errors */
+ ready = -1;
+ } else {
+ ready = CheckPollDescs(pds, npds);
+ }
+ } else {
+ thread->io_pending = PR_FALSE;
+ }
+
+ SetDescPollThread(pds, npds, NULL);
+
+ return ready;
}
@@ -1752,7 +1834,7 @@ void _MD_initfiledesc(PRFileDesc *fd)
PR_ASSERT(fd->secret->md.miscLock == NULL);
fd->secret->md.miscLock = PR_NewLock();
PR_ASSERT(fd->secret->md.miscLock != NULL);
- fd->secret->md.connectionOpen = PR_FALSE; // starts out closed
+ fd->secret->md.orderlyDisconnect = PR_FALSE;
fd->secret->md.readReady = PR_FALSE; // let's not presume we have data ready to read
fd->secret->md.writeReady = PR_TRUE; // let's presume we can write unless we hear otherwise
fd->secret->md.exceptReady = PR_FALSE;
@@ -1789,7 +1871,7 @@ void _MD_makenonblock(PRFileDesc *fd)
// fd changes, but the secret structure does not;
// (b) the notifier func refers only to the secret data structure
// anyway.
- err = OTInstallNotifier(endpointRef, NOTIFIER_ROUTINE, fd->secret);
+ err = OTInstallNotifier(endpointRef, NotifierRoutineUPP, fd->secret);
PR_ASSERT(err == kOTNoError);
// Now that we have a NotifierRoutine installed, we can make the endpoint asynchronous
@@ -1862,11 +1944,11 @@ PR_IMPLEMENT(unsigned long) inet_addr(const char *cp)
OSStatus err;
InetHost host;
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
err = OTInetStringToHost((char*) cp, &host);
- PR_ASSERT(err == kOTNoError);
+ if (err != kOTNoError)
+ return -1;
return host;
}
@@ -1884,7 +1966,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyname(const char * name)
PRUint32 index;
PRThread *me = _PR_MD_CURRENT_THREAD();
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
me->io_pending = PR_TRUE;
@@ -1925,7 +2006,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int
PR_ASSERT(type == AF_INET);
PR_ASSERT(addrlen == sizeof(struct in_addr));
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
OTInetHostToString((InetHost)addr, sHostInfo.name);
@@ -1936,7 +2016,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int
PR_IMPLEMENT(char *) inet_ntoa(struct in_addr addr)
{
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
OTInetHostToString((InetHost)addr.s_addr, sHostInfo.name);
@@ -1950,7 +2029,6 @@ PRStatus _MD_gethostname(char *name, int namelen)
OSStatus err;
InetInterfaceInfo info;
- if (!gOTInitialized)
_MD_FinishInitNetAccess();
/*
diff --git a/pr/src/md/mac/macthr.c b/pr/src/md/mac/macthr.c
index 53d61206..59b67a67 100644
--- a/pr/src/md/mac/macthr.c
+++ b/pr/src/md/mac/macthr.c
@@ -275,6 +275,8 @@ void WaitOnThisThread(PRThread *thread, PRIntervalTime timeout)
thread->md.osErrCode = kETIMEDOUTErr;
PR_SetError(PR_IO_TIMEOUT_ERROR, kETIMEDOUTErr);
}
+
+ thread->io_pending = PR_FALSE;
PR_Unlock(thread->md.asyncIOLock);
_PR_FAST_INTSON(is);
}
diff --git a/pr/src/md/mac/mdmac.c b/pr/src/md/mac/mdmac.c
index c762baa7..bca487a7 100644
--- a/pr/src/md/mac/mdmac.c
+++ b/pr/src/md/mac/mdmac.c
@@ -344,7 +344,7 @@ void PR_InitMemory(void) {
#if TARGET_CARBON
extern OTClientContextPtr clientContext;
-#define CLOSE_OPEN_TRANSPORT() CloseOpenTransport(clientContext)
+#define CLOSE_OPEN_TRANSPORT() CloseOpenTransportInContext(clientContext)
#else
@@ -739,7 +739,7 @@ extern long _MD_GetArchitecture(char *buf, long count)
{
long len;
-#if defined(GENERATINGPOWERPC) && GENERATINGPOWERPC
+#if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC
len = PR_snprintf(buf, count, "PowerPC");
#else
len = PR_snprintf(buf, count, "Motorola68k");
diff --git a/pr/src/md/mac/prcpucfg.h b/pr/src/md/mac/prcpucfg.h
index bc203a42..9483f1f3 100644
--- a/pr/src/md/mac/prcpucfg.h
+++ b/pr/src/md/mac/prcpucfg.h
@@ -112,6 +112,6 @@
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
-#endif NO_NSPR_10_SUPPORT
+#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */
diff --git a/pr/src/md/os2/.cvsignore b/pr/src/md/os2/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/pr/src/md/os2/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/pr/src/md/os2/Makefile.in b/pr/src/md/os2/Makefile.in
index 72414033..08f866d7 100644
--- a/pr/src/md/os2/Makefile.in
+++ b/pr/src/md/os2/Makefile.in
@@ -38,12 +38,13 @@ CSRCS = \
os2sock.c \
os2_errors.c \
os2poll.c \
+ os2rng.c \
$(NULL)
endif
TARGETS = $(OBJS)
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
+INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
DEFINES += -D_NSPR_BUILD_
@@ -51,7 +52,6 @@ include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)
-install:: export
diff --git a/pr/src/md/os2/Makefile b/pr/src/md/os2/objs.mk
index 03e4c863..82693637 100644
--- a/pr/src/md/os2/Makefile
+++ b/pr/src/md/os2/objs.mk
@@ -15,39 +15,23 @@
# Reserved.
#
-#! gmake
-
-MOD_DEPTH = ../../../..
-
-include $(MOD_DEPTH)/config/config.mk
-
-ifeq ($(OS_TARGET), OS2)
-CSRCS = \
- os2misc.c \
- os2sem.c \
- os2inrval.c \
- os2gc.c \
- os2thred.c \
- os2io.c \
- os2cv.c \
- os2sock.c \
- os2_errors.c \
- os2poll.c \
- os2rng.c \
- $(NULL)
-endif
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(MOD_DEPTH)/config/rules.mk
-
-export:: $(TARGETS)
-
-install:: export
-
-
+# This makefile appends to the variable OBJS the platform-dependent
+# object modules that will be part of the nspr20 library.
+
+CSRCS = \
+ os2io.c \
+ os2sock.c \
+ os2thred.c \
+ os2cv.c \
+ os2gc.c \
+ os2misc.c \
+ os2inrval.c \
+ os2sem.c \
+ os2_errors.c \
+ os2poll.c \
+ os2rng.c \
+ $(NULL)
+
+OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
+ $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
diff --git a/pr/src/md/os2/os2cv.c b/pr/src/md/os2/os2cv.c
index 1205f3af..f91ae80d 100644
--- a/pr/src/md/os2/os2cv.c
+++ b/pr/src/md/os2/os2cv.c
@@ -219,7 +219,7 @@ static void md_PostNotifyToCvar(_MDCVar *cvar, _MDLock *lock,
* 0 when it succeeds.
*
*/
-PR_IMPLEMENT(PRInt32)
+PRInt32
_PR_MD_NEW_CV(_MDCVar *cv)
{
cv->magic = _MD_MAGIC_CV;
@@ -230,7 +230,7 @@ _PR_MD_NEW_CV(_MDCVar *cv)
return 0;
}
-PR_IMPLEMENT(void) _PR_MD_FREE_CV(_MDCVar *cv)
+void _PR_MD_FREE_CV(_MDCVar *cv)
{
cv->magic = (PRUint32)-1;
return;
@@ -239,7 +239,7 @@ PR_IMPLEMENT(void) _PR_MD_FREE_CV(_MDCVar *cv)
/*
* _PR_MD_WAIT_CV() -- Wait on condition variable
*/
-PR_IMPLEMENT(void)
+void
_PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout )
{
PRThread *thred = _PR_MD_CURRENT_THREAD();
@@ -306,21 +306,21 @@ _PR_MD_WAIT_CV(_MDCVar *cv, _MDLock *lock, PRIntervalTime timeout )
return;
} /* --- end _PR_MD_WAIT_CV() --- */
-PR_IMPLEMENT(void)
+void
_PR_MD_NOTIFY_CV(_MDCVar *cv, _MDLock *lock)
{
md_PostNotifyToCvar(cv, lock, PR_FALSE);
return;
}
-PR_IMPLEMENT(void)
+void
_PR_MD_NOTIFYALL_CV(_MDCVar *cv, _MDLock *lock)
{
md_PostNotifyToCvar(cv, lock, PR_TRUE);
return;
}
-PR_IMPLEMENT(void)
+void
_PR_MD_UNLOCK(_MDLock *lock)
{
if (0 != lock->notified.length) {
diff --git a/pr/src/md/os2/os2inrval.c b/pr/src/md/os2/os2inrval.c
index ecba3068..ea2dd38a 100644
--- a/pr/src/md/os2/os2inrval.c
+++ b/pr/src/md/os2/os2inrval.c
@@ -29,7 +29,7 @@ PRInt32 _os2_highMask = 0;
-PR_IMPLEMENT(void)
+void
_PR_MD_INTERVAL_INIT()
{
if (DosTmrQueryFreq(&_os2_ticksPerSec) == NO_ERROR)
@@ -46,7 +46,7 @@ _PR_MD_INTERVAL_INIT()
PR_ASSERT(_os2_ticksPerSec > PR_INTERVAL_MIN && _os2_ticksPerSec < PR_INTERVAL_MAX);
}
-PR_IMPLEMENT(PRIntervalTime)
+PRIntervalTime
_PR_MD_GET_INTERVAL()
{
QWORD count;
@@ -69,7 +69,7 @@ _PR_MD_GET_INTERVAL()
}
}
-PR_IMPLEMENT(PRIntervalTime)
+PRIntervalTime
_PR_MD_INTERVAL_PER_SEC()
{
if(_os2_ticksPerSec != -1)
diff --git a/pr/src/md/os2/os2io.c b/pr/src/md/os2/os2io.c
index e6977ff7..e7e7b705 100644
--- a/pr/src/md/os2/os2io.c
+++ b/pr/src/md/os2/os2io.c
@@ -14,6 +14,23 @@
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
+ *
+ * This Original Code has been modified by IBM Corporation.
+ * Modifications made by IBM described herein are
+ * Copyright (c) International Business Machines
+ * Corporation, 2000
+ *
+ * Modifications to Mozilla code or documentation
+ * identified per MPL Section 3.3
+ *
+ * Date Modified by Description of modification
+ * 03/23/2000 IBM Corp. Changed write() to DosWrite(). EMX i/o
+ * calls cannot be intermixed with DosXXX
+ * calls since EMX remaps file/socket
+ * handles.
+ * 04/27/2000 IBM Corp. Changed open file to be more like NT and
+ * better handle PR_TRUNCATE | PR_CREATE_FILE
+ * and also fixed _PR_MD_SET_FD_INHERITABLE
*/
/* OS2 IO module
@@ -107,25 +124,40 @@ _PR_MD_OPEN(const char *name, PRIntn osflags, int mode)
{
HFILE file;
PRInt32 access = OPEN_SHARE_DENYNONE;
- PRInt32 flags = OPEN_ACTION_OPEN_IF_EXISTS;
+ PRInt32 flags = 0L;
PRInt32 rc;
PRUword actionTaken;
ULONG CurMaxFH = 0;
LONG ReqCount = 1;
ULONG fattr;
-
+
+ if (osflags & PR_SYNC) access |= OPEN_FLAGS_WRITE_THROUGH;
+
if (osflags & PR_RDONLY)
access |= OPEN_ACCESS_READONLY;
else if (osflags & PR_WRONLY)
access |= OPEN_ACCESS_WRITEONLY;
else if(osflags & PR_RDWR)
access |= OPEN_ACCESS_READWRITE;
- if (osflags & PR_CREATE_FILE)
- flags |= OPEN_ACTION_CREATE_IF_NEW;
- else if (osflags & PR_TRUNCATE){
- flags &= ~OPEN_ACTION_OPEN_IF_EXISTS;
- flags |= OPEN_ACTION_REPLACE_IF_EXISTS;
+
+ if ( osflags & PR_CREATE_FILE && osflags & PR_EXCL )
+ {
+ flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS;
+ }
+ else if (osflags & PR_CREATE_FILE)
+ {
+ if (osflags & PR_TRUNCATE)
+ flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+ else
+ flags = OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
+ }
+ else
+ {
+ if (osflags & PR_TRUNCATE)
+ flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+ else
+ flags = OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
}
if (isxdigit(mode) == 0) /* file attribs are hex, UNIX modes octal */
@@ -182,23 +214,16 @@ _PR_MD_WRITE(PRFileDesc *fd, const void *buf, PRInt32 len)
PRInt32 bytes;
int rv;
- /* No longer using DosWrite since it doesn't convert \n to \n\r like C runtime does */
-#if 0
rv = DosWrite((HFILE)fd->secret->md.osfd,
(PVOID)buf,
len,
- &bytes);
+ (PULONG)&bytes);
if (rv != NO_ERROR)
{
- _PR_MD_MAP_WRITE_ERROR(rv);
+ _PR_MD_MAP_WRITE_ERROR(rv);
return -1;
}
-#else
- bytes = write(fd->secret->md.osfd, buf, len);
- if (bytes == -1)
- _PR_MD_MAP_WRITE_ERROR(errno);
-#endif
return bytes;
} /* --- end _PR_MD_WRITE() --- */
@@ -718,7 +743,7 @@ _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable)
}
if (inheritable)
- flags &= OPEN_FLAGS_NOINHERIT;
+ flags &= ~OPEN_FLAGS_NOINHERIT;
else
flags |= OPEN_FLAGS_NOINHERIT;
diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c
index 27277e68..28c9a641 100644
--- a/pr/src/md/os2/os2misc.c
+++ b/pr/src/md/os2/os2misc.c
@@ -473,7 +473,7 @@ PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen)
return PR_FAILURE;
}
-PR_IMPLEMENT(void)
+void
_PR_MD_WAKEUP_CPUS( void )
{
return;
diff --git a/pr/src/md/os2/os2poll.c b/pr/src/md/os2/os2poll.c
index 47b1791e..99740c66 100644
--- a/pr/src/md/os2/os2poll.c
+++ b/pr/src/md/os2/os2poll.c
@@ -61,6 +61,9 @@ PRInt32 _PR_MD_PR_POLL(
return 0;
}
+ remaining = timeout;
+ start = PR_IntervalNow();
+
FD_ZERO(&rd);
FD_ZERO(&wt);
FD_ZERO(&ex);
@@ -161,9 +164,6 @@ PRInt32 _PR_MD_PR_POLL(
if (0 != ready) return ready; /* no need to block */
- remaining = timeout;
- start = PR_IntervalNow();
-
retry:
if (timeout != PR_INTERVAL_NO_TIMEOUT)
{
@@ -260,3 +260,151 @@ 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/os2sem.c b/pr/src/md/os2/os2sem.c
index 86a41f58..57131beb 100644
--- a/pr/src/md/os2/os2sem.c
+++ b/pr/src/md/os2/os2sem.c
@@ -24,7 +24,7 @@
#include "primpl.h"
-PR_IMPLEMENT(void)
+void
_PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value)
{
int rv;
@@ -36,7 +36,7 @@ _PR_MD_NEW_SEM(_MDSemaphore *md, PRUintn value)
PR_ASSERT(rv == NO_ERROR);
}
-PR_IMPLEMENT(void)
+void
_PR_MD_DESTROY_SEM(_MDSemaphore *md)
{
int rv;
@@ -45,7 +45,7 @@ _PR_MD_DESTROY_SEM(_MDSemaphore *md)
}
-PR_IMPLEMENT(PRStatus)
+PRStatus
_PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks)
{
int rv;
@@ -57,13 +57,13 @@ _PR_MD_TIMED_WAIT_SEM(_MDSemaphore *md, PRIntervalTime ticks)
return PR_FAILURE;
}
-PR_IMPLEMENT(PRStatus)
+PRStatus
_PR_MD_WAIT_SEM(_MDSemaphore *md)
{
return _PR_MD_TIMED_WAIT_SEM(md, PR_INTERVAL_NO_TIMEOUT);
}
-PR_IMPLEMENT(void)
+void
_PR_MD_POST_SEM(_MDSemaphore *md)
{
int rv;
diff --git a/pr/src/md/os2/os2sock.c b/pr/src/md/os2/os2sock.c
index 34f5ff43..d8e78a0e 100644
--- a/pr/src/md/os2/os2sock.c
+++ b/pr/src/md/os2/os2sock.c
@@ -55,7 +55,7 @@ _PR_MD_SOCKET(int af, int type, int flags)
{
int rv = sock_errno();
soclose(sock);
- _PR_MD_MAP_SOCKET_ERROR(rv);
+ _PR_MD_MAP_SOCKET_ERROR(rv);
return (PRInt32) -1;
}
@@ -82,8 +82,8 @@ _MD_CloseSocket(PRInt32 osfd)
PRInt32 rv = -1;
rv = soclose((int) osfd );
- if (rv < 0)
- _PR_MD_MAP_SOCKET_ERROR(sock_errno());
+ if (rv < 0)
+ _PR_MD_MAP_SOCKET_ERROR(sock_errno());
return rv;
}
@@ -94,7 +94,7 @@ _MD_SocketAvailable(PRFileDesc *fd)
PRInt32 result;
if (ioctl(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) {
- PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno());
+ PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno());
return -1;
}
return result;
@@ -124,18 +124,18 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
&& (!fd->secret->nonblocking))
{
#ifdef BSD_SELECT
- if ((rv = select(osfd + 1, &rd, NULL, NULL,NULL)) == -1) {
+ if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL,NULL)) == -1) {
#else
- if ((rv = select(socks, 1, 0, 0, -1)) == -1) {
+ if ((rv = _MD_SELECT(socks, 1, 0, 0, -1)) == -1) {
#endif
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
break;
- }
+ }
}
else {
- _PR_MD_MAP_ACCEPT_ERROR(err);
+ _PR_MD_MAP_ACCEPT_ERROR(err);
break;
- }
+ }
}
return(rv);
}
@@ -146,14 +146,14 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,
if (((err = sock_errno()) == EWOULDBLOCK)
&& (!fd->secret->nonblocking))
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
}
else
{
_PR_MD_MAP_ACCEPT_ERROR(err);
}
}
- return(rv);
+ return(rv);
}
else
{
@@ -165,26 +165,25 @@ retry:
{
#ifdef BSD_SELECT
tv.tv_sec = PR_IntervalToSeconds(timeout);
- tv.tv_usec = PR_IntervalToMicroseconds(
- timeout - PR_SecondsToInterval(tv.tv_sec));
+ tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec));
tvp = &tv;
- rv = select(osfd + 1, &rd, NULL, NULL, tvp);
+ rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp);
#else
long lTimeout = PR_IntervalToMilliseconds(timeout);
- rv = select(socks, 1, 0, 0, lTimeout);
+ rv = _MD_SELECT(socks, 1, 0, 0, lTimeout);
#endif
if (rv > 0) {
goto retry;
}
else if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
rv = -1;
} else {
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
}
} else {
- _PR_MD_MAP_ACCEPT_ERROR(err);
+ _PR_MD_MAP_ACCEPT_ERROR(err);
}
}
}
@@ -201,7 +200,11 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
PRInt32 rv;
int err, len;
#ifdef BSD_SELECT
+#ifdef XP_OS2//_VACPP
+ fd_set wd;
+#else
fd_set wd, ex;
+#endif #vacpp
struct timeval tv, *tvp;
#else
int socks[1];
@@ -219,17 +222,20 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
else
{
tv.tv_sec = PR_IntervalToSeconds(timeout);
- tv.tv_usec = PR_IntervalToMicroseconds(
- timeout - PR_SecondsToInterval(tv.tv_sec));
+ tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec));
tvp = &tv;
}
FD_ZERO(&wd);
FD_SET(osfd, &wd);
+#ifdef XP_OS2//_VACPP
+ rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp);
+#else
FD_ZERO(&ex);
FD_SET(osfd, &ex);
- rv = select(osfd + 1, NULL, &wd, &ex, tvp);
-#else
+ rv = _MD_SELECT(osfd + 1, NULL, &wd, &ex, tvp);
+#endif #vacpp
+#else #!bsd_select
if (timeout == PR_INTERVAL_NO_TIMEOUT)
lTimeout = -1;
else
@@ -238,11 +244,38 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
}
socks[0] = osfd;
- rv = select(socks, 0, 1, 1, lTimeout);
+#ifdef XP_OS2//_VACPP
+ rv = _MD_SELECT(socks, 0, 1, 0, lTimeout);
+#else
+ rv = _MD_SELECT(socks, 0, 1, 1, lTimeout);
+#endif #vacpp
#endif
if (rv > 0)
{
#ifdef BSD_SELECT
+#ifdef XP_OS2//_VACPP
+ if (FD_ISSET(osfd, &wd))
+ {
+ //DosSleep(0);
+ len = sizeof(err);
+ if (getsockopt(osfd, SOL_SOCKET, SO_ERROR,
+ (char *) &err, &len) < 0)
+ {
+ _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno());
+ return -1;
+ }
+
+ if (err != 0)
+ {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ return -1;
+ }
+ else
+ return 0; /* it's connected */
+ }
+ else
+ return -1;
+#else
if (FD_ISSET(osfd, &ex))
{
DosSleep(0);
@@ -264,24 +297,37 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen,
/* it's connected */
return 0;
}
-#else
- if (getsockopt(osfd, SOL_SOCKET, SO_ERROR,
- (char *) &err, &len) < 0)
- {
- _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno());
- return -1;
- }
- else
- return 0; /* It's connected ! */
+#endif #vacpp
+#else #!bsd_select
+ if (socks[0] == osfd)
+ {
+ len = sizeof(err);
+ if (getsockopt(osfd, SOL_SOCKET, SO_ERROR,
+ (char *) &err, &len) < 0)
+ {
+ _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno());
+ return -1;
+ }
+
+ if (err != 0)
+ {
+ _PR_MD_MAP_CONNECT_ERROR(err);
+ return -1;
+ }
+ else
+ return 0; /* it's connected */
+ }
+ else
+ return -1;
#endif
- }
+ }
else if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
return(-1);
} else if (rv < 0)
{
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
return(-1);
}
}
@@ -340,7 +386,7 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
timeout - PR_SecondsToInterval(tv.tv_sec));
tvp = &tv;
}
- if ((rv = select(osfd + 1, &rd, NULL, NULL, tvp)) == -1)
+ if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1)
#else
socks[0] = osfd;
if (timeout == PR_INTERVAL_NO_TIMEOUT)
@@ -351,22 +397,22 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
{
lTimeout = PR_IntervalToMilliseconds(timeout);
}
- if ((rv = select(socks, 1, 0, 0, lTimeout)) == -1)
+ if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1)
#endif
{
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
return -1;
}
else if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
rv = -1;
break;
}
}
else
{
- _PR_MD_MAP_RECV_ERROR(err);
+ _PR_MD_MAP_RECV_ERROR(err);
break;
}
} /* end while() */
@@ -409,7 +455,7 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
}
FD_ZERO(&wd);
FD_SET(osfd, &wd);
- if ((rv = select( osfd + 1, NULL, &wd, NULL,tvp)) == -1) {
+ if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL,tvp)) == -1) {
#else
if ( timeout == PR_INTERVAL_NO_TIMEOUT )
{
@@ -420,21 +466,21 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
lTimeout = PR_IntervalToMilliseconds(timeout);
}
socks[0] = osfd;
- if ((rv = select( socks, 0, 1, 0, lTimeout)) == -1) {
+ if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) {
#endif
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
break;
- }
+ }
if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- return -1;
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ return -1;
}
}
else {
- _PR_MD_MAP_SEND_ERROR(err);
+ _PR_MD_MAP_SEND_ERROR(err);
return -1;
- }
+ }
}
bytesSent += rv;
if (fd->secret->nonblocking)
@@ -457,7 +503,7 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
}
FD_ZERO(&wd);
FD_SET(osfd, &wd);
- if ((rv = select(osfd + 1, NULL, &wd, NULL,tvp)) == -1) {
+ if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL,tvp)) == -1) {
#else
if ( timeout == PR_INTERVAL_NO_TIMEOUT )
{
@@ -468,15 +514,15 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
lTimeout = PR_IntervalToMilliseconds(timeout);
}
socks[0] = osfd;
- if ((rv = select(socks, 0, 1, 0,lTimeout)) == -1) {
+ if ((rv = _MD_SELECT(socks, 0, 1, 0,lTimeout)) == -1) {
#endif
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
break;
- }
+ }
if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- return -1;
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ return -1;
}
}
}
@@ -520,7 +566,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
}
FD_ZERO(&wd);
FD_SET(osfd, &wd);
- if ((rv = select(osfd + 1, NULL, &wd, NULL, tvp)) == -1) {
+ if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp)) == -1) {
#else
if ( timeout == PR_INTERVAL_NO_TIMEOUT )
{
@@ -531,21 +577,21 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
lTimeout = PR_IntervalToMilliseconds(timeout);
}
socks[0] = osfd;
- if ((rv = select(socks, 0, 1, 0, lTimeout)) == -1) {
+ if ((rv = _MD_SELECT(socks, 0, 1, 0, lTimeout)) == -1) {
#endif
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
break;
- }
+ }
if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- return -1;
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ return -1;
}
}
else {
- _PR_MD_MAP_SENDTO_ERROR(err);
+ _PR_MD_MAP_SENDTO_ERROR(err);
return -1;
- }
+ }
}
bytesSent += rv;
if (fd->secret->nonblocking)
@@ -568,7 +614,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
}
FD_ZERO(&wd);
FD_SET(osfd, &wd);
- if ((rv = select( osfd + 1, NULL, &wd, NULL, tvp)) == -1) {
+ if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL, tvp)) == -1) {
#else
if ( timeout == PR_INTERVAL_NO_TIMEOUT )
{
@@ -579,15 +625,15 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
lTimeout = PR_IntervalToMilliseconds(timeout);
}
socks[0] = osfd;
- if ((rv = select( socks, 0, 1, 0, lTimeout)) == -1) {
+ if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) {
#endif
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
break;
- }
+ }
if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
- return -1;
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ return -1;
}
}
}
@@ -616,20 +662,20 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
&& (!fd->secret->nonblocking))
{
#ifdef BSD_SELECT
- if (timeout == PR_INTERVAL_NO_TIMEOUT)
- {
- tvp = NULL;
- }
- else
- {
- tv.tv_sec = PR_IntervalToSeconds(timeout);
- tv.tv_usec = PR_IntervalToMicroseconds(
- timeout - PR_SecondsToInterval(tv.tv_sec));
- tvp = &tv;
- }
- FD_ZERO(&rd);
- FD_SET(osfd, &rd);
- if ((rv = select(osfd + 1, &rd, NULL, NULL, tvp)) == -1)
+ if (timeout == PR_INTERVAL_NO_TIMEOUT)
+ {
+ tvp = NULL;
+ }
+ else
+ {
+ tv.tv_sec = PR_IntervalToSeconds(timeout);
+ tv.tv_usec = PR_IntervalToMicroseconds(
+ timeout - PR_SecondsToInterval(tv.tv_sec));
+ tvp = &tv;
+ }
+ FD_ZERO(&rd);
+ FD_SET(osfd, &rd);
+ if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1)
#else
if (timeout == PR_INTERVAL_NO_TIMEOUT)
{
@@ -640,14 +686,14 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
lTimeout = PR_IntervalToMilliseconds(timeout);
}
socks[0] = osfd;
- if ((rv = select(socks, 1, 0, 0, lTimeout)) == -1)
+ if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1)
#endif
{
- _PR_MD_MAP_SELECT_ERROR(sock_errno());
+ _PR_MD_MAP_SELECT_ERROR(sock_errno());
return -1;
} else if (rv == 0)
{
- PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
+ PR_SetError(PR_IO_TIMEOUT_ERROR, 0);
rv = -1;
break;
}
@@ -657,7 +703,7 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
}
else
{
- _PR_MD_MAP_RECVFROM_ERROR(err);
+ _PR_MD_MAP_RECVFROM_ERROR(err);
break;
}
}
@@ -702,12 +748,12 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTi
PRInt32
_PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how)
{
-PRInt32 rv;
+ PRInt32 rv;
rv = shutdown(fd->secret->md.osfd, how);
- if (rv < 0)
- _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno());
- return rv;
+ if (rv < 0)
+ _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno());
+ return rv;
}
PRStatus
@@ -717,11 +763,11 @@ _PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len)
rv = getsockname((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len);
if (rv==0)
- return PR_SUCCESS;
- else {
- _PR_MD_MAP_GETSOCKNAME_ERROR(sock_errno());
- return PR_FAILURE;
- }
+ return PR_SUCCESS;
+ else {
+ _PR_MD_MAP_GETSOCKNAME_ERROR(sock_errno());
+ return PR_FAILURE;
+ }
}
PRStatus
@@ -731,11 +777,11 @@ _PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len)
rv = getpeername((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len);
if (rv==0)
- return PR_SUCCESS;
- else {
- _PR_MD_MAP_GETPEERNAME_ERROR(sock_errno());
- return PR_FAILURE;
- }
+ return PR_SUCCESS;
+ else {
+ _PR_MD_MAP_GETPEERNAME_ERROR(sock_errno());
+ return PR_FAILURE;
+ }
}
PRStatus
@@ -745,11 +791,11 @@ _PR_MD_GETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval,
rv = getsockopt((int)fd->secret->md.osfd, level, optname, optval, optlen);
if (rv==0)
- return PR_SUCCESS;
- else {
- _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno());
- return PR_FAILURE;
- }
+ return PR_SUCCESS;
+ else {
+ _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno());
+ return PR_FAILURE;
+ }
}
PRStatus
@@ -759,11 +805,11 @@ _PR_MD_SETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* op
rv = setsockopt((int)fd->secret->md.osfd, level, optname, (char *) optval, optlen);
if (rv==0)
- return PR_SUCCESS;
- else {
- _PR_MD_MAP_SETSOCKOPT_ERROR(sock_errno());
- return PR_FAILURE;
- }
+ return PR_SUCCESS;
+ else {
+ _PR_MD_MAP_SETSOCKOPT_ERROR(sock_errno());
+ return PR_FAILURE;
+ }
}
void
diff --git a/pr/src/md/os2/os2thred.c b/pr/src/md/os2/os2thred.c
index b6c1615b..cbb8603c 100644
--- a/pr/src/md/os2/os2thred.c
+++ b/pr/src/md/os2/os2thred.c
@@ -36,7 +36,7 @@ _NSPR_TLS* pThreadLocalStorage = 0;
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
APIRET (* APIENTRY QueryThreadContext)(TID, ULONG, PCONTEXTRECORD);
-PR_IMPLEMENT(void)
+void
_PR_MD_ENSURE_TLS(void)
{
if(!pThreadLocalStorage)
@@ -50,7 +50,7 @@ _PR_MD_ENSURE_TLS(void)
}
}
-PR_IMPLEMENT(void)
+void
_PR_MD_EARLY_INIT()
{
HMODULE hmod;
@@ -77,7 +77,7 @@ _pr_SetThreadMDHandle(PRThread *thread)
}
-PR_IMPLEMENT(PRStatus)
+PRStatus
_PR_MD_INIT_THREAD(PRThread *thread)
{
#ifdef XP_OS2_EMX
@@ -98,7 +98,7 @@ _PR_MD_INIT_THREAD(PRThread *thread)
return (thread->md.blocked_sema.sem != 0) ? PR_SUCCESS : PR_FAILURE;
}
-PR_IMPLEMENT(PRStatus)
+PRStatus
_PR_MD_CREATE_THREAD(PRThread *thread,
void (*start)(void *),
PRThreadPriority priority,
@@ -119,14 +119,14 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
return PR_SUCCESS;
}
-PR_IMPLEMENT(void)
+void
_PR_MD_YIELD(void)
{
/* Isn't there some problem with DosSleep(0) on OS/2? */
DosSleep(0);
}
-PR_IMPLEMENT(void)
+void
_PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
{
int nativePri;
@@ -159,7 +159,7 @@ _PR_MD_SET_PRIORITY(_MDThread *thread, PRThreadPriority newPri)
return;
}
-PR_IMPLEMENT(void)
+void
_PR_MD_CLEAN_THREAD(PRThread *thread)
{
if (&thread->md.blocked_sema) {
@@ -172,7 +172,7 @@ _PR_MD_CLEAN_THREAD(PRThread *thread)
}
}
-PR_IMPLEMENT(void)
+void
_PR_MD_EXIT_THREAD(PRThread *thread)
{
_PR_MD_DESTROY_SEM(&thread->md.blocked_sema);
@@ -200,7 +200,7 @@ _PR_MD_EXIT_THREAD(PRThread *thread)
}
-PR_IMPLEMENT(void)
+void
_PR_MD_EXIT(PRIntn status)
{
_exit(status);
@@ -240,19 +240,19 @@ _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask)
}
#endif /* HAVE_THREAD_AFFINITY */
-PR_IMPLEMENT(void)
+void
_PR_MD_SUSPEND_CPU(_PRCPU *cpu)
{
_PR_MD_SUSPEND_THREAD(cpu->thread);
}
-PR_IMPLEMENT(void)
+void
_PR_MD_RESUME_CPU(_PRCPU *cpu)
{
_PR_MD_RESUME_THREAD(cpu->thread);
}
-PR_IMPLEMENT(void)
+void
_PR_MD_SUSPEND_THREAD(PRThread *thread)
{
if (_PR_IS_NATIVE_THREAD(thread)) {
@@ -266,7 +266,7 @@ _PR_MD_SUSPEND_THREAD(PRThread *thread)
}
}
-PR_IMPLEMENT(void)
+void
_PR_MD_RESUME_THREAD(PRThread *thread)
{
if (_PR_IS_NATIVE_THREAD(thread)) {
diff --git a/pr/src/md/unix/.cvsignore b/pr/src/md/unix/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/pr/src/md/unix/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/pr/src/md/unix/Makefile b/pr/src/md/unix/Makefile
deleted file mode 100644
index de8baadd..00000000
--- a/pr/src/md/unix/Makefile
+++ /dev/null
@@ -1,316 +0,0 @@
-#
-# The contents of this file are subject to the Netscape Public License
-# Version 1.1 (the "NPL"); you may not use this file except in
-# compliance with the NPL. You may obtain a copy of the NPL at
-# http://www.mozilla.org/NPL/
-#
-# Software distributed under the NPL is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
-# for the specific language governing rights and limitations under the
-# NPL.
-#
-# The Initial Developer of this code under the NPL is Netscape
-# Communications Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All Rights
-# Reserved.
-#
-
-MOD_DEPTH = ../../../..
-
-include $(MOD_DEPTH)/config/config.mk
-
-# Disable optimization of the nspr on SunOS4.1.3
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-OPTIMIZER =
-endif
-endif
-
-CSRCS = \
- unix.c \
- unix_errors.c \
- uxproces.c \
- uxrng.c \
- uxshm.c \
- uxwrap.c \
- $(NULL)
-
-ifneq ($(USE_PTHREADS),1)
-CSRCS += uxpoll.c
-endif
-
-ifeq ($(PTHREADS_USER),1)
-CSRCS += pthreads_user.c
-endif
-
-IRIX_CSRCS = \
- irix.c \
- $(NULL)
-
-SUNOS4_CSRCS = \
- sunos4.c \
- $(NULL)
-
-SOLARIS_CSRCS = \
- solaris.c \
- $(NULL)
-
-AIX_CSRCS = \
- aix.c \
- $(NULL)
-
-FREEBSD_CSRCS = \
- freebsd.c \
- $(NULL)
-
-NETBSD_CSRCS = \
- netbsd.c \
- $(NULL)
-
-OPENBSD_CSRCS = \
- openbsd.c \
- $(NULL)
-
-BSDI_CSRCS = \
- bsdi.c \
- $(NULL)
-
-HPUX_CSRCS = \
- hpux.c \
- $(NULL)
-
-OPENVMS_CSRCS = \
- openvms.c \
- $(NULL)
-
-OSF1_CSRCS = \
- osf1.c \
- $(NULL)
-
-LINUX_CSRCS = \
- linux.c \
- $(NULL)
-
-UNIXWARE_CSRCS = \
- unixware.c \
- $(NULL)
-
-RELIANTUNIX_CSRCS = \
- reliantunix.c \
- $(NULL)
-
-RHAPSODY_CSRCS = \
- rhapsody.c \
- $(NULL)
-
-NEXTSTEP_CSRCS = \
- nextstep.c \
- $(NULL)
-
-NEC_CSRCS = \
- nec.c \
- $(NULL)
-
-SONY_CSRCS = \
- sony.c \
- $(NULL)
-
-NCR_CSRCS = \
- ncr.c \
- $(NULL)
-
-SCOOS_CSRCS = \
- scoos.c \
- $(NULL)
-
-DGUX_CSRCS = \
- dgux.c \
- $(NULL)
-
-QNX_CSRCS = \
- qnx.c \
- $(NULL)
-
-NTO_CSRCS = \
- nto.c \
- $(NULL)
-
-ifeq ($(OS_ARCH),IRIX)
-CSRCS += $(IRIX_CSRCS)
-endif
-
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-CSRCS += $(SUNOS4_CSRCS)
-else
-CSRCS += $(SOLARIS_CSRCS)
-endif
-endif
-
-ifeq ($(OS_ARCH),AIX)
-CSRCS += $(AIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),FreeBSD)
-CSRCS += $(FREEBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),NetBSD)
-CSRCS += $(NETBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenBSD)
-CSRCS += $(OPENBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),BSD_OS)
-CSRCS += $(BSDI_CSRCS)
-endif
-ifeq ($(OS_ARCH),HP-UX)
-CSRCS += $(HPUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenVMS)
-CSRCS += $(OPENVMS_CSRCS)
-endif
-ifeq ($(OS_ARCH),OSF1)
-CSRCS += $(OSF1_CSRCS)
-endif
-ifeq ($(OS_ARCH),Linux)
-CSRCS += $(LINUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),UNIXWARE)
-CSRCS += $(UNIXWARE_CSRCS)
-endif
-ifeq ($(OS_ARCH),SINIX)
-CSRCS += $(RELIANTUNIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),Rhapsody)
-CSRCS += $(RHAPSODY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEXTSTEP)
-CSRCS += $(NEXTSTEP_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEC)
-CSRCS += $(NEC_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEWS-OS)
-CSRCS += $(SONY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NCR)
-CSRCS += $(NCR_CSRCS)
-endif
-ifeq ($(OS_ARCH),SCOOS)
-CSRCS += $(SCOOS_CSRCS)
-endif
-ifeq ($(OS_ARCH),DGUX)
-CSRCS += $(DGUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),NTO)
-CSRCS += $(NTO_CSRCS)
-endif
-ifeq ($(OS_ARCH),QNX)
-ifeq ($(OS_TARGET),NTO)
-CSRCS += $(NTO_CSRCS)
-else
-CSRCS += $(QNX_CSRCS)
-endif
-endif
-
-#
-# Some Unix platforms have an assembly language file.
-# E.g., AIX 3.2, Solaris (both sparc and x86).
-#
-ifeq ($(OS_ARCH), AIX)
- ifeq ($(OS_RELEASE), 3.2)
- ASFILES = os_$(OS_ARCH).s
- endif
-endif
-
-ifeq ($(OS_ARCH),SunOS)
- ifneq ($(OS_RELEASE),4.1.3_U1)
- ifneq ($(LOCAL_THREADS_ONLY),1)
- ifeq ($(CPU_ARCH),x86)
- ASFILES = os_$(OS_ARCH)_x86.s
- else
- ASFILES = os_$(OS_ARCH).s
- ifneq ($(USE_64),1)
- ASFILES += os_$(OS_ARCH)_32.s
- endif
- endif
- endif
- endif
-endif
-
-ifeq ($(OS_ARCH), SINIX)
- ifeq ($(CPU_ARCH),mips)
- ASFILES = os_ReliantUNIX.s
- endif
-endif
-
-ifeq ($(OS_ARCH)$(OS_RELEASE),BSD_OS2.1)
- ASFILES = os_BSD_386_2.s
-endif
-
-ifeq ($(OS_ARCH), IRIX)
- ASFILES = os_Irix.s
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
- ASFILES = os_HPUX.s
-endif
-
-TARGETS = $(OBJS)
-
-ifeq ($(OS_ARCH),AIX)
-ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
-ifneq ($(USE_PTHREADS), 1)
-#TARGETS += $(OBJDIR)/aixwrap.$(OBJ_SUFFIX)
-endif
-endif
-endif
-
-ifeq ($(OS_ARCH),SunOS)
- ifneq ($(OS_RELEASE),4.1.3_U1)
- ifeq ($(OS_TEST),sun4u)
- LIBRARY_NAME = $(ULTRASPARC_LIBRARY)
- LIBRARY_VERSION = $(MOD_VERSION)
- ULTRASPARC_ASFILES = os_$(OS_ARCH)_ultrasparc.s
- ULTRASPARC_ASOBJS = $(addprefix $(OBJDIR)/,$(ULTRASPARC_ASFILES:.s=.$(OBJ_SUFFIX)))
- TARGETS += $(ULTRASPARC_ASOBJS) $(SHARED_LIBRARY)
- RELEASE_LIBS = $(SHARED_LIBRARY)
- endif
- endif
-endif
-
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(MOD_DEPTH)/config/rules.mk
-
-export:: $(TARGETS)
-#ifeq ($(OS_ARCH),AIX)
-#ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
-#ifneq ($(USE_PTHREADS), 1)
-# $(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(DIST)/lib
-#endif
-#endif
-#endif
-
-ifeq ($(OS_ARCH),SunOS)
-ifneq ($(OS_RELEASE),4.1.3_U1)
-ifeq ($(OS_TEST),sun4u)
-$(SHARED_LIBRARY): $(ULTRASPARC_ASOBJS)
- $(LD) -G -z text -o $@ $(ULTRASPARC_ASOBJS)
- $(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
-
-$(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES)
-ifeq ($(USE_64),1)
- /usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v9 $<
-else
- /usr/ccs/bin/as -o $@ -K PIC -P -D_ASM -D__STDC__=0 -xarch=v8plus $<
-endif
-
-clean::
- rm -rf $(ULTRASPARC_ASOBJS)
-endif
-endif
-endif
-
-install:: export
diff --git a/pr/src/md/unix/Makefile.in b/pr/src/md/unix/Makefile.in
index 9fb73bf8..9db24b49 100644
--- a/pr/src/md/unix/Makefile.in
+++ b/pr/src/md/unix/Makefile.in
@@ -24,17 +24,6 @@ include $(MOD_DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
-ifndef USE_AUTOCONF
-
-# Disable optimization of the nspr on SunOS4.1.3
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-OPTIMIZER =
-endif
-endif
-
-endif # ! USE_AUTOCONF
-
CSRCS = \
unix.c \
unix_errors.c \
@@ -52,235 +41,16 @@ ifeq ($(PTHREADS_USER),1)
CSRCS += pthreads_user.c
endif
-ifndef USE_AUTOCONF
-
-IRIX_CSRCS = \
- irix.c \
- $(NULL)
-
-SUNOS4_CSRCS = \
- sunos4.c \
- $(NULL)
-
-SOLARIS_CSRCS = \
- solaris.c \
- $(NULL)
-
-AIX_CSRCS = \
- aix.c \
- $(NULL)
-
-FREEBSD_CSRCS = \
- freebsd.c \
- $(NULL)
-
-NETBSD_CSRCS = \
- netbsd.c \
- $(NULL)
-
-OPENBSD_CSRCS = \
- openbsd.c \
- $(NULL)
-
-BSDI_CSRCS = \
- bsdi.c \
- $(NULL)
-
-HPUX_CSRCS = \
- hpux.c \
- $(NULL)
-
-OPENVMS_CSRCS = \
- openvms.c \
- $(NULL)
-
-OSF1_CSRCS = \
- osf1.c \
- $(NULL)
-
-LINUX_CSRCS = \
- linux.c \
- $(NULL)
-
-UNIXWARE_CSRCS = \
- unixware.c \
- $(NULL)
-
-RELIANTUNIX_CSRCS = \
- reliantunix.c \
- $(NULL)
-
-RHAPSODY_CSRCS = \
- rhapsody.c \
- $(NULL)
-
-NEXTSTEP_CSRCS = \
- nextstep.c \
- $(NULL)
-
-NEC_CSRCS = \
- nec.c \
- $(NULL)
-
-SONY_CSRCS = \
- sony.c \
- $(NULL)
-
-NCR_CSRCS = \
- ncr.c \
- $(NULL)
-
-SCOOS_CSRCS = \
- scoos.c \
- $(NULL)
-
-DGUX_CSRCS = \
- dgux.c \
- $(NULL)
-
-QNX_CSRCS = \
- qnx.c \
- $(NULL)
-
-NTO_CSRCS = \
- nto.c \
- $(NULL)
-
-ifeq ($(OS_ARCH),IRIX)
-CSRCS += $(IRIX_CSRCS)
-endif
-
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-CSRCS += $(SUNOS4_CSRCS)
-else
-CSRCS += $(SOLARIS_CSRCS)
-endif
-endif
-
-ifeq ($(OS_ARCH),AIX)
-CSRCS += $(AIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),FreeBSD)
-CSRCS += $(FREEBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),NetBSD)
-CSRCS += $(NETBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenBSD)
-CSRCS += $(OPENBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),BSD_OS)
-CSRCS += $(BSDI_CSRCS)
-endif
-ifeq ($(OS_ARCH),HP-UX)
-CSRCS += $(HPUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenVMS)
-CSRCS += $(OPENVMS_CSRCS)
-endif
-ifeq ($(OS_ARCH),OSF1)
-CSRCS += $(OSF1_CSRCS)
-endif
-ifeq ($(OS_ARCH),Linux)
-CSRCS += $(LINUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),UNIXWARE)
-CSRCS += $(UNIXWARE_CSRCS)
-endif
-ifeq ($(OS_ARCH),SINIX)
-CSRCS += $(RELIANTUNIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),Rhapsody)
-CSRCS += $(RHAPSODY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEXTSTEP)
-CSRCS += $(NEXTSTEP_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEC)
-CSRCS += $(NEC_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEWS-OS)
-CSRCS += $(SONY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NCR)
-CSRCS += $(NCR_CSRCS)
-endif
-ifeq ($(OS_ARCH),SCOOS)
-CSRCS += $(SCOOS_CSRCS)
-endif
-ifeq ($(OS_ARCH),DGUX)
-CSRCS += $(DGUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),NTO)
-CSRCS += $(NTO_CSRCS)
-endif
-ifeq ($(OS_ARCH),QNX)
-ifeq ($(OS_TARGET),NTO)
-CSRCS += $(NTO_CSRCS)
-else
-CSRCS += $(QNX_CSRCS)
-endif
-endif
-
-#
-# Some Unix platforms have an assembly language file.
-# E.g., AIX 3.2, Solaris (both sparc and x86).
-#
-ifeq ($(OS_ARCH), AIX)
- ifeq ($(OS_RELEASE), 3.2)
- ASFILES = os_$(OS_ARCH).s
- endif
-endif
-
-ifeq ($(OS_ARCH),SunOS)
- ifneq ($(OS_RELEASE),4.1.3_U1)
- ifneq ($(LOCAL_THREADS_ONLY),1)
- ifeq ($(CPU_ARCH),x86)
- ASFILES = os_$(OS_ARCH)_x86.s
- else
- ASFILES = os_$(OS_ARCH).s
- ifneq ($(USE_64),1)
- ASFILES += os_$(OS_ARCH)_32.s
- endif
- endif
- endif
- endif
-endif
-
-ifeq ($(OS_ARCH), SINIX)
- ifeq ($(CPU_ARCH),mips)
- ASFILES = os_ReliantUNIX.s
- endif
-endif
-
-ifeq ($(OS_ARCH)$(OS_RELEASE),BSD_OS2.1)
- ASFILES = os_BSD_386_2.s
-endif
-
-ifeq ($(OS_ARCH), IRIX)
- ASFILES = os_Irix.s
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
- ASFILES = os_HPUX.s
-endif
-
-TARGETS = $(OBJS)
+CSRCS += $(PR_MD_CSRCS)
+ASFILES += $(PR_MD_ASFILES)
-ifeq ($(OS_ARCH),AIX)
-ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
-ifneq ($(USE_PTHREADS), 1)
-#TARGETS += $(OBJDIR)/aixwrap.$(OBJ_SUFFIX)
-endif
-endif
-endif
+TARGETS = $(OBJS)
ifeq ($(OS_ARCH),SunOS)
ifneq ($(OS_RELEASE),4.1.3_U1)
ifeq ($(OS_TEST),sun4u)
LIBRARY_NAME = $(ULTRASPARC_LIBRARY)
- LIBRARY_VERSION = $(MOD_VERSION)
+ LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
ULTRASPARC_ASFILES = os_$(OS_ARCH)_ultrasparc.s
ULTRASPARC_ASOBJS = $(addprefix $(OBJDIR)/,$(ULTRASPARC_ASFILES:.s=.$(OBJ_SUFFIX)))
TARGETS += $(ULTRASPARC_ASOBJS) $(SHARED_LIBRARY)
@@ -289,37 +59,20 @@ ifeq ($(OS_ARCH),SunOS)
endif
endif
-else # USE_AUTOCONF
-
-CSRCS += $(PR_MD_CSRCS)
-ASFILES += $(PR_MD_ASFILES)
-
-TARGETS = $(OBJS)
-
-endif # ! USE_AUTOCONF
-
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
DEFINES += -D_NSPR_BUILD_
include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)
-#ifeq ($(OS_ARCH),AIX)
-#ifeq (,$(filter-out 3.2 4.1,$(OS_RELEASE)))
-#ifneq ($(USE_PTHREADS), 1)
-# $(INSTALL) -m 444 $(OBJDIR)/aixwrap.$(OBJ_SUFFIX) $(DIST)/lib
-#endif
-#endif
-#endif
-ifndef USE_AUTOCONF
ifeq ($(OS_ARCH),SunOS)
ifneq ($(OS_RELEASE),4.1.3_U1)
ifeq ($(OS_TEST),sun4u)
$(SHARED_LIBRARY): $(ULTRASPARC_ASOBJS)
$(LD) -G -z text -o $@ $(ULTRASPARC_ASOBJS)
- $(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/lib
+ $(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_libdir)
$(ULTRASPARC_ASOBJS): $(ULTRASPARC_ASFILES)
ifeq ($(USE_64),1)
@@ -333,5 +86,3 @@ clean::
endif
endif
endif
-endif #!USE_AUTOCONF
-install:: export
diff --git a/pr/src/md/unix/darwin.c b/pr/src/md/unix/darwin.c
index ff5f1ad7..93421318 100644
--- a/pr/src/md/unix/darwin.c
+++ b/pr/src/md/unix/darwin.c
@@ -87,13 +87,32 @@ _MD_CREATE_THREAD(
}
#endif /* ! _PR_PTHREADS */
+#if defined(_PR_PTHREADS)
+
/*
-** Whoops, we don't have a syscall stub for this
+** Stubs for unimplemented functions
*/
-int mprotect (caddr_t addr, size_t size, int prot)
+
+int pthread_condattr_init(pthread_condattr_t *attr)
+{
+ return 0;
+}
+
+int pthread_kill(pthread_t thread, int sig)
{
- return -1;
-}
+ return ENOSYS;
+}
+
+typedef struct siginfo_t siginfo_t;
+
+int sigtimedwait(const sigset_t *set, siginfo_t *info,
+ const struct timespec *timeout)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif /* _PR_PTHREADS */
/* rhapsody.c */
diff --git a/pr/src/md/unix/objs.mk b/pr/src/md/unix/objs.mk
index d8196c81..575584b6 100644
--- a/pr/src/md/unix/objs.mk
+++ b/pr/src/md/unix/objs.mk
@@ -35,226 +35,9 @@ ifeq ($(PTHREADS_USER),1)
CSRCS += pthreads_user.c
endif
-ifdef USE_AUTOCONF
-
CSRCS += $(PR_MD_CSRCS)
ASFILES += $(PR_MD_ASFILES)
-else # ! USE_AUTOCONF
-IRIX_CSRCS = \
- irix.c \
- $(NULL)
-
-SUNOS4_CSRCS = \
- sunos4.c \
- $(NULL)
-
-SOLARIS_CSRCS = \
- solaris.c \
- $(NULL)
-
-AIX_CSRCS = \
- aix.c \
- $(NULL)
-
-FREEBSD_CSRCS = \
- freebsd.c \
- $(NULL)
-
-NETBSD_CSRCS = \
- netbsd.c \
- $(NULL)
-
-OPENBSD_CSRCS = \
- openbsd.c \
- $(NULL)
-
-BSDI_CSRCS = \
- bsdi.c \
- $(NULL)
-
-HPUX_CSRCS = \
- hpux.c \
- $(NULL)
-
-OSF1_CSRCS = \
- osf1.c \
- $(NULL)
-
-OPENVMS_CSRCS = \
- openvms.c \
- $(NULL)
-
-LINUX_CSRCS = \
- linux.c \
- $(NULL)
-
-UNIXWARE_CSRCS = \
- unixware.c \
- $(NULL)
-
-RELIANTUNIX_CSRCS = \
- reliantunix.c \
- $(NULL)
-
-RHAPSODY_CSRCS = \
- rhapsody.c \
- $(NULL)
-
-NEXTSTEP_CSRCS = \
- nextstep.c \
- $(NULL)
-
-NEC_CSRCS = \
- nec.c \
- $(NULL)
-
-SONY_CSRCS = \
- sony.c \
- $(NULL)
-
-NCR_CSRCS = \
- ncr.c \
- $(NULL)
-
-SCOOS_CSRCS = \
- scoos.c \
- $(NULL)
-
-DGUX_CSRCS = \
- dgux.c \
- $(NULL)
-
-QNX_CSRCS = \
- qnx.c \
- $(NULL)
-
-NTO_CSRCS = \
- nto.c \
- $(NULL)
-
-ifeq ($(OS_ARCH),IRIX)
-CSRCS += $(IRIX_CSRCS)
-endif
-
-ifeq ($(OS_ARCH),SunOS)
-ifeq ($(OS_RELEASE),4.1.3_U1)
-CSRCS += $(SUNOS4_CSRCS)
-else
-CSRCS += $(SOLARIS_CSRCS)
-endif
-endif
-
-ifeq ($(OS_ARCH),AIX)
-CSRCS += $(AIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),FreeBSD)
-CSRCS += $(FREEBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),NetBSD)
-CSRCS += $(NETBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenBSD)
-CSRCS += $(OPENBSD_CSRCS)
-endif
-ifeq ($(OS_ARCH),BSD_OS)
-CSRCS += $(BSDI_CSRCS)
-endif
-ifeq ($(OS_ARCH),HP-UX)
-CSRCS += $(HPUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),OSF1)
-CSRCS += $(OSF1_CSRCS)
-endif
-ifeq ($(OS_ARCH),OpenVMS)
-CSRCS += $(OPENVMS_CSRCS)
-endif
-ifeq ($(OS_ARCH),Linux)
-CSRCS += $(LINUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),UNIXWARE)
-CSRCS += $(UNIXWARE_CSRCS)
-endif
-ifeq ($(OS_ARCH),SINIX)
-CSRCS += $(RELIANTUNIX_CSRCS)
-endif
-ifeq ($(OS_ARCH),Rhapsody)
-CSRCS += $(RHAPSODY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEXTSTEP)
-CSRCS += $(NEXTSTEP_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEC)
-CSRCS += $(NEC_CSRCS)
-endif
-ifeq ($(OS_ARCH),NEWS-OS)
-CSRCS += $(SONY_CSRCS)
-endif
-ifeq ($(OS_ARCH),NCR)
-CSRCS += $(NCR_CSRCS)
-endif
-ifeq ($(OS_ARCH),SCOOS)
-CSRCS += $(SCOOS_CSRCS)
-endif
-ifeq ($(OS_ARCH),DGUX)
-CSRCS += $(DGUX_CSRCS)
-endif
-ifeq ($(OS_ARCH),NTO)
-CSRCS += $(NTO_CSRCS)
-endif
-ifeq ($(OS_ARCH),QNX)
-ifeq ($(OS_TARGET),NTO)
-CSRCS += $(NTO_CSRCS)
-else
-CSRCS += $(QNX_CSRCS)
-endif
-endif
-
-#
-# Some Unix platforms have an assembly language file.
-# E.g., AIX 3.2, Solaris (both sparc and x86).
-#
-ifeq ($(OS_ARCH), AIX)
- ifeq ($(OS_RELEASE), 3.2)
- ASFILES = os_$(OS_ARCH).s
- endif
-endif
-
-ifeq ($(OS_ARCH),SunOS)
- ifneq ($(OS_RELEASE),4.1.3_U1)
- ifneq ($(LOCAL_THREADS_ONLY),1)
- ifeq ($(CPU_ARCH),x86)
- ASFILES = os_$(OS_ARCH)_x86.s
- else
- ASFILES = os_$(OS_ARCH).s
- ifneq ($(USE_64),1)
- ASFILES += os_$(OS_ARCH)_32.s
- endif
- endif
- endif
- endif
-endif
-
-ifeq ($(OS_ARCH), SINIX)
- ifeq ($(CPU_ARCH),mips)
- ASFILES = os_ReliantUNIX.s
- endif
-endif
-
-ifeq ($(OS_ARCH), HP-UX)
- ASFILES = os_HPUX.s
-endif
-
-ifeq ($(OS_ARCH), IRIX)
- ASFILES = os_Irix.s
-endif
-
-ifeq ($(OS_ARCH)$(OS_RELEASE),BSD_OS2.1)
- ASFILES = os_BSD_386_2.s
-endif
-
-endif # !USE_AUTOCONF
-
OBJS += $(addprefix md/unix/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
$(addprefix md/unix/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
diff --git a/pr/src/md/unix/os_Linux_x86.s b/pr/src/md/unix/os_Linux_x86.s
new file mode 100644
index 00000000..f72f28d2
--- /dev/null
+++ b/pr/src/md/unix/os_Linux_x86.s
@@ -0,0 +1,95 @@
+/ -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/
+/ The contents of this file are subject to the Netscape Public License
+/ Version 1.1 (the "NPL"); you may not use this file except in
+/ compliance with the NPL. You may obtain a copy of the NPL at
+/ http://www.mozilla.org/NPL/
+/
+/ Software distributed under the NPL is distributed on an "AS IS" basis,
+/ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+/ for the specific language governing rights and limitations under the
+/ NPL.
+/
+/ The Initial Developer of this code under the NPL is Netscape
+/ Communications Corporation. Portions created by Netscape are
+/ Copyright (C) 2000 Netscape Communications Corporation. All Rights
+/ Reserved.
+/
+
+/ PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val)
+/
+/ Atomically increment the integer pointed to by 'val' and return
+/ the result of the increment.
+/
+ .text
+ .globl _PR_x86_AtomicIncrement
+ .align 4
+_PR_x86_AtomicIncrement:
+ movl 4(%esp), %ecx
+ movl $1, %eax
+ lock
+ xaddl %eax, (%ecx)
+ incl %eax
+ ret
+
+/ PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val)
+/
+/ Atomically decrement the integer pointed to by 'val' and return
+/ the result of the decrement.
+/
+ .text
+ .globl _PR_x86_AtomicDecrement
+ .align 4
+_PR_x86_AtomicDecrement:
+ movl 4(%esp), %ecx
+ movl $-1, %eax
+ lock
+ xaddl %eax, (%ecx)
+ decl %eax
+ ret
+
+/ PRInt32 _PR_x86_AtomicSet(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_x86_AtomicSet
+/ .align 4
+/_PR_x86_AtomicSet:
+/ movl 4(%esp), %ecx
+/ movl 8(%esp), %edx
+/ movl (%ecx), %eax
+/retry:
+/ lock
+/ cmpxchgl %edx, (%ecx)
+/ jne retry
+/ ret
+/
+ .text
+ .globl _PR_x86_AtomicSet
+ .align 4
+_PR_x86_AtomicSet:
+ movl 4(%esp), %ecx
+ movl 8(%esp), %eax
+ lock
+ xchgl %eax, (%ecx)
+ ret
+
+/ PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val)
+/
+/ Atomically add 'val' to the integer pointed to by 'ptr'
+/ and return the result of the addition.
+/
+ .text
+ .globl _PR_x86_AtomicAdd
+ .align 4
+_PR_x86_AtomicAdd:
+ 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/unix/rhapsody.c b/pr/src/md/unix/rhapsody.c
index ff5f1ad7..93421318 100644
--- a/pr/src/md/unix/rhapsody.c
+++ b/pr/src/md/unix/rhapsody.c
@@ -87,13 +87,32 @@ _MD_CREATE_THREAD(
}
#endif /* ! _PR_PTHREADS */
+#if defined(_PR_PTHREADS)
+
/*
-** Whoops, we don't have a syscall stub for this
+** Stubs for unimplemented functions
*/
-int mprotect (caddr_t addr, size_t size, int prot)
+
+int pthread_condattr_init(pthread_condattr_t *attr)
+{
+ return 0;
+}
+
+int pthread_kill(pthread_t thread, int sig)
{
- return -1;
-}
+ return ENOSYS;
+}
+
+typedef struct siginfo_t siginfo_t;
+
+int sigtimedwait(const sigset_t *set, siginfo_t *info,
+ const struct timespec *timeout)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+#endif /* _PR_PTHREADS */
/* rhapsody.c */
diff --git a/pr/src/md/unix/uxproces.c b/pr/src/md/unix/uxproces.c
index 8c0a9b96..d6cacf6d 100644
--- a/pr/src/md/unix/uxproces.c
+++ b/pr/src/md/unix/uxproces.c
@@ -27,7 +27,11 @@
#include <dlfcn.h> /* For dlopen, dlsym, dlclose */
#endif
+#if defined(RHAPSODY)
+#include <crt_externs.h>
+#else
extern char **environ;
+#endif
/*
* HP-UX 9 doesn't have the SA_RESTART flag.
@@ -36,6 +40,10 @@ extern char **environ;
#define SA_RESTART 0
#endif
+#if defined(VMS)
+static PRLock *_pr_vms_fork_lock = NULL;
+#endif
+
/*
**********************************************************************
*
@@ -146,7 +154,10 @@ ForkAndExec(
char *const *childEnvp;
char **newEnvp = NULL;
int flags;
-
+#ifdef VMS
+ char VMScurdir[FILENAME_MAX+1] = { '\0' } ;
+#endif
+
process = PR_NEW(PRProcess);
if (!process) {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
@@ -156,7 +167,11 @@ ForkAndExec(
childEnvp = envp;
if (attr && attr->fdInheritBuffer) {
if (NULL == childEnvp) {
+#ifdef RHAPSODY
+ childEnvp = *(_NSGetEnviron());
+#else
childEnvp = environ;
+#endif
}
for (nEnv = 0; childEnvp[nEnv]; nEnv++) {
}
@@ -173,6 +188,65 @@ ForkAndExec(
newEnvp[idx] = NULL;
childEnvp = newEnvp;
}
+#ifdef VMS
+/*
+** Since vfork/exec is implemented VERY differently on OpenVMS, we have to
+** handle the setting up of the standard streams very differently. And since
+** none of this code can ever execute in the context of the child, we have
+** to perform the chdir in the parent so the child is born into the correct
+** directory (and then switch the parent back again).
+*/
+{
+ int decc$set_child_standard_streams(int,int,int);
+ int n, fd_stdin=0, fd_stdout=1, fd_stderr=2;
+
+ /* Set up any standard streams we are given, assuming defaults */
+ if (attr) {
+ if (attr->stdinFd)
+ fd_stdin = attr->stdinFd->secret->md.osfd;
+ if (attr->stdoutFd)
+ fd_stdout = attr->stdoutFd->secret->md.osfd;
+ if (attr->stderrFd)
+ fd_stderr = attr->stderrFd->secret->md.osfd;
+ }
+
+ /*
+ ** Put a lock around anything that isn't going to be thread-safe.
+ */
+ PR_Lock(_pr_vms_fork_lock);
+
+ /*
+ ** Prepare the child's streams. We always do this in case a previous fork
+ ** has left the stream assignments in some non-standard way.
+ */
+ n = decc$set_child_standard_streams(fd_stdin,fd_stdout,fd_stderr);
+ if (n == -1) {
+ PR_SetError(PR_BAD_DESCRIPTOR_ERROR, errno);
+ PR_DELETE(process);
+ if (newEnvp) {
+ PR_DELETE(newEnvp);
+ }
+ PR_Unlock(_pr_vms_fork_lock);
+ return NULL;
+ }
+
+ /* Switch directory if we have to */
+ if (attr) {
+ if (attr->currentDirectory) {
+ if ( (getcwd(VMScurdir,sizeof(VMScurdir)) == NULL) ||
+ (chdir(attr->currentDirectory) < 0) ) {
+ PR_SetError(PR_DIRECTORY_OPEN_ERROR, errno);
+ PR_DELETE(process);
+ if (newEnvp) {
+ PR_DELETE(newEnvp);
+ }
+ PR_Unlock(_pr_vms_fork_lock);
+ return NULL;
+ }
+ }
+ }
+}
+#endif /* VMS */
#ifdef AIX
process->md.pid = (*pr_wp.forkptr)();
@@ -193,7 +267,9 @@ ForkAndExec(
* the standard I/O file descriptors, and hence corrupt
* the parent process's standard I/O data structures.
*/
-
+#ifdef VMS
+ /* OpenVMS has already handled all this above */
+#else
if (attr) {
if (attr->stdinFd
&& attr->stdinFd->secret->md.osfd != 0) {
@@ -234,6 +310,7 @@ ForkAndExec(
}
}
}
+#endif /* !VMS */
if (childEnvp) {
(void)execve(path, argv, childEnvp);
@@ -242,12 +319,35 @@ ForkAndExec(
(void)execv(path, argv);
}
/* Whoops! It returned. That's a bad sign. */
+#ifdef VMS
+ /*
+ ** On OpenVMS we are still in the context of the parent, and so we
+ ** can (and should!) perform normal error handling.
+ */
+ PR_SetError(PR_UNKNOWN_ERROR, errno);
+ PR_DELETE(process);
+ if (newEnvp) {
+ PR_DELETE(newEnvp);
+ }
+ if (VMScurdir[0] != '\0')
+ chdir(VMScurdir);
+ PR_Unlock(_pr_vms_fork_lock);
+ return NULL;
+#else
_exit(1);
+#endif /* VMS */
}
if (newEnvp) {
PR_DELETE(newEnvp);
}
+#ifdef VMS
+ /* If we switched directories, then remember to switch back */
+ if (VMScurdir[0] != '\0') {
+ chdir(VMScurdir); /* can't do much if it fails */
+ }
+ PR_Unlock(_pr_vms_fork_lock);
+#endif /* VMS */
#if defined(_PR_NATIVE_THREADS)
PR_Lock(pr_wp.ml);
@@ -655,6 +755,10 @@ static PRStatus _MD_InitProcesses()
pr_wp.ml = PR_NewLock();
PR_ASSERT(NULL != pr_wp.ml);
+#if defined(VMS)
+ _pr_vms_fork_lock = PR_NewLock();
+ PR_ASSERT(NULL != _pr_vms_fork_lock);
+#endif
#if defined(_PR_NATIVE_THREADS)
pr_wp.numProcs = 0;
pr_wp.cv = PR_NewCondVar(pr_wp.ml);
diff --git a/pr/src/md/unix/uxrng.c b/pr/src/md/unix/uxrng.c
index 23b88705..305d13af 100644
--- a/pr/src/md/unix/uxrng.c
+++ b/pr/src/md/unix/uxrng.c
@@ -261,7 +261,8 @@ GetHighResClock(void *buf, size_t maxbytes)
{
return 0;
}
-#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) || defined(QNX)
+#elif defined(SCO) || defined(UNIXWARE) || defined(BSDI) || defined(NTO) \
+ || defined(QNX) || defined(RHAPSODY)
#include <sys/times.h>
static size_t
diff --git a/pr/src/md/unix/uxshm.c b/pr/src/md/unix/uxshm.c
index 162ffb46..070f9fba 100644
--- a/pr/src/md/unix/uxshm.c
+++ b/pr/src/md/unix/uxshm.c
@@ -609,7 +609,7 @@ extern PRFileMap * _md_ImportFileMapFromString(
PRInt32 osfd;
PRIntn prot; /* really: a PRFileMapProtect */
PRFileDesc *fd;
- PRFileMap *fm;
+ PRFileMap *fm = NULL; /* default return value */
PRFileInfo64 info;
PR_sscanf( fmstring, "%ld:%d", &osfd, &prot );
diff --git a/pr/src/md/windows/.cvsignore b/pr/src/md/windows/.cvsignore
new file mode 100644
index 00000000..f3c7a7c5
--- /dev/null
+++ b/pr/src/md/windows/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/pr/src/md/windows/Makefile b/pr/src/md/windows/Makefile
deleted file mode 100644
index 0655ba19..00000000
--- a/pr/src/md/windows/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# The contents of this file are subject to the Netscape Public License
-# Version 1.1 (the "NPL"); you may not use this file except in
-# compliance with the NPL. You may obtain a copy of the NPL at
-# http://www.mozilla.org/NPL/
-#
-# Software distributed under the NPL is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
-# for the specific language governing rights and limitations under the
-# NPL.
-#
-# The Initial Developer of this code under the NPL is Netscape
-# Communications Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All Rights
-# Reserved.
-#
-
-#! gmake
-
-MOD_DEPTH = ../../../..
-
-include $(MOD_DEPTH)/config/config.mk
-
-ifeq ($(OS_TARGET), WIN16)
-CSRCS = \
- w16null.c \
- w16thred.c \
- w16proc.c \
- w16fmem.c \
- w16sock.c \
- w16mem.c \
- w16io.c \
- w16gc.c \
- w16error.c \
- w16stdio.c \
- w16callb.c \
- ntinrval.c \
- $(NULL)
-else
-ifeq ($(OS_TARGET), WIN95)
-CSRCS = \
- ntmisc.c \
- ntsec.c \
- ntsem.c \
- ntinrval.c \
- ntgc.c \
- w95thred.c \
- w95io.c \
- w95cv.c \
- w32rng.c \
- w95sock.c \
- win32_errors.c \
- w32ipcsem.c \
- w32poll.c \
- w32shm.c \
- w95dllmain.c \
- $(NULL)
-else
-CSRCS = \
- ntdllmn.c \
- ntmisc.c \
- ntsec.c \
- ntsem.c \
- ntinrval.c \
- ntgc.c \
- ntthread.c \
- ntio.c \
- win32_errors.c \
- w32ipcsem.c \
- w32poll.c \
- w32rng.c \
- w32shm.c \
- $(NULL)
-endif
-endif
-
-TARGETS = $(OBJS)
-
-INCLUDES = -I$(DIST)/include -I$(MOD_DEPTH)/pr/include -I$(MOD_DEPTH)/pr/include/private
-
-DEFINES += -D_NSPR_BUILD_
-
-include $(MOD_DEPTH)/config/rules.mk
-
-export:: $(TARGETS)
-
-install:: export
diff --git a/pr/src/md/windows/Makefile.in b/pr/src/md/windows/Makefile.in
index 89100b06..cf5eeac9 100644
--- a/pr/src/md/windows/Makefile.in
+++ b/pr/src/md/windows/Makefile.in
@@ -27,7 +27,7 @@ include $(MOD_DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
ifdef USE_AUTOCONF
-OS_TARGET=$(MOZ_TARGET)
+OS_TARGET=$(MOZ_WIN32_TARGET)
endif
ifeq ($(OS_TARGET), WIN16)
@@ -49,17 +49,18 @@ else
ifeq ($(OS_TARGET), WIN95)
CSRCS = \
ntmisc.c \
+ ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \
w95thred.c \
w95io.c \
w95cv.c \
+ w32rng.c \
w95sock.c \
win32_errors.c \
w32ipcsem.c \
w32poll.c \
- w32rng.c \
w32shm.c \
w95dllmain.c \
$(NULL)
@@ -67,6 +68,7 @@ else
CSRCS = \
ntdllmn.c \
ntmisc.c \
+ ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \
@@ -83,7 +85,7 @@ endif
TARGETS = $(OBJS)
-INCLUDES = -I$(DIST)/include -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
+INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private
DEFINES += -D_NSPR_BUILD_
@@ -91,4 +93,3 @@ include $(topsrcdir)/config/rules.mk
export:: $(TARGETS)
-install:: export
diff --git a/pr/src/md/windows/ntinrval.c b/pr/src/md/windows/ntinrval.c
index ba5e1e8e..ea67302d 100644
--- a/pr/src/md/windows/ntinrval.c
+++ b/pr/src/md/windows/ntinrval.c
@@ -72,7 +72,7 @@ _PR_MD_GET_INTERVAL()
#elif defined(WIN16)
return clock(); /* milliseconds since application start */
#else
- return timeGetTime(); /* milliseconds since system start */
+ return GetTickCount(); /* milliseconds since system start */
#endif
}
diff --git a/pr/src/md/windows/ntio.c b/pr/src/md/windows/ntio.c
index 5326be68..fb8cc5ff 100644
--- a/pr/src/md/windows/ntio.c
+++ b/pr/src/md/windows/ntio.c
@@ -744,7 +744,7 @@ void _PR_Unblock_IO_Wait(PRThread *thr)
* this thread will continue to run on the same cpu until the
* I/O is aborted by closing the FD or calling CancelIO
*/
- thr->md.thr_bound_cpu = me->cpu;
+ thr->md.thr_bound_cpu = cpu;
PR_ASSERT(!(thr->flags & _PR_IDLE_THREAD));
_PR_AddThreadToRunQ(me, thr);
@@ -2044,7 +2044,7 @@ _PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len)
PR_SetError(PR_NOT_CONNECTED_ERROR, 0);
return PR_FAILURE;
}
- *len = PR_NETADDR_SIZE(addr);
+ *len = PR_NETADDR_SIZE(&fd->secret->md.peer_addr);
memcpy(addr, &fd->secret->md.peer_addr, *len);
return PR_SUCCESS;
} else {
@@ -3016,7 +3016,10 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
}
len = GetFullPathName(fn, sizeof(pathbuf), pathbuf,
&filePart);
- PR_ASSERT(0 != len);
+ if (0 == len) {
+ _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
+ return -1;
+ }
if (len > sizeof(pathbuf)) {
PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);
return -1;
diff --git a/pr/src/md/windows/objs.mk b/pr/src/md/windows/objs.mk
index eff0e2b1..3820da67 100644
--- a/pr/src/md/windows/objs.mk
+++ b/pr/src/md/windows/objs.mk
@@ -14,8 +14,9 @@
# Copyright (C) 1999 Christopher Seawood. All Rights Reserved.
#
-ifeq (WINNT,$(MOZ_TARGET))
+ifeq (WINNT,$(MOZ_WIN32_TARGET))
CSRCS = ntmisc.c \
+ ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \
@@ -23,10 +24,14 @@ CSRCS = ntmisc.c \
ntthread.c \
ntdllmn.c \
win32_errors.c \
- w32poll.c
+ w32ipcsem.c \
+ w32poll.c \
+ w32rng.c \
+ w32shm.c
else
-ifeq (WIN95,$(MOZ_TARGET))
+ifeq (WIN95,$(MOZ_WIN32_TARGET))
CSRCS = ntmisc.c \
+ ntsec.c \
ntsem.c \
ntinrval.c \
ntgc.c \
@@ -35,10 +40,13 @@ CSRCS = ntmisc.c \
w95cv.c \
w95sock.c \
win32_errors.c \
+ w32ipcsem.c \
w32poll.c \
+ w32rng.c \
+ w32shm.c \
w95dllmain.c
else
-ifeq (WIN16,$(MOZ_TARGET))
+ifeq (WIN16,$(MOZ_WIN32_TARGET))
CSRCS = w16null.c \
w16thred.c \
w16proc.c \
diff --git a/pr/src/md/windows/w95io.c b/pr/src/md/windows/w95io.c
index d80736fe..3832eb4b 100644
--- a/pr/src/md/windows/w95io.c
+++ b/pr/src/md/windows/w95io.c
@@ -773,7 +773,10 @@ _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info)
}
len = GetFullPathName(fn, sizeof(pathbuf), pathbuf,
&filePart);
- PR_ASSERT(0 != len);
+ if (0 == len) {
+ _PR_MD_MAP_OPENDIR_ERROR(GetLastError());
+ return -1;
+ }
if (len > sizeof(pathbuf)) {
PR_SetError(PR_NAME_TOO_LONG_ERROR, 0);
return -1;