Skip to content

Commit

Permalink
Bug 1477680, land NSPR 4.20 beta snapshot 607196c7ef66, r=me
Browse files Browse the repository at this point in the history
UPGRADE_NSPR_RELEASE
  • Loading branch information
kaie committed Jul 23, 2018
1 parent 5da3dc1 commit beb57a9
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 13 deletions.
2 changes: 1 addition & 1 deletion nsprpub/TAG-INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NSPR_4_19_RTM
607196c7ef66
1 change: 0 additions & 1 deletion nsprpub/config/prdepend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
*/

#error "Do not include this header file."

2 changes: 1 addition & 1 deletion nsprpub/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2488,7 +2488,7 @@ test -n "$target_alias" &&
program_prefix=${target_alias}-
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=19
MOD_MINOR_VERSION=20
MOD_PATCH_VERSION=0
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
Expand Down
2 changes: 1 addition & 1 deletion nsprpub/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dnl ========================================================
dnl = Defaults
dnl ========================================================
MOD_MAJOR_VERSION=4
MOD_MINOR_VERSION=19
MOD_MINOR_VERSION=20
MOD_PATCH_VERSION=0
NSPR_MODNAME=nspr20
_HAVE_PTHREADS=
Expand Down
92 changes: 92 additions & 0 deletions nsprpub/pr/include/md/_linux.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,98 @@
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3

#elif defined(__riscv) && (__riscv_xlen == 32)

#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#undef IS_64

#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8

#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32

#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5

#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4

#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3

#elif defined(__riscv) && (__riscv_xlen == 64)

#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#define IS_64

#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8

#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64

#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6

#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8

#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3

#else

#error "Unknown CPU architecture"
Expand Down
4 changes: 4 additions & 0 deletions nsprpub/pr/include/md/_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
#define _PR_SI_ARCHITECTURE "m32r"
#elif defined(__or1k__)
#define _PR_SI_ARCHITECTURE "or1k"
#elif defined(__riscv) && (__riscv_xlen == 32)
#define _PR_SI_ARCHITECTURE "riscv32"
#elif defined(__riscv) && (__riscv_xlen == 64)
#define _PR_SI_ARCHITECTURE "riscv64"
#else
#error "Unknown CPU architecture"
#endif
Expand Down
6 changes: 3 additions & 3 deletions nsprpub/pr/include/prinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ PR_BEGIN_EXTERN_C
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.19"
#define PR_VERSION "4.20 Beta"
#define PR_VMAJOR 4
#define PR_VMINOR 19
#define PR_VMINOR 20
#define PR_VPATCH 0
#define PR_BETA PR_FALSE
#define PR_BETA PR_TRUE

/*
** PRVersionCheck
Expand Down
16 changes: 15 additions & 1 deletion nsprpub/pr/src/misc/prnetdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

#include <string.h>

#if defined(LINUX)
#include <sys/un.h>
#endif

/*
* On Unix, the error code for gethostbyname() and gethostbyaddr()
* is returned in the global variable h_errno, instead of the usual
Expand Down Expand Up @@ -1366,7 +1370,17 @@ PRUintn _PR_NetAddrSize(const PRNetAddr* addr)
#endif
#if defined(XP_UNIX) || defined(XP_OS2)
else if (AF_UNIX == addr->raw.family)
addrsize = sizeof(addr->local);
{
#if defined(LINUX)
if (addr->local.path[0] == 0)
/* abstract socket address is supported on Linux only */
addrsize = strnlen(addr->local.path + 1,
sizeof(addr->local.path)) +
offsetof(struct sockaddr_un, sun_path) + 1;
else
#endif
addrsize = sizeof(addr->local);
}
#endif
else addrsize = 0;

Expand Down
7 changes: 6 additions & 1 deletion nsprpub/pr/src/pthreads/ptio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,12 @@ static PRStatus pt_Bind(PRFileDesc *fd, const PRNetAddr *addr)
if (addr->raw.family == AF_UNIX)
{
/* Disallow relative pathnames */
if (addr->local.path[0] != '/')
if (addr->local.path[0] != '/'
#if defined(LINUX)
/* Linux has abstract socket address support */
&& addr->local.path[0] != 0
#endif
)
{
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return PR_FAILURE;
Expand Down
3 changes: 2 additions & 1 deletion nsprpub/pr/src/pthreads/ptsynch.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,8 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name)
* From the semctl(2) man page in glibc 2.0
*/
#if (defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)) \
|| defined(FREEBSD) || defined(OPENBSD) || defined(BSDI) \
|| (defined(FREEBSD) && __FreeBSD_version < 1200059) \
|| defined(OPENBSD) || defined(BSDI) \
|| defined(DARWIN) || defined(SYMBIAN)
/* union semun is defined by including <sys/sem.h> */
#else
Expand Down
1 change: 1 addition & 0 deletions nsprpub/pr/tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include $(topsrcdir)/config/config.mk
DIRS = dll

CSRCS = \
abstract.c \
accept.c \
acceptread.c \
acceptreademu.c \
Expand Down
157 changes: 157 additions & 0 deletions nsprpub/pr/tests/abstract.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <stdio.h>

#if defined(LINUX)

#include <string.h>
#include "nspr.h"

static const char abstractSocketName[] = "\0testsocket";

static void
ClientThread(void* aArg)
{
PRFileDesc* socket;
PRNetAddr addr;
PRUint8 buf[1024];
PRInt32 len;
PRInt32 total;

addr.local.family = PR_AF_LOCAL;
memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));

socket = PR_OpenTCPSocket(addr.raw.family);
if (!socket) {
fprintf(stderr, "PR_OpenTCPSokcet failed\n");
exit(1);
}

if (PR_Connect(socket, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE) {
fprintf(stderr, "PR_Connect failed\n");
exit(1);
}

total = 0;
while (total < sizeof(buf)) {
len = PR_Recv(socket, buf + total, sizeof(buf) - total, 0,
PR_INTERVAL_NO_TIMEOUT);
if (len < 1) {
fprintf(stderr, "PR_Recv failed\n");
exit(1);
}
total += len;
}

total = 0;
while (total < sizeof(buf)) {
len = PR_Send(socket, buf + total, sizeof(buf) - total, 0,
PR_INTERVAL_NO_TIMEOUT);
if (len < 1) {
fprintf(stderr, "PR_Send failed\n");
exit(1);
}
total += len;
}

if (PR_Close(socket) == PR_FAILURE) {
fprintf(stderr, "PR_Close failed\n");
exit(1);
}
}

int
main()
{
PRFileDesc* socket;
PRFileDesc* acceptSocket;
PRThread* thread;
PRNetAddr addr;
PRUint8 buf[1024];
PRInt32 len;
PRInt32 total;

addr.local.family = PR_AF_LOCAL;
memcpy(addr.local.path, abstractSocketName, sizeof(abstractSocketName));

socket = PR_OpenTCPSocket(addr.raw.family);
if (!socket) {
fprintf(stderr, "PR_OpenTCPSocket failed\n");
exit(1);
}
if (PR_Bind(socket, &addr) == PR_FAILURE) {
fprintf(stderr, "PR_Bind failed\n");
exit(1);
}

if (PR_Listen(socket, 5) == PR_FAILURE) {
fprintf(stderr, "PR_Listen failed\n");
exit(1);
}

thread = PR_CreateThread(PR_USER_THREAD, ClientThread, 0, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
if (!thread) {
fprintf(stderr, "PR_CreateThread failed");
exit(1);
}

acceptSocket = PR_Accept(socket, NULL, PR_INTERVAL_NO_TIMEOUT);
if (!acceptSocket) {
fprintf(stderr, "PR_Accept failed\n");
exit(1);
}

memset(buf, 'A', sizeof(buf));

total = 0;
while (total < sizeof(buf)) {
len = PR_Send(acceptSocket, buf + total, sizeof(buf) - total, 0,
PR_INTERVAL_NO_TIMEOUT);
if (len < 1) {
fprintf(stderr, "PR_Send failed\n");
exit(1);
}
total += len;
}

total = 0;
while (total < sizeof(buf)) {
len = PR_Recv(acceptSocket, buf + total, sizeof(buf) - total, 0,
PR_INTERVAL_NO_TIMEOUT);
if (len < 1) {
fprintf(stderr, "PR_Recv failed\n");
exit(1);
}
total += len;
}

if (PR_Close(acceptSocket) == PR_FAILURE) {
fprintf(stderr, "PR_Close failed\n");
exit(1);
}

if (PR_JoinThread(thread) == PR_FAILURE) {
fprintf(stderr, "PR_JoinThread failed\n");
exit(1);
}

if (PR_Close(socket) == PR_FAILURE) {
fprintf(stderr, "PR_Close failed\n");
exit(1);
}
printf("PASS\n");
return 0;
}

#else
int
main()
{
prinf("PASS\n");
return 0;
}
#endif
1 change: 1 addition & 0 deletions nsprpub/pr/tests/runtests.pl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ sub win_test_prog {

# MAIN ---------------
@progs = (
"abstract",
"accept",
"acceptread",
"acceptreademu",
Expand Down
1 change: 1 addition & 0 deletions nsprpub/pr/tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ LOGFILE=${NSPR_TEST_LOGFILE:-$NULL_DEVICE}
#

TESTS="
abstract
accept
acceptread
acceptreademu
Expand Down
Loading

0 comments on commit beb57a9

Please sign in to comment.