summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2002-08-28 14:42:54 +0000
committerwtc%netscape.com <devnull@localhost>2002-08-28 14:42:54 +0000
commit959e5c0d526bdcb486a6862ca0f71f8ddb6dda44 (patch)
treed57ab9a43e61899272921935dec7c87b6e33336e
parent46baa58692818746a613746de13d2ca92c03a669 (diff)
downloadnspr-hg-959e5c0d526bdcb486a6862ca0f71f8ddb6dda44.tar.gz
Sync'ed up with the tip.
Modified files: repackage.sh plarena.c prio.h prthread.h _solaris.h _solaris32.cfg _solaris64.cfg _winnt.h primpl.h prmem.c uxshm.c ntthread.c prinit.c prnetdb.c prtpool.c ptthread.c prucpu.c Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rwxr-xr-xadmin/repackage.sh8
-rw-r--r--lib/ds/plarena.c6
-rw-r--r--pr/include/md/_solaris.h6
-rw-r--r--pr/include/md/_solaris32.cfg4
-rw-r--r--pr/include/md/_solaris64.cfg4
-rw-r--r--pr/include/md/_winnt.h2
-rw-r--r--pr/include/prio.h7
-rw-r--r--pr/include/private/primpl.h9
-rw-r--r--pr/include/prthread.h2
-rw-r--r--pr/src/malloc/prmem.c2
-rw-r--r--pr/src/md/unix/uxshm.c2
-rw-r--r--pr/src/md/windows/ntthread.c15
-rw-r--r--pr/src/misc/prinit.c5
-rw-r--r--pr/src/misc/prnetdb.c8
-rw-r--r--pr/src/misc/prtpool.c2
-rw-r--r--pr/src/pthreads/ptthread.c42
-rw-r--r--pr/src/threads/combined/prucpu.c31
17 files changed, 110 insertions, 45 deletions
diff --git a/admin/repackage.sh b/admin/repackage.sh
index fb2a464a..338c6de1 100755
--- a/admin/repackage.sh
+++ b/admin/repackage.sh
@@ -60,10 +60,10 @@
#
# These variables should be modified for each NSPR release.
#
-FROMTOP=/share/builds/components/nspr20/v4.2
-TOTOP=./v4.2
-NSPRDIR=nspr-4.2
-SOURCETAG=NSPR_4_2_RELEASE
+FROMTOP=/share/builds/components/nspr20/v4.2.1
+TOTOP=./v4.2.1
+NSPRDIR=nspr-4.2.1
+SOURCETAG=NSPR_4_2_1_RELEASE
#
# enumerate Unix object directories on /s/b/c
diff --git a/lib/ds/plarena.c b/lib/ds/plarena.c
index 7f144636..ad26f4a3 100644
--- a/lib/ds/plarena.c
+++ b/lib/ds/plarena.c
@@ -165,7 +165,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
do {
if ( a->avail +nb <= a->limit ) {
pool->current = a;
- rp = (void *)a->avail;
+ rp = (char *)a->avail;
a->avail += nb;
return rp;
}
@@ -188,7 +188,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
p->next = a->next;
UnlockArena();
a->avail = a->base;
- rp = (void *)a->avail;
+ rp = (char *)a->avail;
a->avail += nb;
/* the newly allocated arena is linked after pool->current
* and becomes pool->current */
@@ -211,7 +211,7 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
if ( NULL != a ) {
a->limit = (PRUword)a + sz;
a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
- rp = (void *)a->avail;
+ rp = (char *)a->avail;
a->avail += nb;
/* the newly allocated arena is linked after pool->current
* and becomes pool->current */
diff --git a/pr/include/md/_solaris.h b/pr/include/md/_solaris.h
index 42415a5b..3efb498d 100644
--- a/pr/include/md/_solaris.h
+++ b/pr/include/md/_solaris.h
@@ -41,7 +41,13 @@
#define PR_LINKER_ARCH "solaris"
#define _PR_SI_SYSNAME "SOLARIS"
+#ifdef sparc
#define _PR_SI_ARCHITECTURE "sparc"
+#elif defined(i386)
+#define _PR_SI_ARCHITECTURE "x86"
+#else
+#error unknown processor
+#endif
#define PR_DLL_SUFFIX ".so"
#define _PR_VMBASE 0x30000000
diff --git a/pr/include/md/_solaris32.cfg b/pr/include/md/_solaris32.cfg
index 10cb3364..ec19c4d3 100644
--- a/pr/include/md/_solaris32.cfg
+++ b/pr/include/md/_solaris32.cfg
@@ -43,12 +43,12 @@
#define SOLARIS
#endif
-#ifdef sparc
+#if defined(sparc) || defined(__sparc)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_DOUBLE 8
-#elif defined(i386)
+#elif defined(i386) || defined(__i386)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_ALIGN_OF_INT64 4
diff --git a/pr/include/md/_solaris64.cfg b/pr/include/md/_solaris64.cfg
index 8318b74b..54331c51 100644
--- a/pr/include/md/_solaris64.cfg
+++ b/pr/include/md/_solaris64.cfg
@@ -43,12 +43,12 @@
#define SOLARIS
#endif
-#ifdef sparc
+#if defined(sparc) || defined(__sparc)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_DOUBLE 8
-#elif defined(i386)
+#elif defined(i386) || defined(__i386)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_ALIGN_OF_INT64 4
diff --git a/pr/include/md/_winnt.h b/pr/include/md/_winnt.h
index de8a2cf7..8a5b7041 100644
--- a/pr/include/md/_winnt.h
+++ b/pr/include/md/_winnt.h
@@ -346,6 +346,8 @@ extern int _PR_NTFiberSafeSelect(int, fd_set *, fd_set *, fd_set *,
#define _MD_INIT_THREAD _PR_MD_INIT_THREAD
#define _MD_INIT_ATTACHED_THREAD _PR_MD_INIT_THREAD
#define _MD_CREATE_THREAD _PR_MD_CREATE_THREAD
+#define _MD_JOIN_THREAD _PR_MD_JOIN_THREAD
+#define _MD_END_THREAD _PR_MD_END_THREAD
#define _MD_YIELD _PR_MD_YIELD
#define _MD_SET_PRIORITY _PR_MD_SET_PRIORITY
#define _MD_CLEAN_THREAD _PR_MD_CLEAN_THREAD
diff --git a/pr/include/prio.h b/pr/include/prio.h
index 29da2314..12caf4ef 100644
--- a/pr/include/prio.h
+++ b/pr/include/prio.h
@@ -1240,7 +1240,7 @@ NSPR_API(PRStatus) PR_Connect(
* PR_Poll()
* RETURN: PRStatus
* If the nonblocking connect has successfully completed,
- * PR_GetConnectStatus returns PR_SUCCESS. If PR_GetConnectStatus()
+ * PR_ConnectContinue returns PR_SUCCESS. If PR_ConnectContinue()
* returns PR_FAILURE, call PR_GetError():
* - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in
* progress and has not completed yet. The caller should poll
@@ -1880,9 +1880,12 @@ struct PRPollDesc {
** DESCRIPTION:
**
** The call returns as soon as I/O is ready on one or more of the underlying
-** file/socket objects. A count of the number of ready descriptors is
+** socket objects. A count of the number of ready descriptors is
** returned unless a timeout occurs in which case zero is returned.
**
+** PRPollDesc.fd should be set to a pointer to a PRFileDesc object
+** representing a socket. This field can be set to NULL to indicate to
+** PR_Poll that this PRFileDesc object should be ignored.
** PRPollDesc.in_flags should be set to the desired request
** (read/write/except or some combination). Upon successful return from
** this call PRPollDesc.out_flags will be set to indicate what kind of
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index f6a1f63d..5455ed9c 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1022,6 +1022,12 @@ extern PRStatus _PR_MD_CREATE_THREAD(
PRUint32 stackSize);
#define _PR_MD_CREATE_THREAD _MD_CREATE_THREAD
+extern void _PR_MD_JOIN_THREAD(_MDThread *md);
+#define _PR_MD_JOIN_THREAD _MD_JOIN_THREAD
+
+extern void _PR_MD_END_THREAD(void);
+#define _PR_MD_END_THREAD _MD_END_THREAD
+
extern void _PR_MD_YIELD(void);
#define _PR_MD_YIELD _MD_YIELD
@@ -1757,6 +1763,9 @@ extern void _PR_CleanupIO(void);
extern void _PR_CleanupNet(void);
extern void _PR_CleanupLayerCache(void);
extern void _PR_CleanupStacks(void);
+#ifdef WINNT
+extern void _PR_CleanupCPUs(void);
+#endif
extern void _PR_CleanupThreads(void);
extern void _PR_CleanupTPD(void);
extern void _PR_Cleanup(void);
diff --git a/pr/include/prthread.h b/pr/include/prthread.h
index a987202a..334116ce 100644
--- a/pr/include/prthread.h
+++ b/pr/include/prthread.h
@@ -159,7 +159,9 @@ NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
** Never returns NULL.
*/
NSPR_API(PRThread*) PR_GetCurrentThread(void);
+#ifndef NO_NSPR_10_SUPPORT
#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
+#endif /* NO_NSPR_10_SUPPORT */
/*
** Get the priority of "thread".
diff --git a/pr/src/malloc/prmem.c b/pr/src/malloc/prmem.c
index 20cf7e99..c3870ec7 100644
--- a/pr/src/malloc/prmem.c
+++ b/pr/src/malloc/prmem.c
@@ -167,7 +167,7 @@ _PR_InitZones(void)
char *envp;
PRBool *sym;
- if ((sym = pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) {
+ if ((sym = (PRBool *)pr_FindSymbolInProg("nspr_use_zone_allocator")) != NULL) {
use_zone_allocator = *sym;
} else if ((envp = getenv("NSPR_USE_ZONE_ALLOCATOR")) != NULL) {
use_zone_allocator = (atoi(envp) == 1);
diff --git a/pr/src/md/unix/uxshm.c b/pr/src/md/unix/uxshm.c
index 81aa7487..1dc98386 100644
--- a/pr/src/md/unix/uxshm.c
+++ b/pr/src/md/unix/uxshm.c
@@ -94,7 +94,7 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
return( NULL );
}
- shm->ipcname = PR_MALLOC( strlen( ipcname ) + 1 );
+ shm->ipcname = (char*)PR_MALLOC( strlen( ipcname ) + 1 );
if ( NULL == shm->ipcname )
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 );
diff --git a/pr/src/md/windows/ntthread.c b/pr/src/md/windows/ntthread.c
index 1c3fb531..a414e5c7 100644
--- a/pr/src/md/windows/ntthread.c
+++ b/pr/src/md/windows/ntthread.c
@@ -254,6 +254,21 @@ _PR_MD_CREATE_THREAD(PRThread *thread,
return PR_FAILURE;
}
+void
+_PR_MD_JOIN_THREAD(_MDThread *md)
+{
+ DWORD rv;
+
+ rv = WaitForSingleObject(md->handle, INFINITE);
+ PR_ASSERT(WAIT_OBJECT_0 == rv);
+}
+
+void
+_PR_MD_END_THREAD(void)
+{
+ _endthreadex(0);
+}
+
void
_PR_MD_YIELD(void)
{
diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c
index e512f1e0..cd55a9fb 100644
--- a/pr/src/misc/prinit.c
+++ b/pr/src/misc/prinit.c
@@ -451,6 +451,9 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
*/
_PR_CleanupNet();
_PR_CleanupIO();
+#ifdef WINNT
+ _PR_CleanupCPUs();
+#endif
_PR_CleanupThreads();
PR_DestroyLock(_pr_sleeplock);
_pr_sleeplock = NULL;
@@ -562,7 +565,7 @@ PR_ProcessAttrSetCurrentDirectory(
const char *dir)
{
PR_FREEIF(attr->currentDirectory);
- attr->currentDirectory = PR_MALLOC(strlen(dir) + 1);
+ attr->currentDirectory = (char *) PR_MALLOC(strlen(dir) + 1);
if (!attr->currentDirectory) {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
return PR_FAILURE;
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index 58342292..41d151c7 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -246,7 +246,7 @@ _pr_QueryNetIfs(void)
lastlen = 0;
len = 100 * sizeof(struct ifreq); /* initial buffer size guess */
for (;;) {
- buf = PR_Malloc(len);
+ buf = (char *)PR_Malloc(len);
if (NULL == buf) {
close(sock);
return;
@@ -604,7 +604,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByName(
tmpbuf = localbuf;
if (bufsize > sizeof(localbuf))
{
- tmpbuf = PR_Malloc(bufsize);
+ tmpbuf = (char *)PR_Malloc(bufsize);
if (NULL == tmpbuf)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
@@ -736,7 +736,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
tmpbuf = localbuf;
if (bufsize > sizeof(localbuf))
{
- tmpbuf = PR_Malloc(bufsize);
+ tmpbuf = (char *)PR_Malloc(bufsize);
if (NULL == tmpbuf)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
@@ -923,7 +923,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
tmpbuf = localbuf;
if (bufsize > sizeof(localbuf))
{
- tmpbuf = PR_Malloc(bufsize);
+ tmpbuf = (char *)PR_Malloc(bufsize);
if (NULL == tmpbuf)
{
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
diff --git a/pr/src/misc/prtpool.c b/pr/src/misc/prtpool.c
index acf6ec77..d0816b30 100644
--- a/pr/src/misc/prtpool.c
+++ b/pr/src/misc/prtpool.c
@@ -603,7 +603,7 @@ alloc_threadpool(void)
{
PRThreadPool *tp;
- tp = PR_CALLOC(sizeof(*tp));
+ tp = (PRThreadPool *) PR_CALLOC(sizeof(*tp));
if (NULL == tp)
goto failed;
tp->jobq.lock = PR_NewLock();
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c
index 070a887c..7fc2ad4d 100644
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -1091,12 +1091,6 @@ static PRBool suspendAllOn = PR_FALSE;
static PRBool suspendAllSuspended = PR_FALSE;
-/* Are all GCAble threads (except gc'ing thread) suspended? */
-PR_IMPLEMENT(PRBool) PR_SuspendAllSuspended()
-{
- return suspendAllSuspended;
-} /* PR_SuspendAllSuspended */
-
PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg)
{
PRIntn count = 0;
@@ -1247,12 +1241,12 @@ static void suspend_signal_handler(PRIntn sig)
("End suspend_signal_handler thred = %X tid = %X\n", me, me->id));
} /* suspend_signal_handler */
-static void PR_SuspendSet(PRThread *thred)
+static void pt_SuspendSet(PRThread *thred)
{
PRIntn rv;
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("PR_SuspendSet thred %X thread id = %X\n", thred, thred->id));
+ ("pt_SuspendSet thred %X thread id = %X\n", thred, thred->id));
/*
@@ -1262,7 +1256,7 @@ static void PR_SuspendSet(PRThread *thred)
PR_ASSERT((thred->suspend & PT_THREAD_SUSPENDED) == 0);
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("doing pthread_kill in PR_SuspendSet thred %X tid = %X\n",
+ ("doing pthread_kill in pt_SuspendSet thred %X tid = %X\n",
thred, thred->id));
#if defined(VMS)
rv = thread_suspend(thred);
@@ -1272,10 +1266,10 @@ static void PR_SuspendSet(PRThread *thred)
PR_ASSERT(0 == rv);
}
-static void PR_SuspendTest(PRThread *thred)
+static void pt_SuspendTest(PRThread *thred)
{
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("Begin PR_SuspendTest thred %X thread id = %X\n", thred, thred->id));
+ ("Begin pt_SuspendTest thred %X thread id = %X\n", thred, thred->id));
/*
@@ -1301,13 +1295,13 @@ static void PR_SuspendTest(PRThread *thred)
#endif
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("End PR_SuspendTest thred %X tid %X\n", thred, thred->id));
-} /* PR_SuspendTest */
+ ("End pt_SuspendTest thred %X tid %X\n", thred, thred->id));
+} /* pt_SuspendTest */
-PR_IMPLEMENT(void) PR_ResumeSet(PRThread *thred)
+static void pt_ResumeSet(PRThread *thred)
{
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("PR_ResumeSet thred %X thread id = %X\n", thred, thred->id));
+ ("pt_ResumeSet thred %X thread id = %X\n", thred, thred->id));
/*
* Clear the global state and set the thread state so that it will
@@ -1327,12 +1321,12 @@ PR_IMPLEMENT(void) PR_ResumeSet(PRThread *thred)
#endif
#endif
-} /* PR_ResumeSet */
+} /* pt_ResumeSet */
-PR_IMPLEMENT(void) PR_ResumeTest(PRThread *thred)
+static void pt_ResumeTest(PRThread *thred)
{
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
- ("Begin PR_ResumeTest thred %X thread id = %X\n", thred, thred->id));
+ ("Begin pt_ResumeTest thred %X thread id = %X\n", thred, thred->id));
/*
* Wait for the threads resume state to change
@@ -1356,8 +1350,8 @@ PR_IMPLEMENT(void) PR_ResumeTest(PRThread *thred)
thred->suspend &= ~PT_THREAD_RESUMED;
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, (
- "End PR_ResumeTest thred %X tid %X\n", thred, thred->id));
-} /* PR_ResumeTest */
+ "End pt_ResumeTest thred %X tid %X\n", thred, thred->id));
+} /* pt_ResumeTest */
static pthread_once_t pt_gc_support_control = PTHREAD_ONCE_INIT;
@@ -1384,7 +1378,7 @@ PR_IMPLEMENT(void) PR_SuspendAll(void)
while (thred != NULL)
{
if ((thred != me) && _PT_IS_GCABLE_THREAD(thred))
- PR_SuspendSet(thred);
+ pt_SuspendSet(thred);
thred = thred->next;
}
@@ -1393,7 +1387,7 @@ PR_IMPLEMENT(void) PR_SuspendAll(void)
while (thred != NULL)
{
if ((thred != me) && _PT_IS_GCABLE_THREAD(thred))
- PR_SuspendTest(thred);
+ pt_SuspendTest(thred);
thred = thred->next;
}
@@ -1426,7 +1420,7 @@ PR_IMPLEMENT(void) PR_ResumeAll(void)
while (thred != NULL)
{
if ((thred != me) && _PT_IS_GCABLE_THREAD(thred))
- PR_ResumeSet(thred);
+ pt_ResumeSet(thred);
thred = thred->next;
}
@@ -1434,7 +1428,7 @@ PR_IMPLEMENT(void) PR_ResumeAll(void)
while (thred != NULL)
{
if ((thred != me) && _PT_IS_GCABLE_THREAD(thred))
- PR_ResumeTest(thred);
+ pt_ResumeTest(thred);
thred = thred->next;
}
diff --git a/pr/src/threads/combined/prucpu.c b/pr/src/threads/combined/prucpu.c
index be4203d6..3d575d6c 100644
--- a/pr/src/threads/combined/prucpu.c
+++ b/pr/src/threads/combined/prucpu.c
@@ -117,6 +117,31 @@ void _PR_InitCPUs()
_PR_MD_INIT_CPUS();
}
+#ifdef WINNT
+/*
+ * Right now this function merely stops the CPUs and does
+ * not do any other cleanup.
+ *
+ * It is only implemented for WINNT because bug 161998 only
+ * affects the WINNT version of NSPR, but it would be nice
+ * to implement this function for other platforms too.
+ */
+void _PR_CleanupCPUs(void)
+{
+ PRUintn i;
+ PRCList *qp;
+ _PRCPU *cpu;
+
+ _pr_cpus_exit = 1;
+ for (i = 0; i < _pr_numCPU; i++) {
+ _PR_MD_WAKEUP_WAITER(NULL);
+ }
+ for (qp = _PR_CPUQ().next; qp != &_PR_CPUQ(); qp = qp->next) {
+ cpu = _PR_CPU_PTR(qp);
+ _PR_MD_JOIN_THREAD(&cpu->thread->md);
+ }
+}
+#endif
static _PRCPUQueue *_PR_CreateCPUQueue(void)
{
@@ -332,6 +357,12 @@ static void PR_CALLBACK _PR_CPU_Idle(void *_cpu)
/* Wait for an IO to complete */
(void)_PR_MD_PAUSE_CPU(timeout);
+#ifdef WINNT
+ if (_pr_cpus_exit) {
+ /* _PR_CleanupCPUs tells us to exit */
+ _PR_MD_END_THREAD();
+ }
+#endif
#if !defined(_PR_LOCAL_THREADS_ONLY) && !defined(_PR_GLOBAL_THREADS_ONLY)
#ifdef _PR_HAVE_ATOMIC_OPS