#369: just enough new NSPR

This commit is contained in:
Cameron Kaiser 2020-01-22 18:28:01 -08:00
parent b8657e6969
commit ac439d5827
14 changed files with 81 additions and 56 deletions

2
nsprpub/104FX-README Normal file
View File

@ -0,0 +1,2 @@
This version of NSPR is specific to TenFourFox and ABI-compatible with NSPR
4.24. It is not intended for other consumers; you should use mainline NSPR.

View File

@ -1 +1 @@
NSPR_4_13_1_RTM
NSPR_4_24_0_104FX

View File

@ -517,7 +517,7 @@ reversepath(char *inpath, char *name, int len, char *outpath)
xchdir("..");
} else {
cp -= 3;
strncpy(cp, "../", 3);
memcpy(cp, "../", 3);
xchdir(buf);
}
}

View File

@ -31,10 +31,10 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.13.1"
#define PR_VERSION "4.24"
#define PR_VMAJOR 4
#define PR_VMINOR 13
#define PR_VPATCH 1
#define PR_VMINOR 24
#define PR_VPATCH 0
#define PR_BETA PR_FALSE
/*

View File

@ -207,12 +207,16 @@ NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln)
#define PR_ASSERT(_expr) \
((_expr)?((void)0):PR_Assert(# _expr,__FILE__,__LINE__))
#define PR_ASSERT_ARG(_expr) PR_ASSERT(_expr)
#define PR_NOT_REACHED(_reasonStr) \
PR_Assert(_reasonStr,__FILE__,__LINE__)
#else
#define PR_ASSERT(expr) ((void) 0)
/* PR_ASSERT_ARG avoids compiler warning: unused variable */
#define PR_ASSERT_ARG(expr) ((void)(0 && (expr)))
#define PR_NOT_REACHED(reasonStr)
#endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */

View File

@ -16,8 +16,8 @@ static PRIOMethods ipv6_to_v4_tcpMethods;
static PRIOMethods ipv6_to_v4_udpMethods;
static PRDescIdentity _pr_ipv6_to_ipv4_id;
extern PRBool IsValidNetAddr(const PRNetAddr *addr);
extern PRIPv6Addr _pr_in6addr_any;
extern PRIPv6Addr _pr_in6addr_loopback;
extern const PRIPv6Addr _pr_in6addr_any;
extern const PRIPv6Addr _pr_in6addr_loopback;
/*
* convert an IPv4-mapped IPv6 addr to an IPv4 addr
@ -247,7 +247,7 @@ static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketRecvFrom(PRFileDesc *fd, void *buf,
#if defined(_PR_INET6_PROBE)
static PRBool ipv6_is_present;
extern PRBool _pr_test_ipv6_socket(void);
PR_EXTERN(PRBool) _pr_test_ipv6_socket(void);
#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
extern PRStatus _pr_find_getipnodebyname(void);

View File

@ -751,7 +751,7 @@ static PRInt32 PR_CALLBACK SocketSendTo(
#endif
count = 0;
while (amount > 0) {
do {
temp = _PR_MD_SENDTO(fd, buf, amount, flags,
addrp, PR_NETADDR_SIZE(addr), timeout);
if (temp < 0) {
@ -764,7 +764,7 @@ static PRInt32 PR_CALLBACK SocketSendTo(
}
buf = (const void*) ((const char*)buf + temp);
amount -= temp;
}
} while (amount > 0);
return count;
}

View File

@ -59,7 +59,7 @@
** Global lock variable used to bracket calls into rusty libraries that
** aren't thread safe (like libc, libX, etc).
*/
static PRLock *_pr_rename_lock = NULL;
static PRLock *_pr_unix_rename_lock = NULL;
static PRMonitor *_pr_Xfe_mon = NULL;
static PRInt64 minus_one;
@ -204,8 +204,8 @@ PRInt32 _MD_rename(const char *from, const char *to)
** of an existing file. Holding a lock across these two function
** and the open function is known to be a bad idea, but ....
*/
if (NULL != _pr_rename_lock)
PR_Lock(_pr_rename_lock);
if (NULL != _pr_unix_rename_lock)
PR_Lock(_pr_unix_rename_lock);
if (0 == access(to, F_OK))
PR_SetError(PR_FILE_EXISTS_ERROR, 0);
else
@ -216,8 +216,8 @@ PRInt32 _MD_rename(const char *from, const char *to)
_PR_MD_MAP_RENAME_ERROR(err);
}
}
if (NULL != _pr_rename_lock)
PR_Unlock(_pr_rename_lock);
if (NULL != _pr_unix_rename_lock)
PR_Unlock(_pr_unix_rename_lock);
return rv;
}
@ -260,15 +260,15 @@ int rv, err;
** This lock is used to enforce rename semantics as described
** in PR_Rename. Look there for more fun details.
*/
if (NULL !=_pr_rename_lock)
PR_Lock(_pr_rename_lock);
if (NULL !=_pr_unix_rename_lock)
PR_Lock(_pr_unix_rename_lock);
rv = mkdir(name, mode);
if (rv < 0) {
err = _MD_ERRNO();
_PR_MD_MAP_MKDIR_ERROR(err);
}
if (NULL !=_pr_rename_lock)
PR_Unlock(_pr_rename_lock);
if (NULL !=_pr_unix_rename_lock)
PR_Unlock(_pr_unix_rename_lock);
return rv;
}
@ -2219,8 +2219,8 @@ PRInt32 _MD_open(const char *name, PRIntn flags, PRIntn mode)
if (flags & PR_CREATE_FILE)
{
osflags |= O_CREAT;
if (NULL !=_pr_rename_lock)
PR_Lock(_pr_rename_lock);
if (NULL !=_pr_unix_rename_lock)
PR_Lock(_pr_unix_rename_lock);
}
#if defined(ANDROID)
@ -2234,8 +2234,8 @@ PRInt32 _MD_open(const char *name, PRIntn flags, PRIntn mode)
_PR_MD_MAP_OPEN_ERROR(err);
}
if ((flags & PR_CREATE_FILE) && (NULL !=_pr_rename_lock))
PR_Unlock(_pr_rename_lock);
if ((flags & PR_CREATE_FILE) && (NULL !=_pr_unix_rename_lock))
PR_Unlock(_pr_unix_rename_lock);
return rv;
}
@ -2877,8 +2877,8 @@ void _PR_UnixInit(void)
PR_ASSERT(0 == rv);
#endif /* HPUX && _PR_DCETHREADS */
_pr_rename_lock = PR_NewLock();
PR_ASSERT(NULL != _pr_rename_lock);
_pr_unix_rename_lock = PR_NewLock();
PR_ASSERT(NULL != _pr_unix_rename_lock);
_pr_Xfe_mon = PR_NewMonitor();
PR_ASSERT(NULL != _pr_Xfe_mon);
@ -2887,9 +2887,9 @@ void _PR_UnixInit(void)
void _PR_UnixCleanup(void)
{
if (_pr_rename_lock) {
PR_DestroyLock(_pr_rename_lock);
_pr_rename_lock = NULL;
if (_pr_unix_rename_lock) {
PR_DestroyLock(_pr_unix_rename_lock);
_pr_unix_rename_lock = NULL;
}
if (_pr_Xfe_mon) {
PR_DestroyMonitor(_pr_Xfe_mon);
@ -3575,12 +3575,20 @@ PRStatus _MD_CreateFileMap(PRFileMap *fmap, PRInt64 size)
}
if (fmap->prot == PR_PROT_READONLY) {
fmap->md.prot = PROT_READ;
#ifdef OSF1V4_MAP_PRIVATE_BUG
#if defined(OSF1V4_MAP_PRIVATE_BUG) || defined(DARWIN) || defined(ANDROID)
/*
* Use MAP_SHARED to work around a bug in OSF1 V4.0D
* (QAR 70220 in the OSF_QAR database) that results in
* corrupted data in the memory-mapped region. This
* bug is fixed in V5.0.
*
* This is also needed on OS X because its implementation of
* POSIX shared memory returns an error for MAP_PRIVATE, even
* when the mapping is read-only.
*
* And this is needed on Android, because mapping ashmem with
* MAP_PRIVATE creates a mapping of zeroed memory instead of
* the shm contents.
*/
fmap->md.flags = MAP_SHARED;
#else

View File

@ -177,19 +177,21 @@ pr_inet_aton(const char *cp, PRUint32 *addr)
case 2: /*%< a.b -- 8.24 bits */
if (val > 0xffffffU)
return (0);
val |= parts[0] << 24;
val |= (unsigned int)parts[0] << 24;
break;
case 3: /*%< a.b.c -- 8.8.16 bits */
if (val > 0xffffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
val |= ((unsigned int)parts[0] << 24) | ((unsigned int)parts[1] << 16);
break;
case 4: /*%< a.b.c.d -- 8.8.8.8 bits */
if (val > 0xffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
val |= ((unsigned int)parts[0] << 24) |
((unsigned int)parts[1] << 16) |
((unsigned int)parts[2] << 8);
break;
}
*addr = PR_htonl(val);

View File

@ -1405,7 +1405,7 @@ PR_IMPLEMENT(PRStatus) PR_InitializeNetAddr(
PRStatus rv = PR_SUCCESS;
if (!_pr_initialized) _PR_ImplicitInitialization();
if (val != PR_IpAddrNull) memset(addr, 0, sizeof(addr->inet));
if (val != PR_IpAddrNull) memset(addr, 0, sizeof(*addr));
addr->inet.family = AF_INET;
addr->inet.port = htons(port);
switch (val)
@ -1777,18 +1777,12 @@ PR_IMPLEMENT(PRUint64) PR_ntohll(PRUint64 n)
#ifdef IS_BIG_ENDIAN
return n;
#else
PRUint64 tmp;
PRUint32 hi, lo;
LL_L2UI(lo, n);
LL_SHR(tmp, n, 32);
LL_L2UI(hi, tmp);
lo = (PRUint32)n;
hi = (PRUint32)(n >> 32);
hi = PR_ntohl(hi);
lo = PR_ntohl(lo);
LL_UI2L(n, lo);
LL_SHL(n, n, 32);
LL_UI2L(tmp, hi);
LL_ADD(n, n, tmp);
return n;
return ((PRUint64)lo << 32) + (PRUint64)hi;
#endif
} /* ntohll */
@ -1797,18 +1791,12 @@ PR_IMPLEMENT(PRUint64) PR_htonll(PRUint64 n)
#ifdef IS_BIG_ENDIAN
return n;
#else
PRUint64 tmp;
PRUint32 hi, lo;
LL_L2UI(lo, n);
LL_SHR(tmp, n, 32);
LL_L2UI(hi, tmp);
lo = (PRUint32)n;
hi = (PRUint32)(n >> 32);
hi = htonl(hi);
lo = htonl(lo);
LL_UI2L(n, lo);
LL_SHL(n, n, 32);
LL_UI2L(tmp, hi);
LL_ADD(n, n, tmp);
return n;
return ((PRUint64)lo << 32) + (PRUint64)hi;
#endif
} /* htonll */

View File

@ -3847,7 +3847,8 @@ static PRInt32 _pr_poll_with_poll(
/* now locate the NSPR layer at the bottom of the stack */
PRFileDesc *bottom = PR_GetIdentitiesLayer(
pds[index].fd, PR_NSPR_IO_LAYER);
PR_ASSERT(NULL != bottom); /* what to do about that? */
/* ignore a socket without PR_NSPR_IO_LAYER available */
pds[index].out_flags = 0; /* pre-condition */
if ((NULL != bottom)
&& (_PR_FILEDESC_OPEN == bottom->secret->state))
@ -4105,7 +4106,8 @@ static PRInt32 _pr_poll_with_select(
/* now locate the NSPR layer at the bottom of the stack */
PRFileDesc *bottom = PR_GetIdentitiesLayer(
pds[index].fd, PR_NSPR_IO_LAYER);
PR_ASSERT(NULL != bottom); /* what to do about that? */
/* ignore a socket without PR_NSPR_IO_LAYER available */
pds[index].out_flags = 0; /* pre-condition */
if ((NULL != bottom)
&& (_PR_FILEDESC_OPEN == bottom->secret->state))

View File

@ -1015,7 +1015,23 @@ void _PR_InitThreads(
* GCC supports the constructor and destructor attributes as of
* version 2.5.
*/
#if defined(DARWIN)
/*
* The dynamic linker on OSX doesn't execute __attribute__((destructor))
* destructors in the right order wrt non-__attribute((destructor)) destructors
* in other libraries. So use atexit() instead, which does.
* See https://bugzilla.mozilla.org/show_bug.cgi?id=1399746#c99
*/
static void _PR_Fini(void);
__attribute__ ((constructor))
static void _register_PR_Fini() {
atexit(_PR_Fini);
}
#else
static void _PR_Fini(void) __attribute__ ((destructor));
#endif
#elif defined(__SUNPRO_C)
/*
* Sun Studio compiler

View File

@ -10,6 +10,7 @@
#include <sys/types.h>
#include <limits.h>
#include <string.h>
#include <stdint.h>
int
main(int argc, char **argv)

View File

@ -39,7 +39,9 @@ static char *compatible_version[] = {
"4.9.6",
"4.10", "4.10.1", "4.10.2", "4.10.3", "4.10.4",
"4.10.5", "4.10.6", "4.10.7", "4.10.8", "4.10.9",
"4.10.10", "4.11", "4.12", "4.13",
"4.10.10", "4.11", "4.12", "4.13", "4.14", "4.15",
"4.16", "4.17", "4.18", "4.19", "4.20", "4.21", "4.22",
"4.23", "4.24",
PR_VERSION
};
@ -55,8 +57,8 @@ static char *incompatible_version[] = {
"3.0", "3.0.1",
"3.1", "3.1.1", "3.1.2", "3.1.3",
"3.5", "3.5.1",
"4.13.2",
"4.14", "4.14.1",
"4.25.1",
"4.26", "4.26.1",
"10.0", "11.1", "12.14.20"
};