mirror of
https://github.com/roytam1/mozilla45esr.git
synced 2026-05-26 14:59:19 +00:00
import NSPR-4.19 and NSS-3.36.2(with vc2013 fix)
This commit is contained in:
Vendored
+11
@@ -269,6 +269,7 @@ NSSSMIME_GetVersion
|
||||
NSS_SMIMESignerInfo_SaveSMIMEProfile
|
||||
NSS_SMIMEUtil_FindBulkAlgForRecipients
|
||||
NSSSSL_GetVersion
|
||||
_NSSUTIL_Access
|
||||
NSSUTIL_ArgDecodeNumber
|
||||
NSSUTIL_ArgFetchValue
|
||||
NSSUTIL_ArgGetLabel
|
||||
@@ -290,6 +291,7 @@ NSSUTIL_MkModuleSpec
|
||||
NSSUTIL_MkNSSString
|
||||
NSSUTIL_MkSlotString
|
||||
NSSUTIL_Quote
|
||||
_NSSUTIL_UTF8ToWide
|
||||
PK11_AlgtagToMechanism
|
||||
PK11_Authenticate
|
||||
PK11_ChangePW
|
||||
@@ -440,12 +442,14 @@ PORT_ArenaStrdup_Util
|
||||
PORT_ArenaUnmark_Util
|
||||
PORT_ArenaZAlloc
|
||||
PORT_ArenaZAlloc_Util
|
||||
PORT_DestroyCheapArena
|
||||
PORT_Free
|
||||
PORT_FreeArena
|
||||
PORT_FreeArena_Util
|
||||
PORT_Free_Util
|
||||
PORT_GetError
|
||||
PORT_GetError_Util
|
||||
PORT_InitCheapArena
|
||||
PORT_NewArena
|
||||
PORT_NewArena_Util
|
||||
PORT_Realloc_Util
|
||||
@@ -652,6 +656,7 @@ SSL_HandshakeCallback
|
||||
SSL_HandshakeNegotiatedExtension
|
||||
SSL_ImplementedCiphers DATA
|
||||
SSL_ImportFD
|
||||
SSL_NamedGroupConfig
|
||||
SSL_NumImplementedCiphers DATA
|
||||
SSL_OptionSet
|
||||
SSL_OptionSetDefault
|
||||
@@ -684,3 +689,9 @@ VFY_VerifyDataWithAlgorithmID
|
||||
VFY_VerifyDigestDirect
|
||||
_SGN_VerifyPKCS1DigestInfo
|
||||
__PK11_SetCertificateNickname
|
||||
NSS_SecureMemcmpZero
|
||||
PORT_ZAllocAlignedOffset_Util
|
||||
CERT_FindCertByNicknameOrEmailAddrCX
|
||||
SECKEY_GetPrivateKeyType
|
||||
SEC_DerSignDataWithAlgorithmID
|
||||
SEC_CreateSignatureAlgorithmParameters
|
||||
|
||||
Vendored
+12
@@ -277,6 +277,7 @@ NSSSMIME_GetVersion
|
||||
NSS_SMIMESignerInfo_SaveSMIMEProfile
|
||||
NSS_SMIMEUtil_FindBulkAlgForRecipients
|
||||
NSSSSL_GetVersion
|
||||
_NSSUTIL_Access
|
||||
NSSUTIL_ArgDecodeNumber
|
||||
NSSUTIL_ArgFetchValue
|
||||
NSSUTIL_ArgGetLabel
|
||||
@@ -298,6 +299,7 @@ NSSUTIL_MkModuleSpec
|
||||
NSSUTIL_MkNSSString
|
||||
NSSUTIL_MkSlotString
|
||||
NSSUTIL_Quote
|
||||
_NSSUTIL_UTF8ToWide
|
||||
PK11_AlgtagToMechanism
|
||||
PK11_Authenticate
|
||||
PK11_ChangePW
|
||||
@@ -448,12 +450,14 @@ PORT_ArenaStrdup_Util
|
||||
PORT_ArenaUnmark_Util
|
||||
PORT_ArenaZAlloc
|
||||
PORT_ArenaZAlloc_Util
|
||||
PORT_DestroyCheapArena
|
||||
PORT_Free
|
||||
PORT_FreeArena
|
||||
PORT_FreeArena_Util
|
||||
PORT_Free_Util
|
||||
PORT_GetError
|
||||
PORT_GetError_Util
|
||||
PORT_InitCheapArena
|
||||
PORT_NewArena
|
||||
PORT_NewArena_Util
|
||||
PORT_Realloc_Util
|
||||
@@ -660,6 +664,7 @@ SSL_HandshakeCallback
|
||||
SSL_HandshakeNegotiatedExtension
|
||||
SSL_ImplementedCiphers @DATA@
|
||||
SSL_ImportFD
|
||||
SSL_NamedGroupConfig
|
||||
SSL_NumImplementedCiphers @DATA@
|
||||
SSL_OptionSet
|
||||
SSL_OptionSetDefault
|
||||
@@ -692,6 +697,13 @@ VFY_VerifyDataWithAlgorithmID
|
||||
VFY_VerifyDigestDirect
|
||||
_SGN_VerifyPKCS1DigestInfo
|
||||
__PK11_SetCertificateNickname
|
||||
# These symbols are not used by Firefox but are used across NSS library boundaries.
|
||||
NSS_SecureMemcmpZero
|
||||
PORT_ZAllocAlignedOffset_Util
|
||||
CERT_FindCertByNicknameOrEmailAddrCX
|
||||
SECKEY_GetPrivateKeyType
|
||||
SEC_DerSignDataWithAlgorithmID
|
||||
SEC_CreateSignatureAlgorithmParameters
|
||||
# These symbols are not used by Firefox itself, but are used by Java's security
|
||||
# libraries, which in turn are used by Java applets/plugins/etc. Provide them
|
||||
# to make Java code happy.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
NSPR_4_12_RTM
|
||||
@@ -10,3 +10,4 @@
|
||||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
|
||||
|
||||
Vendored
+54
-10
@@ -2488,7 +2488,7 @@ test -n "$target_alias" &&
|
||||
program_prefix=${target_alias}-
|
||||
|
||||
MOD_MAJOR_VERSION=4
|
||||
MOD_MINOR_VERSION=12
|
||||
MOD_MINOR_VERSION=19
|
||||
MOD_PATCH_VERSION=0
|
||||
NSPR_MODNAME=nspr20
|
||||
_HAVE_PTHREADS=
|
||||
@@ -5424,6 +5424,40 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pragma diagnostic" >&5
|
||||
$as_echo_n "checking for pragma diagnostic... " >&6; }
|
||||
if test "$GNU_CC" = "1"; then
|
||||
cat >dummy-hello.c <<EOF
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
int main() {
|
||||
char *dummy = "";
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
|
||||
if test $? != 0; then
|
||||
${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
|
||||
if test $? = 0; then
|
||||
CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
|
||||
_res=yes
|
||||
else
|
||||
_res=no
|
||||
fi
|
||||
else
|
||||
_res=no
|
||||
fi
|
||||
rm -f dummy-hello.c dummy-hello.s
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_res" >&5
|
||||
$as_echo "$_res" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
_SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
|
||||
|
||||
@@ -6524,6 +6558,15 @@ fi
|
||||
|
||||
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
|
||||
|
||||
|
||||
HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
|
||||
|
||||
if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
|
||||
$as_echo "#define HAS_CONNECTX 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
AS='$(CC) -x assembler-with-cpp'
|
||||
CFLAGS="$CFLAGS -Wall -fno-common"
|
||||
case "${target_cpu}" in
|
||||
@@ -6673,6 +6716,8 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
|
||||
|
||||
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
|
||||
|
||||
CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
|
||||
MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
|
||||
if test "$MOZ_OBJFORMAT" = "elf"; then
|
||||
@@ -6975,6 +7020,8 @@ tools are selected during the Xcode/Developer Tools installation." "$LINENO" 5
|
||||
|
||||
$as_echo "#define HAVE_FCNTL_FILE_LOCKING 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
|
||||
|
||||
case "${target}" in
|
||||
*-android*|*-linuxandroid*)
|
||||
OS_TARGET=Android
|
||||
@@ -7281,6 +7328,8 @@ $as_echo "$as_me: WARNING: Unknown version of the Microsoft (R) Manifest Tool."
|
||||
|
||||
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
|
||||
|
||||
if test -z "$USE_NSPR_THREADS"; then
|
||||
USE_PTHREADS=1
|
||||
fi
|
||||
@@ -7337,6 +7386,8 @@ $as_echo "$as_me: WARNING: Unknown version of the Microsoft (R) Manifest Tool."
|
||||
|
||||
$as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define HAVE_POINTER_LOCALTIME_R 1" >>confdefs.h
|
||||
|
||||
CFLAGS="$CFLAGS -ansi -Wall"
|
||||
CXXFLAGS="$CXXFLAGS -ansi -Wall"
|
||||
DLL_SUFFIX=so.1.0
|
||||
@@ -8423,19 +8474,12 @@ case "$target" in
|
||||
|
||||
fi
|
||||
if test "$USE_PTHREADS"; then
|
||||
if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
|
||||
$as_echo "#define _REENTRANT 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define _PR_DCETHREADS 1" >>confdefs.h
|
||||
|
||||
else
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define _POSIX_C_SOURCE 199506L
|
||||
_ACEOF
|
||||
|
||||
$as_echo "#define _PR_HAVE_THREADSAFE_GETHOST 1" >>confdefs.h
|
||||
$as_echo "#define _PR_HAVE_THREADSAFE_GETHOST 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
fi
|
||||
if test "$USE_USER_PTHREADS"; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
|
||||
+48
-8
@@ -15,7 +15,7 @@ dnl ========================================================
|
||||
dnl = Defaults
|
||||
dnl ========================================================
|
||||
MOD_MAJOR_VERSION=4
|
||||
MOD_MINOR_VERSION=12
|
||||
MOD_MINOR_VERSION=19
|
||||
MOD_PATCH_VERSION=0
|
||||
NSPR_MODNAME=nspr20
|
||||
_HAVE_PTHREADS=
|
||||
@@ -715,6 +715,40 @@ else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl Check for pragma diagnostic
|
||||
dnl ========================================================
|
||||
|
||||
AC_MSG_CHECKING([for pragma diagnostic])
|
||||
if test "$GNU_CC" = "1"; then
|
||||
cat >dummy-hello.c <<EOF
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
int main() {
|
||||
char *dummy = "";
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC} -Werror=unused-but-set-variable -S dummy-hello.c -o dummy-hello.s 2>&5
|
||||
if test $? != 0; then
|
||||
${CC} -Werror=unused-but-set-variable -D_PR_HAS_PRAGMA_DIAGNOSTIC -S dummy-hello.c -o dummy-hello.s 2>&5
|
||||
if test $? = 0; then
|
||||
CFLAGS="$CFLAGS -D_PR_HAS_PRAGMA_DIAGNOSTIC=1"
|
||||
_res=yes
|
||||
else
|
||||
_res=no
|
||||
fi
|
||||
else
|
||||
_res=no
|
||||
fi
|
||||
rm -f dummy-hello.c dummy-hello.s
|
||||
AC_MSG_RESULT([$_res])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
dnl Profile guided optimization
|
||||
dnl ========================================================
|
||||
@@ -1349,6 +1383,13 @@ case "$target" in
|
||||
AC_DEFINE(DARWIN)
|
||||
AC_DEFINE(HAVE_BSD_FLOCK)
|
||||
AC_DEFINE(HAVE_SOCKLEN_T)
|
||||
AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
|
||||
changequote(,)
|
||||
HOST_DARWIN_MAJOR=`echo "$build_os" | sed -E -e 's/^darwin([0-9]+).*$/\1/'`
|
||||
changequote([,])
|
||||
if test "$HOST_DARWIN_MAJOR" -ge 15 ; then
|
||||
AC_DEFINE(HAS_CONNECTX)
|
||||
fi
|
||||
AS='$(CC) -x assembler-with-cpp'
|
||||
CFLAGS="$CFLAGS -Wall -fno-common"
|
||||
case "${target_cpu}" in
|
||||
@@ -1519,6 +1560,7 @@ tools are selected during the Xcode/Developer Tools installation.])
|
||||
AC_DEFINE(FREEBSD)
|
||||
AC_DEFINE(HAVE_BSD_FLOCK)
|
||||
AC_DEFINE(HAVE_SOCKLEN_T)
|
||||
AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
|
||||
CFLAGS="$CFLAGS $(DSO_CFLAGS) -ansi -Wall"
|
||||
MOZ_OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
|
||||
if test "$MOZ_OBJFORMAT" = "elf"; then
|
||||
@@ -1789,6 +1831,7 @@ tools are selected during the Xcode/Developer Tools installation.])
|
||||
AC_DEFINE(XP_UNIX)
|
||||
AC_DEFINE(_GNU_SOURCE)
|
||||
AC_DEFINE(HAVE_FCNTL_FILE_LOCKING)
|
||||
AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
|
||||
case "${target}" in
|
||||
*-android*|*-linuxandroid*)
|
||||
OS_TARGET=Android
|
||||
@@ -2078,6 +2121,7 @@ tools are selected during the Xcode/Developer Tools installation.])
|
||||
AC_DEFINE(NETBSD)
|
||||
AC_DEFINE(HAVE_BSD_FLOCK)
|
||||
AC_DEFINE(HAVE_SOCKLEN_T)
|
||||
AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
|
||||
if test -z "$USE_NSPR_THREADS"; then
|
||||
USE_PTHREADS=1
|
||||
fi
|
||||
@@ -2126,6 +2170,7 @@ tools are selected during the Xcode/Developer Tools installation.])
|
||||
AC_DEFINE(OPENBSD)
|
||||
AC_DEFINE(HAVE_BSD_FLOCK)
|
||||
AC_DEFINE(HAVE_SOCKLEN_T)
|
||||
AC_DEFINE(HAVE_POINTER_LOCALTIME_R)
|
||||
CFLAGS="$CFLAGS -ansi -Wall"
|
||||
CXXFLAGS="$CXXFLAGS -ansi -Wall"
|
||||
DLL_SUFFIX=so.1.0
|
||||
@@ -2844,13 +2889,8 @@ case "$target" in
|
||||
AC_DEFINE(_PR_LOCAL_THREADS_ONLY)
|
||||
fi
|
||||
if test "$USE_PTHREADS"; then
|
||||
if echo "$OS_RELEASE" | egrep '^(B.10.10|B.10.20)' >/dev/null; then
|
||||
AC_DEFINE(_REENTRANT)
|
||||
AC_DEFINE(_PR_DCETHREADS)
|
||||
else
|
||||
AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
|
||||
AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
|
||||
AC_DEFINE(_PR_HAVE_THREADSAFE_GETHOST)
|
||||
fi
|
||||
if test "$USE_USER_PTHREADS"; then
|
||||
AC_DEFINE_UNQUOTED(_POSIX_C_SOURCE,199506L)
|
||||
|
||||
+17
-135
@@ -17,8 +17,6 @@
|
||||
#include "prlock.h"
|
||||
#include "prinit.h"
|
||||
|
||||
static PLArena *arena_freelist;
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
static PLArenaStats *arena_stats_list;
|
||||
|
||||
@@ -29,49 +27,6 @@ static PLArenaStats *arena_stats_list;
|
||||
|
||||
#define PL_ARENA_DEFAULT_ALIGN sizeof(double)
|
||||
|
||||
static PRLock *arenaLock;
|
||||
static PRCallOnceType once;
|
||||
static const PRCallOnceType pristineCallOnce;
|
||||
|
||||
/*
|
||||
** InitializeArenas() -- Initialize arena operations.
|
||||
**
|
||||
** InitializeArenas() is called exactly once and only once from
|
||||
** LockArena(). This function creates the arena protection
|
||||
** lock: arenaLock.
|
||||
**
|
||||
** Note: If the arenaLock cannot be created, InitializeArenas()
|
||||
** fails quietly, returning only PR_FAILURE. This percolates up
|
||||
** to the application using the Arena API. He gets no arena
|
||||
** from PL_ArenaAllocate(). It's up to him to fail gracefully
|
||||
** or recover.
|
||||
**
|
||||
*/
|
||||
static PRStatus InitializeArenas( void )
|
||||
{
|
||||
PR_ASSERT( arenaLock == NULL );
|
||||
arenaLock = PR_NewLock();
|
||||
if ( arenaLock == NULL )
|
||||
return PR_FAILURE;
|
||||
else
|
||||
return PR_SUCCESS;
|
||||
} /* end ArenaInitialize() */
|
||||
|
||||
static PRStatus LockArena( void )
|
||||
{
|
||||
PRStatus rc = PR_CallOnce( &once, InitializeArenas );
|
||||
|
||||
if ( PR_FAILURE != rc )
|
||||
PR_Lock( arenaLock );
|
||||
return(rc);
|
||||
} /* end LockArena() */
|
||||
|
||||
static void UnlockArena( void )
|
||||
{
|
||||
PR_Unlock( arenaLock );
|
||||
return;
|
||||
} /* end UnlockArena() */
|
||||
|
||||
PR_IMPLEMENT(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
|
||||
{
|
||||
@@ -124,14 +79,7 @@ PR_IMPLEMENT(void) PL_InitArenaPool(
|
||||
** pool.
|
||||
**
|
||||
** First, try to satisfy the request from arenas starting at
|
||||
** pool->current.
|
||||
**
|
||||
** If there is not enough space in the arena pool->current, try
|
||||
** to claim an arena, on a first fit basis, from the global
|
||||
** freelist (arena_freelist).
|
||||
**
|
||||
** If no arena in arena_freelist is suitable, then try to
|
||||
** allocate a new arena from the heap.
|
||||
** pool->current. Then try to allocate a new arena from the heap.
|
||||
**
|
||||
** Returns: pointer to allocated space or NULL
|
||||
**
|
||||
@@ -169,37 +117,6 @@ PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
|
||||
} while( NULL != (a = a->next) );
|
||||
}
|
||||
|
||||
/* attempt to allocate from arena_freelist */
|
||||
{
|
||||
PLArena *p; /* previous pointer, for unlinking from freelist */
|
||||
|
||||
/* lock the arena_freelist. Make access to the freelist MT-Safe */
|
||||
if ( PR_FAILURE == LockArena())
|
||||
return(0);
|
||||
|
||||
for ( a = arena_freelist, p = NULL; a != NULL ; p = a, a = a->next ) {
|
||||
if ( nb <= a->limit - a->base ) {
|
||||
if ( p == NULL )
|
||||
arena_freelist = a->next;
|
||||
else
|
||||
p->next = a->next;
|
||||
UnlockArena();
|
||||
a->avail = a->base;
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
/* the newly allocated arena is linked after pool->current
|
||||
* and becomes pool->current */
|
||||
a->next = pool->current->next;
|
||||
pool->current->next = a;
|
||||
pool->current = a;
|
||||
if ( NULL == pool->first.next )
|
||||
pool->first.next = a;
|
||||
return(rp);
|
||||
}
|
||||
}
|
||||
UnlockArena();
|
||||
}
|
||||
|
||||
/* attempt to allocate from the heap */
|
||||
{
|
||||
PRUint32 sz = PR_MAX(pool->arenasize, nb);
|
||||
@@ -246,10 +163,11 @@ PR_IMPLEMENT(void *) PL_ArenaGrow(
|
||||
return newp;
|
||||
}
|
||||
|
||||
static void ClearArenaList(PLArena *a, PRInt32 pattern)
|
||||
PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
|
||||
{
|
||||
PLArena *a;
|
||||
|
||||
for (; a; a = a->next) {
|
||||
for (a = pool->first.next; a; a = a->next) {
|
||||
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
|
||||
a->avail = a->base;
|
||||
PL_CLEAR_UNUSED_PATTERN(a, pattern);
|
||||
@@ -257,48 +175,25 @@ static void ClearArenaList(PLArena *a, PRInt32 pattern)
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern)
|
||||
{
|
||||
ClearArenaList(pool->first.next, pattern);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free tail arenas linked after head, which may not be the true list head.
|
||||
* Reset pool->current to point to head in case it pointed at a tail arena.
|
||||
*/
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head)
|
||||
{
|
||||
PLArena **ap, *a;
|
||||
|
||||
ap = &head->next;
|
||||
a = *ap;
|
||||
PLArena *a = head->next;
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
ClearArenaList(a, PL_FREE_PATTERN);
|
||||
#endif
|
||||
head->next = NULL;
|
||||
|
||||
if (reallyFree) {
|
||||
do {
|
||||
*ap = a->next;
|
||||
PL_CLEAR_ARENA(a);
|
||||
PL_COUNT_ARENA(pool,--);
|
||||
PR_DELETE(a);
|
||||
} while ((a = *ap) != 0);
|
||||
} else {
|
||||
/* Insert the whole arena chain at the front of the freelist. */
|
||||
do {
|
||||
PL_MAKE_MEM_NOACCESS((void*)(*ap)->base,
|
||||
(*ap)->limit - (*ap)->base);
|
||||
ap = &(*ap)->next;
|
||||
} while (*ap);
|
||||
LockArena();
|
||||
*ap = arena_freelist;
|
||||
arena_freelist = a;
|
||||
head->next = 0;
|
||||
UnlockArena();
|
||||
}
|
||||
do {
|
||||
PLArena *tmp = a;
|
||||
a = a->next;
|
||||
PL_CLEAR_ARENA(tmp);
|
||||
PL_COUNT_ARENA(pool,--);
|
||||
PR_DELETE(tmp);
|
||||
} while (a);
|
||||
|
||||
pool->current = head;
|
||||
}
|
||||
@@ -310,7 +205,7 @@ PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
||||
for (a = &pool->first; a; a = a->next) {
|
||||
if (PR_UPTRDIFF(mark, a->base) <= PR_UPTRDIFF(a->avail, a->base)) {
|
||||
a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
|
||||
FreeArenaList(pool, a, PR_FALSE);
|
||||
FreeArenaList(pool, a);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -318,13 +213,13 @@ PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
||||
|
||||
PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_FALSE);
|
||||
FreeArenaList(pool, &pool->first);
|
||||
COUNT(pool, ndeallocs);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_TRUE);
|
||||
FreeArenaList(pool, &pool->first);
|
||||
#ifdef PL_ARENAMETER
|
||||
{
|
||||
PLArenaStats *stats, **statsp;
|
||||
@@ -348,19 +243,6 @@ PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap)
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaFinish(void)
|
||||
{
|
||||
PLArena *a, *next;
|
||||
|
||||
for (a = arena_freelist; a; a = next) {
|
||||
next = a->next;
|
||||
PR_DELETE(a);
|
||||
}
|
||||
arena_freelist = NULL;
|
||||
|
||||
if (arenaLock) {
|
||||
PR_DestroyLock(arenaLock);
|
||||
arenaLock = NULL;
|
||||
}
|
||||
once = pristineCallOnce;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
|
||||
*/
|
||||
#include "prtypes.h"
|
||||
#include "plarenas.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
@@ -47,6 +46,8 @@ struct PLArenaStats {
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
struct PLArenaPool {
|
||||
PLArena first; /* first arena in pool list */
|
||||
PLArena *current; /* arena from which to allocate space */
|
||||
@@ -225,6 +226,74 @@ PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t
|
||||
(a) = 0; \
|
||||
PR_END_MACRO
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum gross size per arena of size bytes. The net size per arena
|
||||
** is smaller than the gross size by a header of four pointers plus any
|
||||
** necessary padding for alignment.
|
||||
**
|
||||
** Note: choose a gross size that's a power of two to avoid the heap allocator
|
||||
** rounding the size up.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
** NOTE: this function is now a no-op. If you want to free a single
|
||||
** PLArenaPoolUse use PL_FreeArenaPool() or PL_FinishArenaPool().
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
** NOT IMPLEMENTED. Do not use.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**
|
||||
** WARNING: do not call these functions directly. Always use the
|
||||
** PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
** memset contents of all arenas in pool to pattern
|
||||
*/
|
||||
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
|
||||
|
||||
/*
|
||||
** A function like malloc_size() or malloc_usable_size() that measures the
|
||||
** size of a heap block.
|
||||
*/
|
||||
typedef size_t (*PLMallocSizeFn)(const void *ptr);
|
||||
|
||||
/*
|
||||
** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
|
||||
** structure.
|
||||
*/
|
||||
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -3,79 +3,10 @@
|
||||
* 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/. */
|
||||
|
||||
#ifndef PLARENAS_H
|
||||
#define PLARENAS_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum gross size per arena of size bytes. The net size per arena
|
||||
** is smaller than the gross size by a header of four pointers plus any
|
||||
** necessary padding for alignment.
|
||||
**
|
||||
** Note: choose a gross size that's a power of two to avoid the heap allocator
|
||||
** rounding the size up.
|
||||
** PLArena-related declarations used to be split between plarenas.h and
|
||||
** plarena.h. That split wasn't useful, so now all the declarations are in
|
||||
** plarena.h. However, this file still exists so that any old code that
|
||||
** includes it will still work.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
** NOT IMPLEMENTED. Do not use.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**
|
||||
** WARNING: do not call these functions directly. Always use the
|
||||
** PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
/*
|
||||
** memset contents of all arenas in pool to pattern
|
||||
*/
|
||||
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
|
||||
|
||||
/*
|
||||
** A function like malloc_size() or malloc_usable_size() that measures the
|
||||
** size of a heap block.
|
||||
*/
|
||||
typedef size_t (*PLMallocSizeFn)(const void *ptr);
|
||||
|
||||
/*
|
||||
** Measure all memory used by a PLArenaPool, excluding the PLArenaPool
|
||||
** structure.
|
||||
*/
|
||||
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
|
||||
const PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* PLARENAS_H */
|
||||
#include "plarena.h"
|
||||
|
||||
@@ -74,6 +74,10 @@ static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
@@ -88,6 +92,9 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
@@ -88,6 +92,9 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
|
||||
@@ -48,8 +48,10 @@ PL_strcasecmp(const char *a, const char *b)
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
@@ -67,8 +69,10 @@ PL_strncasecmp(const char *a, const char *b, PRUint32 max)
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strcmp(a, b);
|
||||
}
|
||||
@@ -18,8 +20,10 @@ PL_strcmp(const char *a, const char *b)
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
if( (const char *)0 == a )
|
||||
return ((const char *)0 == b) ? 0 : -1;
|
||||
if( (const char *)0 == b )
|
||||
return 1;
|
||||
|
||||
return (PRIntn)strncmp(a, b, (size_t)max);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
@@ -88,6 +92,9 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
|
||||
@@ -498,6 +498,9 @@
|
||||
|
||||
#elif defined(__mips__)
|
||||
|
||||
/* For _ABI64 */
|
||||
#include <sgidefs.h>
|
||||
|
||||
#ifdef __MIPSEB__
|
||||
#define IS_BIG_ENDIAN 1
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
|
||||
@@ -14,29 +14,7 @@
|
||||
#define _PR_MD_DISABLE_CLOCK_INTERRUPTS()
|
||||
#define _PR_MD_ENABLE_CLOCK_INTERRUPTS()
|
||||
|
||||
/* In good standards fashion, the DCE threads (based on posix-4) are not
|
||||
* quite the same as newer posix implementations. These are mostly name
|
||||
* changes and small differences, so macros usually do the trick
|
||||
*/
|
||||
#ifdef _PR_DCETHREADS
|
||||
#define _PT_PTHREAD_MUTEXATTR_INIT pthread_mutexattr_create
|
||||
#define _PT_PTHREAD_MUTEXATTR_DESTROY pthread_mutexattr_delete
|
||||
#define _PT_PTHREAD_MUTEX_INIT(m, a) pthread_mutex_init(&(m), a)
|
||||
#define _PT_PTHREAD_MUTEX_IS_LOCKED(m) (0 == pthread_mutex_trylock(&(m)))
|
||||
#define _PT_PTHREAD_CONDATTR_INIT pthread_condattr_create
|
||||
#define _PT_PTHREAD_COND_INIT(m, a) pthread_cond_init(&(m), a)
|
||||
#define _PT_PTHREAD_CONDATTR_DESTROY pthread_condattr_delete
|
||||
|
||||
/* Notes about differences between DCE threads and pthreads 10:
|
||||
* 1. pthread_mutex_trylock returns 1 when it locks the mutex
|
||||
* 0 when it does not. The latest pthreads has a set of errno-like
|
||||
* return values.
|
||||
* 2. return values from pthread_cond_timedwait are different.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#elif defined(BSDI)
|
||||
#if defined(BSDI)
|
||||
/*
|
||||
* Mutex and condition attributes are not supported. The attr
|
||||
* argument to pthread_mutex_init() and pthread_cond_init() must
|
||||
@@ -106,13 +84,7 @@
|
||||
* PR_EnterMonitor calls any of these functions, infinite
|
||||
* recursion ensues.
|
||||
*/
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define _PT_PTHREAD_INVALIDATE_THR_HANDLE(t) \
|
||||
memset(&(t), 0, sizeof(pthread_t))
|
||||
#define _PT_PTHREAD_THR_HANDLE_IS_INVALID(t) \
|
||||
(!memcmp(&(t), &pt_zero_tid, sizeof(pthread_t)))
|
||||
#define _PT_PTHREAD_COPY_THR_HANDLE(st, dt) (dt) = (st)
|
||||
#elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
|
||||
#if defined(IRIX) || defined(OSF1) || defined(AIX) || defined(SOLARIS) \
|
||||
|| defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
|
||||
|| defined(HPUX) || defined(FREEBSD) \
|
||||
|| defined(NETBSD) || defined(OPENBSD) || defined(BSDI) \
|
||||
@@ -125,17 +97,7 @@
|
||||
#error "pthreads is not supported for this architecture"
|
||||
#endif
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define _PT_PTHREAD_ATTR_INIT pthread_attr_create
|
||||
#define _PT_PTHREAD_ATTR_DESTROY pthread_attr_delete
|
||||
#define _PT_PTHREAD_CREATE(t, a, f, r) pthread_create(t, a, f, r)
|
||||
#define _PT_PTHREAD_KEY_CREATE pthread_keycreate
|
||||
#define _PT_PTHREAD_ATTR_SETSCHEDPOLICY pthread_attr_setsched
|
||||
#define _PT_PTHREAD_ATTR_GETSTACKSIZE(a, s) \
|
||||
(*(s) = pthread_attr_getstacksize(*(a)), 0)
|
||||
#define _PT_PTHREAD_GETSPECIFIC(k, r) \
|
||||
pthread_getspecific((k), (pthread_addr_t *) &(r))
|
||||
#elif defined(_PR_PTHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#define _PT_PTHREAD_ATTR_INIT pthread_attr_init
|
||||
#define _PT_PTHREAD_ATTR_DESTROY pthread_attr_destroy
|
||||
#define _PT_PTHREAD_CREATE(t, a, f, r) pthread_create(t, &a, f, r)
|
||||
@@ -147,22 +109,6 @@
|
||||
#error "Cannot determine pthread strategy"
|
||||
#endif
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define _PT_PTHREAD_EXPLICIT_SCHED _PT_PTHREAD_DEFAULT_SCHED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pthread_mutex_trylock returns different values in DCE threads and
|
||||
* pthreads.
|
||||
*/
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define PT_TRYLOCK_SUCCESS 1
|
||||
#define PT_TRYLOCK_BUSY 0
|
||||
#else
|
||||
#define PT_TRYLOCK_SUCCESS 0
|
||||
#define PT_TRYLOCK_BUSY EBUSY
|
||||
#endif
|
||||
|
||||
/*
|
||||
* These platforms don't have sigtimedwait()
|
||||
*/
|
||||
@@ -190,16 +136,9 @@
|
||||
#define PT_PRIO_MIN DEFAULT_PRIO
|
||||
#define PT_PRIO_MAX DEFAULT_PRIO
|
||||
#elif defined(HPUX)
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define PT_PRIO_MIN PRI_OTHER_MIN
|
||||
#define PT_PRIO_MAX PRI_OTHER_MAX
|
||||
#else /* defined(_PR_DCETHREADS) */
|
||||
#include <sys/sched.h>
|
||||
#define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER)
|
||||
#define PT_PRIO_MAX sched_get_priority_max(SCHED_OTHER)
|
||||
#endif /* defined(_PR_DCETHREADS) */
|
||||
|
||||
#elif defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) \
|
||||
|| defined(FREEBSD) || defined(SYMBIAN)
|
||||
#define PT_PRIO_MIN sched_get_priority_min(SCHED_OTHER)
|
||||
@@ -238,9 +177,7 @@
|
||||
* Needed for garbage collection -- Look at PR_Suspend/PR_Resume
|
||||
* implementation.
|
||||
*/
|
||||
#if defined(_PR_DCETHREADS)
|
||||
#define _PT_PTHREAD_YIELD() pthread_yield()
|
||||
#elif defined(OSF1)
|
||||
#if defined(OSF1)
|
||||
/*
|
||||
* sched_yield can't be called from a signal handler. Must use
|
||||
* the _np version.
|
||||
|
||||
@@ -290,6 +290,9 @@ extern void _MD_MakeNonblock(PRFileDesc *f);
|
||||
extern PRInt32 _MD_CloseSocket(PROsfd osfd);
|
||||
#define _MD_CLOSE_SOCKET _MD_CloseSocket
|
||||
#define _MD_SENDTO _PR_MD_SENDTO
|
||||
#ifdef _WIN64
|
||||
#define _MD_TCPSENDTO _PR_MD_TCPSENDTO
|
||||
#endif
|
||||
#define _MD_RECVFROM _PR_MD_RECVFROM
|
||||
#define _MD_SOCKETPAIR(s, type, proto, sv) -1
|
||||
#define _MD_GETSOCKNAME _PR_MD_GETSOCKNAME
|
||||
|
||||
@@ -54,7 +54,7 @@ struct sockaddr_dl;
|
||||
#endif /* XP_UNIX */
|
||||
#include <netdb.h>
|
||||
|
||||
#if defined(FREEBSD) || defined(BSDI) || defined(QNX)
|
||||
#if defined(BSDI) || defined(QNX)
|
||||
#include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ PR_BEGIN_EXTERN_C
|
||||
** The format of the version string is
|
||||
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
|
||||
*/
|
||||
#define PR_VERSION "4.12"
|
||||
#define PR_VERSION "4.19"
|
||||
#define PR_VMAJOR 4
|
||||
#define PR_VMINOR 12
|
||||
#define PR_VMINOR 19
|
||||
#define PR_VPATCH 0
|
||||
#define PR_BETA PR_FALSE
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ union PRNetAddr {
|
||||
PRIPv6Addr ip; /* the actual 128 bits of address */
|
||||
PRUint32 scope_id; /* set of interfaces for a scope */
|
||||
} ipv6;
|
||||
#if defined(XP_UNIX) || defined(XP_OS2)
|
||||
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN)
|
||||
struct { /* Unix domain socket address */
|
||||
PRUint16 family; /* address family (AF_UNIX) */
|
||||
#ifdef XP_OS2
|
||||
@@ -196,8 +196,8 @@ typedef enum PRSockOption
|
||||
PR_SockOpt_Linger, /* linger on close if data present */
|
||||
PR_SockOpt_Reuseaddr, /* allow local address reuse */
|
||||
PR_SockOpt_Keepalive, /* keep connections alive */
|
||||
PR_SockOpt_RecvBufferSize, /* send buffer size */
|
||||
PR_SockOpt_SendBufferSize, /* receive buffer size */
|
||||
PR_SockOpt_RecvBufferSize, /* receive buffer size */
|
||||
PR_SockOpt_SendBufferSize, /* send buffer size */
|
||||
|
||||
PR_SockOpt_IpTimeToLive, /* time to live */
|
||||
PR_SockOpt_IpTypeOfService, /* type of service and precedence */
|
||||
|
||||
@@ -6,14 +6,6 @@
|
||||
#ifndef primpl_h___
|
||||
#define primpl_h___
|
||||
|
||||
/*
|
||||
* HP-UX 10.10's pthread.h (DCE threads) includes dce/cma.h, which
|
||||
* has:
|
||||
* #define sigaction _sigaction_sys
|
||||
* This macro causes chaos if signal.h gets included before pthread.h.
|
||||
* To be safe, we include pthread.h first.
|
||||
*/
|
||||
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
@@ -1225,6 +1217,13 @@ extern PRInt32 _PR_MD_SENDTO(
|
||||
const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
|
||||
#define _PR_MD_SENDTO _MD_SENDTO
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
extern PRInt32 _PR_MD_TCPSENDTO(
|
||||
PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
|
||||
const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
|
||||
#define _PR_MD_TCPSENDTO _MD_TCPSENDTO
|
||||
#endif
|
||||
|
||||
extern PRInt32 _PR_MD_SOCKETPAIR(int af, int type, int flags, PROsfd *osfd);
|
||||
#define _PR_MD_SOCKETPAIR _MD_SOCKETPAIR
|
||||
|
||||
@@ -1747,6 +1746,18 @@ struct PRFilePrivate {
|
||||
* requires knowing the address family of the
|
||||
* socket, we save the address family here. */
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
/* This is necessary for TCP Fast Open. TCP Fast Open in windows must
|
||||
* use ConnectEx function which uses OVERLAPPED. TCPSendTo will call
|
||||
* ConnectEx to send fast open data. If ConnectEx returns
|
||||
* ERROR_IO_PENDING we need to save OVERLAPPED structure and we will
|
||||
* use it in ConnectContinue to get the final result of ConnectEx.
|
||||
*/
|
||||
PRBool alreadyConnected;
|
||||
PRBool overlappedActive;
|
||||
OVERLAPPED ol;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef _WIN64
|
||||
@@ -1858,7 +1869,7 @@ extern PRFileDesc *_pr_stderr;
|
||||
** and functions with macros that expand to the native thread
|
||||
** types and functions on each platform.
|
||||
*/
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#define _PR_ZONE_ALLOCATOR
|
||||
#endif
|
||||
|
||||
@@ -2146,6 +2157,18 @@ extern PRUint32 connectCount;
|
||||
|
||||
#endif /* XP_BEOS */
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
typedef struct _PRFileDescList {
|
||||
PRFileDesc *fd;
|
||||
struct _PRFileDescList *next;
|
||||
} PRFileDescList;
|
||||
|
||||
extern PRLock *_fd_waiting_for_overlapped_done_lock;
|
||||
extern PRFileDescList *_fd_waiting_for_overlapped_done;
|
||||
extern void CheckOverlappedPendingSocketsAreDone();
|
||||
#endif
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* primpl_h___ */
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
** A locking mechanism, built on the existing PRLock definiion,
|
||||
** A locking mechanism, built on the existing PRLock definition,
|
||||
** is provided that will permit applications to define a Lock
|
||||
** Hierarchy (or Lock Ordering) schema. An application designed
|
||||
** using the Ordered Lock functions will terminate with a
|
||||
** diagnostic message when a lock inversion condition is
|
||||
** detected.
|
||||
**
|
||||
** The lock ordering detection is complile-time enabled only. in
|
||||
** The lock ordering detection is compile-time enabled only. In
|
||||
** optimized builds of NSPR, the Ordered Lock functions map
|
||||
** directly to PRLock functions, providing no lock order
|
||||
** detection.
|
||||
**
|
||||
** The Ordered Lock Facility is compiled in when DEBUG is defined at
|
||||
** compile time. Ordered Lock can be forced on in optimized builds by
|
||||
** defining FORCE_NSPR_ORDERED_LOCK at compile time. Both the
|
||||
** compile-time. Ordered Lock can be forced on in optimized builds by
|
||||
** defining FORCE_NSPR_ORDERED_LOCK at compile-time. Both the
|
||||
** application using Ordered Lock and NSPR must be compiled with the
|
||||
** facility enabled to achieve the desired results.
|
||||
**
|
||||
|
||||
@@ -231,7 +231,7 @@ PR_BEGIN_EXTERN_C
|
||||
** to use <stdint.h>. A patch to do that is in NSPR bug 634793.
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
|
||||
#if defined(__APPLE__) || defined(__OpenBSD__)
|
||||
#define PR_ALTERNATE_INT64_TYPEDEF
|
||||
#endif
|
||||
|
||||
@@ -245,16 +245,24 @@ PR_BEGIN_EXTERN_C
|
||||
#if PR_BYTES_PER_BYTE == 1
|
||||
typedef unsigned char PRUint8;
|
||||
/*
|
||||
** There are two scenarios that require us to define PRInt8 as type 'char'.
|
||||
** (1)
|
||||
** Some cfront-based C++ compilers do not like 'signed char' and
|
||||
** issue the warning message:
|
||||
** warning: "signed" not implemented (ignored)
|
||||
** For these compilers, we have to define PRInt8 as plain 'char'.
|
||||
** Make sure that plain 'char' is indeed signed under these compilers.
|
||||
** (2)
|
||||
** Mozilla C++ code expects the PRInt{N} and int{N}_t types to match (see bug
|
||||
** 634793). If a platform defines int8_t as 'char', but NSPR defines it as
|
||||
** 'signed char', it results in a type mismatch.
|
||||
** On such platforms we define PRInt8 as 'char' to avoid the mismatch.
|
||||
*/
|
||||
#if (defined(HPUX) && defined(__cplusplus) \
|
||||
#if (defined(HPUX) && defined(__cplusplus) /* reason 1*/ \
|
||||
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|
||||
|| (defined(SCO) && defined(__cplusplus) \
|
||||
&& !defined(__GNUC__) && __cplusplus == 1L)
|
||||
|| (defined(SCO) && defined(__cplusplus) /* reason 1 */ \
|
||||
&& !defined(__GNUC__) && __cplusplus == 1L) \
|
||||
|| (defined(__sun) && defined(__cplusplus)) /* reason 2 */
|
||||
typedef char PRInt8;
|
||||
#else
|
||||
typedef signed char PRInt8;
|
||||
|
||||
@@ -138,12 +138,8 @@ endif
|
||||
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
ifeq ($(USE_PTHREADS), 1)
|
||||
ifeq (,$(filter-out B.10.10 B.10.20,$(OS_RELEASE)))
|
||||
OS_LIBS = -ldce
|
||||
else
|
||||
OS_LIBS = -lpthread -lrt
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PTHREADS_USER), 1)
|
||||
OS_LIBS = -lpthread
|
||||
endif
|
||||
|
||||
@@ -119,6 +119,10 @@ PR_IMPLEMENT(PRFileDesc*) PR_AllocFileDesc(
|
||||
fd->methods = methods;
|
||||
fd->secret->state = _PR_FILEDESC_OPEN;
|
||||
fd->secret->md.osfd = osfd;
|
||||
#if defined(_WIN64)
|
||||
fd->secret->alreadyConnected = PR_FALSE;
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
#endif
|
||||
_PR_MD_INIT_FILEDESC(fd);
|
||||
} else {
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
@@ -133,11 +137,82 @@ PR_IMPLEMENT(void) PR_FreeFileDesc(PRFileDesc *fd)
|
||||
_PR_Putfd(fd);
|
||||
}
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
|
||||
PRFileDescList *_fd_waiting_for_overlapped_done = NULL;
|
||||
PRLock *_fd_waiting_for_overlapped_done_lock = NULL;
|
||||
|
||||
void CheckOverlappedPendingSocketsAreDone()
|
||||
{
|
||||
if (!_fd_waiting_for_overlapped_done_lock ||
|
||||
!_fd_waiting_for_overlapped_done) {
|
||||
return;
|
||||
}
|
||||
|
||||
PR_Lock(_fd_waiting_for_overlapped_done_lock);
|
||||
|
||||
PRFileDescList *cur = _fd_waiting_for_overlapped_done;
|
||||
PRFileDescList *previous = NULL;
|
||||
while (cur) {
|
||||
PR_ASSERT(cur->fd->secret->overlappedActive);
|
||||
PRFileDesc *fd = cur->fd;
|
||||
DWORD rvSent;
|
||||
if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) {
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("CheckOverlappedPendingSocketsAreDone GetOverlappedResult succeeded\n"));
|
||||
} else {
|
||||
DWORD err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("CheckOverlappedPendingSocketsAreDone GetOverlappedResult failed %d\n", err));
|
||||
if (err != ERROR_IO_INCOMPLETE) {
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fd->secret->overlappedActive) {
|
||||
|
||||
_PR_MD_CLOSE_SOCKET(fd->secret->md.osfd);
|
||||
fd->secret->state = _PR_FILEDESC_CLOSED;
|
||||
#ifdef _PR_HAVE_PEEK_BUFFER
|
||||
if (fd->secret->peekBuffer) {
|
||||
PR_ASSERT(fd->secret->peekBufSize > 0);
|
||||
PR_DELETE(fd->secret->peekBuffer);
|
||||
fd->secret->peekBufSize = 0;
|
||||
fd->secret->peekBytes = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_FreeFileDesc(fd);
|
||||
|
||||
if (previous) {
|
||||
previous->next = cur->next;
|
||||
} else {
|
||||
_fd_waiting_for_overlapped_done = cur->next;
|
||||
}
|
||||
PRFileDescList *del = cur;
|
||||
cur = cur->next;
|
||||
PR_Free(del);
|
||||
} else {
|
||||
previous = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(_fd_waiting_for_overlapped_done_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Wait for some i/o to finish on one or more more poll descriptors.
|
||||
*/
|
||||
PR_IMPLEMENT(PRInt32) PR_Poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
|
||||
{
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
// For each iteration check if TFO overlapped IOs are down.
|
||||
CheckOverlappedPendingSocketsAreDone();
|
||||
#endif
|
||||
|
||||
return(_PR_MD_PR_POLL(pds, npds, timeout));
|
||||
}
|
||||
|
||||
|
||||
+38
-32
@@ -47,7 +47,8 @@ static PRStatus PR_CALLBACK pl_TopClose (PRFileDesc *fd)
|
||||
rv = fd->lower->methods->close(fd->lower);
|
||||
_PR_DestroyIOLayer(fd);
|
||||
return rv;
|
||||
} else if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {
|
||||
}
|
||||
if ((fd->higher) && (PR_IO_LAYER_HEAD == fd->higher->identity)) {
|
||||
/*
|
||||
* lower layers of new style stack
|
||||
*/
|
||||
@@ -201,16 +202,16 @@ static PRFileDesc* PR_CALLBACK pl_TopAccept (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (newstyle_stack) {
|
||||
newstack->lower = newfd;
|
||||
newfd->higher = newstack;
|
||||
return newstack;
|
||||
} else {
|
||||
/* this PR_PushIOLayer call cannot fail */
|
||||
rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);
|
||||
PR_ASSERT(PR_SUCCESS == rv);
|
||||
return newfd; /* that's it */
|
||||
}
|
||||
if (newstyle_stack)
|
||||
{
|
||||
newstack->lower = newfd;
|
||||
newfd->higher = newstack;
|
||||
return newstack;
|
||||
}
|
||||
/* this PR_PushIOLayer call cannot fail */
|
||||
rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack);
|
||||
PR_ASSERT(PR_SUCCESS == rv);
|
||||
return newfd; /* that's it */
|
||||
}
|
||||
|
||||
static PRStatus PR_CALLBACK pl_DefBind (PRFileDesc *fd, const PRNetAddr *addr)
|
||||
@@ -326,12 +327,11 @@ static PRInt32 PR_CALLBACK pl_DefAcceptread (
|
||||
(*nd)->higher = newstack;
|
||||
*nd = newstack;
|
||||
return nbytes;
|
||||
} else {
|
||||
/* this PR_PushIOLayer call cannot fail */
|
||||
rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);
|
||||
PR_ASSERT(PR_SUCCESS == rv);
|
||||
return nbytes;
|
||||
}
|
||||
/* this PR_PushIOLayer call cannot fail */
|
||||
rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack);
|
||||
PR_ASSERT(PR_SUCCESS == rv);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
static PRInt32 PR_CALLBACK pl_DefTransmitfile (
|
||||
@@ -494,10 +494,9 @@ static PRStatus _PR_DestroyIOLayer(PRFileDesc *stack)
|
||||
{
|
||||
if (NULL == stack)
|
||||
return PR_FAILURE;
|
||||
else {
|
||||
PR_DELETE(stack);
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
PR_DELETE(stack);
|
||||
return PR_SUCCESS;
|
||||
} /* _PR_DestroyIOLayer */
|
||||
|
||||
PR_IMPLEMENT(PRStatus) PR_PushIOLayer(
|
||||
@@ -652,9 +651,11 @@ retry:
|
||||
if ((NULL != names) && (identity < length))
|
||||
{
|
||||
/* what we did is still okay */
|
||||
memcpy(
|
||||
names, identity_cache.name,
|
||||
identity_cache.length * sizeof(char*));
|
||||
if (identity_cache.length != 0) {
|
||||
memcpy(
|
||||
names, identity_cache.name,
|
||||
identity_cache.length * sizeof(char*));
|
||||
}
|
||||
old = identity_cache.name;
|
||||
identity_cache.name = names;
|
||||
identity_cache.length = length;
|
||||
@@ -683,12 +684,17 @@ retry:
|
||||
|
||||
PR_IMPLEMENT(const char*) PR_GetNameForIdentity(PRDescIdentity ident)
|
||||
{
|
||||
const char *rv = NULL;
|
||||
if (!_pr_initialized) _PR_ImplicitInitialization();
|
||||
|
||||
if (PR_TOP_IO_LAYER == ident) return NULL;
|
||||
if ((PR_TOP_IO_LAYER != ident) && (ident >= 0)) {
|
||||
PR_Lock(identity_cache.ml);
|
||||
PR_ASSERT(ident <= identity_cache.ident);
|
||||
rv = (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
|
||||
PR_Unlock(identity_cache.ml);
|
||||
}
|
||||
|
||||
PR_ASSERT(ident <= identity_cache.ident);
|
||||
return (ident > identity_cache.ident) ? NULL : identity_cache.name[ident];
|
||||
return rv;
|
||||
} /* PR_GetNameForIdentity */
|
||||
|
||||
PR_IMPLEMENT(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd)
|
||||
@@ -697,8 +703,8 @@ PR_IMPLEMENT(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd)
|
||||
if (PR_IO_LAYER_HEAD == fd->identity) {
|
||||
PR_ASSERT(NULL != fd->lower);
|
||||
return fd->lower->identity;
|
||||
} else
|
||||
return fd->identity;
|
||||
}
|
||||
return fd->identity;
|
||||
} /* PR_GetLayersIdentity */
|
||||
|
||||
PR_IMPLEMENT(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity id)
|
||||
@@ -706,10 +712,10 @@ PR_IMPLEMENT(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd, PRDescIdentity i
|
||||
PRFileDesc *layer = fd;
|
||||
|
||||
if (PR_TOP_IO_LAYER == id) {
|
||||
if (PR_IO_LAYER_HEAD == fd->identity)
|
||||
return fd->lower;
|
||||
else
|
||||
return fd;
|
||||
if (PR_IO_LAYER_HEAD == fd->identity) {
|
||||
return fd->lower;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
for (layer = fd; layer != NULL; layer = layer->lower)
|
||||
|
||||
@@ -24,17 +24,16 @@ PR_IMPLEMENT(PRFileMap *) PR_CreateFileMap(
|
||||
|| prot == PR_PROT_WRITECOPY);
|
||||
fmap = PR_NEWZAP(PRFileMap);
|
||||
if (NULL == fmap) {
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return NULL;
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return NULL;
|
||||
}
|
||||
fmap->fd = fd;
|
||||
fmap->prot = prot;
|
||||
if (_PR_MD_CREATE_FILE_MAP(fmap, size) == PR_SUCCESS) {
|
||||
return fmap;
|
||||
} else {
|
||||
return fmap;
|
||||
}
|
||||
PR_DELETE(fmap);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRInt32) PR_GetMemMapAlignment(void)
|
||||
|
||||
@@ -461,7 +461,7 @@ static struct NumArg* BuildArgArray( const char *fmt, va_list ap, int* rv, struc
|
||||
if( c == '%' ) continue;
|
||||
|
||||
cn = 0;
|
||||
while( c && c != '$' ){ /* should imporve error check later */
|
||||
while( c && c != '$' ){ /* should improve error check later */
|
||||
cn = cn*10 + c - '0';
|
||||
c = *p++;
|
||||
}
|
||||
@@ -745,7 +745,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
|
||||
if( nas != NULL ){
|
||||
/* the fmt contains the Numbered Arguments feature */
|
||||
i = 0;
|
||||
while( c && c != '$' ){ /* should imporve error check later */
|
||||
while( c && c != '$' ){ /* should improve error check later */
|
||||
i = ( i * 10 ) + ( c - '0' );
|
||||
c = *fmt++;
|
||||
}
|
||||
|
||||
@@ -409,7 +409,8 @@ Convert(ScanfState *state, const char *fmt)
|
||||
ch = GET(state);
|
||||
if (ch == EOF) {
|
||||
return NULL;
|
||||
} else if (state->assign) {
|
||||
}
|
||||
if (state->assign) {
|
||||
*cArg++ = ch;
|
||||
}
|
||||
}
|
||||
@@ -602,10 +603,9 @@ StringGetChar(void *stream)
|
||||
|
||||
if (*cPtr == '\0') {
|
||||
return EOF;
|
||||
} else {
|
||||
*((char **) stream) = cPtr + 1;
|
||||
return (unsigned char) *cPtr;
|
||||
}
|
||||
*((char **) stream) = cPtr + 1;
|
||||
return (unsigned char) *cPtr;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN64)
|
||||
#ifndef SO_UPDATE_CONNECT_CONTEXT
|
||||
#define SO_UPDATE_CONNECT_CONTEXT 0x7010
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* These two functions are only used in assertions. */
|
||||
@@ -298,12 +304,72 @@ static PRStatus PR_CALLBACK SocketConnectContinue(
|
||||
if (err != 0) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
} else {
|
||||
#if defined(_WIN64)
|
||||
if (fd->secret->overlappedActive) {
|
||||
PRInt32 rvSent;
|
||||
if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == FALSE) {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketConnectContinue GetOverlappedResult failed %d\n", err));
|
||||
if (err != ERROR_IO_INCOMPLETE) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (err == 0) {
|
||||
PR_SetError(PR_UNKNOWN_ERROR, 0);
|
||||
}
|
||||
#else
|
||||
PR_SetError(PR_UNKNOWN_ERROR, 0);
|
||||
#endif
|
||||
}
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
PR_ASSERT(out_flags & PR_POLL_WRITE);
|
||||
|
||||
#if defined(_WIN64)
|
||||
if (fd->secret->alreadyConnected) {
|
||||
fd->secret->alreadyConnected = PR_FALSE;
|
||||
}
|
||||
/* TCP Fast Open on Windows must use ConnectEx, which uses overlapped
|
||||
* input/output.
|
||||
* To get result we need to use GetOverlappedResult. */
|
||||
if (fd->secret->overlappedActive) {
|
||||
PR_ASSERT(fd->secret->nonblocking);
|
||||
PRInt32 rvSent;
|
||||
if (GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) {
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketConnectContinue GetOverlappedResult succeeded\n"));
|
||||
/* When ConnectEx is used, all previously set socket options and
|
||||
* property are not enabled and to enable them
|
||||
* SO_UPDATE_CONNECT_CONTEXT option need to be set. */
|
||||
if (setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0) != 0) {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketConnectContinue setting SO_UPDATE_CONNECT_CONTEXT failed %d\n", err));
|
||||
_PR_MD_MAP_SETSOCKOPT_ERROR(err);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
return PR_SUCCESS;
|
||||
} else {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketConnectContinue GetOverlappedResult failed %d\n", err));
|
||||
if (err != ERROR_IO_INCOMPLETE) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
return PR_FAILURE;
|
||||
} else {
|
||||
PR_SetError(PR_IN_PROGRESS_ERROR, 0);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return PR_SUCCESS;
|
||||
|
||||
#elif defined(XP_OS2)
|
||||
@@ -671,6 +737,56 @@ static PRStatus PR_CALLBACK SocketClose(PRFileDesc *fd)
|
||||
}
|
||||
|
||||
if (fd->secret->state == _PR_FILEDESC_OPEN) {
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
/* TCP Fast Open on Windows must use ConnectEx, which uses overlapped
|
||||
* input/output. Before closing such a socket we must cancelIO.
|
||||
*/
|
||||
if (fd->secret->overlappedActive) {
|
||||
PR_ASSERT(fd->secret->nonblocking);
|
||||
if (CancelIo((HANDLE) fd->secret->md.osfd) == TRUE) {
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketClose - CancelIo succeeded\n"));
|
||||
} else {
|
||||
DWORD err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketClose - CancelIo failed err=%x\n", err));
|
||||
}
|
||||
|
||||
DWORD rvSent;
|
||||
if (GetOverlappedResult((HANDLE)fd->secret->md.osfd, &fd->secret->ol, &rvSent, FALSE) == TRUE) {
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketClose GetOverlappedResult succeeded\n"));
|
||||
} else {
|
||||
DWORD err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("SocketClose GetOverlappedResult failed %d\n", err));
|
||||
if (err != ERROR_IO_INCOMPLETE) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
fd->secret->overlappedActive = PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fd->secret->overlappedActive &&
|
||||
_fd_waiting_for_overlapped_done_lock) {
|
||||
// Put osfd into the list to be checked later.
|
||||
PRFileDescList *forWaiting = PR_NEW(PRFileDescList);
|
||||
if (!forWaiting) {
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
forWaiting->fd = fd;
|
||||
|
||||
PR_Lock(_fd_waiting_for_overlapped_done_lock);
|
||||
forWaiting->next = _fd_waiting_for_overlapped_done;
|
||||
_fd_waiting_for_overlapped_done = forWaiting;
|
||||
PR_Unlock(_fd_waiting_for_overlapped_done_lock);
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_PR_MD_CLOSE_SOCKET(fd->secret->md.osfd) < 0) {
|
||||
return PR_FAILURE;
|
||||
}
|
||||
@@ -751,7 +867,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,10 +880,60 @@ static PRInt32 PR_CALLBACK SocketSendTo(
|
||||
}
|
||||
buf = (const void*) ((const char*)buf + temp);
|
||||
amount -= temp;
|
||||
}
|
||||
} while (amount > 0);
|
||||
return count;
|
||||
}
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
static PRInt32 PR_CALLBACK SocketTCPSendTo(
|
||||
PRFileDesc *fd, const void *buf, PRInt32 amount,
|
||||
PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout)
|
||||
{
|
||||
PRInt32 temp, count;
|
||||
const PRNetAddr *addrp = addr;
|
||||
#if defined(_PR_INET6)
|
||||
PRNetAddr addrCopy;
|
||||
#endif
|
||||
PRThread *me = _PR_MD_CURRENT_THREAD();
|
||||
|
||||
if (_PR_PENDING_INTERRUPT(me)) {
|
||||
me->flags &= ~_PR_INTERRUPT;
|
||||
PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);
|
||||
return -1;
|
||||
}
|
||||
if (_PR_IO_PENDING(me)) {
|
||||
PR_SetError(PR_IO_PENDING_ERROR, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
#if defined(_PR_INET6)
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
}
|
||||
#endif
|
||||
|
||||
count = 0;
|
||||
while (amount > 0) {
|
||||
temp = _PR_MD_TCPSENDTO(fd, buf, amount, flags,
|
||||
addrp, PR_NETADDR_SIZE(addr), timeout);
|
||||
if (temp < 0) {
|
||||
count = -1;
|
||||
break;
|
||||
}
|
||||
count += temp;
|
||||
if (fd->secret->nonblocking) {
|
||||
break;
|
||||
}
|
||||
buf = (const void*) ((const char*)buf + temp);
|
||||
amount -= temp;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
static PRInt32 PR_CALLBACK SocketRecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount,
|
||||
PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
|
||||
{
|
||||
@@ -1066,6 +1232,15 @@ static PRInt16 PR_CALLBACK SocketPoll(
|
||||
PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags)
|
||||
{
|
||||
*out_flags = 0;
|
||||
|
||||
#if defined(_WIN64)
|
||||
if (in_flags & PR_POLL_WRITE) {
|
||||
if (fd->secret->alreadyConnected) {
|
||||
out_flags = PR_POLL_WRITE;
|
||||
return PR_POLL_WRITE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return in_flags;
|
||||
} /* SocketPoll */
|
||||
|
||||
@@ -1090,7 +1265,11 @@ static PRIOMethods tcpMethods = {
|
||||
SocketRecv,
|
||||
SocketSend,
|
||||
(PRRecvfromFN)_PR_InvalidInt,
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
SocketTCPSendTo, /* This is for fast open. We imitate Linux interface. */
|
||||
#else
|
||||
(PRSendtoFN)_PR_InvalidInt,
|
||||
#endif
|
||||
SocketPoll,
|
||||
SocketAcceptRead,
|
||||
SocketTransmitFile,
|
||||
|
||||
@@ -2713,8 +2713,13 @@ static void* _MD_Unix_mmap64(
|
||||
} /* _MD_Unix_mmap64 */
|
||||
#endif /* defined(_PR_NO_LARGE_FILES) || defined(SOLARIS2_5) */
|
||||
|
||||
/* Android <= 19 doesn't have mmap64. */
|
||||
#if defined(ANDROID) && __ANDROID_API__ <= 19
|
||||
/* NDK non-unified headers for API < 21 don't have mmap64. However,
|
||||
* NDK unified headers do provide mmap64 for all API versions when building
|
||||
* with clang. Therefore, we should provide mmap64 here for API < 21 if we're
|
||||
* not using clang or if we're using non-unified headers. We check for
|
||||
* non-unified headers by the lack of __ANDROID_API_L__ macro. */
|
||||
#if defined(ANDROID) && __ANDROID_API__ < 21 && \
|
||||
(!defined(__clang__) || !defined(__ANDROID_API_L__))
|
||||
PR_IMPORT(void) *__mmap2(void *, size_t, int, int, int, size_t);
|
||||
|
||||
#define ANDROID_PAGE_SIZE 4096
|
||||
@@ -2784,9 +2789,9 @@ static void _PR_InitIOV(void)
|
||||
_md_iovector._stat64 = stat;
|
||||
_md_iovector._lseek64 = _MD_Unix_lseek64;
|
||||
#elif defined(_PR_HAVE_OFF64_T)
|
||||
#if defined(IRIX5_3) || defined(ANDROID)
|
||||
#if defined(IRIX5_3) || (defined(ANDROID) && __ANDROID_API__ < 21)
|
||||
/*
|
||||
* Android doesn't have open64. We pass the O_LARGEFILE flag to open
|
||||
* Android < 21 doesn't have open64. We pass the O_LARGEFILE flag to open
|
||||
* in _MD_open.
|
||||
*/
|
||||
_md_iovector._open64 = open;
|
||||
@@ -2794,8 +2799,14 @@ static void _PR_InitIOV(void)
|
||||
_md_iovector._open64 = open64;
|
||||
#endif
|
||||
_md_iovector._mmap64 = mmap64;
|
||||
#if (defined(ANDROID) && __ANDROID_API__ < 21)
|
||||
/* Same as the open64 case for Android. */
|
||||
_md_iovector._fstat64 = fstat;
|
||||
_md_iovector._stat64 = stat;
|
||||
#else
|
||||
_md_iovector._fstat64 = fstat64;
|
||||
_md_iovector._stat64 = stat64;
|
||||
#endif
|
||||
_md_iovector._lseek64 = lseek64;
|
||||
#elif defined(_PR_HAVE_LARGE_OFF_T)
|
||||
_md_iovector._open64 = open;
|
||||
@@ -2854,28 +2865,11 @@ void _PR_UnixInit(void)
|
||||
#endif
|
||||
#endif /* !defined(_PR_PTHREADS) */
|
||||
|
||||
/*
|
||||
* Under HP-UX DCE threads, sigaction() installs a per-thread
|
||||
* handler, so we use sigvector() to install a process-wide
|
||||
* handler.
|
||||
*/
|
||||
#if defined(HPUX) && defined(_PR_DCETHREADS)
|
||||
{
|
||||
struct sigvec vec;
|
||||
|
||||
vec.sv_handler = SIG_IGN;
|
||||
vec.sv_mask = 0;
|
||||
vec.sv_flags = 0;
|
||||
rv = sigvector(SIGPIPE, &vec, NULL);
|
||||
PR_ASSERT(0 == rv);
|
||||
}
|
||||
#else
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigact.sa_flags = 0;
|
||||
rv = sigaction(SIGPIPE, &sigact, 0);
|
||||
PR_ASSERT(0 == rv);
|
||||
#endif /* HPUX && _PR_DCETHREADS */
|
||||
|
||||
_pr_rename_lock = PR_NewLock();
|
||||
PR_ASSERT(NULL != _pr_rename_lock);
|
||||
@@ -3316,11 +3310,11 @@ int _MD_unix_get_nonblocking_connect_error(int osfd)
|
||||
return errno;
|
||||
} else {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ECONNREFUSED;
|
||||
}
|
||||
}
|
||||
#elif defined(UNIXWARE)
|
||||
/*
|
||||
* getsockopt() fails with EPIPE, so use getmsg() instead.
|
||||
@@ -3331,17 +3325,17 @@ int _MD_unix_get_nonblocking_connect_error(int osfd)
|
||||
rv = getmsg(osfd, NULL, NULL, &flags);
|
||||
PR_ASSERT(-1 == rv || 0 == rv);
|
||||
if (-1 == rv && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
return errno;
|
||||
return errno;
|
||||
}
|
||||
return 0; /* no error */
|
||||
return 0; /* no error */
|
||||
#else
|
||||
int err;
|
||||
_PRSockLen_t optlen = sizeof(err);
|
||||
if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char *) &err, &optlen) == -1) {
|
||||
return errno;
|
||||
} else {
|
||||
return err;
|
||||
}
|
||||
int err;
|
||||
_PRSockLen_t optlen = sizeof(err);
|
||||
if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == -1) {
|
||||
return errno;
|
||||
}
|
||||
return err;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -247,13 +247,14 @@ ForkAndExec(
|
||||
PR_DELETE(newEnvp);
|
||||
}
|
||||
return NULL;
|
||||
} else if (0 == process->md.pid) { /* the child process */
|
||||
/*
|
||||
* If the child process needs to exit, it must call _exit().
|
||||
* Do not call exit(), because exit() will flush and close
|
||||
* the standard I/O file descriptors, and hence corrupt
|
||||
* the parent process's standard I/O data structures.
|
||||
*/
|
||||
}
|
||||
if (0 == process->md.pid) { /* the child process */
|
||||
/*
|
||||
* If the child process needs to exit, it must call _exit().
|
||||
* Do not call exit(), because exit() will flush and close
|
||||
* the standard I/O file descriptors, and hence corrupt
|
||||
* the parent process's standard I/O data structures.
|
||||
*/
|
||||
|
||||
#if !defined(NTO) && !defined(SYMBIAN)
|
||||
if (attr) {
|
||||
@@ -498,10 +499,9 @@ ExtractExitStatus(int rawExitStatus)
|
||||
#endif
|
||||
if (WIFEXITED(rawExitStatus)) {
|
||||
return WEXITSTATUS(rawExitStatus);
|
||||
} else {
|
||||
}
|
||||
PR_ASSERT(WIFSIGNALED(rawExitStatus));
|
||||
return _PR_SIGNALED_EXITSTATUS;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -624,8 +624,8 @@ static void WaitPidDaemonThread(void *unused)
|
||||
} while (sizeof(buf) == rv || (-1 == rv && EINTR == errno));
|
||||
|
||||
#ifdef _PR_SHARE_CLONES
|
||||
PR_Unlock(pr_wp.ml);
|
||||
while ((op = pr_wp.opHead) != NULL) {
|
||||
PR_Unlock(pr_wp.ml);
|
||||
op->process = ForkAndExec(op->path, op->argv,
|
||||
op->envp, op->attr);
|
||||
if (NULL == op->process) {
|
||||
@@ -639,8 +639,8 @@ static void WaitPidDaemonThread(void *unused)
|
||||
}
|
||||
op->done = PR_TRUE;
|
||||
PR_NotifyCondVar(op->doneCV);
|
||||
PR_Unlock(pr_wp.ml);
|
||||
}
|
||||
PR_Unlock(pr_wp.ml);
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
@@ -685,10 +685,6 @@ static void pr_SigchldHandler(int sig)
|
||||
|
||||
static void pr_InstallSigchldHandler()
|
||||
{
|
||||
#if defined(HPUX) && defined(_PR_DCETHREADS)
|
||||
#error "HP-UX DCE threads have their own SIGCHLD handler"
|
||||
#endif
|
||||
|
||||
struct sigaction act, oact;
|
||||
int rv;
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ extern PRSharedMemory * _MD_OpenSharedMemory(
|
||||
|
||||
/* copy args to struct */
|
||||
strcpy( shm->ipcname, ipcname );
|
||||
shm->size = size;
|
||||
shm->mode = mode;
|
||||
shm->size = size;
|
||||
shm->mode = mode;
|
||||
shm->flags = flags;
|
||||
shm->ident = _PR_SHM_IDENT;
|
||||
|
||||
@@ -500,30 +500,32 @@ extern PRFileMap* _md_OpenAnonFileMap(
|
||||
("_md_OpenAnonFileMap(): PR_snprintf(): failed, generating filename"));
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
|
||||
/* create the file */
|
||||
osfd = open( genName, (O_CREAT | O_EXCL | O_RDWR), mode );
|
||||
if ( -1 == osfd ) {
|
||||
if ( EEXIST == errno ) {
|
||||
PR_smprintf_free( genName );
|
||||
continue; /* name exists, try again */
|
||||
} else {
|
||||
_PR_MD_MAP_OPEN_ERROR( errno );
|
||||
PR_LOG( _pr_shma_lm, PR_LOG_DEBUG,
|
||||
("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d",
|
||||
genName, PR_GetOSError()));
|
||||
PR_smprintf_free( genName );
|
||||
goto Finished;
|
||||
}
|
||||
osfd = open(genName, (O_CREAT | O_EXCL | O_RDWR), mode);
|
||||
if (-1 == osfd) {
|
||||
if (EEXIST == errno) {
|
||||
PR_smprintf_free(genName);
|
||||
continue; /* name exists, try again */
|
||||
}
|
||||
_PR_MD_MAP_OPEN_ERROR(errno);
|
||||
PR_LOG(
|
||||
_pr_shma_lm,
|
||||
PR_LOG_DEBUG,
|
||||
("_md_OpenAnonFileMap(): open(): failed, filename: %s, errno: %d",
|
||||
genName,
|
||||
PR_GetOSError()));
|
||||
PR_smprintf_free(genName);
|
||||
goto Finished;
|
||||
}
|
||||
break; /* name generation and open successful, break; */
|
||||
} /* end for() */
|
||||
|
||||
if ( incr == maxTries ) {
|
||||
PR_ASSERT( -1 == osfd );
|
||||
PR_ASSERT( EEXIST == errno );
|
||||
_PR_MD_MAP_OPEN_ERROR( errno );
|
||||
goto Finished;
|
||||
if (incr == maxTries) {
|
||||
PR_ASSERT(-1 == osfd);
|
||||
PR_ASSERT(EEXIST == errno);
|
||||
_PR_MD_MAP_OPEN_ERROR(errno);
|
||||
goto Finished;
|
||||
}
|
||||
|
||||
urc = unlink( genName );
|
||||
|
||||
@@ -27,6 +27,9 @@ PRUint32 _nt_idleCount;
|
||||
extern __declspec(thread) PRThread *_pr_io_restarted_io;
|
||||
extern DWORD _pr_io_restartedIOIndex;
|
||||
|
||||
typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
|
||||
static SETTHREADDESCRIPTION sSetThreadDescription = NULL;
|
||||
|
||||
/* Must check the restarted_io *before* decrementing no_sched to 0 */
|
||||
#define POST_SWITCH_WORK() \
|
||||
PR_BEGIN_MACRO \
|
||||
@@ -79,6 +82,8 @@ _nt_handle_restarted_io(PRThread *restarted_io)
|
||||
void
|
||||
_PR_MD_EARLY_INIT()
|
||||
{
|
||||
HMODULE hModule;
|
||||
|
||||
_MD_NEW_LOCK( &_nt_idleLock );
|
||||
_nt_idleCount = 0;
|
||||
PR_INIT_CLIST(&_nt_idleList);
|
||||
@@ -98,6 +103,15 @@ _PR_MD_EARLY_INIT()
|
||||
_pr_intsOffIndex = TlsAlloc();
|
||||
_pr_io_restartedIOIndex = TlsAlloc();
|
||||
}
|
||||
|
||||
// SetThreadDescription is Windows 10 build 1607+
|
||||
hModule = GetModuleHandleW(L"kernel32.dll");
|
||||
if (hModule) {
|
||||
sSetThreadDescription =
|
||||
(SETTHREADDESCRIPTION) GetProcAddress(
|
||||
hModule,
|
||||
"SetThreadDescription");
|
||||
}
|
||||
}
|
||||
|
||||
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
|
||||
@@ -293,7 +307,16 @@ _PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
THREADNAME_INFO info;
|
||||
#endif
|
||||
|
||||
if (sSetThreadDescription) {
|
||||
WCHAR wideName[MAX_PATH];
|
||||
if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
|
||||
sSetThreadDescription(GetCurrentThread(), wideName);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (!IsDebuggerPresent())
|
||||
return;
|
||||
|
||||
|
||||
@@ -155,7 +155,8 @@ PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout)
|
||||
pd->out_flags = 0; /* pre-condition */
|
||||
/* make sure this is an NSPR supported stack */
|
||||
bottom = PR_GetIdentitiesLayer(pd->fd, PR_NSPR_IO_LAYER);
|
||||
PR_ASSERT(NULL != bottom); /* what to do about that? */
|
||||
/* ignore a socket without PR_NSPR_IO_LAYER available */
|
||||
|
||||
if ((NULL != bottom)
|
||||
&& (_PR_FILEDESC_OPEN == bottom->secret->state))
|
||||
{
|
||||
|
||||
@@ -9,6 +9,12 @@
|
||||
|
||||
#include "primpl.h"
|
||||
|
||||
#if defined(_WIN64)
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define READ_FD 1
|
||||
#define WRITE_FD 2
|
||||
#define CONNECT_FD 3
|
||||
@@ -294,8 +300,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
|
||||
PRInt32 rv, err;
|
||||
PRInt32 bytesSent = 0;
|
||||
|
||||
while(bytesSent < amount)
|
||||
{
|
||||
do {
|
||||
while ((rv = sendto( osfd, buf, amount, 0, (struct sockaddr *) addr,
|
||||
addrlen)) == -1)
|
||||
{
|
||||
@@ -327,10 +332,182 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(bytesSent < amount);
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
|
||||
static PRCallOnceType _pr_has_connectex_once;
|
||||
typedef BOOL (PASCAL FAR * _pr_win_connectex_ptr)(_In_ SOCKET s, _In_reads_bytes_(namelen) const struct sockaddr FAR *name, _In_ int namelen, _In_reads_bytes_opt_(dwSendDataLength) PVOID lpSendBuffer, _In_ DWORD dwSendDataLength, _Out_ LPDWORD lpdwBytesSent, _Inout_ LPOVERLAPPED lpOverlapped);
|
||||
|
||||
#ifndef WSAID_CONNECTEX
|
||||
#define WSAID_CONNECTEX \
|
||||
{0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
|
||||
#endif
|
||||
#ifndef SIO_GET_EXTENSION_FUNCTION_POINTER
|
||||
#define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006
|
||||
#endif
|
||||
#ifndef TCP_FASTOPEN
|
||||
#define TCP_FASTOPEN 15
|
||||
#endif
|
||||
|
||||
#ifndef SO_UPDATE_CONNECT_CONTEXT
|
||||
#define SO_UPDATE_CONNECT_CONTEXT 0x7010
|
||||
#endif
|
||||
|
||||
static _pr_win_connectex_ptr _pr_win_connectex = NULL;
|
||||
|
||||
static PRStatus PR_CALLBACK _pr_set_connectex(void)
|
||||
{
|
||||
_pr_win_connectex = NULL;
|
||||
SOCKET sock;
|
||||
PRInt32 dwBytes;
|
||||
int rc;
|
||||
|
||||
/* Dummy socket needed for WSAIoctl */
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == INVALID_SOCKET)
|
||||
return PR_SUCCESS;
|
||||
|
||||
GUID guid = WSAID_CONNECTEX;
|
||||
rc = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER,
|
||||
&guid, sizeof(guid),
|
||||
&_pr_win_connectex, sizeof(_pr_win_connectex),
|
||||
&dwBytes, NULL, NULL);
|
||||
if (rc != 0) {
|
||||
_pr_win_connectex = NULL;
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
rc = closesocket(sock);
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
_PR_MD_TCPSENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
|
||||
const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout)
|
||||
{
|
||||
if (!_fd_waiting_for_overlapped_done_lock) {
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
if (PR_CallOnce(&_pr_has_connectex_once, _pr_set_connectex) != PR_SUCCESS) {
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
if (_pr_win_connectex == NULL) {
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
PROsfd osfd = fd->secret->md.osfd;
|
||||
PRInt32 rv, err;
|
||||
PRInt32 bytesSent = 0;
|
||||
DWORD rvSent;
|
||||
|
||||
BOOL option = 1;
|
||||
rv = setsockopt((SOCKET)osfd, IPPROTO_TCP, TCP_FASTOPEN, (char*)&option, sizeof(option));
|
||||
if (rv != 0) {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("_PR_MD_TCPSENDTO error set opt TCP_FASTOPEN failed %d\n", err));
|
||||
if (err == WSAENOPROTOOPT) {
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
} else {
|
||||
_PR_MD_MAP_SETSOCKOPT_ERROR(err);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ConnectEx requires the socket to be initially bound. We will use INADDR_ANY. */
|
||||
PRNetAddr bindAddr;
|
||||
memset(&bindAddr, 0, sizeof(bindAddr));
|
||||
bindAddr.raw.family = addr->raw.family;
|
||||
|
||||
rv = bind((SOCKET)osfd, (const struct sockaddr *)&(bindAddr.inet), PR_NETADDR_SIZE(&bindAddr));
|
||||
if (rv != 0) {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("_PR_MD_TCPSENDTO error bind failed %d\n", err));
|
||||
_PR_MD_MAP_SETSOCKOPT_ERROR(err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("_PR_MD_TCPSENDTO calling _pr_win_connectex %d %p\n", amount, (char*)buf));
|
||||
|
||||
rvSent = 0;
|
||||
memset(&fd->secret->ol, 0, sizeof(fd->secret->ol));
|
||||
/* ConnectEx return TRUE on a success and FALSE on an error. */
|
||||
if (_pr_win_connectex( (SOCKET)osfd, (struct sockaddr *) addr,
|
||||
addrlen, buf, amount,
|
||||
&rvSent, &fd->secret->ol) == TRUE) {
|
||||
/* When ConnectEx is used, all previously set socket options and
|
||||
* property are not enabled and to enable them
|
||||
* SO_UPDATE_CONNECT_CONTEXT option need to be set. */
|
||||
rv = setsockopt((SOCKET)osfd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
|
||||
if (rv != 0) {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("_PR_MD_TCPSENDTO setting SO_UPDATE_CONNECT_CONTEXT failed %d\n", err));
|
||||
_PR_MD_MAP_SETSOCKOPT_ERROR(err);
|
||||
return -1;
|
||||
}
|
||||
/* We imitate Linux here. SendTo will return number of bytes send but
|
||||
* it can not return connection success at the same time, so we return
|
||||
* number of bytes send and "connection success" will be return on the
|
||||
* connectcontinue. */
|
||||
fd->secret->alreadyConnected = PR_TRUE;
|
||||
return rvSent;
|
||||
} else {
|
||||
err = WSAGetLastError();
|
||||
PR_LOG(_pr_io_lm, PR_LOG_MIN,
|
||||
("_PR_MD_TCPSENDTO error _pr_win_connectex failed %d\n", err));
|
||||
if (err != ERROR_IO_PENDING) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
return -1;
|
||||
} else if (fd->secret->nonblocking) {
|
||||
/* Remember that overlapped structure is set. We will need to get
|
||||
* the final result of ConnectEx call. */
|
||||
fd->secret->overlappedActive = PR_TRUE;
|
||||
|
||||
/* ConnectEx will copy supplied data to a internal buffer and send
|
||||
* them during Fast Open or after connect. Therefore we can assumed
|
||||
* this data already send. */
|
||||
if (amount > 0) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
_PR_MD_MAP_CONNECT_ERROR(WSAEWOULDBLOCK);
|
||||
return -1;
|
||||
}
|
||||
// err is ERROR_IO_PENDING and socket is blocking, so query
|
||||
// GetOverlappedResult.
|
||||
err = ERROR_IO_INCOMPLETE;
|
||||
while (err == ERROR_IO_INCOMPLETE) {
|
||||
rv = socket_io_wait(osfd, WRITE_FD, timeout);
|
||||
if ( rv < 0 ) {
|
||||
return -1;
|
||||
}
|
||||
rv = GetOverlappedResult(osfd, &fd->secret->ol, &rvSent, FALSE);
|
||||
if ( rv == TRUE ) {
|
||||
return rvSent;
|
||||
} else {
|
||||
err = WSAGetLastError();
|
||||
if (err != ERROR_IO_INCOMPLETE) {
|
||||
_PR_MD_MAP_CONNECT_ERROR(err);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32
|
||||
_PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags,
|
||||
PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
/* -*- 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
|
||||
@@ -27,14 +28,32 @@ DWORD _pr_currentCPUIndex;
|
||||
int _pr_intsOff = 0;
|
||||
_PRInterruptTable _pr_interruptTable[] = { { 0 } };
|
||||
|
||||
typedef HRESULT (WINAPI *SETTHREADDESCRIPTION)(HANDLE, PCWSTR);
|
||||
static SETTHREADDESCRIPTION sSetThreadDescription = NULL;
|
||||
|
||||
void
|
||||
_PR_MD_EARLY_INIT()
|
||||
{
|
||||
HMODULE hModule;
|
||||
|
||||
#ifndef _PR_USE_STATIC_TLS
|
||||
_pr_currentThreadIndex = TlsAlloc();
|
||||
_pr_lastThreadIndex = TlsAlloc();
|
||||
_pr_currentCPUIndex = TlsAlloc();
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
_fd_waiting_for_overlapped_done_lock = PR_NewLock();
|
||||
#endif
|
||||
|
||||
// SetThreadDescription is Windows 10 build 1607+
|
||||
hModule = GetModuleHandleW(L"kernel32.dll");
|
||||
if (hModule) {
|
||||
sSetThreadDescription =
|
||||
(SETTHREADDESCRIPTION) GetProcAddress(
|
||||
hModule,
|
||||
"SetThreadDescription");
|
||||
}
|
||||
}
|
||||
|
||||
void _PR_MD_CLEANUP_BEFORE_EXIT(void)
|
||||
@@ -50,6 +69,29 @@ void _PR_MD_CLEANUP_BEFORE_EXIT(void)
|
||||
TlsFree(_pr_lastThreadIndex);
|
||||
TlsFree(_pr_currentCPUIndex);
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64) && defined(WIN95)
|
||||
// For each iteration check if TFO overlapped IOs are down.
|
||||
if (_fd_waiting_for_overlapped_done_lock) {
|
||||
PRIntervalTime delay = PR_MillisecondsToInterval(1000);
|
||||
PRFileDescList *cur;
|
||||
do {
|
||||
CheckOverlappedPendingSocketsAreDone();
|
||||
|
||||
PR_Lock(_fd_waiting_for_overlapped_done_lock);
|
||||
cur = _fd_waiting_for_overlapped_done;
|
||||
PR_Unlock(_fd_waiting_for_overlapped_done_lock);
|
||||
#if defined(DO_NOT_WAIT_FOR_CONNECT_OVERLAPPED_OPERATIONS)
|
||||
cur = NULL;
|
||||
#endif
|
||||
if (cur) {
|
||||
PR_Sleep(delay); // wait another 1s.
|
||||
}
|
||||
} while (cur);
|
||||
|
||||
PR_DestroyLock(_fd_waiting_for_overlapped_done_lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PRStatus
|
||||
@@ -190,7 +232,16 @@ _PR_MD_SET_CURRENT_THREAD_NAME(const char *name)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
THREADNAME_INFO info;
|
||||
#endif
|
||||
|
||||
if (sSetThreadDescription) {
|
||||
WCHAR wideName[MAX_PATH];
|
||||
if (MultiByteToWideChar(CP_ACP, 0, name, -1, wideName, MAX_PATH)) {
|
||||
sSetThreadDescription(GetCurrentThread(), wideName);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
if (!IsDebuggerPresent())
|
||||
return;
|
||||
|
||||
|
||||
@@ -166,21 +166,26 @@ void _MD_win32_map_default_error(PRInt32 err)
|
||||
prError = PR_ADDRESS_IN_USE_ERROR;
|
||||
break;
|
||||
case WSAEADDRNOTAVAIL:
|
||||
case ERROR_INVALID_NETNAME:
|
||||
prError = PR_ADDRESS_NOT_AVAILABLE_ERROR;
|
||||
break;
|
||||
case WSAEAFNOSUPPORT:
|
||||
case ERROR_INCORRECT_ADDRESS:
|
||||
prError = PR_ADDRESS_NOT_SUPPORTED_ERROR;
|
||||
break;
|
||||
case WSAEALREADY:
|
||||
case ERROR_ALREADY_INITIALIZED:
|
||||
prError = PR_ALREADY_INITIATED_ERROR;
|
||||
break;
|
||||
case WSAEBADF:
|
||||
prError = PR_BAD_DESCRIPTOR_ERROR;
|
||||
break;
|
||||
case WSAECONNABORTED:
|
||||
case ERROR_CONNECTION_ABORTED:
|
||||
prError = PR_CONNECT_ABORTED_ERROR;
|
||||
break;
|
||||
case WSAECONNREFUSED:
|
||||
case ERROR_CONNECTION_REFUSED:
|
||||
prError = PR_CONNECT_REFUSED_ERROR;
|
||||
break;
|
||||
case WSAECONNRESET:
|
||||
@@ -193,6 +198,7 @@ void _MD_win32_map_default_error(PRInt32 err)
|
||||
prError = PR_ACCESS_FAULT_ERROR;
|
||||
break;
|
||||
case WSAEHOSTUNREACH:
|
||||
case ERROR_HOST_UNREACHABLE:
|
||||
prError = PR_HOST_UNREACHABLE_ERROR;
|
||||
break;
|
||||
case WSAEINVAL:
|
||||
@@ -208,12 +214,14 @@ void _MD_win32_map_default_error(PRInt32 err)
|
||||
prError = PR_BUFFER_OVERFLOW_ERROR;
|
||||
break;
|
||||
case WSAENETDOWN:
|
||||
case ERROR_NO_NETWORK:
|
||||
prError = PR_NETWORK_DOWN_ERROR;
|
||||
break;
|
||||
case WSAENETRESET:
|
||||
prError = PR_CONNECT_ABORTED_ERROR;
|
||||
break;
|
||||
case WSAENETUNREACH:
|
||||
case ERROR_NETWORK_UNREACHABLE:
|
||||
prError = PR_NETWORK_UNREACHABLE_ERROR;
|
||||
break;
|
||||
case WSAENOBUFS:
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#if !defined(_PR_HAVE_ATOMIC_OPS)
|
||||
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
/*
|
||||
* PR_AtomicDecrement() is used in NSPR's thread-specific data
|
||||
* destructor. Because thread-specific data destructors may be
|
||||
@@ -190,7 +190,7 @@ _PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
|
||||
pthread_mutex_unlock(&atomic_locks[idx]);
|
||||
return rv;
|
||||
}
|
||||
#else /* _PR_PTHREADS && !_PR_DCETHREADS */
|
||||
#else /* _PR_PTHREADS */
|
||||
/*
|
||||
* We use a single lock for all the emulated atomic operations.
|
||||
* The lock contention should be acceptable.
|
||||
@@ -259,7 +259,7 @@ _PR_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
|
||||
PR_Unlock(atomic_lock);
|
||||
return rv;
|
||||
}
|
||||
#endif /* _PR_PTHREADS && !_PR_DCETHREADS */
|
||||
#endif /* _PR_PTHREADS */
|
||||
|
||||
#endif /* !_PR_HAVE_ATOMIC_OPS */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
#include "prlong.h"
|
||||
|
||||
static PRInt64 ll_zero = LL_INIT( 0x00000000,0x00000000 );
|
||||
static PRInt64 ll_maxint = LL_INIT( 0x7fffffff, 0xffffffff );
|
||||
static PRInt64 ll_minint = LL_INIT( 0x80000000, 0x00000000 );
|
||||
static PRUint64 ll_maxuint = LL_INIT( 0xffffffff, 0xffffffff );
|
||||
static PRInt64 ll_zero = PR_INT64(0x0000000000000000);
|
||||
static PRInt64 ll_maxint = PR_INT64(0x7fffffffffffffff);
|
||||
static PRInt64 ll_minint = PR_INT64(0x8000000000000000);
|
||||
static PRUint64 ll_maxuint = PR_UINT64(0xffffffffffffffff);
|
||||
|
||||
PR_IMPLEMENT(PRInt64) LL_Zero(void) { return ll_zero; }
|
||||
PR_IMPLEMENT(PRInt64) LL_MaxInt(void) { return ll_maxint; }
|
||||
|
||||
@@ -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)
|
||||
@@ -1483,18 +1483,20 @@ PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val)
|
||||
if (val == PR_IpAddrAny) {
|
||||
if (_PR_IN6_IS_ADDR_UNSPECIFIED((PRIPv6Addr *)&addr->ipv6.ip)) {
|
||||
return PR_TRUE;
|
||||
} else if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
&& _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
== htonl(INADDR_ANY)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
&& _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
== htonl(INADDR_ANY)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
} else if (val == PR_IpAddrLoopback) {
|
||||
if (_PR_IN6_IS_ADDR_LOOPBACK((PRIPv6Addr *)&addr->ipv6.ip)) {
|
||||
return PR_TRUE;
|
||||
} else if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
&& _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
== htonl(INADDR_LOOPBACK)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (_PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
&& _PR_IN6_V4MAPPED_TO_IPADDR((PRIPv6Addr *)&addr->ipv6.ip)
|
||||
== htonl(INADDR_LOOPBACK)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
} else if (val == PR_IpAddrV4Mapped
|
||||
&& _PR_IN6_IS_ADDR_V4MAPPED((PRIPv6Addr *)&addr->ipv6.ip)) {
|
||||
@@ -1504,8 +1506,9 @@ PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val)
|
||||
if (addr->raw.family == AF_INET) {
|
||||
if (val == PR_IpAddrAny && addr->inet.ip == htonl(INADDR_ANY)) {
|
||||
return PR_TRUE;
|
||||
} else if (val == PR_IpAddrLoopback
|
||||
&& addr->inet.ip == htonl(INADDR_LOOPBACK)) {
|
||||
}
|
||||
if (val == PR_IpAddrLoopback
|
||||
&& addr->inet.ip == htonl(INADDR_LOOPBACK)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1777,18 +1780,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 +1794,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 */
|
||||
|
||||
|
||||
@@ -279,8 +279,7 @@ static int IsLeapYear(PRInt16 year)
|
||||
{
|
||||
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -495,6 +494,20 @@ PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params)
|
||||
|
||||
#define MT_safe_localtime localtime_r
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
||||
/* Visual C++ has had localtime_s() since Visual C++ 2005. */
|
||||
|
||||
static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
|
||||
{
|
||||
errno_t err = localtime_s(result, clock);
|
||||
if (err != 0) {
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define HAVE_LOCALTIME_MONITOR 1 /* We use 'monitor' to serialize our calls
|
||||
@@ -580,6 +593,7 @@ PR_LocalTimeParameters(const PRExplodedTime *gmt)
|
||||
|
||||
PRTimeParameters retVal;
|
||||
struct tm localTime;
|
||||
struct tm *localTimeResult;
|
||||
time_t secs;
|
||||
PRTime secs64;
|
||||
PRInt64 usecPerSec;
|
||||
@@ -606,7 +620,12 @@ PR_LocalTimeParameters(const PRExplodedTime *gmt)
|
||||
*/
|
||||
|
||||
secs = 86400L;
|
||||
(void) MT_safe_localtime(&secs, &localTime);
|
||||
localTimeResult = MT_safe_localtime(&secs, &localTime);
|
||||
PR_ASSERT(localTimeResult != NULL);
|
||||
if (localTimeResult == NULL) {
|
||||
/* Shouldn't happen. Use safe fallback for optimized builds. */
|
||||
return PR_GMTParameters(gmt);
|
||||
}
|
||||
|
||||
/* GMT is 00:00:00, 2nd of Jan. */
|
||||
|
||||
@@ -957,6 +976,7 @@ PR_ParseTimeStringToExplodedTime(
|
||||
int hour = -1;
|
||||
int min = -1;
|
||||
int sec = -1;
|
||||
struct tm *localTimeResult;
|
||||
|
||||
const char *rest = string;
|
||||
|
||||
@@ -1215,7 +1235,7 @@ PR_ParseTimeStringToExplodedTime(
|
||||
if ((end - rest) > 2)
|
||||
/* it is [0-9][0-9][0-9]+: */
|
||||
break;
|
||||
else if ((end - rest) == 2)
|
||||
if ((end - rest) == 2)
|
||||
tmp_hour = ((rest[0]-'0')*10 +
|
||||
(rest[1]-'0'));
|
||||
else
|
||||
@@ -1230,12 +1250,12 @@ PR_ParseTimeStringToExplodedTime(
|
||||
if (end == rest)
|
||||
/* no digits after first colon? */
|
||||
break;
|
||||
else if ((end - rest) > 2)
|
||||
if ((end - rest) > 2)
|
||||
/* it is [0-9][0-9][0-9]+: */
|
||||
break;
|
||||
else if ((end - rest) == 2)
|
||||
if ((end - rest) == 2)
|
||||
tmp_min = ((rest[0]-'0')*10 +
|
||||
(rest[1]-'0'));
|
||||
(rest[1]-'0'));
|
||||
else
|
||||
tmp_min = (rest[0]-'0');
|
||||
|
||||
@@ -1253,7 +1273,7 @@ PR_ParseTimeStringToExplodedTime(
|
||||
else if ((end - rest) > 2)
|
||||
/* it is [0-9][0-9][0-9]+: */
|
||||
break;
|
||||
else if ((end - rest) == 2)
|
||||
if ((end - rest) == 2)
|
||||
tmp_sec = ((rest[0]-'0')*10 +
|
||||
(rest[1]-'0'));
|
||||
else
|
||||
@@ -1287,7 +1307,7 @@ PR_ParseTimeStringToExplodedTime(
|
||||
rest = end;
|
||||
break;
|
||||
}
|
||||
else if ((*end == '/' || *end == '-') &&
|
||||
if ((*end == '/' || *end == '-') &&
|
||||
end[1] >= '0' && end[1] <= '9')
|
||||
{
|
||||
/* Perhaps this is 6/16/95, 16/6/95, 6-16-95, or 16-6-95
|
||||
@@ -1618,7 +1638,11 @@ PR_ParseTimeStringToExplodedTime(
|
||||
zone_offset for the date we are parsing is the same as
|
||||
the zone offset on 00:00:00 2 Jan 1970 GMT. */
|
||||
secs = 86400;
|
||||
(void) MT_safe_localtime(&secs, &localTime);
|
||||
localTimeResult = MT_safe_localtime(&secs, &localTime);
|
||||
PR_ASSERT(localTimeResult != NULL);
|
||||
if (localTimeResult == NULL) {
|
||||
return PR_FAILURE;
|
||||
}
|
||||
zone_offset = localTime.tm_min
|
||||
+ 60 * localTime.tm_hour
|
||||
+ 1440 * (localTime.tm_mday - 2);
|
||||
@@ -1989,24 +2013,22 @@ pr_WeekOfYear(const PRExplodedTime* time, unsigned int firstDayOfWeek)
|
||||
dayOfWeek = time->tm_wday - firstDayOfWeek;
|
||||
if (dayOfWeek < 0)
|
||||
dayOfWeek += 7;
|
||||
|
||||
dayOfYear = time->tm_yday - dayOfWeek;
|
||||
|
||||
dayOfYear = time->tm_yday - dayOfWeek;
|
||||
|
||||
if( dayOfYear <= 0 )
|
||||
{
|
||||
/* If dayOfYear is <= 0, it is in the first partial week of the year. */
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there
|
||||
* are any days left over ( dayOfYear % 7 ). Because we are only counting to
|
||||
* the first day of the week containing the given time, rather than to the
|
||||
* actual day representing the given time, any days in week 0 will be "absorbed"
|
||||
* as extra days in the given week.
|
||||
*/
|
||||
return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 );
|
||||
}
|
||||
|
||||
/* Count the number of full weeks ( dayOfYear / 7 ) then add a week if there
|
||||
* are any days left over ( dayOfYear % 7 ). Because we are only counting to
|
||||
* the first day of the week containing the given time, rather than to the
|
||||
* actual day representing the given time, any days in week 0 will be "absorbed"
|
||||
* as extra days in the given week.
|
||||
*/
|
||||
return (dayOfYear / 7) + ( (dayOfYear % 7) == 0 ? 0 : 1 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -862,16 +862,16 @@ PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod,
|
||||
if ((rv == PR_FAILURE) && ((err = PR_GetError()) == PR_IN_PROGRESS_ERROR)){
|
||||
/* connection pending */
|
||||
return(queue_io_job(tpool, iod, fn, arg, joinable, JOB_IO_CONNECT));
|
||||
} else {
|
||||
/*
|
||||
* connection succeeded or failed; add to jobq right away
|
||||
*/
|
||||
if (rv == PR_FAILURE)
|
||||
iod->error = err;
|
||||
else
|
||||
iod->error = 0;
|
||||
return(PR_QueueJob(tpool, fn, arg, joinable));
|
||||
}
|
||||
/*
|
||||
* connection succeeded or failed; add to jobq right away
|
||||
*/
|
||||
if (rv == PR_FAILURE)
|
||||
iod->error = err;
|
||||
else
|
||||
iod->error = 0;
|
||||
return(PR_QueueJob(tpool, fn, arg, joinable));
|
||||
|
||||
}
|
||||
|
||||
/* queue a job, when a timer expires */
|
||||
|
||||
@@ -74,6 +74,10 @@ static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
@@ -88,6 +92,9 @@ PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
#ifdef _PR_HAS_PRAGMA_DIAGNOSTIC
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
/* prvrsion.c */
|
||||
|
||||
|
||||
+174
-77
@@ -164,6 +164,9 @@ static ssize_t (*pt_aix_sendfile_fptr)() = NULL;
|
||||
#ifndef TCP_CORK
|
||||
#define TCP_CORK 3
|
||||
#endif
|
||||
#ifndef MSG_FASTOPEN
|
||||
#define MSG_FASTOPEN 0x20000000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _PR_IPV6_V6ONLY_PROBE
|
||||
@@ -821,7 +824,7 @@ retry:
|
||||
op->arg3.amount -= bytes; /* and reduce the required count */
|
||||
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
{
|
||||
op->result.code = -1;
|
||||
return PR_TRUE;
|
||||
@@ -850,7 +853,7 @@ static PRBool pt_write_cont(pt_Continuation *op, PRInt16 revents)
|
||||
op->arg3.amount -= bytes; /* and reduce the required count */
|
||||
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
{
|
||||
op->result.code = -1;
|
||||
return PR_TRUE;
|
||||
@@ -892,7 +895,7 @@ static PRBool pt_writev_cont(pt_Continuation *op, PRInt16 revents)
|
||||
op->arg3.amount -= iov_index; /* and array length */
|
||||
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
{
|
||||
op->result.code = -1;
|
||||
return PR_TRUE;
|
||||
@@ -915,7 +918,7 @@ static PRBool pt_sendto_cont(pt_Continuation *op, PRInt16 revents)
|
||||
op->arg3.amount -= bytes; /* and reduce the required count */
|
||||
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
|
||||
{
|
||||
op->result.code = -1;
|
||||
return PR_TRUE;
|
||||
@@ -1542,23 +1545,26 @@ static PRStatus pt_Connect(
|
||||
pt_SockLen addr_len;
|
||||
const PRNetAddr *addrp = addr;
|
||||
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
PRNetAddr addrCopy;
|
||||
#endif
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
#endif
|
||||
|
||||
if (pt_TestAbort()) return PR_FAILURE;
|
||||
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
addr_len = PR_NETADDR_SIZE(addr);
|
||||
#if defined(_PR_INET6)
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
md_af = AF_INET6;
|
||||
#ifndef _PR_HAVE_SOCKADDR_LEN
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#ifdef _PR_INET6
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
md_af = AF_INET6;
|
||||
#else
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
@@ -1732,9 +1738,11 @@ static PRStatus pt_Bind(PRFileDesc *fd, const PRNetAddr *addr)
|
||||
pt_SockLen addr_len;
|
||||
const PRNetAddr *addrp = addr;
|
||||
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
PRNetAddr addrCopy;
|
||||
#endif
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
#endif
|
||||
|
||||
if (pt_TestAbort()) return PR_FAILURE;
|
||||
|
||||
@@ -1749,15 +1757,16 @@ static PRStatus pt_Bind(PRFileDesc *fd, const PRNetAddr *addr)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_PR_INET6)
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
md_af = AF_INET6;
|
||||
#ifndef _PR_HAVE_SOCKADDR_LEN
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#ifdef _PR_INET6
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
md_af = AF_INET6;
|
||||
#else
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
addr_len = PR_NETADDR_SIZE(addr);
|
||||
@@ -1886,19 +1895,6 @@ static PRInt32 pt_Send(
|
||||
PRInt32 tmp_amount = amount;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Under HP-UX DCE threads, pthread.h includes dce/cma_ux.h,
|
||||
* which has the following:
|
||||
* # define send cma_send
|
||||
* extern int cma_send (int , void *, int, int );
|
||||
* So we need to cast away the 'const' of argument #2 for send().
|
||||
*/
|
||||
#if defined (HPUX) && defined(_PR_DCETHREADS)
|
||||
#define PT_SENDBUF_CAST (void *)
|
||||
#else
|
||||
#define PT_SENDBUF_CAST
|
||||
#endif
|
||||
|
||||
if (pt_TestAbort()) return bytes;
|
||||
|
||||
/*
|
||||
@@ -1909,9 +1905,9 @@ static PRInt32 pt_Send(
|
||||
#if defined(SOLARIS)
|
||||
PR_ASSERT(0 == flags);
|
||||
retry:
|
||||
bytes = write(fd->secret->md.osfd, PT_SENDBUF_CAST buf, tmp_amount);
|
||||
bytes = write(fd->secret->md.osfd, buf, tmp_amount);
|
||||
#else
|
||||
bytes = send(fd->secret->md.osfd, PT_SENDBUF_CAST buf, amount, flags);
|
||||
bytes = send(fd->secret->md.osfd, buf, amount, flags);
|
||||
#endif
|
||||
syserrno = errno;
|
||||
|
||||
@@ -1989,22 +1985,25 @@ static PRInt32 pt_SendTo(
|
||||
pt_SockLen addr_len;
|
||||
const PRNetAddr *addrp = addr;
|
||||
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
PRNetAddr addrCopy;
|
||||
#endif
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
#endif
|
||||
|
||||
if (pt_TestAbort()) return bytes;
|
||||
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
#if defined(_PR_INET6)
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
md_af = AF_INET6;
|
||||
#ifndef _PR_HAVE_SOCKADDR_LEN
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#ifdef _PR_INET6
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
md_af = AF_INET6;
|
||||
#else
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
addr_len = PR_NETADDR_SIZE(addr);
|
||||
@@ -2044,6 +2043,101 @@ static PRInt32 pt_SendTo(
|
||||
return bytes;
|
||||
} /* pt_SendTo */
|
||||
|
||||
#if defined(LINUX) || defined(DARWIN)
|
||||
/* Linux uses SendTo to send data during TCP Fast Open. OSX uses connectx, but
|
||||
* we will make it imitate the Linux's interface. */
|
||||
static PRInt32 pt_TCP_SendTo(
|
||||
PRFileDesc *fd, const void *buf,
|
||||
PRInt32 amount, PRIntn flags, const PRNetAddr *addr,
|
||||
PRIntervalTime timeout)
|
||||
{
|
||||
#if defined(LINUX) || HAS_CONNECTX
|
||||
PRInt32 syserrno, bytes = -1;
|
||||
PRBool fNeedContinue = PR_FALSE;
|
||||
pt_SockLen addr_len;
|
||||
const PRNetAddr *addrp = addr;
|
||||
#if defined(_PR_HAVE_SOCKADDR_LEN) || defined(_PR_INET6)
|
||||
PRNetAddr addrCopy;
|
||||
#endif
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
PRUint16 md_af = addr->raw.family;
|
||||
#endif
|
||||
|
||||
if (pt_TestAbort()) return bytes;
|
||||
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
addr_len = PR_NETADDR_SIZE(addr);
|
||||
#if defined(_PR_INET6)
|
||||
if (addr->raw.family == PR_AF_INET6) {
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
md_af = AF_INET6;
|
||||
#else
|
||||
/* If _PR_INET6 is defined and it is PR_AF_INET6 we set family
|
||||
* to AF_INET6. */
|
||||
addrCopy = *addr;
|
||||
addrCopy.raw.family = AF_INET6;
|
||||
addrp = &addrCopy;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
/* if _PR_HAVE_SOCKADDR_LEN is defined and it is PR_AF_INET6 we set family
|
||||
* to AF_INET6 and we set address length. */
|
||||
addrCopy = *addr;
|
||||
((struct sockaddr*)&addrCopy)->sa_len = addr_len;
|
||||
((struct sockaddr*)&addrCopy)->sa_family = md_af;
|
||||
addrp = &addrCopy;
|
||||
#endif
|
||||
|
||||
#ifndef HAS_CONNECTX
|
||||
bytes = sendto(
|
||||
fd->secret->md.osfd, buf, amount, MSG_FASTOPEN,
|
||||
(struct sockaddr*)addrp, addr_len);
|
||||
#else
|
||||
sa_endpoints_t endpoints;
|
||||
endpoints.sae_srcif = 0;
|
||||
endpoints.sae_srcaddr = NULL;
|
||||
endpoints.sae_srcaddrlen = 0;
|
||||
endpoints.sae_dstaddr = (struct sockaddr *)addrp;
|
||||
endpoints.sae_dstaddrlen = addr_len;
|
||||
struct iovec iov[1];
|
||||
iov[0].iov_base = buf;
|
||||
iov[0].iov_len = amount;
|
||||
PRInt32 rv = connectx(fd->secret->md.osfd, &endpoints, SAE_ASSOCID_ANY,
|
||||
CONNECT_DATA_IDEMPOTENT, iov, 1, &bytes, NULL);
|
||||
#endif
|
||||
syserrno = errno;
|
||||
if ( (bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN)
|
||||
&& (!fd->secret->nonblocking) ) {
|
||||
if (PR_INTERVAL_NO_WAIT == timeout) syserrno = ETIMEDOUT;
|
||||
else fNeedContinue = PR_TRUE;
|
||||
}
|
||||
if (fNeedContinue == PR_TRUE) {
|
||||
pt_Continuation op;
|
||||
op.arg1.osfd = fd->secret->md.osfd;
|
||||
op.arg2.buffer = (void*)buf;
|
||||
op.arg3.amount = amount;
|
||||
op.arg4.flags = flags;
|
||||
op.arg5.addr = (PRNetAddr*)addrp;
|
||||
op.timeout = timeout;
|
||||
op.result.code = 0; /* initialize the number sent */
|
||||
op.function = pt_sendto_cont;
|
||||
op.event = POLLOUT | POLLPRI;
|
||||
bytes = pt_Continue(&op);
|
||||
syserrno = op.syserrno;
|
||||
}
|
||||
if (bytes < 0) {
|
||||
pt_MapError(_PR_MD_MAP_SENDTO_ERROR, syserrno);
|
||||
}
|
||||
return bytes;
|
||||
#else /* !HAS_CONNECTX */
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
return -1;
|
||||
#endif
|
||||
} /* pt_TCP_SendTo */
|
||||
#endif /* LINUX || DARWIN */
|
||||
|
||||
static PRInt32 pt_RecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount,
|
||||
PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
|
||||
{
|
||||
@@ -2767,22 +2861,21 @@ static PRStatus pt_GetSockName(PRFileDesc *fd, PRNetAddr *addr)
|
||||
if (rv == -1) {
|
||||
pt_MapError(_PR_MD_MAP_GETSOCKNAME_ERROR, errno);
|
||||
return PR_FAILURE;
|
||||
} else {
|
||||
}
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
/* ignore the sa_len field of struct sockaddr */
|
||||
if (addr)
|
||||
{
|
||||
addr->raw.family = ((struct sockaddr*)addr)->sa_family;
|
||||
}
|
||||
/* ignore the sa_len field of struct sockaddr */
|
||||
if (addr)
|
||||
{
|
||||
addr->raw.family = ((struct sockaddr*)addr)->sa_family;
|
||||
}
|
||||
#endif /* _PR_HAVE_SOCKADDR_LEN */
|
||||
#ifdef _PR_INET6
|
||||
if (AF_INET6 == addr->raw.family)
|
||||
addr->raw.family = PR_AF_INET6;
|
||||
if (AF_INET6 == addr->raw.family)
|
||||
addr->raw.family = PR_AF_INET6;
|
||||
#endif
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);
|
||||
return PR_SUCCESS;
|
||||
} /* pt_GetSockName */
|
||||
|
||||
static PRStatus pt_GetPeerName(PRFileDesc *fd, PRNetAddr *addr)
|
||||
@@ -2798,22 +2891,21 @@ static PRStatus pt_GetPeerName(PRFileDesc *fd, PRNetAddr *addr)
|
||||
if (rv == -1) {
|
||||
pt_MapError(_PR_MD_MAP_GETPEERNAME_ERROR, errno);
|
||||
return PR_FAILURE;
|
||||
} else {
|
||||
}
|
||||
#ifdef _PR_HAVE_SOCKADDR_LEN
|
||||
/* ignore the sa_len field of struct sockaddr */
|
||||
if (addr)
|
||||
{
|
||||
addr->raw.family = ((struct sockaddr*)addr)->sa_family;
|
||||
}
|
||||
/* ignore the sa_len field of struct sockaddr */
|
||||
if (addr)
|
||||
{
|
||||
addr->raw.family = ((struct sockaddr*)addr)->sa_family;
|
||||
}
|
||||
#endif /* _PR_HAVE_SOCKADDR_LEN */
|
||||
#ifdef _PR_INET6
|
||||
if (AF_INET6 == addr->raw.family)
|
||||
addr->raw.family = PR_AF_INET6;
|
||||
if (AF_INET6 == addr->raw.family)
|
||||
addr->raw.family = PR_AF_INET6;
|
||||
#endif
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
PR_ASSERT(IsValidNetAddr(addr) == PR_TRUE);
|
||||
PR_ASSERT(IsValidNetAddrLen(addr, addr_len) == PR_TRUE);
|
||||
return PR_SUCCESS;
|
||||
} /* pt_GetPeerName */
|
||||
|
||||
static PRStatus pt_GetSocketOption(PRFileDesc *fd, PRSocketOptionData *data)
|
||||
@@ -3155,7 +3247,11 @@ static PRIOMethods _pr_tcp_methods = {
|
||||
pt_Recv,
|
||||
pt_Send,
|
||||
(PRRecvfromFN)_PR_InvalidInt,
|
||||
#if defined(LINUX) || defined(DARWIN)
|
||||
pt_TCP_SendTo, /* This is for TCP Fast Open. Linux uses SendTo function for this. OSX uses connectx, but we imitate Linux. */
|
||||
#else
|
||||
(PRSendtoFN)_PR_InvalidInt,
|
||||
#endif
|
||||
pt_Poll,
|
||||
pt_AcceptRead,
|
||||
pt_TransmitFile,
|
||||
@@ -3602,8 +3698,8 @@ PR_IMPLEMENT(PRStatus) PR_Delete(const char *name)
|
||||
if (rv == -1) {
|
||||
pt_MapError(_PR_MD_MAP_UNLINK_ERROR, errno);
|
||||
return PR_FAILURE;
|
||||
} else
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
return PR_SUCCESS;
|
||||
} /* PR_Delete */
|
||||
|
||||
PR_IMPLEMENT(PRStatus) PR_Access(const char *name, PRAccessHow how)
|
||||
@@ -3727,11 +3823,10 @@ PR_IMPLEMENT(PRStatus) PR_RmDir(const char *name)
|
||||
|
||||
rv = rmdir(name);
|
||||
if (0 == rv) {
|
||||
return PR_SUCCESS;
|
||||
} else {
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
pt_MapError(_PR_MD_MAP_RMDIR_ERROR, errno);
|
||||
return PR_FAILURE;
|
||||
}
|
||||
} /* PR_Rmdir */
|
||||
|
||||
|
||||
@@ -3847,7 +3942,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 +4201,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))
|
||||
|
||||
@@ -23,11 +23,6 @@ static pthread_condattr_t _pt_cvar_attr;
|
||||
|
||||
#if defined(DEBUG)
|
||||
extern PTDebug pt_debug; /* this is shared between several modules */
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
static pthread_t pt_zero_tid; /* a null pthread_t (pthread_t is a struct
|
||||
* in DCE threads) to compare with */
|
||||
#endif /* defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(DEBUG) */
|
||||
|
||||
#if defined(FREEBSD)
|
||||
@@ -55,11 +50,10 @@ void _PR_InitLocks(void)
|
||||
rv = _PT_PTHREAD_MUTEXATTR_INIT(&_pt_mattr);
|
||||
PR_ASSERT(0 == rv);
|
||||
|
||||
#ifdef LINUX
|
||||
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
|
||||
#if (defined(LINUX) && (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
|
||||
(defined(FREEBSD) && __FreeBSD_version > 700055)
|
||||
rv = pthread_mutexattr_settype(&_pt_mattr, PTHREAD_MUTEX_ADAPTIVE_NP);
|
||||
PR_ASSERT(0 == rv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
rv = _PT_PTHREAD_CONDATTR_INIT(&_pt_cvar_attr);
|
||||
@@ -264,12 +258,7 @@ static PRIntn pt_TimedWait(
|
||||
rv = pthread_cond_timedwait(cv, ml, &tmo);
|
||||
|
||||
/* NSPR doesn't report timeouts */
|
||||
#ifdef _PR_DCETHREADS
|
||||
if (rv == -1) return (errno == EAGAIN) ? 0 : errno;
|
||||
else return rv;
|
||||
#else
|
||||
return (rv == ETIMEDOUT) ? 0 : rv;
|
||||
#endif
|
||||
} /* pt_TimedWait */
|
||||
|
||||
|
||||
@@ -1172,14 +1161,14 @@ PR_IMPLEMENT(PRStatus) PR_DeleteSemaphore(const char *name)
|
||||
PR_IMPLEMENT(PRStatus) PRP_TryLock(PRLock *lock)
|
||||
{
|
||||
PRIntn rv = pthread_mutex_trylock(&lock->mutex);
|
||||
if (rv == PT_TRYLOCK_SUCCESS)
|
||||
if (rv == 0)
|
||||
{
|
||||
PR_ASSERT(PR_FALSE == lock->locked);
|
||||
lock->locked = PR_TRUE;
|
||||
lock->owner = pthread_self();
|
||||
}
|
||||
/* XXX set error code? */
|
||||
return (PT_TRYLOCK_SUCCESS == rv) ? PR_SUCCESS : PR_FAILURE;
|
||||
return (0 == rv) ? PR_SUCCESS : PR_FAILURE;
|
||||
} /* PRP_TryLock */
|
||||
|
||||
PR_IMPLEMENT(PRCondVar*) PRP_NewNakedCondVar(void)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
** Exports: ptthread.h
|
||||
*/
|
||||
|
||||
#if defined(_PR_PTHREADS) || defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
|
||||
#include "prlog.h"
|
||||
#include "primpl.h"
|
||||
@@ -58,7 +58,7 @@ static struct _PT_Bookeeping
|
||||
pthread_key_t key; /* thread private data key */
|
||||
PRBool keyCreated; /* whether 'key' should be deleted */
|
||||
PRThread *first, *last; /* list of threads we know about */
|
||||
#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
PRInt32 minPrio, maxPrio; /* range of scheduling priorities */
|
||||
#endif
|
||||
} pt_book = {0};
|
||||
@@ -67,7 +67,7 @@ static void _pt_thread_death(void *arg);
|
||||
static void _pt_thread_death_internal(void *arg, PRBool callDestructors);
|
||||
static void init_pthread_gc_support(void);
|
||||
|
||||
#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
static PRIntn pt_PriorityMap(PRThreadPriority pri)
|
||||
{
|
||||
#ifdef NTO
|
||||
@@ -148,21 +148,6 @@ static void *_pt_root(void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** DCE Threads can't detach during creation, so do it late.
|
||||
** I would like to do it only here, but that doesn't seem
|
||||
** to work.
|
||||
*/
|
||||
#if defined(_PR_DCETHREADS)
|
||||
if (detached)
|
||||
{
|
||||
/* pthread_detach() modifies its argument, so we must pass a copy */
|
||||
pthread_t self = id;
|
||||
rv = pthread_detach(&self);
|
||||
PR_ASSERT(0 == rv);
|
||||
}
|
||||
#endif /* defined(_PR_DCETHREADS) */
|
||||
|
||||
/* Set up the thread stack information */
|
||||
_PR_InitializeStack(thred->stack);
|
||||
|
||||
@@ -329,7 +314,7 @@ static PRThread* _PR_CreateThread(
|
||||
|
||||
if (EPERM != pt_schedpriv)
|
||||
{
|
||||
#if !defined(_PR_DCETHREADS) && _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
struct sched_param schedule;
|
||||
#endif
|
||||
|
||||
@@ -340,10 +325,7 @@ static PRThread* _PR_CreateThread(
|
||||
|
||||
/* Use the default scheduling policy */
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
rv = pthread_attr_setprio(&tattr, pt_PriorityMap(priority));
|
||||
PR_ASSERT(0 == rv);
|
||||
#elif _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
rv = pthread_attr_getschedparam(&tattr, &schedule);
|
||||
PR_ASSERT(0 == rv);
|
||||
schedule.sched_priority = pt_PriorityMap(priority);
|
||||
@@ -353,19 +335,13 @@ static PRThread* _PR_CreateThread(
|
||||
rv = pthread_attr_setschedpolicy(&tattr, SCHED_RR); /* Round Robin */
|
||||
PR_ASSERT(0 == rv);
|
||||
#endif
|
||||
#endif /* !defined(_PR_DCETHREADS) */
|
||||
#endif /* _POSIX_THREAD_PRIORITY_SCHEDULING > 0 */
|
||||
}
|
||||
|
||||
/*
|
||||
* DCE threads can't set detach state before creating the thread.
|
||||
* AIX can't set detach late. Why can't we all just get along?
|
||||
*/
|
||||
#if !defined(_PR_DCETHREADS)
|
||||
rv = pthread_attr_setdetachstate(&tattr,
|
||||
((PR_JOINABLE_THREAD == state) ?
|
||||
PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
|
||||
PR_ASSERT(0 == rv);
|
||||
#endif /* !defined(_PR_DCETHREADS) */
|
||||
|
||||
/*
|
||||
* If stackSize is 0, we use the default pthread stack size.
|
||||
@@ -456,7 +432,6 @@ static PRThread* _PR_CreateThread(
|
||||
*/
|
||||
rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);
|
||||
|
||||
#if !defined(_PR_DCETHREADS)
|
||||
if (EPERM == rv)
|
||||
{
|
||||
#if defined(IRIX)
|
||||
@@ -482,15 +457,10 @@ static PRThread* _PR_CreateThread(
|
||||
#endif /* IRIX */
|
||||
rv = _PT_PTHREAD_CREATE(&id, tattr, _pt_root, thred);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (0 != rv)
|
||||
{
|
||||
#if defined(_PR_DCETHREADS)
|
||||
PRIntn oserr = errno;
|
||||
#else
|
||||
PRIntn oserr = rv;
|
||||
#endif
|
||||
PR_Lock(pt_book.ml);
|
||||
if (thred->state & PT_THREAD_SYSTEM)
|
||||
pt_book.system -= 1;
|
||||
@@ -602,10 +572,6 @@ PR_IMPLEMENT(PRStatus) PR_JoinThread(PRThread *thred)
|
||||
PR_ASSERT(rv == 0 && result == NULL);
|
||||
if (0 == rv)
|
||||
{
|
||||
#ifdef _PR_DCETHREADS
|
||||
rv = pthread_detach(&id);
|
||||
PR_ASSERT(0 == rv);
|
||||
#endif
|
||||
/*
|
||||
* PR_FALSE, because the thread already called the TPD
|
||||
* destructors before exiting _pt_root.
|
||||
@@ -693,10 +659,7 @@ PR_IMPLEMENT(void) PR_SetThreadPriority(PRThread *thred, PRThreadPriority newPri
|
||||
else if ((PRIntn)PR_PRIORITY_LAST < (PRIntn)newPri)
|
||||
newPri = PR_PRIORITY_LAST;
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
rv = pthread_setprio(thred->id, pt_PriorityMap(newPri));
|
||||
/* pthread_setprio returns the old priority */
|
||||
#elif _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
if (EPERM != pt_schedpriv)
|
||||
{
|
||||
int policy;
|
||||
@@ -927,7 +890,7 @@ void _PR_InitThreads(
|
||||
pthread_init();
|
||||
#endif
|
||||
|
||||
#if defined(_PR_DCETHREADS) || _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
|
||||
#if defined(FREEBSD)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
@@ -1015,7 +978,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
|
||||
@@ -1161,11 +1140,7 @@ PR_IMPLEMENT(void) PR_ProcessExit(PRIntn status)
|
||||
|
||||
PR_IMPLEMENT(PRUint32) PR_GetThreadID(PRThread *thred)
|
||||
{
|
||||
#if defined(_PR_DCETHREADS)
|
||||
return (PRUint32)&thred->id; /* this is really a sham! */
|
||||
#else
|
||||
return (PRUint32)thred->id; /* and I don't know what they will do with it */
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1197,18 +1172,6 @@ PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void *arg)
|
||||
* Garbage collection support follows.
|
||||
*/
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
|
||||
/*
|
||||
* statics for Garbage Collection support. We don't need to protect these
|
||||
* signal masks since the garbage collector itself is protected by a lock
|
||||
* and multiple threads will not be garbage collecting at the same time.
|
||||
*/
|
||||
static sigset_t javagc_vtalarm_sigmask;
|
||||
static sigset_t javagc_intsoff_sigmask;
|
||||
|
||||
#else /* defined(_PR_DCETHREADS) */
|
||||
|
||||
/* a bogus signal mask for forcing a timed wait */
|
||||
/* Not so bogus in AIX as we really do a sigwait */
|
||||
static sigset_t sigwait_set;
|
||||
@@ -1224,8 +1187,6 @@ static void suspend_signal_handler(PRIntn sig);
|
||||
static void null_signal_handler(PRIntn sig);
|
||||
#endif
|
||||
|
||||
#endif /* defined(_PR_DCETHREADS) */
|
||||
|
||||
/*
|
||||
* Linux pthreads use SIGUSR1 and SIGUSR2 internally, which
|
||||
* conflict with the use of these two signals in our GC support.
|
||||
@@ -1236,12 +1197,6 @@ static void init_pthread_gc_support(void)
|
||||
#ifndef SYMBIAN
|
||||
PRIntn rv;
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
rv = sigemptyset(&javagc_vtalarm_sigmask);
|
||||
PR_ASSERT(0 == rv);
|
||||
rv = sigaddset(&javagc_vtalarm_sigmask, SIGVTALRM);
|
||||
PR_ASSERT(0 == rv);
|
||||
#else /* defined(_PR_DCETHREADS) */
|
||||
{
|
||||
struct sigaction sigact_usr2;
|
||||
|
||||
@@ -1269,7 +1224,6 @@ static void init_pthread_gc_support(void)
|
||||
PR_ASSERT(0 ==rv);
|
||||
}
|
||||
#endif /* defined(PT_NO_SIGTIMEDWAIT) */
|
||||
#endif /* defined(_PR_DCETHREADS) */
|
||||
#endif /* SYMBIAN */
|
||||
}
|
||||
|
||||
@@ -1300,9 +1254,7 @@ PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg)
|
||||
PRThread* thred = pt_book.first;
|
||||
|
||||
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
|
||||
#if !defined(_PR_DCETHREADS)
|
||||
PRThread *me = PR_GetCurrentThread();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("Begin PR_EnumerateThreads\n"));
|
||||
@@ -1331,9 +1283,7 @@ PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg)
|
||||
|
||||
if (_PT_IS_GCABLE_THREAD(thred))
|
||||
{
|
||||
#if !defined(_PR_DCETHREADS)
|
||||
PR_ASSERT((thred == me) || (thred->suspend & PT_THREAD_SUSPENDED));
|
||||
#endif
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS,
|
||||
("In PR_EnumerateThreads callback thread %p thid = %X\n",
|
||||
thred, thred->id));
|
||||
@@ -1361,8 +1311,6 @@ PR_IMPLEMENT(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg)
|
||||
* proceed until the thread is suspended or resumed.
|
||||
*/
|
||||
|
||||
#if !defined(_PR_DCETHREADS)
|
||||
|
||||
/*
|
||||
* In the signal handler, we can not use condition variable notify or wait.
|
||||
* This does not work consistently across all pthread platforms. We also can not
|
||||
@@ -1661,78 +1609,6 @@ PR_IMPLEMENT(void *)PR_GetSP(PRThread *thred)
|
||||
return thred->sp;
|
||||
} /* PR_GetSP */
|
||||
|
||||
#else /* !defined(_PR_DCETHREADS) */
|
||||
|
||||
static pthread_once_t pt_gc_support_control = pthread_once_init;
|
||||
|
||||
/*
|
||||
* For DCE threads, there is no pthread_kill or a way of suspending or resuming a
|
||||
* particular thread. We will just disable the preemption (virtual timer alarm) and
|
||||
* let the executing thread finish the garbage collection. This stops all other threads
|
||||
* (GC able or not) and is very inefficient but there is no other choice.
|
||||
*/
|
||||
PR_IMPLEMENT(void) PR_SuspendAll()
|
||||
{
|
||||
PRIntn rv;
|
||||
|
||||
rv = pthread_once(&pt_gc_support_control, init_pthread_gc_support);
|
||||
PR_ASSERT(0 == rv); /* returns -1 on failure */
|
||||
#ifdef DEBUG
|
||||
suspendAllOn = PR_TRUE;
|
||||
#endif
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("Begin PR_SuspendAll\n"));
|
||||
/*
|
||||
* turn off preemption - i.e add virtual alarm signal to the set of
|
||||
* blocking signals
|
||||
*/
|
||||
rv = sigprocmask(
|
||||
SIG_BLOCK, &javagc_vtalarm_sigmask, &javagc_intsoff_sigmask);
|
||||
PR_ASSERT(0 == rv);
|
||||
suspendAllSuspended = PR_TRUE;
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("End PR_SuspendAll\n"));
|
||||
} /* PR_SuspendAll */
|
||||
|
||||
PR_IMPLEMENT(void) PR_ResumeAll()
|
||||
{
|
||||
PRIntn rv;
|
||||
|
||||
suspendAllSuspended = PR_FALSE;
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("Begin PR_ResumeAll\n"));
|
||||
/* turn on preemption - i.e re-enable virtual alarm signal */
|
||||
|
||||
rv = sigprocmask(SIG_SETMASK, &javagc_intsoff_sigmask, (sigset_t *)NULL);
|
||||
PR_ASSERT(0 == rv);
|
||||
#ifdef DEBUG
|
||||
suspendAllOn = PR_FALSE;
|
||||
#endif
|
||||
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("End PR_ResumeAll\n"));
|
||||
} /* PR_ResumeAll */
|
||||
|
||||
/* Return the stack pointer for the given thread- used by the GC */
|
||||
PR_IMPLEMENT(void*)PR_GetSP(PRThread *thred)
|
||||
{
|
||||
pthread_t tid = thred->id;
|
||||
char *thread_tcb, *top_sp;
|
||||
|
||||
/*
|
||||
* For HPUX DCE threads, pthread_t is a struct with the
|
||||
* following three fields (see pthread.h, dce/cma.h):
|
||||
* cma_t_address field1;
|
||||
* short int field2;
|
||||
* short int field3;
|
||||
* where cma_t_address is typedef'd to be either void*
|
||||
* or char*.
|
||||
*/
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("Begin PR_GetSP\n"));
|
||||
thread_tcb = (char*)tid.field1;
|
||||
top_sp = *(char**)(thread_tcb + 128);
|
||||
PR_LOG(_pr_gc_lm, PR_LOG_ALWAYS, ("End PR_GetSP %p \n", top_sp));
|
||||
return top_sp;
|
||||
} /* PR_GetSP */
|
||||
|
||||
#endif /* !defined(_PR_DCETHREADS) */
|
||||
|
||||
PR_IMPLEMENT(PRStatus) PR_SetCurrentThreadName(const char *name)
|
||||
{
|
||||
PRThread *thread;
|
||||
@@ -1817,6 +1693,6 @@ PR_IMPLEMENT(const char *) PR_GetThreadName(const PRThread *thread)
|
||||
return thread->name;
|
||||
}
|
||||
|
||||
#endif /* defined(_PR_PTHREADS) || defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
|
||||
/* ptthread.c */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HPUX) && defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(HPUX) && defined(_PR_PTHREADS)
|
||||
|
||||
#include <pthread.h>
|
||||
#define HAVE_UNIX98_RWLOCK
|
||||
|
||||
@@ -373,9 +373,6 @@ endif
|
||||
ifeq (,$(filter-out FreeBSD OpenBSD BSD_OS QNX Darwin OpenUNIX,$(OS_ARCH)))
|
||||
LIBPTHREAD =
|
||||
endif
|
||||
ifeq ($(OS_ARCH)$(basename $(OS_RELEASE)),HP-UXB.10)
|
||||
LIBPTHREAD = -ldce
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_TARGET),Android)
|
||||
|
||||
@@ -143,12 +143,13 @@ ClientThread(void *_action)
|
||||
if (action != CLIENT_TIMEOUT_SEND) {
|
||||
if ((rv = PR_Send(sock, buf, CLIENT_DATA,
|
||||
0, timeoutTime))< 0) {
|
||||
if (!debug_mode)
|
||||
if (!debug_mode) {
|
||||
failed_already=1;
|
||||
else
|
||||
PR_fprintf(output,
|
||||
} else {
|
||||
PR_fprintf(output,
|
||||
"client: unable to send to server (%d, %ld, %ld)\n",
|
||||
CLIENT_DATA, rv, PR_GetError());
|
||||
}
|
||||
goto ErrorExit;
|
||||
}
|
||||
} else {
|
||||
@@ -200,8 +201,9 @@ int i;
|
||||
continue;
|
||||
}
|
||||
failed_already=1;
|
||||
if (debug_mode)
|
||||
if (debug_mode) {
|
||||
PR_fprintf(output,"accept: ERROR - PR_Bind failed\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -411,15 +411,15 @@ static PRUint32 TimeThis(
|
||||
PRUint32 overhead, usecs;
|
||||
PRIntervalTime predicted, timein, timeout, ticks;
|
||||
|
||||
if (debug_mode)
|
||||
printf("Testing %s ...", msg);
|
||||
if (debug_mode)
|
||||
printf("Testing %s ...", msg);
|
||||
|
||||
timein = PR_IntervalNow();
|
||||
predicted = func(loops);
|
||||
timeout = PR_IntervalNow();
|
||||
|
||||
if (debug_mode)
|
||||
printf(" done\n");
|
||||
if (debug_mode)
|
||||
printf(" done\n");
|
||||
|
||||
ticks = timeout - timein;
|
||||
usecs = PR_IntervalToMicroseconds(ticks);
|
||||
@@ -491,17 +491,17 @@ int prmain(int argc, char** argv)
|
||||
|
||||
for (cpu = 1; cpu <= cpus; ++cpu)
|
||||
{
|
||||
if (debug_mode)
|
||||
if (debug_mode)
|
||||
printf("\nAlarm: Using %d CPU(s)\n", cpu);
|
||||
|
||||
PR_SetConcurrency(cpu);
|
||||
|
||||
/* some basic time test */
|
||||
(void)TimeThis("ConditionNotify", ConditionNotify, loops);
|
||||
(void)TimeThis("ConditionTimeout", ConditionTimeout, loops);
|
||||
(void)TimeThis("Alarms1", Alarms1, loops);
|
||||
(void)TimeThis("Alarms2", Alarms2, loops);
|
||||
(void)TimeThis("Alarms3", Alarms3, loops);
|
||||
PR_SetConcurrency(cpu);
|
||||
|
||||
/* some basic time test */
|
||||
(void)TimeThis("ConditionNotify", ConditionNotify, loops);
|
||||
(void)TimeThis("ConditionTimeout", ConditionTimeout, loops);
|
||||
(void)TimeThis("Alarms1", Alarms1, loops);
|
||||
(void)TimeThis("Alarms2", Alarms2, loops);
|
||||
(void)TimeThis("Alarms3", Alarms3, loops);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -111,16 +111,6 @@ static int32 threadStartFunc(void *arg)
|
||||
static void * threadStartFunc(void *arg)
|
||||
#endif
|
||||
{
|
||||
#ifdef _PR_DCETHREADS
|
||||
{
|
||||
int rv;
|
||||
pthread_t self = pthread_self();
|
||||
rv = pthread_detach(&self);
|
||||
if (debug_mode) PR_ASSERT(0 == rv);
|
||||
else if (0 != rv) failed_already=1;
|
||||
}
|
||||
#endif
|
||||
|
||||
Measure(AttachDetach, "Attach/Detach");
|
||||
|
||||
#ifndef IRIX
|
||||
@@ -206,14 +196,12 @@ int main(int argc, char **argv)
|
||||
goto exit_now;
|
||||
}
|
||||
|
||||
#ifndef _PR_DCETHREADS
|
||||
rv = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
if (debug_mode) PR_ASSERT(0 == rv);
|
||||
else if (0 != rv) {
|
||||
failed_already=1;
|
||||
goto exit_now;
|
||||
}
|
||||
#endif /* !_PR_DCETHREADS */
|
||||
rv = _PT_PTHREAD_CREATE(&threadID, attr, threadStartFunc, NULL);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "thread creation failed: error code %d\n", rv);
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
|
||||
PRIntn failed_already=0;
|
||||
PRIntn debug_mode=0;
|
||||
|
||||
@@ -80,20 +78,13 @@ static PRIntn prmain(PRIntn argc, char **argv)
|
||||
|
||||
} /* prmain */
|
||||
|
||||
#endif /* #if defined(_PR_DCETHREADS) */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
#if defined(_PR_DCETHREADS)
|
||||
PR_Initialize(prmain, argc, argv, 0);
|
||||
if(failed_already)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
} /* main */
|
||||
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ static int _debug_on = 0;
|
||||
|
||||
#define DPRINTF(arg) if (_debug_on) PR_fprintf arg
|
||||
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#include "md/_pth.h"
|
||||
static void *pthread_start(void *arg)
|
||||
@@ -63,7 +63,7 @@ static void *pthread_start(void *arg)
|
||||
start(data);
|
||||
return NULL;
|
||||
} /* pthread_start */
|
||||
#endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
|
||||
#if defined(IRIX) && !defined(_PR_PTHREADS)
|
||||
#include <sys/types.h>
|
||||
@@ -109,7 +109,7 @@ static PRStatus NSPRPUB_TESTS_CreateThread(StartFn start, void *arg)
|
||||
}
|
||||
break;
|
||||
case thread_pthread:
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
{
|
||||
int rv;
|
||||
pthread_t id;
|
||||
@@ -137,7 +137,7 @@ static PRStatus NSPRPUB_TESTS_CreateThread(StartFn start, void *arg)
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
rv = PR_FAILURE;
|
||||
break;
|
||||
#endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
|
||||
case thread_sproc:
|
||||
#if defined(IRIX) && !defined(_PR_PTHREADS)
|
||||
|
||||
@@ -196,51 +196,6 @@ finish:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _PR_DCETHREADS
|
||||
|
||||
#include <syscall.h>
|
||||
|
||||
pid_t PR_UnixFork1(void)
|
||||
{
|
||||
pid_t parent = getpid();
|
||||
int rv = syscall(SYS_fork);
|
||||
|
||||
if (rv == -1) {
|
||||
return (pid_t) -1;
|
||||
} else {
|
||||
/* For each process, rv is the pid of the other process */
|
||||
if (rv == parent) {
|
||||
/* the child */
|
||||
return 0;
|
||||
} else {
|
||||
/* the parent */
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(SOLARIS)
|
||||
|
||||
/*
|
||||
* It seems like that in Solaris 2.4 one must call fork1() if the
|
||||
* the child process is going to use thread functions. Solaris 2.5
|
||||
* doesn't have this problem. Calling fork() also works.
|
||||
*/
|
||||
|
||||
pid_t PR_UnixFork1(void)
|
||||
{
|
||||
return fork1();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
pid_t PR_UnixFork1(void)
|
||||
{
|
||||
return fork();
|
||||
}
|
||||
|
||||
#endif /* PR_DCETHREADS */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
@@ -250,7 +205,7 @@ int main(int argc, char **argv)
|
||||
|
||||
DoIO();
|
||||
|
||||
pid = PR_UnixFork1();
|
||||
pid = fork();
|
||||
|
||||
if (pid == (pid_t) -1) {
|
||||
fprintf(stderr, "Fork failed: errno %d\n", errno);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
||||
@@ -606,7 +606,7 @@ typedef struct StartObject
|
||||
void *arg;
|
||||
} StartObject;
|
||||
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include "md/_pth.h"
|
||||
#include <pthread.h>
|
||||
|
||||
@@ -619,7 +619,7 @@ static void *pthread_start(void *arg)
|
||||
start(data);
|
||||
return NULL;
|
||||
} /* pthread_start */
|
||||
#endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
|
||||
#if defined(IRIX) && !defined(_PR_PTHREADS)
|
||||
#include <sys/types.h>
|
||||
@@ -657,10 +657,10 @@ static PRStatus JoinThread(PRThread *thread)
|
||||
rv = PR_JoinThread(thread);
|
||||
break;
|
||||
case thread_pthread:
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
rv = PR_SUCCESS;
|
||||
break;
|
||||
#endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
case thread_win32:
|
||||
#if defined(WIN32)
|
||||
rv = PR_SUCCESS;
|
||||
@@ -690,7 +690,7 @@ static PRStatus NewThread(
|
||||
}
|
||||
break;
|
||||
case thread_pthread:
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
{
|
||||
int rv;
|
||||
pthread_t id;
|
||||
@@ -717,7 +717,7 @@ static PRStatus NewThread(
|
||||
#else
|
||||
PR_SetError(PR_NOT_IMPLEMENTED_ERROR, 0);
|
||||
rv = PR_FAILURE;
|
||||
#endif /* defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS) */
|
||||
#endif /* defined(_PR_PTHREADS) */
|
||||
break;
|
||||
|
||||
case thread_sproc:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
@@ -313,7 +313,7 @@ PRThread* create_new_thread(PRThreadType type,
|
||||
PRInt32 native_thread = 0;
|
||||
|
||||
PR_ASSERT(state == PR_UNJOINABLE_THREAD);
|
||||
#if (defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)) || defined(WIN32)
|
||||
#if defined(_PR_PTHREADS) || defined(WIN32)
|
||||
switch(index % 4) {
|
||||
case 0:
|
||||
scope = (PR_LOCAL_THREAD);
|
||||
@@ -332,7 +332,7 @@ PRInt32 native_thread = 0;
|
||||
break;
|
||||
}
|
||||
if (native_thread) {
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
pthread_t tid;
|
||||
if (!pthread_create(&tid, NULL, (void * (*)(void *)) start, arg))
|
||||
return((PRThread *) tid);
|
||||
|
||||
@@ -43,8 +43,8 @@ int main(int argc, char **argv)
|
||||
"PR_SockOpt_Linger", /* linger on close if data present */
|
||||
"PR_SockOpt_Reuseaddr", /* allow local address reuse */
|
||||
"PR_SockOpt_Keepalive", /* keep connections alive */
|
||||
"PR_SockOpt_RecvBufferSize", /* send buffer size */
|
||||
"PR_SockOpt_SendBufferSize", /* receive buffer size */
|
||||
"PR_SockOpt_RecvBufferSize", /* receive buffer size */
|
||||
"PR_SockOpt_SendBufferSize", /* send buffer size */
|
||||
|
||||
"PR_SockOpt_IpTimeToLive", /* time to live */
|
||||
"PR_SockOpt_IpTypeOfService", /* type of service and precedence */
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#endif
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#ifdef SYMBIAN
|
||||
@@ -104,7 +104,7 @@ PRInt32 native_thread = 0;
|
||||
|
||||
PR_ASSERT(state == PR_UNJOINABLE_THREAD);
|
||||
|
||||
#if (defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)) || defined(WIN32) || defined(XP_OS2)
|
||||
#if defined(_PR_PTHREADS) || defined(WIN32) || defined(XP_OS2)
|
||||
|
||||
switch(index % 4) {
|
||||
case 0:
|
||||
@@ -124,7 +124,7 @@ PRInt32 native_thread = 0;
|
||||
break;
|
||||
}
|
||||
if (native_thread) {
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
pthread_t tid;
|
||||
if (!pthread_create(&tid, NULL, start, arg))
|
||||
return((PRThread *) tid);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
|
||||
#if defined(_PR_PTHREADS)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ 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.10.10", "4.11", "4.12", "4.13", "4.14", "4.15",
|
||||
"4.16", "4.17", "4.18",
|
||||
PR_VERSION
|
||||
};
|
||||
|
||||
@@ -55,8 +56,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.11.1",
|
||||
"4.12.1",
|
||||
"4.19.1",
|
||||
"4.20", "4.20.1",
|
||||
"10.0", "11.1", "12.14.20"
|
||||
};
|
||||
|
||||
|
||||
@@ -3,3 +3,19 @@
|
||||
*OPT.OBJ/
|
||||
*DBG.OBJ/
|
||||
*DBG.OBJD/
|
||||
out/*
|
||||
*.pyc
|
||||
*.bak
|
||||
*.out
|
||||
*.rej
|
||||
*.patch
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
#*
|
||||
.#*
|
||||
.ycm_extra_conf.py*
|
||||
fuzz/libFuzzer/*
|
||||
fuzz/corpus
|
||||
fuzz/out
|
||||
.chk
|
||||
|
||||
+30
-4
@@ -27,7 +27,8 @@ include $(CORE_DEPTH)/coreconf/config.mk
|
||||
#######################################################################
|
||||
|
||||
ifdef NSS_DISABLE_GTESTS
|
||||
DIRS := $(filter-out external_tests,$(DIRS))
|
||||
DIRS := $(filter-out gtests,$(DIRS))
|
||||
DIRS := $(filter-out cpputil,$(DIRS))
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
@@ -46,7 +47,7 @@ include $(CORE_DEPTH)/coreconf/rules.mk
|
||||
# (7) Execute "local" rules. (OPTIONAL). #
|
||||
#######################################################################
|
||||
|
||||
nss_build_all: build_nspr all
|
||||
nss_build_all: build_nspr all latest
|
||||
|
||||
nss_clean_all: clobber_nspr clobber
|
||||
|
||||
@@ -83,8 +84,18 @@ ifdef USE_STATIC_RTL
|
||||
NSPR_CONFIGURE_OPTS += --enable-static-rtl
|
||||
endif
|
||||
ifdef NS_USE_GCC
|
||||
NSPR_COMPILERS = CC=gcc CXX=g++
|
||||
NSPR_CONFIGURE_ENV = CC=gcc CXX=g++
|
||||
endif
|
||||
ifdef CC
|
||||
NSPR_CONFIGURE_ENV = CC=$(CC)
|
||||
endif
|
||||
ifdef CCC
|
||||
NSPR_CONFIGURE_ENV += CXX=$(CCC)
|
||||
endif
|
||||
# Remove -arch definitions. NSPR can't handle that.
|
||||
NSPR_CONFIGURE_ENV := $(filter-out -arch x86_64,$(NSPR_CONFIGURE_ENV))
|
||||
NSPR_CONFIGURE_ENV := $(filter-out -arch i386,$(NSPR_CONFIGURE_ENV))
|
||||
NSPR_CONFIGURE_ENV := $(filter-out -arch ppc,$(NSPR_CONFIGURE_ENV))
|
||||
|
||||
#
|
||||
# Some pwd commands on Windows (for example, the pwd
|
||||
@@ -107,17 +118,29 @@ else
|
||||
NSPR_PREFIX = $$(topsrcdir)/../dist/$(OBJDIR_NAME)
|
||||
endif
|
||||
|
||||
ifndef NSS_GYP_PREFIX
|
||||
$(NSPR_CONFIG_STATUS): $(NSPR_CONFIGURE)
|
||||
mkdir -p $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)
|
||||
cd $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) ; \
|
||||
$(NSPR_COMPILERS) sh ../configure \
|
||||
$(NSPR_CONFIGURE_ENV) sh ../configure \
|
||||
$(NSPR_CONFIGURE_OPTS) \
|
||||
--with-dist-prefix='$(NSPR_PREFIX)' \
|
||||
--with-dist-includedir='$(NSPR_PREFIX)/include'
|
||||
else
|
||||
$(NSPR_CONFIG_STATUS): $(NSPR_CONFIGURE)
|
||||
mkdir -p $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)
|
||||
cd $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) ; \
|
||||
$(NSPR_CONFIGURE_ENV) sh ../configure \
|
||||
$(NSPR_CONFIGURE_OPTS) \
|
||||
--prefix='$(NSS_GYP_PREFIX)'
|
||||
endif
|
||||
|
||||
build_nspr: $(NSPR_CONFIG_STATUS)
|
||||
$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME)
|
||||
|
||||
install_nspr: build_nspr
|
||||
$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) install
|
||||
|
||||
clobber_nspr: $(NSPR_CONFIG_STATUS)
|
||||
$(MAKE) -C $(CORE_DEPTH)/../nspr/$(OBJDIR_NAME) clobber
|
||||
|
||||
@@ -132,3 +155,6 @@ nss_RelEng_bld: import all
|
||||
package:
|
||||
$(MAKE) -C pkg publish
|
||||
|
||||
latest:
|
||||
echo $(OBJDIR_NAME) > $(CORE_DEPTH)/../dist/latest
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
NSS_3_21_4_RTM
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
1 function with some indirect sub-type change:
|
||||
|
||||
[C]'function SECStatus SSL_GetChannelInfo(PRFileDesc*, SSLChannelInfo*, PRUintn)' at sslinfo.c:12:1 has some indirect sub-type changes:
|
||||
parameter 2 of type 'SSLChannelInfo*' has sub-type changes:
|
||||
in pointed to type 'typedef SSLChannelInfo' at sslt.h:318:1:
|
||||
underlying type 'struct SSLChannelInfoStr' at sslt.h:259:1 changed:
|
||||
type size hasn't changed
|
||||
1 data member change:
|
||||
type of 'SSLSignatureScheme SSLChannelInfoStr::signatureScheme' changed:
|
||||
underlying type 'enum __anonymous_enum__' at sslt.h:115:1 changed:
|
||||
type size hasn't changed
|
||||
3 enumerator deletions:
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_sha256' value '2052'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_sha384' value '2053'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_sha512' value '2054'
|
||||
|
||||
6 enumerator insertions:
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_rsae_sha256' value '2052'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_rsae_sha384' value '2053'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_rsae_sha512' value '2054'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_pss_sha256' value '2057'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_pss_sha384' value '2058'
|
||||
'__anonymous_enum__::ssl_sig_rsa_pss_pss_sha512' value '2059'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
NSS_3_35_BRANCH
|
||||
@@ -19,6 +19,9 @@ proc_args()
|
||||
"--test-nss")
|
||||
TEST_NSS=1
|
||||
;;
|
||||
"--check-abi")
|
||||
CHECK_ABI=1
|
||||
;;
|
||||
"--build-jss")
|
||||
BUILD_JSS=1
|
||||
;;
|
||||
@@ -40,6 +43,7 @@ proc_args()
|
||||
echo " --build-jss"
|
||||
echo " --test-nss"
|
||||
echo " --test-jss"
|
||||
echo " --check-abi"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -199,7 +203,7 @@ test_nss()
|
||||
print_log "$ cd ${HGDIR}/nss/tests"
|
||||
cd ${HGDIR}/nss/tests
|
||||
print_log "$ ./all.sh"
|
||||
./all.sh 2>&1 | tee ${LOG_TMP} | grep ${GREP_BUFFER} ": #"
|
||||
./all.sh 2>&1 | tee ${LOG_TMP} | egrep ${GREP_BUFFER} ": #|^\[.{10}\] "
|
||||
OUTPUTFILE=${LOG_TMP}
|
||||
fi
|
||||
|
||||
@@ -208,13 +212,132 @@ test_nss()
|
||||
RET=$?
|
||||
|
||||
print_log "######## details of detected failures (if any) ########"
|
||||
grep -B50 FAIL ${OUTPUTFILE}
|
||||
grep -B50 -w FAILED ${OUTPUTFILE}
|
||||
[ $? -eq 1 ] || RET=1
|
||||
|
||||
print_result "NSS - tests - ${BITS} bits - ${OPT}" ${RET} 0
|
||||
return ${RET}
|
||||
}
|
||||
|
||||
check_abi()
|
||||
{
|
||||
print_log "######## NSS ABI CHECK - ${BITS} bits - ${OPT} ########"
|
||||
print_log "######## creating temporary HG clones ########"
|
||||
|
||||
rm -rf ${HGDIR}/baseline
|
||||
mkdir ${HGDIR}/baseline
|
||||
BASE_NSS=`cat ${HGDIR}/nss/automation/abi-check/previous-nss-release`
|
||||
hg clone -u "${BASE_NSS}" "${HGDIR}/nss" "${HGDIR}/baseline/nss"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "invalid tag in automation/abi-check/previous-nss-release"
|
||||
return 1
|
||||
fi
|
||||
|
||||
BASE_NSPR=NSPR_$(head -1 ${HGDIR}/baseline/nss/automation/release/nspr-version.txt | cut -d . -f 1-2 | tr . _)_BRANCH
|
||||
hg clone -u "${BASE_NSPR}" "${HGDIR}/nspr" "${HGDIR}/baseline/nspr"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "nonexisting tag ${BASE_NSPR} derived from ${BASE_NSS} automation/release/nspr-version.txt"
|
||||
# Assume that version hasn't been released yet, fall back to trunk
|
||||
pushd "${HGDIR}/baseline/nspr"
|
||||
hg update default
|
||||
popd
|
||||
fi
|
||||
|
||||
print_log "######## building baseline NSPR/NSS ########"
|
||||
pushd ${HGDIR}/baseline/nss
|
||||
|
||||
print_log "$ ${MAKE} ${NSS_BUILD_TARGET}"
|
||||
${MAKE} ${NSS_BUILD_TARGET} 2>&1 | tee -a ${LOG_ALL}
|
||||
RET=$?
|
||||
print_result "NSS - build - ${BITS} bits - ${OPT}" ${RET} 0
|
||||
if [ ${RET} -ne 0 ]; then
|
||||
tail -100 ${LOG_ALL}
|
||||
return ${RET}
|
||||
fi
|
||||
popd
|
||||
|
||||
ABI_PROBLEM_FOUND=0
|
||||
ABI_REPORT=${OUTPUTDIR}/abi-diff.txt
|
||||
rm -f ${ABI_REPORT}
|
||||
PREVDIST=${HGDIR}/baseline/dist
|
||||
NEWDIST=${HGDIR}/dist
|
||||
ALL_SOs="libfreebl3.so libfreeblpriv3.so libnspr4.so libnss3.so libnssckbi.so libnssdbm3.so libnsssysinit.so libnssutil3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so"
|
||||
for SO in ${ALL_SOs}; do
|
||||
if [ ! -f ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt ]; then
|
||||
touch ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt
|
||||
fi
|
||||
abidiff --hd1 $PREVDIST/public/ --hd2 $NEWDIST/public \
|
||||
$PREVDIST/*/lib/$SO $NEWDIST/*/lib/$SO \
|
||||
> ${HGDIR}/nss/automation/abi-check/new-report-temp$SO.txt
|
||||
RET=$?
|
||||
cat ${HGDIR}/nss/automation/abi-check/new-report-temp$SO.txt \
|
||||
| grep -v "^Functions changes summary:" \
|
||||
| grep -v "^Variables changes summary:" \
|
||||
> ${HGDIR}/nss/automation/abi-check/new-report-$SO.txt
|
||||
rm -f ${HGDIR}/nss/automation/abi-check/new-report-temp$SO.txt
|
||||
ABIDIFF_ERROR=$((($RET & 0x01) != 0))
|
||||
ABIDIFF_USAGE_ERROR=$((($RET & 0x02) != 0))
|
||||
ABIDIFF_ABI_CHANGE=$((($RET & 0x04) != 0))
|
||||
ABIDIFF_ABI_INCOMPATIBLE_CHANGE=$((($RET & 0x08) != 0))
|
||||
ABIDIFF_UNKNOWN_BIT_SET=$((($RET & 0xf0) != 0))
|
||||
|
||||
# If abidiff reports an error, or a usage error, or if it sets a result
|
||||
# bit value this script doesn't know yet about, we'll report failure.
|
||||
# For ABI changes, we don't yet report an error. We'll compare the
|
||||
# result report with our whitelist. This allows us to silence changes
|
||||
# that we're already aware of and have been declared acceptable.
|
||||
|
||||
REPORT_RET_AS_FAILURE=0
|
||||
if [ $ABIDIFF_ERROR -ne 0 ]; then
|
||||
print_log "abidiff reported ABIDIFF_ERROR."
|
||||
REPORT_RET_AS_FAILURE=1
|
||||
fi
|
||||
if [ $ABIDIFF_USAGE_ERROR -ne 0 ]; then
|
||||
print_log "abidiff reported ABIDIFF_USAGE_ERROR."
|
||||
REPORT_RET_AS_FAILURE=1
|
||||
fi
|
||||
if [ $ABIDIFF_UNKNOWN_BIT_SET -ne 0 ]; then
|
||||
print_log "abidiff reported ABIDIFF_UNKNOWN_BIT_SET."
|
||||
REPORT_RET_AS_FAILURE=1
|
||||
fi
|
||||
|
||||
if [ $ABIDIFF_ABI_CHANGE -ne 0 ]; then
|
||||
print_log "Ignoring abidiff result ABI_CHANGE, instead we'll check for non-whitelisted differences."
|
||||
fi
|
||||
if [ $ABIDIFF_ABI_INCOMPATIBLE_CHANGE -ne 0 ]; then
|
||||
print_log "Ignoring abidiff result ABIDIFF_ABI_INCOMPATIBLE_CHANGE, instead we'll check for non-whitelisted differences."
|
||||
fi
|
||||
|
||||
if [ $REPORT_RET_AS_FAILURE -ne 0 ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
print_log "abidiff {$PREVDIST , $NEWDIST} for $SO FAILED with result $RET, or failed writing to ${HGDIR}/nss/automation/abi-check/new-report-$SO.txt"
|
||||
fi
|
||||
if [ ! -f ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
print_log "FAILED to access report file: ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt"
|
||||
fi
|
||||
|
||||
diff -wB -u ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt \
|
||||
${HGDIR}/nss/automation/abi-check/new-report-$SO.txt >> ${ABI_REPORT}
|
||||
if [ ! -f ${ABI_REPORT} ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
print_log "FAILED to compare exepcted and new report: ${HGDIR}/nss/automation/abi-check/new-report-$SO.txt"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -s ${ABI_REPORT} ]; then
|
||||
print_log "FAILED: there are new unexpected ABI changes"
|
||||
cat ${ABI_REPORT}
|
||||
return 1
|
||||
elif [ $ABI_PROBLEM_FOUND -ne 0 ]; then
|
||||
print_log "FAILED: failure executing the ABI checks"
|
||||
cat ${ABI_REPORT}
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
test_jss()
|
||||
{
|
||||
print_log "######## JSS - tests - ${BITS} bits - ${OPT} ########"
|
||||
@@ -243,6 +366,39 @@ test_jss()
|
||||
return ${RET}
|
||||
}
|
||||
|
||||
create_objdir_dist_link()
|
||||
{
|
||||
# compute relevant 'dist' OBJDIR_NAME subdirectory names for JSS and NSS
|
||||
OS_TARGET=`uname -s`
|
||||
OS_RELEASE=`uname -r | sed 's/-.*//' | sed 's/-.*//' | cut -d . -f1,2`
|
||||
CPU_TAG=_`uname -m`
|
||||
# OBJDIR_NAME_COMPILER appears to be defined for NSS but not JSS
|
||||
OBJDIR_NAME_COMPILER=_cc
|
||||
LIBC_TAG=_glibc
|
||||
IMPL_STRATEGY=_PTH
|
||||
if [ "${RUN_BITS}" = "64" ]; then
|
||||
OBJDIR_TAG=_${RUN_BITS}_${RUN_OPT}.OBJ
|
||||
else
|
||||
OBJDIR_TAG=_${RUN_OPT}.OBJ
|
||||
fi
|
||||
|
||||
# define NSS_OBJDIR_NAME
|
||||
NSS_OBJDIR_NAME=${OS_TARGET}${OS_RELEASE}${CPU_TAG}${OBJDIR_NAME_COMPILER}
|
||||
NSS_OBJDIR_NAME=${NSS_OBJDIR_NAME}${LIBC_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}
|
||||
print_log "create_objdir_dist_link(): NSS_OBJDIR_NAME='${NSS_OBJDIR_NAME}'"
|
||||
|
||||
# define JSS_OBJDIR_NAME
|
||||
JSS_OBJDIR_NAME=${OS_TARGET}${OS_RELEASE}${CPU_TAG}
|
||||
JSS_OBJDIR_NAME=${JSS_OBJDIR_NAME}${LIBC_TAG}${IMPL_STRATEGY}${OBJDIR_TAG}
|
||||
print_log "create_objdir_dist_link(): JSS_OBJDIR_NAME='${JSS_OBJDIR_NAME}'"
|
||||
|
||||
if [ -e "${HGDIR}/dist/${NSS_OBJDIR_NAME}" ]; then
|
||||
SOURCE=${HGDIR}/dist/${NSS_OBJDIR_NAME}
|
||||
TARGET=${HGDIR}/dist/${JSS_OBJDIR_NAME}
|
||||
ln -s ${SOURCE} ${TARGET} >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
build_and_test()
|
||||
{
|
||||
if [ -n "${BUILD_NSS}" ]; then
|
||||
@@ -255,7 +411,13 @@ build_and_test()
|
||||
[ $? -eq 0 ] || return 1
|
||||
fi
|
||||
|
||||
if [ -n "${CHECK_ABI}" ]; then
|
||||
check_abi
|
||||
[ $? -eq 0 ] || return 1
|
||||
fi
|
||||
|
||||
if [ -n "${BUILD_JSS}" ]; then
|
||||
create_objdir_dist_link
|
||||
build_jss
|
||||
[ $? -eq 0 ] || return 1
|
||||
fi
|
||||
@@ -288,12 +450,14 @@ prepare()
|
||||
mv ${OUTPUTDIR} ${OUTPUTDIR}.last >/dev/null 2>&1
|
||||
mkdir -p ${OUTPUTDIR}
|
||||
|
||||
if [ -z "${NSS_DISABLE_ECC}" -a -n "${NSS_ECC_MORE_THAN_SUITE_B}" ]; then
|
||||
cd ${HGDIR}/nss
|
||||
ECF="lib/freebl/ecl/ecl-curve.h"
|
||||
print_log "hg revert -r NSS_3_11_1_RTM ${ECF}"
|
||||
hg revert -r NSS_3_11_1_RTM security/nss/${ECF}
|
||||
cp -f security/nss/${ECF} ${ECF}
|
||||
# Remove temporary test files from previous jobs, that weren't cleaned up
|
||||
# by move_results(), e.g. caused by unexpected interruptions.
|
||||
rm -rf ${HGDIR}/tests_results/
|
||||
|
||||
cd ${HGDIR}/nss
|
||||
|
||||
if [ -n "${FEWER_STRESS_ITERATIONS}" ]; then
|
||||
sed -i 's/-c_1000_/-c_500_/g' tests/ssl/sslstress.txt
|
||||
fi
|
||||
|
||||
return 0
|
||||
@@ -324,6 +488,7 @@ main()
|
||||
{
|
||||
VALID=0
|
||||
RET=1
|
||||
FAIL=0
|
||||
|
||||
for BITS in 32 64; do
|
||||
echo ${RUN_BITS} | grep ${BITS} > /dev/null
|
||||
@@ -336,7 +501,10 @@ main()
|
||||
set_env
|
||||
run_all
|
||||
RET=$?
|
||||
print_log "### result of run_all is ${RET}"
|
||||
print_log "### result of run_all is ${RET}"
|
||||
if [ ${RET} -ne 0 ]; then
|
||||
FAIL=${RET}
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
@@ -345,7 +513,7 @@ main()
|
||||
return 1
|
||||
fi
|
||||
|
||||
return ${RET}
|
||||
return ${FAIL}
|
||||
}
|
||||
|
||||
#function killallsub()
|
||||
@@ -373,6 +541,8 @@ echo "tinderbox args: $0 $@"
|
||||
proc_args "$@"
|
||||
main
|
||||
|
||||
#RET=$?
|
||||
RET=$?
|
||||
print_log "### result of main is ${RET}"
|
||||
|
||||
#rm $IS_RUNNING_FILE
|
||||
#exit ${RET}
|
||||
exit ${RET}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
echo running > ..\buildbot-is-building
|
||||
|
||||
echo running: "%MOZILLABUILD%\msys\bin\bash" -c "hg/tinder/buildbot/build.sh %*"
|
||||
"%MOZILLABUILD%\msys\bin\bash" -c "hg/tinder/buildbot/build.sh %*"
|
||||
echo running: "%MOZILLABUILD%\msys\bin\bash" -c "hg/nss/automation/buildbot-slave/build.sh %*"
|
||||
"%MOZILLABUILD%\msys\bin\bash" -c "hg/nss/automation/buildbot-slave/build.sh %*"
|
||||
|
||||
if %errorlevel% neq 0 (
|
||||
set EXITCODE=1
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Franziskus Kiefer <franziskuskiefer@gmail.com>
|
||||
|
||||
RUN useradd -d /home/worker -s /bin/bash -m worker
|
||||
WORKDIR /home/worker
|
||||
|
||||
# Install dependencies.
|
||||
ADD setup.sh /tmp/setup.sh
|
||||
RUN bash /tmp/setup.sh
|
||||
|
||||
# Change user.
|
||||
USER worker
|
||||
|
||||
# Env variables.
|
||||
ENV HOME /home/worker
|
||||
ENV SHELL /bin/bash
|
||||
ENV USER worker
|
||||
ENV LOGNAME worker
|
||||
ENV HOSTNAME taskcluster-worker
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV HOST localhost
|
||||
ENV DOMSUF localdomain
|
||||
|
||||
# Entrypoint.
|
||||
ENTRYPOINT ["/home/worker/nss/automation/clang-format/run_clang_format.sh"]
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $(id -u) -eq 0 ]]; then
|
||||
# Drop privileges by re-running this script.
|
||||
# Note: this mangles arguments, better to avoid running scripts as root.
|
||||
exec su worker -c "$0 $*"
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Apply clang-format on the provided folder and verify that this doesn't change any file.
|
||||
# If any file differs after formatting, the script eventually exits with 1.
|
||||
# Any differences between formatted and unformatted files is printed to stdout to give a hint what's wrong.
|
||||
|
||||
# Includes a default set of directories NOT to clang-format on.
|
||||
blacklist=(
|
||||
"./automation" \
|
||||
"./coreconf" \
|
||||
"./doc" \
|
||||
"./pkg" \
|
||||
"./tests" \
|
||||
"./lib/libpkix" \
|
||||
"./lib/zlib" \
|
||||
"./lib/sqlite" \
|
||||
"./gtests/google_test" \
|
||||
"./out" \
|
||||
)
|
||||
|
||||
top=$(cd "$(dirname $0)/../.."; pwd -P)
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
dirs=("$@")
|
||||
else
|
||||
cd "$top"
|
||||
dirs=($(find . -maxdepth 2 -mindepth 1 -type d ! -path '*/.*' -print))
|
||||
fi
|
||||
|
||||
format_folder()
|
||||
{
|
||||
for black in "${blacklist[@]}"; do
|
||||
if [[ "$1" == "$black"* ]]; then
|
||||
echo "skip $1"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
for dir in "${dirs[@]}"; do
|
||||
if format_folder "$dir"; then
|
||||
c="${dir//[^\/]}"
|
||||
echo "formatting $dir ..."
|
||||
depth=()
|
||||
if [ "${#c}" == "1" ]; then
|
||||
depth+=(-maxdepth 1)
|
||||
fi
|
||||
find "$dir" "${depth[@]}" -type f \( -name '*.[ch]' -o -name '*.cc' \) -exec clang-format -i {} \+
|
||||
fi
|
||||
done
|
||||
|
||||
TMPFILE=$(mktemp /tmp/$(basename $0).XXXXXX)
|
||||
trap 'rm -f $TMPFILE' exit
|
||||
if [[ -d "$top/.hg" ]]; then
|
||||
hg diff --git "$top" | tee $TMPFILE
|
||||
else
|
||||
git -C "$top" diff | tee $TMPFILE
|
||||
fi
|
||||
[[ ! -s $TMPFILE ]]
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -v -e -x
|
||||
|
||||
# Update packages.
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -y update && apt-get -y upgrade
|
||||
|
||||
# Install packages.
|
||||
apt_packages=()
|
||||
apt_packages+=('ca-certificates')
|
||||
apt_packages+=('curl')
|
||||
apt_packages+=('xz-utils')
|
||||
apt_packages+=('mercurial')
|
||||
apt_packages+=('git')
|
||||
apt_packages+=('locales')
|
||||
apt-get install -y --no-install-recommends ${apt_packages[@]}
|
||||
|
||||
# Download clang.
|
||||
curl -L https://releases.llvm.org/3.9.1/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz -o clang.tar.xz
|
||||
curl -L https://releases.llvm.org/3.9.1/clang+llvm-3.9.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz.sig -o clang.tar.xz.sig
|
||||
# Verify the signature.
|
||||
gpg --keyserver pool.sks-keyservers.net --recv-keys B6C8F98282B944E3B0D5C2530FC3042E345AD05D
|
||||
gpg --verify clang.tar.xz.sig
|
||||
# Install into /usr/local/.
|
||||
tar xJvf *.tar.xz -C /usr/local --strip-components=1
|
||||
|
||||
# Cleanup.
|
||||
function cleanup() {
|
||||
rm -f clang.tar.xz clang.tar.xz.sig
|
||||
}
|
||||
trap cleanup ERR EXIT
|
||||
|
||||
locale-gen en_US.UTF-8
|
||||
dpkg-reconfigure locales
|
||||
|
||||
# Cleanup.
|
||||
rm -rf ~/.ccache ~/.cache
|
||||
apt-get autoremove -y
|
||||
apt-get clean
|
||||
apt-get autoclean
|
||||
|
||||
# We're done. Remove this script.
|
||||
rm $0
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash -eu
|
||||
#
|
||||
# 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/.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# List of targets disabled for oss-fuzz.
|
||||
declare -A disabled=([pkcs8]=1)
|
||||
|
||||
# List of targets we want to fuzz in TLS and non-TLS mode.
|
||||
declare -A tls_targets=([tls-client]=1 [tls-server]=1 [dtls-client]=1 [dtls-server]=1)
|
||||
|
||||
# Helper function that copies a fuzzer binary and its seed corpus.
|
||||
copy_fuzzer()
|
||||
{
|
||||
local fuzzer=$1
|
||||
local name=$2
|
||||
|
||||
# Copy the binary.
|
||||
cp ../dist/Debug/bin/$fuzzer $OUT/$name
|
||||
|
||||
# Zip and copy the corpus, if any.
|
||||
if [ -d "$SRC/nss-corpus/$name" ]; then
|
||||
zip $OUT/${name}_seed_corpus.zip $SRC/nss-corpus/$name/*
|
||||
else
|
||||
zip $OUT/${name}_seed_corpus.zip $SRC/nss-corpus/*/*
|
||||
fi
|
||||
}
|
||||
|
||||
# Copy libFuzzer options
|
||||
cp fuzz/options/*.options $OUT/
|
||||
|
||||
# Build the library (non-TLS fuzzing mode).
|
||||
CXX="$CXX -stdlib=libc++" LDFLAGS="$CFLAGS" \
|
||||
./build.sh -c -v --fuzz=oss --fuzz --disable-tests
|
||||
|
||||
# Copy fuzzing targets.
|
||||
for fuzzer in $(find ../dist/Debug/bin -name "nssfuzz-*" -printf "%f\n"); do
|
||||
name=${fuzzer:8}
|
||||
if [ -z "${disabled[$name]:-}" ]; then
|
||||
[ -n "${tls_targets[$name]:-}" ] && name="${name}-no_fuzzer_mode"
|
||||
copy_fuzzer $fuzzer $name
|
||||
fi
|
||||
done
|
||||
|
||||
# Build the library again (TLS fuzzing mode).
|
||||
CXX="$CXX -stdlib=libc++" LDFLAGS="$CFLAGS" \
|
||||
./build.sh -c -v --fuzz=oss --fuzz=tls --disable-tests
|
||||
|
||||
# Copy dual mode targets in TLS mode.
|
||||
for name in "${!tls_targets[@]}"; do
|
||||
if [ -z "${disabled[$name]:-}" ]; then
|
||||
copy_fuzzer nssfuzz-$name $name
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,10 @@
|
||||
4.19
|
||||
|
||||
# The first line of this file must contain the human readable NSPR
|
||||
# version number, which is the minimum required version of NSPR
|
||||
# that is supported by this version of NSS.
|
||||
#
|
||||
# This information is used by release automation,
|
||||
# when creating an NSS source archive.
|
||||
#
|
||||
# All other lines in this file are ignored.
|
||||
@@ -0,0 +1,288 @@
|
||||
#!/usr/bin/python
|
||||
# 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/.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
import shutil
|
||||
import glob
|
||||
from optparse import OptionParser
|
||||
from subprocess import check_call
|
||||
from subprocess import check_output
|
||||
|
||||
nssutil_h = "lib/util/nssutil.h"
|
||||
softkver_h = "lib/softoken/softkver.h"
|
||||
nss_h = "lib/nss/nss.h"
|
||||
nssckbi_h = "lib/ckfw/builtins/nssckbi.h"
|
||||
abi_base_version_file = "automation/abi-check/previous-nss-release"
|
||||
|
||||
abi_report_files = ['automation/abi-check/expected-report-libfreebl3.so.txt',
|
||||
'automation/abi-check/expected-report-libfreeblpriv3.so.txt',
|
||||
'automation/abi-check/expected-report-libnspr4.so.txt',
|
||||
'automation/abi-check/expected-report-libnss3.so.txt',
|
||||
'automation/abi-check/expected-report-libnssckbi.so.txt',
|
||||
'automation/abi-check/expected-report-libnssdbm3.so.txt',
|
||||
'automation/abi-check/expected-report-libnsssysinit.so.txt',
|
||||
'automation/abi-check/expected-report-libnssutil3.so.txt',
|
||||
'automation/abi-check/expected-report-libplc4.so.txt',
|
||||
'automation/abi-check/expected-report-libplds4.so.txt',
|
||||
'automation/abi-check/expected-report-libsmime3.so.txt',
|
||||
'automation/abi-check/expected-report-libsoftokn3.so.txt',
|
||||
'automation/abi-check/expected-report-libssl3.so.txt']
|
||||
|
||||
def check_call_noisy(cmd, *args, **kwargs):
|
||||
print "Executing command:", cmd
|
||||
check_call(cmd, *args, **kwargs)
|
||||
|
||||
o = OptionParser(usage="client.py [options] remove_beta | set_beta | print_library_versions | print_root_ca_version | set_root_ca_version | set_version_to_minor_release | set_version_to_patch_release | set_release_candidate_number | set_4_digit_release_number | create_nss_release_archive")
|
||||
|
||||
try:
|
||||
options, args = o.parse_args()
|
||||
action = args[0]
|
||||
except IndexError:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
def exit_with_failure(what):
|
||||
print "failure: ", what
|
||||
sys.exit(2)
|
||||
|
||||
def check_files_exist():
|
||||
if (not os.path.exists(nssutil_h) or not os.path.exists(softkver_h)
|
||||
or not os.path.exists(nss_h) or not os.path.exists(nssckbi_h)):
|
||||
exit_with_failure("cannot find expected header files, must run from inside NSS hg directory")
|
||||
|
||||
def sed_inplace(sed_expression, filename):
|
||||
backup_file = filename + '.tmp'
|
||||
check_call_noisy(["sed", "-i.tmp", sed_expression, filename])
|
||||
os.remove(backup_file)
|
||||
|
||||
def toggle_beta_status(is_beta):
|
||||
check_files_exist()
|
||||
if (is_beta):
|
||||
print "adding Beta status to version numbers"
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VERSION *\"[0-9.]\+\)\" *$/\\1 Beta\"/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *NSSUTIL_BETA *\)PR_FALSE *$/\\1PR_TRUE/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VERSION *\"[0-9.]\+\" *SOFTOKEN_ECC_STRING\) *$/\\1 \" Beta"/', softkver_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_BETA *\)PR_FALSE *$/\\1PR_TRUE/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VERSION *\"[0-9.]\+\" *_NSS_CUSTOMIZED\) *$/\\1 \" Beta"/', nss_h)
|
||||
sed_inplace('s/^\(#define *NSS_BETA *\)PR_FALSE *$/\\1PR_TRUE/', nss_h)
|
||||
else:
|
||||
print "removing Beta status from version numbers"
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VERSION *\"[0-9.]\+\) *Beta\" *$/\\1\"/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *NSSUTIL_BETA *\)PR_TRUE *$/\\1PR_FALSE/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VERSION *\"[0-9.]\+\" *SOFTOKEN_ECC_STRING\) *\" *Beta\" *$/\\1/', softkver_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_BETA *\)PR_TRUE *$/\\1PR_FALSE/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VERSION *\"[0-9.]\+\" *_NSS_CUSTOMIZED\) *\" *Beta\" *$/\\1/', nss_h)
|
||||
sed_inplace('s/^\(#define *NSS_BETA *\)PR_TRUE *$/\\1PR_FALSE/', nss_h)
|
||||
print "please run 'hg stat' and 'hg diff' to verify the files have been verified correctly"
|
||||
|
||||
def print_beta_versions():
|
||||
check_call_noisy(["egrep", "#define *NSSUTIL_VERSION|#define *NSSUTIL_BETA", nssutil_h])
|
||||
check_call_noisy(["egrep", "#define *SOFTOKEN_VERSION|#define *SOFTOKEN_BETA", softkver_h])
|
||||
check_call_noisy(["egrep", "#define *NSS_VERSION|#define *NSS_BETA", nss_h])
|
||||
|
||||
def remove_beta_status():
|
||||
print "--- removing beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(False)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def set_beta_status():
|
||||
print "--- adding beta flags. Existing versions were:"
|
||||
print_beta_versions()
|
||||
toggle_beta_status(True)
|
||||
print "--- finished modifications, new versions are:"
|
||||
print_beta_versions()
|
||||
|
||||
def print_library_versions():
|
||||
check_files_exist()
|
||||
check_call_noisy(["egrep", "#define *NSSUTIL_VERSION|#define NSSUTIL_VMAJOR|#define *NSSUTIL_VMINOR|#define *NSSUTIL_VPATCH|#define *NSSUTIL_VBUILD|#define *NSSUTIL_BETA", nssutil_h])
|
||||
check_call_noisy(["egrep", "#define *SOFTOKEN_VERSION|#define SOFTOKEN_VMAJOR|#define *SOFTOKEN_VMINOR|#define *SOFTOKEN_VPATCH|#define *SOFTOKEN_VBUILD|#define *SOFTOKEN_BETA", softkver_h])
|
||||
check_call_noisy(["egrep", "#define *NSS_VERSION|#define NSS_VMAJOR|#define *NSS_VMINOR|#define *NSS_VPATCH|#define *NSS_VBUILD|#define *NSS_BETA", nss_h])
|
||||
|
||||
def print_root_ca_version():
|
||||
check_files_exist()
|
||||
check_call_noisy(["grep", "define *NSS_BUILTINS_LIBRARY_VERSION", nssckbi_h])
|
||||
|
||||
|
||||
def ensure_arguments_after_action(how_many, usage):
|
||||
if (len(sys.argv) != (2+how_many)):
|
||||
exit_with_failure("incorrect number of arguments, expected parameters are:\n" + usage)
|
||||
|
||||
def set_major_versions(major):
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VMAJOR *\).*$/\\1' + major + '/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VMAJOR *\).*$/\\1' + major + '/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VMAJOR *\).*$/\\1' + major + '/', nss_h)
|
||||
|
||||
def set_minor_versions(minor):
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VMINOR *\).*$/\\1' + minor + '/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VMINOR *\).*$/\\1' + minor + '/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VMINOR *\).*$/\\1' + minor + '/', nss_h)
|
||||
|
||||
def set_patch_versions(patch):
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VPATCH *\).*$/\\1' + patch + '/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VPATCH *\).*$/\\1' + patch + '/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VPATCH *\).*$/\\1' + patch + '/', nss_h)
|
||||
|
||||
def set_build_versions(build):
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VBUILD *\).*$/\\1' + build + '/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VBUILD *\).*$/\\1' + build + '/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VBUILD *\).*$/\\1' + build + '/', nss_h)
|
||||
|
||||
def set_full_lib_versions(version):
|
||||
sed_inplace('s/^\(#define *NSSUTIL_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', nssutil_h)
|
||||
sed_inplace('s/^\(#define *SOFTOKEN_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', softkver_h)
|
||||
sed_inplace('s/^\(#define *NSS_VERSION *\"\)\([0-9.]\+\)\(.*\)$/\\1' + version + '\\3/', nss_h)
|
||||
|
||||
def set_root_ca_version():
|
||||
ensure_arguments_after_action(2, "major_version minor_version")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
version = major + '.' + minor
|
||||
sed_inplace('s/^\(#define *NSS_BUILTINS_LIBRARY_VERSION *\"\).*$/\\1' + version + '/', nssckbi_h)
|
||||
sed_inplace('s/^\(#define *NSS_BUILTINS_LIBRARY_VERSION_MAJOR *\).*$/\\1' + major + '/', nssckbi_h)
|
||||
sed_inplace('s/^\(#define *NSS_BUILTINS_LIBRARY_VERSION_MINOR *\).*$/\\1' + minor + '/', nssckbi_h)
|
||||
|
||||
def set_all_lib_versions(version, major, minor, patch, build):
|
||||
grep_major = check_output(['grep', 'define.*NSS_VMAJOR', nss_h])
|
||||
grep_minor = check_output(['grep', 'define.*NSS_VMINOR', nss_h])
|
||||
|
||||
old_major = int(grep_major.split()[2]);
|
||||
old_minor = int(grep_minor.split()[2]);
|
||||
|
||||
new_major = int(major)
|
||||
new_minor = int(minor)
|
||||
|
||||
if (old_major < new_major or (old_major == new_major and old_minor < new_minor)):
|
||||
print "You're increasing the minor (or major) version:"
|
||||
print "- erasing ABI comparison expectations"
|
||||
new_branch = "NSS_" + str(old_major) + "_" + str(old_minor) + "_BRANCH"
|
||||
print "- setting reference branch to the branch of the previous version: " + new_branch
|
||||
with open(abi_base_version_file, "w") as abi_base:
|
||||
abi_base.write("%s\n" % new_branch)
|
||||
for report_file in abi_report_files:
|
||||
with open(report_file, "w") as report_file_handle:
|
||||
report_file_handle.truncate()
|
||||
|
||||
set_full_lib_versions(version)
|
||||
set_major_versions(major)
|
||||
set_minor_versions(minor)
|
||||
set_patch_versions(patch)
|
||||
set_build_versions(build)
|
||||
|
||||
def set_version_to_minor_release():
|
||||
ensure_arguments_after_action(2, "major_version minor_version")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
version = major + '.' + minor
|
||||
patch = "0"
|
||||
build = "0"
|
||||
set_all_lib_versions(version, major, minor, patch, build)
|
||||
|
||||
def set_version_to_patch_release():
|
||||
ensure_arguments_after_action(3, "major_version minor_version patch_release")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
patch = args[3].strip()
|
||||
version = major + '.' + minor + '.' + patch
|
||||
build = "0"
|
||||
set_all_lib_versions(version, major, minor, patch, build)
|
||||
|
||||
def set_release_candidate_number():
|
||||
ensure_arguments_after_action(1, "release_candidate_number")
|
||||
build = args[1].strip()
|
||||
set_build_versions(build)
|
||||
|
||||
def set_4_digit_release_number():
|
||||
ensure_arguments_after_action(4, "major_version minor_version patch_release 4th_digit_release_number")
|
||||
major = args[1].strip()
|
||||
minor = args[2].strip()
|
||||
patch = args[3].strip()
|
||||
build = args[4].strip()
|
||||
version = major + '.' + minor + '.' + patch + '.' + build
|
||||
set_all_lib_versions(version, major, minor, patch, build)
|
||||
|
||||
def create_nss_release_archive():
|
||||
ensure_arguments_after_action(3, "nss_release_version nss_hg_release_tag path_to_stage_directory")
|
||||
nssrel = args[1].strip() #e.g. 3.19.3
|
||||
nssreltag = args[2].strip() #e.g. NSS_3_19_3_RTM
|
||||
stagedir = args[3].strip() #e.g. ../stage
|
||||
|
||||
with open('automation/release/nspr-version.txt') as nspr_version_file:
|
||||
nsprrel = next(nspr_version_file).strip()
|
||||
|
||||
nspr_tar = "nspr-" + nsprrel + ".tar.gz"
|
||||
nsprtar_with_path= stagedir + "/v" + nsprrel + "/src/" + nspr_tar
|
||||
if (not os.path.exists(nsprtar_with_path)):
|
||||
exit_with_failure("cannot find nspr archive at expected location " + nsprtar_with_path)
|
||||
|
||||
nss_stagedir= stagedir + "/" + nssreltag + "/src"
|
||||
if (os.path.exists(nss_stagedir)):
|
||||
exit_with_failure("nss stage directory already exists: " + nss_stagedir)
|
||||
|
||||
nss_tar = "nss-" + nssrel + ".tar.gz"
|
||||
|
||||
check_call_noisy(["mkdir", "-p", nss_stagedir])
|
||||
check_call_noisy(["hg", "archive", "-r", nssreltag, "--prefix=nss-" + nssrel + "/nss",
|
||||
stagedir + "/" + nssreltag + "/src/" + nss_tar, "-X", ".hgtags"])
|
||||
check_call_noisy(["tar", "-xz", "-C", nss_stagedir, "-f", nsprtar_with_path])
|
||||
print "changing to directory " + nss_stagedir
|
||||
os.chdir(nss_stagedir)
|
||||
check_call_noisy(["tar", "-xz", "-f", nss_tar])
|
||||
check_call_noisy(["mv", "-i", "nspr-" + nsprrel + "/nspr", "nss-" + nssrel + "/"])
|
||||
check_call_noisy(["rmdir", "nspr-" + nsprrel])
|
||||
|
||||
nss_nspr_tar = "nss-" + nssrel + "-with-nspr-" + nsprrel + ".tar.gz"
|
||||
|
||||
check_call_noisy(["tar", "-cz", "--remove-files", "-f", nss_nspr_tar, "nss-" + nssrel])
|
||||
check_call("sha1sum " + nss_tar + " " + nss_nspr_tar + " > SHA1SUMS", shell=True)
|
||||
check_call("sha256sum " + nss_tar + " " + nss_nspr_tar + " > SHA256SUMS", shell=True)
|
||||
print "created directory " + nss_stagedir + " with files:"
|
||||
check_call_noisy(["ls", "-l"])
|
||||
|
||||
if action in ('remove_beta'):
|
||||
remove_beta_status()
|
||||
|
||||
elif action in ('set_beta'):
|
||||
set_beta_status()
|
||||
|
||||
elif action in ('print_library_versions'):
|
||||
print_library_versions()
|
||||
|
||||
elif action in ('print_root_ca_version'):
|
||||
print_root_ca_version()
|
||||
|
||||
elif action in ('set_root_ca_version'):
|
||||
set_root_ca_version()
|
||||
|
||||
# x.y version number - 2 parameters
|
||||
elif action in ('set_version_to_minor_release'):
|
||||
set_version_to_minor_release()
|
||||
|
||||
# x.y.z version number - 3 parameters
|
||||
elif action in ('set_version_to_patch_release'):
|
||||
set_version_to_patch_release()
|
||||
|
||||
# change the release candidate number, usually increased by one,
|
||||
# usually if previous release candiate had a bug
|
||||
# 1 parameter
|
||||
elif action in ('set_release_candidate_number'):
|
||||
set_release_candidate_number()
|
||||
|
||||
# use the build/release candiate number in the identifying version number
|
||||
# 4 parameters
|
||||
elif action in ('set_4_digit_release_number'):
|
||||
set_4_digit_release_number()
|
||||
|
||||
elif action in ('create_nss_release_archive'):
|
||||
create_nss_release_archive()
|
||||
|
||||
else:
|
||||
o.print_help()
|
||||
sys.exit(2)
|
||||
|
||||
sys.exit(0)
|
||||
@@ -0,0 +1,8 @@
|
||||
/* 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/. */
|
||||
|
||||
bmul : {n,m} (fin n, n >= 1, m == n*2 - 1) => [n] -> [n] -> ([n], [n])
|
||||
bmul a b = (take`{n} prod, drop`{n} prod)
|
||||
where prod = pad (pmult a b : [m])
|
||||
pad x = zero # x
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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/.
|
||||
|
||||
import "bmul.cry";
|
||||
|
||||
print "Loading LLVM bitcode...";
|
||||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc";
|
||||
|
||||
let SpecBinaryMul n = do {
|
||||
x <- llvm_var "x" (llvm_int n);
|
||||
y <- llvm_var "y" (llvm_int n);
|
||||
llvm_ptr "r_high" (llvm_int n);
|
||||
r_high <- llvm_var "*r_high" (llvm_int n);
|
||||
llvm_ptr "r_low" (llvm_int n);
|
||||
r_low <- llvm_var "*r_low" (llvm_int n);
|
||||
|
||||
let res = {{ bmul x y }};
|
||||
llvm_ensure_eq "*r_high" {{ res.0 }};
|
||||
llvm_ensure_eq "*r_low" {{ res.1 }};
|
||||
|
||||
llvm_verify_tactic abc;
|
||||
};
|
||||
|
||||
print "Proving equality for 32-bit bmul()...";
|
||||
time (llvm_verify m "bmul32" [] (SpecBinaryMul 32));
|
||||
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
** ChaCha20 specification
|
||||
** Author: Austin Seipp <aseipp@pobox.com>. Released in the Public Domain.
|
||||
**
|
||||
** Based on RFC 7539 - "ChaCha20 and Poly1305 for IETF Protocols"
|
||||
** https://tools.ietf.org/html/rfc7539
|
||||
*/
|
||||
module chacha20 where
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -- Implementation -------------------------------------------------------- */
|
||||
|
||||
type Round = [16][32] // An input to the ChaCha20 core function
|
||||
type Block = [64][8] // An output block from the ChaCha20 core function.
|
||||
type Key = [32][8] // A 32-byte input key
|
||||
type Nonce = [12][8] // A 12-byte nonce
|
||||
type Counter = [32] // Starting block counter. Usually 1 or 0.
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- Quarter Round ----------------- */
|
||||
|
||||
// The quarter round. This takes 4 32-bit integers and diffuses them
|
||||
// appropriately, and is the core of the column and diagonal round.
|
||||
qround : [4][32] -> [4][32]
|
||||
qround [ a0, b0, c0, d0 ] = [ a2, b4, c2, d4 ]
|
||||
where
|
||||
a1 = a0 + b0 /* a += b; d ^= a; d <<<= 16 */
|
||||
d1 = d0 ^ a1
|
||||
d2 = d1 <<< 16
|
||||
|
||||
c1 = c0 + d2 /* c += d; b ^= c; b <<<= 12 */
|
||||
b1 = b0 ^ c1
|
||||
b2 = b1 <<< 12
|
||||
|
||||
a2 = a1 + b2 /* a += b; d ^= a; d <<<= 8 */
|
||||
d3 = d2 ^ a2
|
||||
d4 = d3 <<< 8
|
||||
|
||||
c2 = c1 + d4 /* c += d; b ^= c; b <<<= 7 */
|
||||
b3 = b2 ^ c2
|
||||
b4 = b3 <<< 7
|
||||
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- Column and diagonal rounds ---- */
|
||||
|
||||
// Perform the column round, followed by the diagonal round on the
|
||||
// input state, which are both defined in terms of the quarter
|
||||
// round. ChaCha20 requires 20 total rounds of interleaving
|
||||
// column/diagonal passes on the state, and therefore `cdround` actually
|
||||
// does two passes at once (mostly for simplicity).
|
||||
cdround : Round -> Round
|
||||
cdround [ x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ]
|
||||
= [ z0, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13, z14, z15 ]
|
||||
where
|
||||
// Column round
|
||||
[ y0, y4, y8, y12 ] = qround [ x0, x4, x8, x12 ]
|
||||
[ y1, y5, y9, y13 ] = qround [ x1, x5, x9, x13 ]
|
||||
[ y2, y6, y10, y14 ] = qround [ x2, x6, x10, x14 ]
|
||||
[ y3, y7, y11, y15 ] = qround [ x3, x7, x11, x15 ]
|
||||
|
||||
// Diagonal round
|
||||
[ z0, z5, z10, z15 ] = qround [ y0, y5, y10, y15 ]
|
||||
[ z1, z6, z11, z12 ] = qround [ y1, y6, y11, y12 ]
|
||||
[ z2, z7, z8, z13 ] = qround [ y2, y7, y8, y13 ]
|
||||
[ z3, z4, z9, z14 ] = qround [ y3, y4, y9, y14 ]
|
||||
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- Block encryption -------------- */
|
||||
|
||||
// Given an input round, calculate the core ChaCha20 algorithm over
|
||||
// the round and return an output block. These output blocks form the
|
||||
// stream which you XOR your plaintext with, and successive iterations of
|
||||
// the core algorithm result in an infinite stream you can use as a
|
||||
// cipher.
|
||||
core : Round -> Block
|
||||
core x = block
|
||||
where
|
||||
rounds = iterate cdround x // Do a bunch of column/diagonal passes...
|
||||
result = rounds @ 10 // And grab the 10th result (20 total passes)
|
||||
block = blocked (x + result) // Add to input, convert to output block
|
||||
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- Key Expansion ----------------- */
|
||||
|
||||
// Key expansion. Given a nonce and a key, compute a round (which is
|
||||
// fed to the core algorithm above) by taking the initial round state and
|
||||
// mixing in the key and nonce appropriately.
|
||||
kexp : Key -> Counter -> Nonce -> Round
|
||||
kexp k c n = [ c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15 ]
|
||||
where
|
||||
// The following describes the layout of the output round, which
|
||||
// is fed into the core algorithm successively.
|
||||
|
||||
// Bytes 0-3: Constants
|
||||
[ c0, c1, c2, c3 ] = [ 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 ]
|
||||
|
||||
// Bytes 4-11: Key
|
||||
[ c4, c5, c6, c7 ] = map rjoin (groupBy`{4} kslice1 : [4][4][8]) : [4][32]
|
||||
[ c8, c9, c10, c11 ] = map rjoin (groupBy`{4} kslice2 : [4][4][8]) : [4][32]
|
||||
kslice1 = k @@ ([ 0 .. 15 ] : [16][32]) // Top half
|
||||
kslice2 = k @@ ([ 16 .. 31 ] : [16][32]) // Bottom half
|
||||
|
||||
// Bytes 12: Counter, starts off with whatever the user specified
|
||||
// (usually 0 or 1)
|
||||
[ c12 ] = [ c ]
|
||||
|
||||
// Bytes 14-15: Nonce
|
||||
[ c13, c14, c15 ] = map rjoin (groupBy`{4} n)
|
||||
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- Round increments -------------- */
|
||||
|
||||
// Take a given number of iterations and the input round (after key
|
||||
// expansion!), and calculate the input round for the core algorithm
|
||||
// function. This allows you to index into a particular Round which
|
||||
// can be passed to the 'core' function.
|
||||
iround : [64] -> Round -> Round
|
||||
iround n r = (iterate once r) @ n where
|
||||
// Given a round, increment the counter inside (index no 12)
|
||||
once [ x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ]
|
||||
= [ x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12+1, x13, x14, x15 ]
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* -- ChaCha20 encryption ----------- */
|
||||
|
||||
// Produce a psuedo-random stream given a nonce and a key, which can
|
||||
// be XOR'd with your data to encrypt it.
|
||||
stream : {n} (fin n) => Key -> Counter -> Nonce -> [n][8]
|
||||
stream k c n = take`{n} (join rounds) // Take n bytes from the final result
|
||||
where
|
||||
// Expand key
|
||||
key = kexp k c n
|
||||
|
||||
// Produce the stream by successively incrementing the input round
|
||||
// by `i`, and running the core algorithm to get the resulting
|
||||
// stream for the `i`th input. Once these are concatenated, you have
|
||||
// an infinite list representing the ChaCha20 stream.
|
||||
rounds = [ core (iround i key) | i <- [ 0, 1 ... ] ]
|
||||
|
||||
|
||||
// Given an message, a nonce, and a key, produce an encrypted
|
||||
// message. This is simply defined as the XOR of the message and the
|
||||
// corresponding encryption stream.
|
||||
encrypt : {n} (fin n) => Key -> Counter -> Nonce -> [n][8] -> [n][8]
|
||||
encrypt k c n m = m ^ (stream k c n)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -- Theorems, tests ------------------------------------------------------- */
|
||||
|
||||
// Tests are private
|
||||
private
|
||||
qround01 = qround in == out
|
||||
where
|
||||
in = [ 0x11111111, 0x01020304, 0x9b8d6f43, 0x01234567 ]
|
||||
out = [ 0xea2a92f4, 0xcb1cf8ce, 0x4581472e, 0x5881c4bb ]
|
||||
|
||||
core01 = kexp k 1 n == out
|
||||
where
|
||||
n = [ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4a,
|
||||
0x00, 0x00, 0x00, 0x00 ]
|
||||
k = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f ]
|
||||
out = [ 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574,
|
||||
0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c,
|
||||
0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c,
|
||||
0x00000001, 0x09000000, 0x4a000000, 0x00000000 ]
|
||||
|
||||
core02 = core (kexp k 1 n) == out
|
||||
where
|
||||
n = [ 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4a,
|
||||
0x00, 0x00, 0x00, 0x00 ]
|
||||
k = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f ]
|
||||
out = [ 0x10, 0xf1, 0xe7, 0xe4, 0xd1, 0x3b, 0x59, 0x15,
|
||||
0x50, 0x0f, 0xdd, 0x1f, 0xa3, 0x20, 0x71, 0xc4,
|
||||
0xc7, 0xd1, 0xf4, 0xc7, 0x33, 0xc0, 0x68, 0x03,
|
||||
0x04, 0x22, 0xaa, 0x9a, 0xc3, 0xd4, 0x6c, 0x4e,
|
||||
0xd2, 0x82, 0x64, 0x46, 0x07, 0x9f, 0xaa, 0x09,
|
||||
0x14, 0xc2, 0xd7, 0x05, 0xd9, 0x8b, 0x02, 0xa2,
|
||||
0xb5, 0x12, 0x9c, 0xd1, 0xde, 0x16, 0x4e, 0xb9,
|
||||
0xcb, 0xd0, 0x83, 0xe8, 0xa2, 0x50, 0x3c, 0x4e ]
|
||||
|
||||
rfctest01 = encrypt zero zero zero zero
|
||||
== [ 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, 0x40, 0x5d,
|
||||
0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, 0xbd, 0xd2, 0x19, 0xb8,
|
||||
0xa0, 0x8d, 0xed, 0x1a, 0xa8, 0x36, 0xef, 0xcc, 0x8b, 0x77,
|
||||
0x0d, 0xc7, 0xda, 0x41, 0x59, 0x7c, 0x51, 0x57, 0x48, 0x8d,
|
||||
0x77, 0x24, 0xe0, 0x3f, 0xb8, 0xd8, 0x4a, 0x37, 0x6a, 0x43,
|
||||
0xb8, 0xf4, 0x15, 0x18, 0xa1, 0x1c, 0xc3, 0x87, 0xb6, 0x69,
|
||||
0xb2, 0xee, 0x65, 0x86 ]
|
||||
|
||||
rfctest02 = encrypt (zero # [1]) 1 (zero # [2]) msg == out
|
||||
where
|
||||
out = [ 0xa3, 0xfb, 0xf0, 0x7d, 0xf3, 0xfa, 0x2f, 0xde, 0x4f, 0x37,
|
||||
0x6c, 0xa2, 0x3e, 0x82, 0x73, 0x70, 0x41, 0x60, 0x5d, 0x9f,
|
||||
0x4f, 0x4f, 0x57, 0xbd, 0x8c, 0xff, 0x2c, 0x1d, 0x4b, 0x79,
|
||||
0x55, 0xec, 0x2a, 0x97, 0x94, 0x8b, 0xd3, 0x72, 0x29, 0x15,
|
||||
0xc8, 0xf3, 0xd3, 0x37, 0xf7, 0xd3, 0x70, 0x05, 0x0e, 0x9e,
|
||||
0x96, 0xd6, 0x47, 0xb7, 0xc3, 0x9f, 0x56, 0xe0, 0x31, 0xca,
|
||||
0x5e, 0xb6, 0x25, 0x0d, 0x40, 0x42, 0xe0, 0x27, 0x85, 0xec,
|
||||
0xec, 0xfa, 0x4b, 0x4b, 0xb5, 0xe8, 0xea, 0xd0, 0x44, 0x0e,
|
||||
0x20, 0xb6, 0xe8, 0xdb, 0x09, 0xd8, 0x81, 0xa7, 0xc6, 0x13,
|
||||
0x2f, 0x42, 0x0e, 0x52, 0x79, 0x50, 0x42, 0xbd, 0xfa, 0x77,
|
||||
0x73, 0xd8, 0xa9, 0x05, 0x14, 0x47, 0xb3, 0x29, 0x1c, 0xe1,
|
||||
0x41, 0x1c, 0x68, 0x04, 0x65, 0x55, 0x2a, 0xa6, 0xc4, 0x05,
|
||||
0xb7, 0x76, 0x4d, 0x5e, 0x87, 0xbe, 0xa8, 0x5a, 0xd0, 0x0f,
|
||||
0x84, 0x49, 0xed, 0x8f, 0x72, 0xd0, 0xd6, 0x62, 0xab, 0x05,
|
||||
0x26, 0x91, 0xca, 0x66, 0x42, 0x4b, 0xc8, 0x6d, 0x2d, 0xf8,
|
||||
0x0e, 0xa4, 0x1f, 0x43, 0xab, 0xf9, 0x37, 0xd3, 0x25, 0x9d,
|
||||
0xc4, 0xb2, 0xd0, 0xdf, 0xb4, 0x8a, 0x6c, 0x91, 0x39, 0xdd,
|
||||
0xd7, 0xf7, 0x69, 0x66, 0xe9, 0x28, 0xe6, 0x35, 0x55, 0x3b,
|
||||
0xa7, 0x6c, 0x5c, 0x87, 0x9d, 0x7b, 0x35, 0xd4, 0x9e, 0xb2,
|
||||
0xe6, 0x2b, 0x08, 0x71, 0xcd, 0xac, 0x63, 0x89, 0x39, 0xe2,
|
||||
0x5e, 0x8a, 0x1e, 0x0e, 0xf9, 0xd5, 0x28, 0x0f, 0xa8, 0xca,
|
||||
0x32, 0x8b, 0x35, 0x1c, 0x3c, 0x76, 0x59, 0x89, 0xcb, 0xcf,
|
||||
0x3d, 0xaa, 0x8b, 0x6c, 0xcc, 0x3a, 0xaf, 0x9f, 0x39, 0x79,
|
||||
0xc9, 0x2b, 0x37, 0x20, 0xfc, 0x88, 0xdc, 0x95, 0xed, 0x84,
|
||||
0xa1, 0xbe, 0x05, 0x9c, 0x64, 0x99, 0xb9, 0xfd, 0xa2, 0x36,
|
||||
0xe7, 0xe8, 0x18, 0xb0, 0x4b, 0x0b, 0xc3, 0x9c, 0x1e, 0x87,
|
||||
0x6b, 0x19, 0x3b, 0xfe, 0x55, 0x69, 0x75, 0x3f, 0x88, 0x12,
|
||||
0x8c, 0xc0, 0x8a, 0xaa, 0x9b, 0x63, 0xd1, 0xa1, 0x6f, 0x80,
|
||||
0xef, 0x25, 0x54, 0xd7, 0x18, 0x9c, 0x41, 0x1f, 0x58, 0x69,
|
||||
0xca, 0x52, 0xc5, 0xb8, 0x3f, 0xa3, 0x6f, 0xf2, 0x16, 0xb9,
|
||||
0xc1, 0xd3, 0x00, 0x62, 0xbe, 0xbc, 0xfd, 0x2d, 0xc5, 0xbc,
|
||||
0xe0, 0x91, 0x19, 0x34, 0xfd, 0xa7, 0x9a, 0x86, 0xf6, 0xe6,
|
||||
0x98, 0xce, 0xd7, 0x59, 0xc3, 0xff, 0x9b, 0x64, 0x77, 0x33,
|
||||
0x8f, 0x3d, 0xa4, 0xf9, 0xcd, 0x85, 0x14, 0xea, 0x99, 0x82,
|
||||
0xcc, 0xaf, 0xb3, 0x41, 0xb2, 0x38, 0x4d, 0xd9, 0x02, 0xf3,
|
||||
0xd1, 0xab, 0x7a, 0xc6, 0x1d, 0xd2, 0x9c, 0x6f, 0x21, 0xba,
|
||||
0x5b, 0x86, 0x2f, 0x37, 0x30, 0xe3, 0x7c, 0xfd, 0xc4, 0xfd,
|
||||
0x80, 0x6c, 0x22, 0xf2, 0x21 ]
|
||||
|
||||
msg = [ 0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x49, 0x45, 0x54, 0x46, 0x20, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x6e, 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69, 0x62,
|
||||
0x75, 0x74, 0x6f, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x70,
|
||||
0x75, 0x62, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x61, 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72,
|
||||
0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61,
|
||||
0x6e, 0x20, 0x49, 0x45, 0x54, 0x46, 0x20, 0x49, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x6e, 0x65, 0x74, 0x2d, 0x44, 0x72, 0x61, 0x66,
|
||||
0x74, 0x20, 0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73, 0x74, 0x61,
|
||||
0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6d, 0x61, 0x64,
|
||||
0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x69, 0x6e, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54,
|
||||
0x46, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
|
||||
0x20, 0x69, 0x73, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64,
|
||||
0x65, 0x72, 0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49,
|
||||
0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x69,
|
||||
0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2e, 0x20, 0x53,
|
||||
0x75, 0x63, 0x68, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d,
|
||||
0x65, 0x6e, 0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75,
|
||||
0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20, 0x73, 0x74,
|
||||
0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x69,
|
||||
0x6e, 0x20, 0x49, 0x45, 0x54, 0x46, 0x20, 0x73, 0x65, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20,
|
||||
0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20, 0x77, 0x72,
|
||||
0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20,
|
||||
0x65, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63,
|
||||
0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61, 0x64, 0x65,
|
||||
0x20, 0x61, 0x74, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x70, 0x6c, 0x61, 0x63,
|
||||
0x65, 0x2c, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61,
|
||||
0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x65, 0x64, 0x20, 0x74, 0x6f ]
|
||||
|
||||
rfctest03 = encrypt key 42 (zero # [2]) msg == out
|
||||
where
|
||||
key = [ 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, 0xf3, 0x33,
|
||||
0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, 0x47, 0x39, 0x17, 0xc1,
|
||||
0x40, 0x2b, 0x80, 0x09, 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70,
|
||||
0x75, 0xc0 ]
|
||||
out = [ 0x27, 0x54, 0x77, 0x61, 0x73, 0x20, 0x62, 0x72, 0x69, 0x6c,
|
||||
0x6c, 0x69, 0x67, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x73, 0x6c, 0x69, 0x74, 0x68, 0x79, 0x20,
|
||||
0x74, 0x6f, 0x76, 0x65, 0x73, 0x0a, 0x44, 0x69, 0x64, 0x20,
|
||||
0x67, 0x79, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x67,
|
||||
0x69, 0x6d, 0x62, 0x6c, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x77, 0x61, 0x62, 0x65, 0x3a, 0x0a, 0x41,
|
||||
0x6c, 0x6c, 0x20, 0x6d, 0x69, 0x6d, 0x73, 0x79, 0x20, 0x77,
|
||||
0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f,
|
||||
0x72, 0x6f, 0x67, 0x6f, 0x76, 0x65, 0x73, 0x2c, 0x0a, 0x41,
|
||||
0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x6f, 0x6d,
|
||||
0x65, 0x20, 0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75,
|
||||
0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e ]
|
||||
|
||||
msg = [ 0x62, 0xe6, 0x34, 0x7f, 0x95, 0xed, 0x87, 0xa4, 0x5f, 0xfa,
|
||||
0xe7, 0x42, 0x6f, 0x27, 0xa1, 0xdf, 0x5f, 0xb6, 0x91, 0x10,
|
||||
0x04, 0x4c, 0x0d, 0x73, 0x11, 0x8e, 0xff, 0xa9, 0x5b, 0x01,
|
||||
0xe5, 0xcf, 0x16, 0x6d, 0x3d, 0xf2, 0xd7, 0x21, 0xca, 0xf9,
|
||||
0xb2, 0x1e, 0x5f, 0xb1, 0x4c, 0x61, 0x68, 0x71, 0xfd, 0x84,
|
||||
0xc5, 0x4f, 0x9d, 0x65, 0xb2, 0x83, 0x19, 0x6c, 0x7f, 0xe4,
|
||||
0xf6, 0x05, 0x53, 0xeb, 0xf3, 0x9c, 0x64, 0x02, 0xc4, 0x22,
|
||||
0x34, 0xe3, 0x2a, 0x35, 0x6b, 0x3e, 0x76, 0x43, 0x12, 0xa6,
|
||||
0x1a, 0x55, 0x32, 0x05, 0x57, 0x16, 0xea, 0xd6, 0x96, 0x25,
|
||||
0x68, 0xf8, 0x7d, 0x3f, 0x3f, 0x77, 0x04, 0xc6, 0xa8, 0xd1,
|
||||
0xbc, 0xd1, 0xbf, 0x4d, 0x50, 0xd6, 0x15, 0x4b, 0x6d, 0xa7,
|
||||
0x31, 0xb1, 0x87, 0xb5, 0x8d, 0xfd, 0x72, 0x8a, 0xfa, 0x36,
|
||||
0x75, 0x7a, 0x79, 0x7a, 0xc1, 0x88, 0xd1 ]
|
||||
|
||||
property allTestsPass =
|
||||
([ // Basic tests
|
||||
qround01, core01, core02
|
||||
// Full RFC test vectors
|
||||
, rfctest01, rfctest02, rfctest03
|
||||
] : [_]Bit) == ~zero // All test bits should equal one
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -- Private utilities ----------------------------------------------------- */
|
||||
|
||||
private
|
||||
// Convert a round into a block, by splitting every 32-bit round entry
|
||||
// into 4 bytes, and then serialize those values into a full block.
|
||||
blocked : Round -> Block
|
||||
blocked x = join (map toBytes x)
|
||||
where
|
||||
// This essentially splits a 32-bit number into 4-byte
|
||||
// little-endian form, where 'rjoin' is the inverse and would merge
|
||||
// 4 bytes as a 32-bit little endian number.
|
||||
toBytes : [32] -> [4][8]
|
||||
toBytes v = reverse (groupBy`{8} v)
|
||||
|
||||
// Map a function over a finite list.
|
||||
map : { a, b, c }
|
||||
(a -> b) -> [c]a -> [c]b
|
||||
map f xs = [ f x | x <- xs ]
|
||||
|
||||
// Map a function iteratively over a seed value, producing an infinite
|
||||
// list of successive function applications:
|
||||
//
|
||||
// iterate f 0 == [ 0, f 0, f (f 0), f (f (f 0)), ... ]
|
||||
iterate : { a } (a -> a) -> a -> [inf]a
|
||||
iterate f x = [x] # [ f v | v <- iterate f x ]
|
||||
where
|
||||
// NB: Needs a binded name in order to tie the recursive knot.
|
||||
xs = [x] # [ f v | v <- xs ]
|
||||
|
||||
// rjoin = join . reverse
|
||||
// This encodes a sequence of values as a little endian number
|
||||
// e.g. [ 0xaa, 0xbb, 0xcc, 0xdd ] is serialized as \xdd\xcc\xbb\xaa
|
||||
rjoin : {a, b, c}
|
||||
( fin a, fin c
|
||||
) => [c][a]b -> [a * c]b
|
||||
rjoin x = join (reverse x)
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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/.
|
||||
|
||||
import "chacha20.cry" as chacha20;
|
||||
|
||||
print "Proving ChaCha20 spec...";
|
||||
prove_print abc {{ chacha20::allTestsPass }};
|
||||
|
||||
print "Loading LLVM bitcode...";
|
||||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc";
|
||||
|
||||
let SpecChaCha20 n = do {
|
||||
llvm_ptr "output" (llvm_array n (llvm_int 8));
|
||||
output <- llvm_var "*output" (llvm_array n (llvm_int 8));
|
||||
|
||||
llvm_ptr "plain" (llvm_array n (llvm_int 8));
|
||||
plain <- llvm_var "*plain" (llvm_array n (llvm_int 8));
|
||||
|
||||
len <- llvm_var "len" (llvm_int 32);
|
||||
llvm_assert_eq "len" {{ `n : [32] }};
|
||||
|
||||
llvm_ptr "k" (llvm_array 32 (llvm_int 8));
|
||||
k <- llvm_var "*k" (llvm_array 32 (llvm_int 8));
|
||||
|
||||
llvm_ptr "n1" (llvm_array 12 (llvm_int 8));
|
||||
n1 <- llvm_var "*n1" (llvm_array 12 (llvm_int 8));
|
||||
|
||||
ctr <- llvm_var "ctr" (llvm_int 32);
|
||||
|
||||
llvm_ensure_eq "*output" {{ chacha20::encrypt k ctr n1 plain }};
|
||||
|
||||
llvm_verify_tactic abc;
|
||||
};
|
||||
|
||||
print "Proving equality for a single block...";
|
||||
time (llvm_verify m "Hacl_Chacha20_chacha20" [] (SpecChaCha20 64));
|
||||
|
||||
print "Proving equality for multiple blocks...";
|
||||
time (llvm_verify m "Hacl_Chacha20_chacha20" [] (SpecChaCha20 256));
|
||||
@@ -0,0 +1,38 @@
|
||||
// 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/.
|
||||
|
||||
import "poly1305.cry" as poly1305;
|
||||
|
||||
print "Proving Poly1305 spec...";
|
||||
prove_print abc {{ poly1305::allTestsPass }};
|
||||
|
||||
print "Loading LLVM bitcode...";
|
||||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc";
|
||||
|
||||
let SpecPoly1305 n = do {
|
||||
llvm_ptr "output" (llvm_array 16 (llvm_int 8));
|
||||
output <- llvm_var "*output" (llvm_array 16 (llvm_int 8));
|
||||
|
||||
llvm_ptr "input" (llvm_array n (llvm_int 8));
|
||||
input <- llvm_var "*input" (llvm_array n (llvm_int 8));
|
||||
|
||||
llvm_var "len1" (llvm_int 64);
|
||||
llvm_ptr "k1" (llvm_array 32 (llvm_int 8));
|
||||
k1 <- llvm_var "*k1" (llvm_array 32 (llvm_int 8));
|
||||
|
||||
llvm_assert_eq "*input" {{ zero : [n][8] }};
|
||||
llvm_assert_eq "len1" {{ `n : [64] }};
|
||||
|
||||
llvm_assert_eq "*k1" {{ zero : [32][8] }};
|
||||
|
||||
let res = {{ poly1305::Poly1305 input (take`{16} k1) (drop`{16} k1) }};
|
||||
llvm_ensure_eq "*output" {{ res }};
|
||||
|
||||
llvm_verify_tactic abc;
|
||||
};
|
||||
|
||||
print "Proving equality for a single block...";
|
||||
// This is currently disabled as it takes way too long. We need to help Z3
|
||||
// prove this before we can enable it on Taskcluster.
|
||||
//time (llvm_verify m "Hacl_Poly1305_64_crypto_onetimeauth" [] (SpecPoly1305 16));
|
||||
@@ -0,0 +1,336 @@
|
||||
/* 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/. */
|
||||
|
||||
/* This file provides a spec of the Poly1305 one-time authenticator.
|
||||
* See <https://tools.ietf.org/html/rfc7539> for details. */
|
||||
|
||||
module poly1305 where
|
||||
|
||||
P : [136]
|
||||
P = 2^^130 - 5
|
||||
|
||||
Poly1305 : {n} (fin n) => [n][8] -> [16][8] -> [16][8] -> [16][8]
|
||||
Poly1305 msg r s = reverse (groupBy (drop ((rounds ! 0) + s')))
|
||||
where
|
||||
rounds = [zero] # [ Poly1305_block acc r' b | b <- blocks | acc <- rounds ]
|
||||
r' = zero # (Poly1305_clamp (join (reverse r)))
|
||||
s' = zero # (join (reverse s))
|
||||
blocks = Poly1305_split msg
|
||||
|
||||
private
|
||||
// 0x0f - for r[3], r[7], r[11], r[15]
|
||||
// 0xfc - for r[4], r[8], r[12]
|
||||
Poly1305_clamp r = r && 0x0ffffffc0ffffffc0ffffffc0fffffff
|
||||
|
||||
// Poly1305_block : ((acc + msg) * r) % P
|
||||
Poly1305_block : [136] -> [136] -> [136] -> [136]
|
||||
Poly1305_block acc r msg = drop (prod % (zero # P))
|
||||
where
|
||||
acc' : [137]
|
||||
// Add the current block to the accumulator.
|
||||
acc' = (zero # acc) + (zero # msg)
|
||||
prod : [273]
|
||||
// Multiply the new accumulator value by r.
|
||||
prod = ((zero : [137]) # r) * ((zero : [136]) # acc')
|
||||
|
||||
Poly1305_split : {n, nb, nf} (fin n, nf == n / 16, nb == (n + 15) / 16) => [n][8] -> [nb][136]
|
||||
Poly1305_split msg = take ((h1 : [nf][136]) # h2)
|
||||
where
|
||||
// Split all full 16-byte blocks and append 0x01, then convert to LE.
|
||||
h1 = [ join (reverse (b # [0x01])) | b <- groupBy`{16} (take msg)]
|
||||
// Pad the remaining bytes (if any) and convert to LE.
|
||||
h2 = [join (reverse ((drop`{nf * 16} msg) # [0x01] # zero))]
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -- Tests ----------------------------------------------------------------- */
|
||||
|
||||
private
|
||||
// https://tools.ietf.org/html/rfc7539#section-2.5.2
|
||||
rval1 = [0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33,
|
||||
0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8]
|
||||
sval1 = [0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd,
|
||||
0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b]
|
||||
text1 = [0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
|
||||
0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f,
|
||||
0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65,
|
||||
0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f,
|
||||
0x75, 0x70]
|
||||
|
||||
rfctest01 = Poly1305 text1 rval1 sval1
|
||||
== [0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6,
|
||||
0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #1
|
||||
rval2 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval2 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text2 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
rfctest02 = Poly1305 text2 rval2 sval2
|
||||
== [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #2
|
||||
rval3 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval3 = [0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70,
|
||||
0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e]
|
||||
text3 = [0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d,
|
||||
0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74,
|
||||
0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x49, 0x45,
|
||||
0x54, 0x46, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x6e,
|
||||
0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72,
|
||||
0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x20, 0x66,
|
||||
0x6f, 0x72, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69,
|
||||
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61,
|
||||
0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72,
|
||||
0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66,
|
||||
0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54, 0x46,
|
||||
0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65,
|
||||
0x74, 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x20,
|
||||
0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73,
|
||||
0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x77, 0x69,
|
||||
0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
|
||||
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49,
|
||||
0x45, 0x54, 0x46, 0x20, 0x61, 0x63, 0x74, 0x69,
|
||||
0x76, 0x69, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20,
|
||||
0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72,
|
||||
0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49,
|
||||
0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x22, 0x2e, 0x20, 0x53, 0x75, 0x63, 0x68, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75,
|
||||
0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45,
|
||||
0x54, 0x46, 0x20, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20,
|
||||
0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20,
|
||||
0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63,
|
||||
0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63,
|
||||
0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61,
|
||||
0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e,
|
||||
0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f,
|
||||
0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c,
|
||||
0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61,
|
||||
0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f]
|
||||
|
||||
rfctest03 = Poly1305 text3 rval3 sval3
|
||||
== [0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70,
|
||||
0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #3
|
||||
rval4 = [0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70,
|
||||
0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e]
|
||||
sval4 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text4 = [0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d,
|
||||
0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74,
|
||||
0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x49, 0x45,
|
||||
0x54, 0x46, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x6e,
|
||||
0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72,
|
||||
0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x20, 0x66,
|
||||
0x6f, 0x72, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69,
|
||||
0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61,
|
||||
0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72,
|
||||
0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66,
|
||||
0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54, 0x46,
|
||||
0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65,
|
||||
0x74, 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x20,
|
||||
0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73,
|
||||
0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74,
|
||||
0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x77, 0x69,
|
||||
0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65,
|
||||
0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49,
|
||||
0x45, 0x54, 0x46, 0x20, 0x61, 0x63, 0x74, 0x69,
|
||||
0x76, 0x69, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20,
|
||||
0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72,
|
||||
0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49,
|
||||
0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x22, 0x2e, 0x20, 0x53, 0x75, 0x63, 0x68, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75,
|
||||
0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45,
|
||||
0x54, 0x46, 0x20, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20,
|
||||
0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20,
|
||||
0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20,
|
||||
0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63,
|
||||
0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63,
|
||||
0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61,
|
||||
0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e,
|
||||
0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f,
|
||||
0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c,
|
||||
0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61,
|
||||
0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f]
|
||||
|
||||
rfctest04 = Poly1305 text4 rval4 sval4
|
||||
== [0xf3, 0x47, 0x7e, 0x7c, 0xd9, 0x54, 0x17, 0xaf,
|
||||
0x89, 0xa6, 0xb8, 0x79, 0x4c, 0x31, 0x0c, 0xf0]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #4
|
||||
rval5 = [0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a,
|
||||
0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0]
|
||||
sval5 = [0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09,
|
||||
0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0]
|
||||
text5 = [0x27, 0x54, 0x77, 0x61, 0x73, 0x20, 0x62, 0x72,
|
||||
0x69, 0x6c, 0x6c, 0x69, 0x67, 0x2c, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
|
||||
0x6c, 0x69, 0x74, 0x68, 0x79, 0x20, 0x74, 0x6f,
|
||||
0x76, 0x65, 0x73, 0x0a, 0x44, 0x69, 0x64, 0x20,
|
||||
0x67, 0x79, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64,
|
||||
0x20, 0x67, 0x69, 0x6d, 0x62, 0x6c, 0x65, 0x20,
|
||||
0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77,
|
||||
0x61, 0x62, 0x65, 0x3a, 0x0a, 0x41, 0x6c, 0x6c,
|
||||
0x20, 0x6d, 0x69, 0x6d, 0x73, 0x79, 0x20, 0x77,
|
||||
0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20,
|
||||
0x62, 0x6f, 0x72, 0x6f, 0x67, 0x6f, 0x76, 0x65,
|
||||
0x73, 0x2c, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x6d, 0x6f, 0x6d, 0x65, 0x20,
|
||||
0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75,
|
||||
0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e]
|
||||
|
||||
rfctest05 = Poly1305 text5 rval5 sval5
|
||||
== [0x45, 0x41, 0x66, 0x9a, 0x7e, 0xaa, 0xee, 0x61,
|
||||
0xe7, 0x08, 0xdc, 0x7c, 0xbc, 0xc5, 0xeb, 0x62]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #5
|
||||
rval6 = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval6 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text6 = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
|
||||
|
||||
rfctest06 = Poly1305 text6 rval6 sval6
|
||||
== [0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #6
|
||||
rval7 = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval7 = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
|
||||
text7 = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
rfctest07 = Poly1305 text7 rval7 sval7
|
||||
== [0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #7
|
||||
rval8 = [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval8 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text8 = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
rfctest08 = Poly1305 text8 rval8 sval8
|
||||
== [0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #8
|
||||
rval9 = [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval9 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text9 = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xfb, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
|
||||
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01]
|
||||
|
||||
rfctest09 = Poly1305 text9 rval9 sval9
|
||||
== [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #9
|
||||
rval10 = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval10 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text10 = [0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
|
||||
|
||||
rfctest10 = Poly1305 text10 rval10 sval10
|
||||
== [0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #10
|
||||
rval11 = [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval11 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text11 = [0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
rfctest11 = Poly1305 text11 rval11 sval11
|
||||
== [0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
// https://tools.ietf.org/html/rfc7539#appendix-A.3
|
||||
// Test Vector #11
|
||||
rval12 = [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
sval12 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
text12 = [0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
rfctest12 = Poly1305 text12 rval12 sval12
|
||||
== [0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
|
||||
|
||||
property allTestsPass =
|
||||
([ // Full RFC test vectors
|
||||
rfctest01, rfctest02, rfctest03, rfctest04,
|
||||
rfctest05, rfctest06, rfctest07, rfctest08,
|
||||
rfctest09, rfctest10, rfctest11, rfctest12
|
||||
] : [_]Bit) == ~zero // All test bits should equal one
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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/.
|
||||
|
||||
import "poly1305.cry" as poly1305;
|
||||
|
||||
print "Proving Poly1305 spec...";
|
||||
prove_print abc {{ poly1305::allTestsPass }};
|
||||
|
||||
print "Loading LLVM bitcode...";
|
||||
m <- llvm_load_module "../../../dist/Debug/lib/libfreeblpriv3.so.bc";
|
||||
|
||||
let SpecPoly1305 n = do {
|
||||
llvm_ptr "out" (llvm_array 16 (llvm_int 8));
|
||||
out <- llvm_var "*out" (llvm_array 16 (llvm_int 8));
|
||||
|
||||
llvm_ptr "ad" (llvm_array 16 (llvm_int 8));
|
||||
ad <- llvm_var "*ad" (llvm_array 16 (llvm_int 8));
|
||||
|
||||
adLen <- llvm_var "adLen" (llvm_int 32);
|
||||
|
||||
llvm_ptr "ciphertext" (llvm_array n (llvm_int 8));
|
||||
ciphertext <- llvm_var "*ciphertext" (llvm_array n (llvm_int 8));
|
||||
|
||||
ciphertextLen <- llvm_var "ciphertextLen" (llvm_int 32);
|
||||
|
||||
llvm_ptr "key" (llvm_array 32 (llvm_int 8));
|
||||
key <- llvm_var "*key" (llvm_array 32 (llvm_int 8));
|
||||
|
||||
llvm_assert_eq "*ad" {{ zero : [16][8] }};
|
||||
llvm_assert_eq "adLen" {{ 16 : [32] }};
|
||||
|
||||
llvm_assert_eq "*ciphertext" {{ zero : [n][8] }};
|
||||
llvm_assert_eq "ciphertextLen" {{ `n : [32] }};
|
||||
|
||||
llvm_assert_eq "*key" {{ zero : [32][8] }};
|
||||
|
||||
let res = {{ poly1305::Poly1305 (ad # ciphertext # [16, 0, 0, 0, 0, 0, 0, 0] # [`n, 0, 0, 0, 0, 0, 0, 0]) (take`{16} key) (drop`{16} key) }};
|
||||
llvm_ensure_eq "*out" {{ res }};
|
||||
|
||||
llvm_verify_tactic abc;
|
||||
};
|
||||
|
||||
print "Proving equality for a single block...";
|
||||
// This is currently disabled as it takes way too long. We need to help Z3
|
||||
// prove this before we can enable it on Taskcluster.
|
||||
//time (llvm_verify m "Poly1305Do" [] (SpecPoly1305 16));
|
||||
@@ -0,0 +1,30 @@
|
||||
FROM franziskus/xenial:aarch64
|
||||
MAINTAINER Franziskus Kiefer <franziskuskiefer@gmail.com>
|
||||
|
||||
RUN useradd -d /home/worker -s /bin/bash -m worker
|
||||
WORKDIR /home/worker
|
||||
|
||||
# Add build and test scripts.
|
||||
ADD bin /home/worker/bin
|
||||
RUN chmod +x /home/worker/bin/*
|
||||
|
||||
# Install dependencies.
|
||||
ADD setup.sh /tmp/setup.sh
|
||||
RUN bash /tmp/setup.sh
|
||||
|
||||
# Change user.
|
||||
# USER worker # See bug 1347473.
|
||||
|
||||
# Env variables.
|
||||
ENV HOME /home/worker
|
||||
ENV SHELL /bin/bash
|
||||
ENV USER worker
|
||||
ENV LOGNAME worker
|
||||
ENV HOSTNAME taskcluster-worker
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV HOST localhost
|
||||
ENV DOMSUF localdomain
|
||||
|
||||
# Set a default command for debugging.
|
||||
CMD ["/bin/bash", "--login"]
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -v -e -x
|
||||
|
||||
if [ $(id -u) = 0 ]; then
|
||||
# Drop privileges by re-running this script.
|
||||
exec su worker $0
|
||||
fi
|
||||
|
||||
# Default values for testing.
|
||||
REVISION=${NSS_HEAD_REVISION:-default}
|
||||
REPOSITORY=${NSS_HEAD_REPOSITORY:-https://hg.mozilla.org/projects/nss}
|
||||
|
||||
# Clone NSS.
|
||||
for i in 0 2 5; do
|
||||
sleep $i
|
||||
hg clone -r $REVISION $REPOSITORY nss && exit 0
|
||||
rm -rf nss
|
||||
done
|
||||
exit 1
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -v -e -x
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get -y update
|
||||
apt-get -y install software-properties-common
|
||||
|
||||
# Add more repos
|
||||
add-apt-repository "deb http://ports.ubuntu.com/ xenial main restricted universe multiverse"
|
||||
add-apt-repository "deb http://ports.ubuntu.com/ xenial-security main restricted universe multiverse"
|
||||
add-apt-repository "deb http://ports.ubuntu.com/ xenial-updates main restricted universe multiverse"
|
||||
add-apt-repository "deb http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse"
|
||||
|
||||
# Update.
|
||||
apt-get -y update
|
||||
apt-get -y dist-upgrade
|
||||
|
||||
apt_packages=()
|
||||
apt_packages+=('build-essential')
|
||||
apt_packages+=('ca-certificates')
|
||||
apt_packages+=('curl')
|
||||
apt_packages+=('libxml2-utils')
|
||||
apt_packages+=('zlib1g-dev')
|
||||
apt_packages+=('ninja-build')
|
||||
apt_packages+=('gyp')
|
||||
apt_packages+=('mercurial')
|
||||
apt_packages+=('locales')
|
||||
|
||||
# Install packages.
|
||||
apt-get install -y --no-install-recommends ${apt_packages[@]}
|
||||
|
||||
locale-gen en_US.UTF-8
|
||||
dpkg-reconfigure locales
|
||||
|
||||
# Cleanup.
|
||||
rm -rf ~/.ccache ~/.cache
|
||||
apt-get autoremove -y
|
||||
apt-get clean
|
||||
apt-get autoclean
|
||||
rm $0
|
||||
@@ -0,0 +1,27 @@
|
||||
FROM armv7/armhf-ubuntu:16.04
|
||||
MAINTAINER Franziskus Kiefer <franziskuskiefer@gmail.com>
|
||||
|
||||
RUN useradd -d /home/worker -s /bin/bash -m worker
|
||||
WORKDIR /home/worker
|
||||
|
||||
# Add build and test scripts.
|
||||
ADD bin /home/worker/bin
|
||||
RUN chmod +x /home/worker/bin/*
|
||||
|
||||
# Install dependencies.
|
||||
ADD setup.sh /tmp/setup.sh
|
||||
RUN bash /tmp/setup.sh
|
||||
|
||||
# Env variables.
|
||||
ENV HOME /home/worker
|
||||
ENV SHELL /bin/bash
|
||||
ENV USER worker
|
||||
ENV LOGNAME worker
|
||||
ENV HOSTNAME taskcluster-worker
|
||||
ENV LANG en_US.UTF-8
|
||||
ENV LC_ALL en_US.UTF-8
|
||||
ENV HOST localhost
|
||||
ENV DOMSUF localdomain
|
||||
|
||||
# Set a default command for debugging.
|
||||
CMD ["/bin/bash", "--login"]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user