Skip to content

Commit

Permalink
Bug 844784: Update NSPR to NSPR_4_10_4_BETA4. Also includes the changes
Browse files Browse the repository at this point in the history
for bug 972125, bug 963033, bug 767759, bug 971152, bug 936320, and
bug 969061.
  • Loading branch information
wantehchang committed Mar 1, 2014
1 parent cef0b2f commit d23f00c
Show file tree
Hide file tree
Showing 17 changed files with 454 additions and 243 deletions.
2 changes: 1 addition & 1 deletion nsprpub/TAG-INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NSPR_4_10_4_BETA3
NSPR_4_10_4_BETA4
1 change: 1 addition & 0 deletions nsprpub/config/prdepend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*/

#error "Do not include this header file."

255 changes: 137 additions & 118 deletions nsprpub/configure

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions nsprpub/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ USE_PTHREADS=
USE_USER_PTHREADS=
USE_NSPR_THREADS=
USE_N32=
USE_X32=
USE_64=
USE_CPLUS=
USE_IPV6=
Expand Down Expand Up @@ -396,6 +397,15 @@ AC_ARG_ENABLE(n32,
fi
fi ])

AC_ARG_ENABLE(x32,
[ --enable-x32 Enable x32 ABI support (x86_64 only)],
[ if test "$enableval" = "yes"; then
USE_X32=1
else if test "$enableval" = "no"; then
USE_X32=
fi
fi ])

AC_ARG_ENABLE(64bit,
[ --enable-64bit Enable 64-bit support (on certain platforms)],
[ if test "$enableval" = "yes"; then
Expand Down Expand Up @@ -1867,6 +1877,10 @@ tools are selected during the Xcode/Developer Tools installation.])
x86_64)
if test -n "$USE_64"; then
PR_MD_ASFILES=os_Linux_x86_64.s
elif test -n "$USE_X32"; then
PR_MD_ASFILES=os_Linux_x86_64.s
CC="$CC -mx32"
CXX="$CXX -mx32"
else
AC_DEFINE(i386)
PR_MD_ASFILES=os_Linux_x86.s
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/md/_darwin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define IS_BIG_ENDIAN 1
#endif

#ifdef __x86_64__
#ifdef __LP64__
#define IS_64
#endif

Expand Down
6 changes: 4 additions & 2 deletions nsprpub/pr/include/md/_darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#define _PR_SI_ARCHITECTURE "ppc"
#elif defined(__arm__)
#define _PR_SI_ARCHITECTURE "arm"
#elif defined(__aarch64__)
#define _PR_SI_ARCHITECTURE "aarch64"
#else
#error "Unknown CPU architecture"
#endif
Expand Down Expand Up @@ -122,7 +124,7 @@ extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_64_AtomicAdd(ptr, val)
#endif /* __x86_64__ */

#ifdef __arm__
#if defined(__arm__) || defined(__aarch64__)
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
#define _MD_ATOMIC_INCREMENT(val) OSAtomicIncrement32(val)
Expand All @@ -136,7 +138,7 @@ static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
return oldval;
}
#define _MD_ATOMIC_ADD(ptr, val) OSAtomicAdd32(val, ptr)
#endif /* __arm__ */
#endif /* __arm__ || __aarch64__ */

#define USE_SETJMP

Expand Down
2 changes: 1 addition & 1 deletion nsprpub/pr/include/pratom.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ long __cdecl _InterlockedExchangeAdd(long volatile *Addend, long Value);
(defined(__powerpc__) && !defined(__powerpc64__)) || \
(defined(__arm__) && \
defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
defined(__alpha))))
defined(__aarch64__) || defined(__alpha))))

/*
* Because the GCC manual warns that some processors may support
Expand Down
28 changes: 18 additions & 10 deletions nsprpub/pr/include/private/primpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ NSPR_API(void) _PR_PauseCPU(void);
_PR_MD_UNLOCK(&(_lock)->ilock);

extern void _PR_UnblockLockWaiter(PRLock *lock);
extern PRStatus _PR_InitLock(PRLock *lock);
extern void _PR_FreeLock(PRLock *lock);

#define _PR_LOCK_PTR(_qp) \
((PRLock*) ((char*) (_qp) - offsetof(PRLock,links)))
Expand All @@ -550,8 +552,11 @@ extern void _PR_UnblockLockWaiter(PRLock *lock);
#define _PR_CVAR_UNLOCK(_cvar) \
_PR_MD_UNLOCK(&(_cvar)->ilock);

extern PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock);
extern void _PR_FreeCondVar(PRCondVar *cvar);
extern PRStatus _PR_WaitCondVar(
PRThread *thread, PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
extern PRUint32 _PR_CondVarToString(PRCondVar *cvar, char *buf, PRUint32 buflen);

NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
Expand Down Expand Up @@ -1420,8 +1425,6 @@ struct PRLock {
#endif
};

extern void _PR_InitLocks(void);

struct PRCondVar {
PRLock *lock; /* associated lock that protects the condition */
#if defined(_PR_PTHREADS)
Expand All @@ -1446,10 +1449,6 @@ struct PRCondVar {
struct PRMonitor {
const char* name; /* monitor name for debugging */
#if defined(_PR_PTHREADS)
PRIntn notifyTimes; /* number of pending notifies for waitCV.
* The special value -1 means a broadcast
* (PR_NotifyAll). */

pthread_mutex_t lock; /* lock is only held when accessing fields
* of the PRMonitor, instead of being held
* while the monitor is entered. The only
Expand All @@ -1468,9 +1467,20 @@ struct PRMonitor {
* signal entryCV, and releases the reference
* after signaling entryCV. */
#else /* defined(_PR_PTHREADS) */
PRCondVar *cvar; /* associated lock and condition variable queue */
PRLock lock; /* lock is only held when accessing fields
* of the PRMonitor, instead of being held
* while the monitor is entered. The only
* exception is notifyTimes, which is
* protected by the monitor. */
PRThread *owner; /* the owner of the monitor or invalid */
PRCondVar entryCV; /* for threads waiting to enter the monitor */

PRCondVar waitCV; /* for threads waiting on the monitor */
#endif /* defined(_PR_PTHREADS) */
PRUint32 entryCount; /* # of times re-entered */
PRIntn notifyTimes; /* number of pending notifies for waitCV.
* The special value -1 means a broadcast
* (PR_NotifyAll). */
};

/************************************************************************/
Expand All @@ -1490,8 +1500,6 @@ struct PRSemaphore {
#endif /* defined(_PR_BTHREADS) */
};

NSPR_API(void) _PR_InitSem(void);

/*************************************************************************/

struct PRSem {
Expand Down Expand Up @@ -1765,6 +1773,7 @@ struct PRDirUTF16 {
};
#endif /* MOZ_UNICODE */

extern void _PR_InitLocks(void);
extern void _PR_InitSegs(void);
extern void _PR_InitStacks(void);
extern void _PR_InitTPD(void);
Expand All @@ -1782,7 +1791,6 @@ extern void _PR_InitDtoa(void);
extern void _PR_InitTime(void);
extern void _PR_InitMW(void);
extern void _PR_InitRWLocks(void);
extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
extern void _PR_CleanupThread(PRThread *thread);
extern void _PR_CleanupCallOnce(void);
extern void _PR_CleanupMW(void);
Expand Down
4 changes: 2 additions & 2 deletions nsprpub/pr/src/misc/prcountr.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ PR_IMPLEMENT(PRCounterHandle)
break;
}
qnp = (QName *)PR_NEXT_LINK( &qnp->link );
} while( qnp != (QName *)PR_LIST_HEAD( &qNameList ));
} while( qnp != (QName *)&qNameList );
}
/*
** If we did not find a matching QName,
Expand Down Expand Up @@ -174,7 +174,7 @@ PR_IMPLEMENT(PRCounterHandle)
*/
PR_ASSERT( strcmp(rnp->name, rName));
rnp = (RName *)PR_NEXT_LINK( &rnp->link );
} while( rnp != (RName *)PR_LIST_HEAD( &qnp->rNameList ));
} while( rnp != (RName *)&qnp->rNameList );
}

/* Get a new RName structure; initialize its members */
Expand Down
9 changes: 5 additions & 4 deletions nsprpub/pr/src/misc/prnetdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2228,10 +2228,6 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr)
#if !defined(_PR_HAVE_GETADDRINFO)
return pr_StringToNetAddrFB(string, addr);
#else
#if defined(_PR_INET6_PROBE)
if (!_pr_ipv6_is_present())
return pr_StringToNetAddrFB(string, addr);
#endif
/*
* getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some
* platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809),
Expand All @@ -2241,6 +2237,11 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr)
if (!strchr(string, '%'))
return pr_StringToNetAddrFB(string, addr);

#if defined(_PR_INET6_PROBE)
if (!_pr_ipv6_is_present())
return pr_StringToNetAddrFB(string, addr);
#endif

return pr_StringToNetAddrGAI(string, addr);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions nsprpub/pr/src/misc/prtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ PR_IMPLEMENT(PRTraceHandle)
break;
}
qnp = (QName *)PR_NEXT_LINK( &qnp->link );
} while( qnp != (QName *)PR_LIST_HEAD( &qNameList ));
} while( qnp != (QName *)&qNameList );
}
/*
** If we did not find a matching QName,
Expand Down Expand Up @@ -251,7 +251,7 @@ PR_IMPLEMENT(PRTraceHandle)
*/
PR_ASSERT( strcmp(rnp->name, rName));
rnp = (RName *)PR_NEXT_LINK( &rnp->link );
} while( rnp != (RName *)PR_LIST_HEAD( &qnp->rNameList ));
} while( rnp != (RName *)&qnp->rNameList );
}

/* Get a new RName structure; initialize its members */
Expand Down
10 changes: 3 additions & 7 deletions nsprpub/pr/src/pthreads/ptio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3400,6 +3400,8 @@ PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
extern PRBool _pr_ipv6_is_present(void);
PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
{
int osfd;

#if defined(DARWIN)
/*
* Disable IPv6 if Darwin version is less than 7.0.0 (OS X 10.3). IPv6 on
Expand All @@ -3412,24 +3414,18 @@ PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
}
#endif

#if defined(LINUX)
/* If /proc/net/if_inet6 exists, the Linux kernel supports IPv6. */
int rv = access("/proc/net/if_inet6", F_OK);
return (rv == 0);
#else
/*
* HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001)
* suggests that we call open("/dev/ip6", O_RDWR) to determine
* whether IPv6 APIs and the IPv6 stack are on the system.
* Our portable test below seems to work fine, so I am using it.
*/
PRInt32 osfd = socket(AF_INET6, SOCK_STREAM, 0);
osfd = socket(AF_INET6, SOCK_STREAM, 0);
if (osfd != -1) {
close(osfd);
return PR_TRUE;
}
return PR_FALSE;
#endif
}
#endif /* _PR_INET6_PROBE */
#endif
Expand Down
10 changes: 5 additions & 5 deletions nsprpub/pr/src/pthreads/ptsynch.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,12 @@ PR_IMPLEMENT(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar)

/*
* Notifies just get posted to the monitor. The actual notification is done
* when the monitor is exited so that MP systems don't contend for a monitor
* that they can't enter.
* when the monitor is fully exited so that MP systems don't contend for a
* monitor that they can't enter.
*/
static void pt_PostNotifyToMonitor(PRMonitor *mon, PRBool broadcast)
{
PR_ASSERT(NULL != mon);
PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mon);

/* mon->notifyTimes is protected by the monitor, so we don't need to
Expand Down Expand Up @@ -504,6 +505,7 @@ PR_IMPLEMENT(PRMonitor*) PR_NewMonitor(void)
mon->notifyTimes = 0;
mon->entryCount = 0;
mon->refCount = 1;
mon->name = NULL;
return mon;

error3:
Expand Down Expand Up @@ -653,7 +655,7 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon)
PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
{
PRStatus rv;
PRInt16 saved_entries;
PRUint32 saved_entries;
pthread_t saved_owner;

PR_ASSERT(mon != NULL);
Expand Down Expand Up @@ -708,14 +710,12 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)

PR_IMPLEMENT(PRStatus) PR_Notify(PRMonitor *mon)
{
PR_ASSERT(NULL != mon);
pt_PostNotifyToMonitor(mon, PR_FALSE);
return PR_SUCCESS;
} /* PR_Notify */

PR_IMPLEMENT(PRStatus) PR_NotifyAll(PRMonitor *mon)
{
PR_ASSERT(NULL != mon);
pt_PostNotifyToMonitor(mon, PR_TRUE);
return PR_SUCCESS;
} /* PR_NotifyAll */
Expand Down
48 changes: 29 additions & 19 deletions nsprpub/pr/src/threads/combined/prucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,47 +446,57 @@ PR_IMPLEMENT(PRCondVar*) PR_NewCondVar(PRLock *lock)
{
PRCondVar *cvar;

PR_ASSERT(lock != NULL);

cvar = PR_NEWZAP(PRCondVar);
if (cvar) {
#ifdef _PR_GLOBAL_THREADS_ONLY
if(_PR_MD_NEW_CV(&cvar->md)) {
PR_DELETE(cvar);
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
return NULL;
}
#endif
if (_PR_MD_NEW_LOCK(&(cvar->ilock)) == PR_FAILURE) {
PR_DELETE(cvar);
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
return NULL;
}
cvar->lock = lock;
PR_INIT_CLIST(&cvar->condQ);

if (_PR_InitCondVar(cvar, lock) != PR_SUCCESS) {
PR_DELETE(cvar);
return NULL;
}
} else {
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
}
return cvar;
}

PRStatus _PR_InitCondVar(PRCondVar *cvar, PRLock *lock)
{
PR_ASSERT(lock != NULL);

#ifdef _PR_GLOBAL_THREADS_ONLY
if(_PR_MD_NEW_CV(&cvar->md)) {
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
return PR_FAILURE;
}
#endif
if (_PR_MD_NEW_LOCK(&(cvar->ilock)) != PR_SUCCESS) {
PR_SetError(PR_INSUFFICIENT_RESOURCES_ERROR, 0);
return PR_FAILURE;
}
cvar->lock = lock;
PR_INIT_CLIST(&cvar->condQ);
return PR_SUCCESS;
}

/*
** Destroy a condition variable. There must be no thread
** waiting on the condvar. The caller is responsible for guaranteeing
** that the condvar is no longer in use.
**
*/
PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar)
{
_PR_FreeCondVar(cvar);
PR_DELETE(cvar);
}

void _PR_FreeCondVar(PRCondVar *cvar)
{
PR_ASSERT(cvar->condQ.next == &cvar->condQ);

#ifdef _PR_GLOBAL_THREADS_ONLY
_PR_MD_FREE_CV(&cvar->md);
#endif
_PR_MD_FREE_LOCK(&(cvar->ilock));

PR_DELETE(cvar);
}

/*
Expand Down
Loading

0 comments on commit d23f00c

Please sign in to comment.