openbox lab initialized

This commit is contained in:
2025-11-06 00:01:42 +08:00
parent 0fe20bb24c
commit edb0725375
2508 changed files with 670396 additions and 66 deletions

View File

@@ -0,0 +1,115 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef AIX
#define AIX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
/* used by protypes.h only */
#define _PR_AIX_HAVE_BSD_INT_TYPES
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef AIX
#define AIX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 8
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
/* used by protypes.h only */
#define _PR_AIX_HAVE_BSD_INT_TYPES
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,120 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_BEOS
#define XP_BEOS
#undef XP_UNIX
#endif
#ifndef BEOS
#define BEOS
#endif
#define PR_AF_INET6 5 /* same as AF_INET6 */
#ifdef __powerpc__
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#else
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#endif
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
/*
* XXX These two macros need to be investigated for different architectures.
*/
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,170 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef BSDI
#define BSDI
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#if defined(__i386__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__sparc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error "Unknown CPU architecture"
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,165 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#define PR_AF_INET6 30 /* same as AF_INET6 */
#ifdef __LITTLE_ENDIAN__
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#else
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#endif
#ifdef __LP64__
#define IS_64
#endif
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS 1
#ifdef IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#else /* IS_64 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#endif /* IS_64 */
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef DGUX
#define DGUX
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,594 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef FREEBSD
#define FREEBSD
#endif
#define PR_AF_INET6 28 /* same as AF_INET6 */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#if defined(__i386__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#elif defined(__alpha__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#elif defined(__sparc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#elif defined(__ia64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#elif defined(__amd64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#elif defined(__powerpc64__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__aarch64__)
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__arm__)
#if defined(__ARMEB__) || defined(__ARM_BIG_ENDIAN__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#else
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#endif
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__mips64__)
#if defined(__MIPSEB__) || defined(_MIPSEB)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#else
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#endif
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__mips__)
#if defined(__MIPSEB__) || defined(_MIPSEB)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#else
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#endif
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error "Unknown CPU architecture"
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef HPUX
#define HPUX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_AF_INET6 22 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,113 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef HPUX
#define HPUX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_AF_INET6 22 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,119 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef _SGI_MP_SOURCE
#define _SGI_MP_SOURCE
#endif
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef IRIX
#define IRIX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_AF_INET6 24 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define _PR_POLL_BACKCOMPAT
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef _SGI_MP_SOURCE
#define _SGI_MP_SOURCE
#endif
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef IRIX
#define IRIX
#endif
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define IS_64
#define PR_AF_INET6 24 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,351 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef NETBSD
#define NETBSD
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#if defined(__i386__) || defined(__arm32__) || defined(__ARMEL__) || \
defined(__MIPSEL__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#elif defined(__sparc_v9__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#elif defined(__sparc__) || defined(__MIPSEB__) || defined(__ARMEB__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(__alpha__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__amd64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__) || defined(__m68k__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error Must define constants for type sizes here.
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,120 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef NTO
#define NTO
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifdef __i386__
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1L
#define PR_BYTES_PER_SHORT 2L
#define PR_BYTES_PER_INT 4L
#define PR_BYTES_PER_INT64 8L
#define PR_BYTES_PER_LONG 4L
#define PR_BYTES_PER_FLOAT 4L
#define PR_BYTES_PER_DOUBLE 8L
#define PR_BYTES_PER_WORD 4L
#define PR_BYTES_PER_DWORD 8L
#define PR_BITS_PER_BYTE 8L
#define PR_BITS_PER_SHORT 16L
#define PR_BITS_PER_INT 32L
#define PR_BITS_PER_INT64 64L
#define PR_BITS_PER_LONG 32L
#define PR_BITS_PER_FLOAT 32L
#define PR_BITS_PER_DOUBLE 64L
#define PR_BITS_PER_WORD 32L
#define PR_BITS_PER_BYTE_LOG2 3L
#define PR_BITS_PER_SHORT_LOG2 4L
#define PR_BITS_PER_INT_LOG2 5L
#define PR_BITS_PER_INT64_LOG2 6L
#define PR_BITS_PER_LONG_LOG2 5L
#define PR_BITS_PER_FLOAT_LOG2 5L
#define PR_BITS_PER_DOUBLE_LOG2 6L
#define PR_BITS_PER_WORD_LOG2 5L
#define PR_ALIGN_OF_SHORT 2L
#define PR_ALIGN_OF_INT 4L
#define PR_ALIGN_OF_LONG 4L
#define PR_ALIGN_OF_INT64 4L
#define PR_ALIGN_OF_FLOAT 4L
#define PR_ALIGN_OF_DOUBLE 4L
#define PR_ALIGN_OF_POINTER 4L
#define PR_ALIGN_OF_WORD 4L
#define PR_BYTES_PER_WORD_LOG2 2L
#define PR_BYTES_PER_DWORD_LOG2 3L
#define PR_WORDS_PER_DWORD_LOG2 1L
#else
#error Undefined CPU Architecture
#endif
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,353 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef OPENBSD
#define OPENBSD
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#if defined(__i386__) || defined(__arm__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#elif defined(__amd64__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_ALIGN_OF_WORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#elif defined(__sparc_v9__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__sparc__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(__alpha__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__powerpc__) || defined(__m68k__)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error Must define constants for type sizes here.
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,121 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef XP_OS2
#define XP_OS2
#endif
#ifndef OS2
#define OS2
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifdef NO_LONG_LONG
#undef HAVE_LONG_LONG
#else
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG 1
#endif
#endif
#define PR_AF_INET6 24 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef OSF1
#define OSF1
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef IS_64
#define IS_64
#endif
#define PR_AF_INET6 26 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define _PR_POLL_BACKCOMPAT
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef QNX
#define QNX
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 1
#define PR_ALIGN_OF_INT 1
#define PR_ALIGN_OF_LONG 1
#define PR_ALIGN_OF_INT64 1
#define PR_ALIGN_OF_FLOAT 1
#define PR_ALIGN_OF_DOUBLE 1
#define PR_ALIGN_OF_POINTER 1
#define PR_ALIGN_OF_WORD 1
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_WORDS_PER_DWORD_LOG2 1
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,111 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef RISCOS
#define RISCOS
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_WORDS_PER_DWORD_LOG2 1
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef SCO
#define SCO
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define _PR_POLL_BACKCOMPAT
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,171 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef SOLARIS
#define SOLARIS
#endif
#define PR_AF_INET6 26 /* same as AF_INET6 */
#if defined(sparc) || defined(__sparc)
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_DOUBLE 8
#if defined(__sparcv9)
#define IS_64
#endif
#elif defined(__x86_64)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_DOUBLE 8
#define IS_64
#elif defined(i386) || defined(__i386)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_DOUBLE 4
#else
#error unknown processor
#endif
#ifdef IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 8
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 64
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 6
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_POINTER 8
#else /* IS_64 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_POINTER 4
#endif /* IS_64 */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* ifndef nspr_cpucfg___ */

View File

@@ -0,0 +1,170 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef SYMBIAN
#define SYMBIAN
#endif
#define PR_AF_INET6 0x0806 /* same as AF_INET6 */
#ifdef __arm__
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(__WINS__)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else
#error "Unknown CPU architecture"
#endif
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#if PR_ALIGN_OF_DOUBLE == 8
#define HAVE_ALIGNED_DOUBLES
#endif
#if PR_ALIGN_OF_INT64 == 8
#define HAVE_ALIGNED_LONGLONGS
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef UNIXWARE
#define UNIXWARE
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define _PR_POLL_BACKCOMPAT
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_UNIX
#define XP_UNIX
#endif
#ifndef UNIXWARE
#define UNIXWARE
#endif
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define PR_AF_INET6 27 /* same as AF_INET6 */
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 4
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define _PR_POLL_BACKCOMPAT
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,272 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WIN95
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_M_IA64) || defined(_IA64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_M_ARM) || defined(_ARM_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,224 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WINNT
#define WINNT
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#elif defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_M_IA64) || defined(_IA64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

View File

@@ -0,0 +1,43 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nspr_h___
#define nspr_h___
#include "pratom.h"
#include "prbit.h"
#include "prclist.h"
#include "prcmon.h"
#include "prcvar.h"
#include "prdtoa.h"
#include "prenv.h"
#include "prerror.h"
#include "prinet.h"
#include "prinit.h"
#include "prinrval.h"
#include "prio.h"
#include "pripcsem.h"
#include "prlink.h"
#include "prlock.h"
#include "prlog.h"
#include "prlong.h"
#include "prmem.h"
#include "prmon.h"
#include "prmwait.h"
#include "prnetdb.h"
#include "prprf.h"
#include "prproces.h"
#include "prrng.h"
#include "prrwlock.h"
#include "prshm.h"
#include "prshma.h"
#include "prsystem.h"
#include "prthread.h"
#include "prtime.h"
#include "prtpool.h"
#include "prtrace.h"
#include "prtypes.h"
#endif /* nspr_h___ */

View File

@@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: pralarm.h
** Description: API to periodic alarms.
**
**
** Alarms are defined to invoke some client specified function at
** a time in the future. The notification may be a one time event
** or repeated at a fixed interval. The interval at which the next
** notification takes place may be modified by the client code only
** during the respective notification.
**
** The notification is delivered on a thread that is part of the
** alarm context (PRAlarm). The thread will inherit the priority
** of the Alarm creator.
**
** Any number of periodic alarms (PRAlarmID) may be created within
** the context of a single alarm (PRAlarm). The notifications will be
** scheduled as close to the desired time as possible.
**
** Repeating periodic notifies are expected to run at a fixed rate.
** That rate is expressed as some number of notifies per period where
** the period is much larger than a PRIntervalTime (see prinrval.h).
*/
#if !defined(pralarm_h)
#define pralarm_h
#include "prtypes.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
typedef struct PRAlarm PRAlarm;
typedef struct PRAlarmID PRAlarmID;
typedef PRBool (PR_CALLBACK *PRPeriodicAlarmFn)(
PRAlarmID *id, void *clientData, PRUint32 late);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_CreateAlarm
** DESCRIPTION:
** Create an alarm context.
** INPUTS: void
** OUTPUTS: None
** RETURN: PRAlarm*
**
** SIDE EFFECTS:
** This creates an alarm context, which is an object used for subsequent
** notification creations. It also creates a thread that will be used to
** deliver the notifications that are expected to be defined. The client
** is resposible for destroying the context when appropriate.
** RESTRICTIONS:
** None.
** MEMORY: The object (PRAlarm) and a thread to support notifications.
** ALGORITHM: N/A
***********************************************************************/
NSPR_API(PRAlarm*) PR_CreateAlarm(void);
/***********************************************************************
** FUNCTION: PR_DestroyAlarm
** DESCRIPTION:
** Destroys the context created by PR_CreateAlarm().
** INPUTS: PRAlarm*
** OUTPUTS: None
** RETURN: PRStatus
**
** SIDE EFFECTS:
** This destroys the context that was created by PR_CreateAlarm().
** If there are any active alarms (PRAlarmID), they will be cancelled.
** Once that is done, the thread that was used to deliver the alarms
** will be joined.
** RESTRICTIONS:
** None.
** MEMORY: N/A
** ALGORITHM: N/A
***********************************************************************/
NSPR_API(PRStatus) PR_DestroyAlarm(PRAlarm *alarm);
/***********************************************************************
** FUNCTION: PR_SetAlarm
** DESCRIPTION:
** Creates a periodic notifier that is to be delivered to a specified
** function at some fixed interval.
** INPUTS: PRAlarm *alarm Parent alarm context
** PRIntervalTime period Interval over which the notifies
** are delivered.
** PRUint32 rate The rate within the interval that
** the notifies will be delivered.
** PRPeriodicAlarmFn function Entry point where the notifies
** will be delivered.
** OUTPUTS: None
** RETURN: PRAlarmID* Handle to the notifier just created
** or NULL if the request failed.
**
** SIDE EFFECTS:
** A periodic notifier is created. The notifications will be delivered
** by the alarm's internal thread at a fixed interval whose rate is the
** number of interrupts per interval specified. The first notification
** will be delivered as soon as possible, and they will continue until
** the notifier routine indicates that they should cease of the alarm
** context is destroyed (PR_DestroyAlarm).
** RESTRICTIONS:
** None.
** MEMORY: Memory for the notifier object.
** ALGORITHM: The rate at which notifications are delivered are stated
** to be "'rate' notifies per 'interval'". The exact time of
** the notification is computed based on a epoch established
** when the notifier was set. Each notification is delivered
** not ealier than the epoch plus the fixed rate times the
** notification sequence number. Such notifications have the
** potential to be late by not more than 'interval'/'rate'.
** The amount of lateness of one notification is taken into
** account on the next in an attempt to avoid long term slew.
***********************************************************************/
NSPR_API(PRAlarmID*) PR_SetAlarm(
PRAlarm *alarm, PRIntervalTime period, PRUint32 rate,
PRPeriodicAlarmFn function, void *clientData);
/***********************************************************************
** FUNCTION: PR_ResetAlarm
** DESCRIPTION:
** Resets an existing alarm.
** INPUTS: PRAlarmID *id Identify of the notifier.
** PRIntervalTime period Interval over which the notifies
** are delivered.
** PRUint32 rate The rate within the interval that
** the notifies will be delivered.
** OUTPUTS: None
** RETURN: PRStatus Indication of completion.
**
** SIDE EFFECTS:
** An existing alarm may have its period and rate redefined. The
** additional side effect is that the notifier's epoch is recomputed.
** The first notification delivered by the newly refreshed alarm is
** defined to be 'interval'/'rate' from the time of the reset.
** RESTRICTIONS:
** This function may only be called in the notifier for that alarm.
** MEMORY: N/A.
** ALGORITHM: See PR_SetAlarm().
***********************************************************************/
NSPR_API(PRStatus) PR_ResetAlarm(
PRAlarmID *id, PRIntervalTime period, PRUint32 rate);
PR_END_EXTERN_C
#endif /* !defined(pralarm_h) */
/* prinrval.h */

View File

@@ -0,0 +1,149 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** A collection of things thought to be obsolete
*/
#if defined(PROBSLET_H)
#else
#define PROBSLET_H
#include "prio.h"
#include "private/pprio.h" /* for PROsfd */
PR_BEGIN_EXTERN_C
/*
** Yield the current thread. The proper function to use in place of
** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
*/
NSPR_API(PRStatus) PR_Yield(void);
/************************************************************************/
/************* The following definitions are for select *****************/
/************************************************************************/
/*
** The following is obsolete and will be deleted in the next release!
** These are provided for compatibility, but are GUARANTEED to be slow.
**
** Override PR_MAX_SELECT_DESC if you need more space in the select set.
*/
#ifndef PR_MAX_SELECT_DESC
#define PR_MAX_SELECT_DESC 1024
#endif
typedef struct PR_fd_set {
PRUint32 hsize;
PRFileDesc *harray[PR_MAX_SELECT_DESC];
PRUint32 nsize;
PROsfd narray[PR_MAX_SELECT_DESC];
} PR_fd_set;
/*
*************************************************************************
** FUNCTION: PR_Select
** DESCRIPTION:
**
** The call returns as soon as I/O is ready on one or more of the underlying
** file/socket descriptors or an exceptional condition is pending. A count of the
** number of ready descriptors is returned unless a timeout occurs in which case
** zero is returned. On return, PR_Select replaces the given descriptor sets with
** subsets consisting of those descriptors that are ready for the requested condition.
** The total number of ready descriptors in all the sets is the return value.
**
** INPUTS:
** PRInt32 num
** This argument is unused but is provided for select(unix) interface
** compatability. All input PR_fd_set arguments are self-describing
** with its own maximum number of elements in the set.
**
** PR_fd_set *readfds
** A set describing the io descriptors for which ready for reading
** condition is of interest.
**
** PR_fd_set *writefds
** A set describing the io descriptors for which ready for writing
** condition is of interest.
**
** PR_fd_set *exceptfds
** A set describing the io descriptors for which exception pending
** condition is of interest.
**
** Any of the above readfds, writefds or exceptfds may be given as NULL
** pointers if no descriptors are of interest for that particular condition.
**
** PRIntervalTime timeout
** Amount of time the call will block waiting for I/O to become ready.
** If this time expires without any I/O becoming ready, the result will
** be zero.
**
** OUTPUTS:
** PR_fd_set *readfds
** A set describing the io descriptors which are ready for reading.
**
** PR_fd_set *writefds
** A set describing the io descriptors which are ready for writing.
**
** PR_fd_set *exceptfds
** A set describing the io descriptors which have pending exception.
**
** RETURN:PRInt32
** Number of io descriptors with asked for conditions or zero if the function
** timed out or -1 on failure. The reason for the failure is obtained by
** calling PR_GetError().
** XXX can we implement this on windoze and mac?
**************************************************************************
*/
NSPR_API(PRInt32) PR_Select(
PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
PR_fd_set *exceptfds, PRIntervalTime timeout);
/*
** The following are not thread safe for two threads operating on them at the
** same time.
**
** The following routines are provided for manipulating io descriptor sets.
** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.
** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of
** fdset, zero otherwise.
**
** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
** in fdset.
** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.
** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of
** fdset, zero otherwise.
*/
NSPR_API(void) PR_FD_ZERO(PR_fd_set *set);
NSPR_API(void) PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(void) PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(PRInt32) PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
NSPR_API(void) PR_FD_NSET(PROsfd osfd, PR_fd_set *set);
NSPR_API(void) PR_FD_NCLR(PROsfd osfd, PR_fd_set *set);
NSPR_API(PRInt32) PR_FD_NISSET(PROsfd osfd, PR_fd_set *set);
/*
** The next two entry points should not be in the API, but they are
** declared here for historical reasons.
*/
NSPR_API(PRInt32) PR_GetSysfdTableMax(void);
NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size);
#ifndef NO_NSPR_10_SUPPORT
#include <sys/stat.h>
NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
#endif /* NO_NSPR_10_SUPPORT */
PR_END_EXTERN_C
#endif /* defined(PROBSLET_H) */
/* probslet.h */

View File

@@ -0,0 +1,199 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* This header typedefs the old 'native' types to the new PR<type>s.
* These definitions are scheduled to be eliminated at the earliest
* possible time. The NSPR API is implemented and documented using
* the new definitions.
*/
#if !defined(PROTYPES_H)
#define PROTYPES_H
typedef PRUintn uintn;
#ifndef _XP_Core_
typedef PRIntn intn;
#endif
/*
* It is trickier to define uint, int8, uint8, int16, uint16,
* int32, uint32, int64, and uint64 because some of these int
* types are defined by standard header files on some platforms.
* Our strategy here is to include all such standard headers
* first, and then define these int types only if they are not
* defined by those standard headers.
*/
/*
* BeOS defines all the int types below in its standard header
* file SupportDefs.h.
*/
#ifdef XP_BEOS
#include <support/SupportDefs.h>
#endif
/*
* SVR4 typedef of uint is commonly found on UNIX machines.
*
* On AIX 4.3, sys/inttypes.h (which is included by sys/types.h)
* defines the types int8, int16, int32, and int64.
*
* On OS/2, sys/types.h defines uint.
*/
#if defined(XP_UNIX) || defined(XP_OS2)
#include <sys/types.h>
#endif
/* model.h on HP-UX defines int8, int16, and int32. */
#ifdef HPUX
#include <model.h>
#endif
/*
* uint
*/
#if !defined(XP_BEOS) && !defined(XP_OS2) && !defined(XP_UNIX) || defined(NTO)
typedef PRUintn uint;
#endif
/*
* uint64
*/
#if !defined(XP_BEOS)
typedef PRUint64 uint64;
#endif
/*
* uint32
*/
#if !defined(XP_BEOS)
#if !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRUint32 uint32;
#else
typedef unsigned long uint32;
#endif
#endif
/*
* uint16
*/
#if !defined(XP_BEOS)
typedef PRUint16 uint16;
#endif
/*
* uint8
*/
#if !defined(XP_BEOS)
typedef PRUint8 uint8;
#endif
/*
* int64
*/
#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES)
typedef PRInt64 int64;
#endif
/*
* int32
*/
#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
#if !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRInt32 int32;
#else
typedef long int32;
#endif
#endif
/*
* int16
*/
#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt16 int16;
#endif
/*
* int8
*/
#if !defined(XP_BEOS) && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt8 int8;
#endif
typedef PRFloat64 float64;
typedef PRUptrdiff uptrdiff_t;
typedef PRUword uprword_t;
typedef PRWord prword_t;
/* Re: prbit.h */
#define TEST_BIT PR_TEST_BIT
#define SET_BIT PR_SET_BIT
#define CLEAR_BIT PR_CLEAR_BIT
/* Re: prarena.h->plarena.h */
#define PRArena PLArena
#define PRArenaPool PLArenaPool
#define PRArenaStats PLArenaStats
#define PR_ARENA_ALIGN PL_ARENA_ALIGN
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE
#define PR_ARENA_GROW PL_ARENA_GROW
#define PR_ARENA_MARK PL_ARENA_MARK
#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED
#define PR_CLEAR_ARENA PL_CLEAR_ARENA
#define PR_ARENA_RELEASE PL_ARENA_RELEASE
#define PR_COUNT_ARENA PL_COUNT_ARENA
#define PR_ARENA_DESTROY PL_ARENA_DESTROY
#define PR_InitArenaPool PL_InitArenaPool
#define PR_FreeArenaPool PL_FreeArenaPool
#define PR_FinishArenaPool PL_FinishArenaPool
#define PR_CompactArenaPool PL_CompactArenaPool
#define PR_ArenaFinish PL_ArenaFinish
#define PR_ArenaAllocate PL_ArenaAllocate
#define PR_ArenaGrow PL_ArenaGrow
#define PR_ArenaRelease PL_ArenaRelease
#define PR_ArenaCountAllocation PL_ArenaCountAllocation
#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth
#define PR_ArenaCountGrowth PL_ArenaCountGrowth
#define PR_ArenaCountRelease PL_ArenaCountRelease
#define PR_ArenaCountRetract PL_ArenaCountRetract
/* Re: prhash.h->plhash.h */
#define PRHashEntry PLHashEntry
#define PRHashTable PLHashTable
#define PRHashNumber PLHashNumber
#define PRHashFunction PLHashFunction
#define PRHashComparator PLHashComparator
#define PRHashEnumerator PLHashEnumerator
#define PRHashAllocOps PLHashAllocOps
#define PR_NewHashTable PL_NewHashTable
#define PR_HashTableDestroy PL_HashTableDestroy
#define PR_HashTableRawLookup PL_HashTableRawLookup
#define PR_HashTableRawAdd PL_HashTableRawAdd
#define PR_HashTableRawRemove PL_HashTableRawRemove
#define PR_HashTableAdd PL_HashTableAdd
#define PR_HashTableRemove PL_HashTableRemove
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries
#define PR_HashTableLookup PL_HashTableLookup
#define PR_HashTableDump PL_HashTableDump
#define PR_HashString PL_HashString
#define PR_CompareStrings PL_CompareStrings
#define PR_CompareValues PL_CompareValues
#endif /* !defined(PROTYPES_H) */

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prsem_h___
#define prsem_h___
/*
** API for counting semaphores. Semaphores are counting synchronizing
** variables based on a lock and a condition variable. They are lightweight
** contention control for a given count of resources.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PRSemaphore PRSemaphore;
/*
** Create a new semaphore object.
*/
NSPR_API(PRSemaphore*) PR_NewSem(PRUintn value);
/*
** Destroy the given semaphore object.
**
*/
NSPR_API(void) PR_DestroySem(PRSemaphore *sem);
/*
** Wait on a Semaphore.
**
** This routine allows a calling thread to wait or proceed depending upon the
** state of the semahore sem. The thread can proceed only if the counter value
** of the semaphore sem is currently greater than 0. If the value of semaphore
** sem is positive, it is decremented by one and the routine returns immediately
** allowing the calling thread to continue. If the value of semaphore sem is 0,
** the calling thread blocks awaiting the semaphore to be released by another
** thread.
**
** This routine can return PR_PENDING_INTERRUPT if the waiting thread
** has been interrupted.
*/
NSPR_API(PRStatus) PR_WaitSem(PRSemaphore *sem);
/*
** This routine increments the counter value of the semaphore. If other threads
** are blocked for the semaphore, then the scheduler will determine which ONE
** thread will be unblocked.
*/
NSPR_API(void) PR_PostSem(PRSemaphore *sem);
/*
** Returns the value of the semaphore referenced by sem without affecting
** the state of the semaphore. The value represents the semaphore vaule
F** at the time of the call, but may not be the actual value when the
** caller inspects it.
*/
NSPR_API(PRUintn) PR_GetValueSem(PRSemaphore *sem);
PR_END_EXTERN_C
#endif /* prsem_h___ */

View File

@@ -0,0 +1,327 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef plarena_h___
#define plarena_h___
/*
* Lifetime-based fast allocation, inspired by much prior art, including
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
*
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PLArena PLArena;
struct PLArena {
PLArena *next; /* next arena for this lifetime */
PRUword base; /* aligned base address, follows this header */
PRUword limit; /* one beyond last byte in arena */
PRUword avail; /* points to next available byte */
};
#ifdef PL_ARENAMETER
typedef struct PLArenaStats PLArenaStats;
struct PLArenaStats {
PLArenaStats *next; /* next in arenaStats list */
char *name; /* name for debugging */
PRUint32 narenas; /* number of arenas in pool */
PRUint32 nallocs; /* number of PL_ARENA_ALLOCATE() calls */
PRUint32 nreclaims; /* number of reclaims from freeArenas */
PRUint32 nmallocs; /* number of malloc() calls */
PRUint32 ndeallocs; /* number of lifetime deallocations */
PRUint32 ngrows; /* number of PL_ARENA_GROW() calls */
PRUint32 ninplace; /* number of in-place growths */
PRUint32 nreleases; /* number of PL_ARENA_RELEASE() calls */
PRUint32 nfastrels; /* number of "fast path" releases */
PRUint32 nbytes; /* total bytes allocated */
PRUint32 maxalloc; /* maximum allocation size in bytes */
PRFloat64 variance; /* size variance accumulator */
};
#endif
typedef struct PLArenaPool PLArenaPool;
struct PLArenaPool {
PLArena first; /* first arena in pool list */
PLArena *current; /* arena from which to allocate space */
PRUint32 arenasize; /* net exact size of a new arena */
PRUword mask; /* alignment mask (power-of-2 - 1) */
#ifdef PL_ARENAMETER
PLArenaStats stats;
#endif
};
/*
* WARNING: The PL_MAKE_MEM_ macros are for internal use by NSPR. Do NOT use
* them in your code.
*
* NOTE: Valgrind support to be added.
*
* The PL_MAKE_MEM_ macros are modeled after the MOZ_MAKE_MEM_ macros in
* Mozilla's mfbt/MemoryChecking.h. Only AddressSanitizer is supported now.
*
* Provides a common interface to the ASan (AddressSanitizer) and Valgrind
* functions used to mark memory in certain ways. In detail, the following
* three macros are provided:
*
* PL_MAKE_MEM_NOACCESS - Mark memory as unsafe to access (e.g. freed)
* PL_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined
* PL_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined
*
* With Valgrind in use, these directly map to the three respective Valgrind
* macros. With ASan in use, the NOACCESS macro maps to poisoning the memory,
* while the UNDEFINED/DEFINED macros unpoison memory.
*
* With no memory checker available, all macros expand to the empty statement.
*/
/* WARNING: PL_SANITIZE_ADDRESS is for internal use by this header. Do NOT
* define or test this macro in your code.
*/
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
#define PL_SANITIZE_ADDRESS 1
#endif
#elif defined(__SANITIZE_ADDRESS__)
#define PL_SANITIZE_ADDRESS 1
#endif
#if defined(PL_SANITIZE_ADDRESS)
/* These definitions are usually provided through the
* sanitizer/asan_interface.h header installed by ASan.
* See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
*/
PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define PL_MAKE_MEM_NOACCESS(addr, size) \
__asan_poison_memory_region((addr), (size))
#define PL_MAKE_MEM_UNDEFINED(addr, size) \
__asan_unpoison_memory_region((addr), (size))
#define PL_MAKE_MEM_DEFINED(addr, size) \
__asan_unpoison_memory_region((addr), (size))
#else
#define PL_MAKE_MEM_NOACCESS(addr, size)
#define PL_MAKE_MEM_UNDEFINED(addr, size)
#define PL_MAKE_MEM_DEFINED(addr, size)
#endif
/*
* If the including .c file uses only one power-of-2 alignment, it may define
* PL_ARENA_CONST_ALIGN_MASK to the alignment mask and save a few instructions
* per ALLOCATE and GROW.
*/
#ifdef PL_ARENA_CONST_ALIGN_MASK
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \
& ~PL_ARENA_CONST_ALIGN_MASK)
#define PL_INIT_ARENA_POOL(pool, name, size) \
PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)
#else
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)
#endif
#define PL_ARENA_ALLOCATE(p, pool, nb) \
PR_BEGIN_MACRO \
PLArena *_a = (pool)->current; \
PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
PRUword _p = _a->avail; \
if (_nb < (PRUint32)nb) { \
_p = 0; \
} else if (_nb > (_a->limit - _a->avail)) { \
_p = (PRUword)PL_ArenaAllocate(pool, _nb); \
} else { \
_a->avail += _nb; \
} \
p = (void *)_p; \
if (p) { \
PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \
PL_ArenaCountAllocation(pool, (PRUint32)nb); \
} \
PR_END_MACRO
#define PL_ARENA_GROW(p, pool, size, incr) \
PR_BEGIN_MACRO \
PLArena *_a = (pool)->current; \
PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
if (_incr < (PRUint32)incr) { \
p = NULL; \
} else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
_incr <= (_a->limit - _a->avail)) { \
PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \
_a->avail += _incr; \
PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \
} else { \
p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
} \
if (p) {\
PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
} \
PR_END_MACRO
#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
#define PL_CLEAR_UNUSED_PATTERN(a, pattern) \
PR_BEGIN_MACRO \
PR_ASSERT((a)->avail <= (a)->limit); \
PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \
memset((void*)(a)->avail, (pattern), (a)->limit - (a)->avail); \
PR_END_MACRO
#ifdef DEBUG
#define PL_FREE_PATTERN 0xDA
#define PL_CLEAR_UNUSED(a) PL_CLEAR_UNUSED_PATTERN((a), PL_FREE_PATTERN)
#define PL_CLEAR_ARENA(a) \
PR_BEGIN_MACRO \
PL_MAKE_MEM_UNDEFINED((void*)(a), (a)->limit - (PRUword)(a)); \
memset((void*)(a), PL_FREE_PATTERN, (a)->limit - (PRUword)(a)); \
PR_END_MACRO
#else
#define PL_CLEAR_UNUSED(a)
#define PL_CLEAR_ARENA(a)
#endif
#define PL_ARENA_RELEASE(pool, mark) \
PR_BEGIN_MACRO \
char *_m = (char *)(mark); \
PLArena *_a = (pool)->current; \
if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \
_a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \
PL_CLEAR_UNUSED(_a); \
PL_MAKE_MEM_NOACCESS((void*)_a->avail, _a->limit - _a->avail); \
PL_ArenaCountRetract(pool, _m); \
} else { \
PL_ArenaRelease(pool, _m); \
} \
PL_ArenaCountRelease(pool, _m); \
PR_END_MACRO
#ifdef PL_ARENAMETER
#define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op)
#else
#define PL_COUNT_ARENA(pool,op)
#endif
#define PL_ARENA_DESTROY(pool, a, pnext) \
PR_BEGIN_MACRO \
PL_COUNT_ARENA(pool,--); \
if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
*(pnext) = (a)->next; \
PL_CLEAR_ARENA(a); \
free(a); \
(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>
PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb);
PR_EXTERN(void) PL_ArenaCountInplaceGrowth(
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
PR_EXTERN(void) PL_ArenaCountGrowth(
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark);
PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark);
PR_EXTERN(void) PL_DumpArenaStats(FILE *fp);
#else /* !PL_ARENAMETER */
#define PL_ArenaCountAllocation(ap, nb) /* nothing */
#define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */
#define PL_ArenaCountGrowth(ap, size, incr) /* nothing */
#define PL_ArenaCountRelease(ap, mark) /* nothing */
#define PL_ArenaCountRetract(ap, mark) /* nothing */
#endif /* !PL_ARENAMETER */
PR_END_EXTERN_C
#endif /* plarena_h___ */

View File

@@ -0,0 +1,12 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** 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.
**/
#include "plarena.h"

View File

@@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _plbase64_h
#define _plbase64_h
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
* PL_Base64Encode
*
* This routine encodes the data pointed to by the "src" parameter using the
* base64 algorithm, and returns a pointer to the result. If the "srclen"
* parameter is not zero, it specifies the length of the source data. If it
* is zero, the source data is assumed to be null-terminated, and PL_strlen
* is used to determine the source length. If the "dest" parameter is not
* null, it is assumed to point to a buffer of sufficient size (which may be
* calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
* (without any termination). If the "dest" parameter is null, a buffer is
* allocated from the heap to hold the encoded data, and the result *will*
* be terminated with an extra null character. It is the caller's
* responsibility to free the result when it is allocated. A null is returned
* if the allocation fails.
*
* NOTE: when calculating ((srclen + 2)/3)*4), first ensure that
* srclen <= (PR_UINT32_MAX/4) * 3
* to avoid PRUint32 overflow.
*/
PR_EXTERN(char *)
PL_Base64Encode
(
const char *src,
PRUint32 srclen,
char *dest
);
/*
* PL_Base64Decode
*
* This routine decodes the data pointed to by the "src" parameter using
* the base64 algorithm, and returns a pointer to the result. The source
* may either include or exclude any trailing '=' characters. If the
* "srclen" parameter is not zero, it specifies the length of the source
* data. If it is zero, PL_strlen will be used to determine the source
* length. If the "dest" parameter is not null, it is assumed to point to
* a buffer of sufficient size (which may be calculated: (srclen * 3)/4
* when srclen includes the '=' characters) into which the decoded data
* is placed (without any termination). If the "dest" parameter is null,
* a buffer is allocated from the heap to hold the decoded data, and the
* result *will* be terminated with an extra null character. It is the
* caller's responsibility to free the result when it is allocated. A null
* is retuned if the allocation fails, or if the source is not well-coded.
*
* NOTE: when calculating (srclen * 3)/4, first ensure that
* srclen <= PR_UINT32_MAX/3
* to avoid PRUint32 overflow. Alternatively, calculate
* (srclen/4) * 3 + ((srclen%4) * 3)/4
* which is equivalent but doesn't overflow for any value of srclen.
*/
PR_EXTERN(char *)
PL_Base64Decode
(
const char *src,
PRUint32 srclen,
char *dest
);
PR_END_EXTERN_C
#endif /* _plbase64_h */

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: plerror.h
** Description: Simple routine to print translate the calling thread's
** error numbers and print them.
*/
#if defined(PLERROR_H)
#else
#define PLERROR_H
#include "prio.h"
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** Print the messages to "syserr" prepending 'msg' if not NULL.
*/
PR_EXTERN(void) PL_PrintError(const char *msg);
/*
** Print the messages to specified output file prepending 'msg' if not NULL.
*/
PR_EXTERN(void) PL_FPrintError(PRFileDesc *output, const char *msg);
PR_END_EXTERN_C
#endif /* defined(PLERROR_H) */
/* plerror.h */

View File

@@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: plgetopt.h
** Description: utilities to parse argc/argv
*/
#if defined(PLGETOPT_H_)
#else
#define PLGETOPT_H_
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PLOptionInternal PLOptionInternal;
typedef enum
{
PL_OPT_OK, /* all's well with the option */
PL_OPT_EOL, /* end of options list */
PL_OPT_BAD /* invalid option (and value) */
} PLOptStatus;
typedef struct PLLongOpt
{
const char * longOptName; /* long option name string */
PRIntn longOption; /* value put in PLOptState for this option. */
PRBool valueRequired; /* If option name not followed by '=', */
/* value is the next argument from argv. */
} PLLongOpt;
typedef struct PLOptState
{
char option; /* the name of the option */
const char *value; /* the value of that option | NULL */
PLOptionInternal *internal; /* private processing state */
PRIntn longOption; /* value from PLLongOpt put here */
PRIntn longOptIndex; /* index into caller's array of PLLongOpts */
} PLOptState;
/*
* PL_CreateOptState
*
* The argument "options" points to a string of single-character option
* names. Option names that may have an option argument value must be
* followed immediately by a ':' character.
*/
PR_EXTERN(PLOptState*) PL_CreateOptState(
PRIntn argc, char **argv, const char *options);
/*
* PL_CreateLongOptState
*
* Alternative to PL_CreateOptState.
* Allows caller to specify BOTH a string of single-character option names,
* AND an array of structures describing "long" (keyword) option names.
* The array is terminated by a structure in which longOptName is NULL.
* Long option values (arguments) may always be given as "--name=value".
* If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not
* followed by '=' then the next argument from argv is taken as the value.
*/
PR_EXTERN(PLOptState*) PL_CreateLongOptState(
PRIntn argc, char **argv, const char *options,
const PLLongOpt *longOpts);
/*
* PL_DestroyOptState
*
* Call this to destroy the PLOptState returned from PL_CreateOptState or
* PL_CreateLongOptState.
*/
PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt);
/*
* PL_GetNextOpt
*
* When this function returns PL_OPT_OK,
* - opt->option will hold the single-character option name that was parsed,
* or zero.
* When opt->option is zero, the token parsed was either a "long" (keyword)
* option or a positional parameter.
* For a positional parameter,
* - opt->longOptIndex will contain -1, and
* - opt->value will point to the positional parameter string.
* For a long option name,
* - opt->longOptIndex will contain the non-negative index of the
* PLLongOpt structure in the caller's array of PLLongOpt structures
* corresponding to the long option name, and
* For a single-character or long option,
* - opt->longOption will contain the value of the single-character option
* name, or the value of the longOption from the PLLongOpt structure
* for that long option. See notes below.
* - opt->value will point to the argument option string, or will
* be NULL if option does not require argument. If option requires
* argument but it is not provided, PL_OPT_BAD is returned.
* When opt->option is non-zero,
* - opt->longOptIndex will be -1
* When this function returns PL_OPT_EOL, or PL_OPT_BAD, the contents of
* opt are undefined.
*
* Notes: It is possible to ignore opt->option, and always look at
* opt->longOption instead. opt->longOption will contain the same value
* as opt->option for single-character option names, and will contain the
* value of longOption from the PLLongOpt structure for long option names.
* This means that it is possible to equivalence long option names to
* single character names by giving the longOption in the PLLongOpt struct
* the same value as the single-character option name.
* For long options that are NOT intended to be equivalent to any single-
* character option, the longOption value should be chosen to not match
* any possible single character name. It might be advisable to choose
* longOption values greater than 0xff for such long options.
*/
PR_EXTERN(PLOptStatus) PL_GetNextOpt(PLOptState *opt);
PR_END_EXTERN_C
#endif /* defined(PLGETOPT_H_) */
/* plgetopt.h */

View File

@@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef plhash_h___
#define plhash_h___
/*
* API to portable hash table code.
*/
#include <stdio.h>
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PLHashEntry PLHashEntry;
typedef struct PLHashTable PLHashTable;
typedef PRUint32 PLHashNumber;
#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */
typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
/* Flag bits in PLHashEnumerator's return value */
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
typedef struct PLHashAllocOps {
void * (PR_CALLBACK *allocTable)(void *pool, PRSize size);
void (PR_CALLBACK *freeTable)(void *pool, void *item);
PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key);
void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
} PLHashAllocOps;
#define HT_FREE_VALUE 0 /* just free the entry's value */
#define HT_FREE_ENTRY 1 /* free value and entire entry */
struct PLHashEntry {
PLHashEntry *next; /* hash chain linkage */
PLHashNumber keyHash; /* key hash function result */
const void *key; /* ptr to opaque key */
void *value; /* ptr to opaque value */
};
struct PLHashTable {
PLHashEntry **buckets; /* vector of hash buckets */
PRUint32 nentries; /* number of entries in table */
PRUint32 shift; /* multiplicative hash shift */
PLHashFunction keyHash; /* key hash function */
PLHashComparator keyCompare; /* key comparison function */
PLHashComparator valueCompare; /* value comparison function */
const PLHashAllocOps *allocOps; /* allocation operations */
void *allocPriv; /* allocation private data */
#ifdef HASHMETER
PRUint32 nlookups; /* total number of lookups */
PRUint32 nsteps; /* number of hash chains traversed */
PRUint32 ngrows; /* number of table expansions */
PRUint32 nshrinks; /* number of table contractions */
#endif
};
/*
* Create a new hash table.
* If allocOps is null, use default allocator ops built on top of malloc().
*/
PR_EXTERN(PLHashTable *)
PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
PLHashComparator keyCompare, PLHashComparator valueCompare,
const PLHashAllocOps *allocOps, void *allocPriv);
PR_EXTERN(void)
PL_HashTableDestroy(PLHashTable *ht);
/* Higher level access methods */
PR_EXTERN(PLHashEntry *)
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);
PR_EXTERN(PRBool)
PL_HashTableRemove(PLHashTable *ht, const void *key);
PR_EXTERN(void *)
PL_HashTableLookup(PLHashTable *ht, const void *key);
PR_EXTERN(void *)
PL_HashTableLookupConst(PLHashTable *ht, const void *key);
PR_EXTERN(PRIntn)
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);
/* General-purpose C string hash function. */
PR_EXTERN(PLHashNumber)
PL_HashString(const void *key);
/* Compare strings using strcmp(), return true if equal. */
PR_EXTERN(PRIntn)
PL_CompareStrings(const void *v1, const void *v2);
/* Stub function just returns v1 == v2 */
PR_EXTERN(PRIntn)
PL_CompareValues(const void *v1, const void *v2);
/* Low level access methods */
PR_EXTERN(PLHashEntry **)
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);
PR_EXTERN(PLHashEntry **)
PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,
const void *key);
PR_EXTERN(PLHashEntry *)
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,
const void *key, void *value);
PR_EXTERN(void)
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);
/* This can be trivially implemented using PL_HashTableEnumerateEntries. */
PR_EXTERN(PRIntn)
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);
PR_END_EXTERN_C
#endif /* plhash_h___ */

View File

@@ -0,0 +1,437 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _plstr_h
#define _plstr_h
/*
* plstr.h
*
* This header file exports the API to the NSPR portable library or string-
* handling functions.
*
* This API was not designed as an "optimal" or "ideal" string library; it
* was based on the good ol' unix string.3 functions, and was written to
*
* 1) replace the libc functions, for cross-platform consistency,
* 2) complete the API on platforms lacking common functions (e.g.,
* strcase*), and
* 3) to implement some obvious "closure" functions that I've seen
* people hacking around in our code.
*
* Point number three largely means that most functions have an "strn"
* limited-length version, and all comparison routines have a non-case-
* sensitive version available.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
* PL_strlen
*
* Returns the length of the provided string, not including the trailing '\0'.
*/
PR_EXTERN(PRUint32)
PL_strlen(const char *str);
/*
* PL_strnlen
*
* Returns the length of the provided string, not including the trailing '\0',
* up to the indicated maximum. The string will not be examined beyond the
* maximum; if no terminating '\0' is found, the maximum will be returned.
*/
PR_EXTERN(PRUint32)
PL_strnlen(const char *str, PRUint32 max);
/*
* PL_strcpy
*
* Copies the source string, up to and including the trailing '\0', into the
* destination buffer. It does not (can not) verify that the destination
* buffer is large enough. It returns the "dest" argument.
*/
PR_EXTERN(char *)
PL_strcpy(char *dest, const char *src);
/*
* PL_strncpy
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up to and including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. If the source string is longer than the maximum length,
* the result will *not* be null-terminated (JLRU).
*/
PR_EXTERN(char *)
PL_strncpy(char *dest, const char *src, PRUint32 max);
/*
* PL_strncpyz
*
* Copies the source string into the destination buffer, up to and including
* the trailing '\0' or up but not including the max'th character, whichever
* comes first. It does not (can not) verify that the destination buffer is
* large enough. The destination string is always terminated with a '\0',
* unlike the traditional libc implementation. It returns the "dest" argument.
*
* NOTE: If you call this with a source "abcdefg" and a max of 5, the
* destination will end up with "abcd\0" (i.e., its strlen length will be 4)!
*
* This means you can do this:
*
* char buffer[ SOME_SIZE ];
* PL_strncpyz(buffer, src, sizeof(buffer));
*
* and the result will be properly terminated.
*/
PR_EXTERN(char *)
PL_strncpyz(char *dest, const char *src, PRUint32 max);
/*
* PL_strdup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string. The size of the allocated extent is one greater
* than the length of the argument string, because of the terminator. A
* null argument, like a zero-length argument, will result in a pointer to
* a one-byte extent containing the null value. This routine returns null
* upon malloc failure.
*/
PR_EXTERN(char *)
PL_strdup(const char *s);
/*
* PL_strfree
*
* Free memory allocated by PL_strdup
*/
PR_EXTERN(void)
PL_strfree(char *s);
/*
* PL_strndup
*
* Returns a pointer to a malloc'd extent of memory containing a duplicate
* of the argument string, up to the maximum specified. If the argument
* string has a length greater than the value of the specified maximum, the
* return value will be a pointer to an extent of memory of length one
* greater than the maximum specified. A null string, a zero-length string,
* or a zero maximum will all result in a pointer to a one-byte extent
* containing the null value. This routine returns null upon malloc failure.
*/
PR_EXTERN(char *)
PL_strndup(const char *s, PRUint32 max);
/*
* PL_strcat
*
* Appends a copy of the string pointed to by the second argument to the
* end of the string pointed to by the first. The destination buffer is
* not (can not be) checked for sufficient size. A null destination
* argument returns null; otherwise, the first argument is returned.
*/
PR_EXTERN(char *)
PL_strcat(char *dst, const char *src);
/*
* PL_strncat
*
* Appends a copy of the string pointed to by the second argument, up to
* the maximum size specified, to the end of the string pointed to by the
* first. The destination buffer is not (can not be) checked for sufficient
* size. A null destination argument returns null; otherwise, the first
* argument is returned. If the maximum size limits the copy, then the
* result will *not* be null-terminated (JLRU). A null destination
* returns null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strncat(char *dst, const char *src, PRUint32 max);
/*
* PL_strcatn
*
* Appends a copy of the string pointed to by the third argument, to the
* end of the string pointed to by the first. The second argument specifies
* the maximum size of the destination buffer, including the null termination.
* If the existing string in dst is longer than the max, no action is taken.
* The resulting string will be null-terminated. A null destination returns
* null; otherwise, the destination argument is returned.
*/
PR_EXTERN(char *)
PL_strcatn(char *dst, PRUint32 max, const char *src);
/*
* PL_strcmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated. The
* result is positive if the first string comes after the second. The
* NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcmp(const char *a, const char *b);
/*
* PL_strncmp
*
* Returns an integer, the sign of which -- positive, zero, or negative --
* reflects the lexical sorting order of the two strings indicated, up to
* the maximum specified. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n. If the maximum
* is zero, only the existance or non-existance (pointer is null) of the
* strings is compared.
*/
PR_EXTERN(PRIntn)
PL_strncmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strcasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the two strings
* indicated. The result is positive if the first string comes after the
* second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strcasecmp(const char *a, const char *b);
/*
* PL_strncasecmp
*
* Returns an integer, the sign of which -- positive, zero or negative --
* reflects the case-insensitive lexical sorting order of the first n characters
* of the two strings indicated. The result is positive if the first string comes
* after the second. The NSPR implementation is not i18n.
*/
PR_EXTERN(PRIntn)
PL_strncasecmp(const char *a, const char *b, PRUint32 max);
/*
* PL_strchr
*
* Returns a pointer to the first instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strchr(const char *s, char c);
/*
* PL_strrchr
*
* Returns a pointer to the last instance of the specified character in the
* provided string. It returns null if the character is not found, or if the
* provided string is null. The character may be the null character.
*/
PR_EXTERN(char *)
PL_strrchr(const char *s, char c);
/*
* PL_strnchr
*
* Returns a pointer to the first instance of the specified character within the
* first n characters of the provided string. It returns null if the character
* is not found, or if the provided string is null. The character may be the
* null character.
*/
PR_EXTERN(char *)
PL_strnchr(const char *s, char c, PRUint32 n);
/*
* PL_strnrchr
*
* Returns a pointer to the last instance of the specified character within the
* first n characters of the provided string. It returns null if the character is
* not found, or if the provided string is null. The character may be the null
* character.
*/
PR_EXTERN(char *)
PL_strnrchr(const char *s, char c, PRUint32 n);
/*
* NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?
* Use strpbrk, strprbrk, strnpbrk or strnprbrk.
*/
/*
* PL_strpbrk
*
* Returns a pointer to the first instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strpbrk(const char *s, const char *list);
/*
* PL_strprbrk
*
* Returns a pointer to the last instance in the first string of any character
* (not including the terminating null character) of the second string. It returns
* null if either string is null.
*/
PR_EXTERN(char *)
PL_strprbrk(const char *s, const char *list);
/*
* PL_strnpbrk
*
* Returns a pointer to the first instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnpbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strnprbrk
*
* Returns a pointer to the last instance (within the first n characters) of any
* character (not including the terminating null character) of the second string.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strnprbrk(const char *s, const char *list, PRUint32 n);
/*
* PL_strstr
*
* Returns a pointer to the first instance of the little string within the
* big one. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strstr(const char *big, const char *little);
/*
* PL_strrstr
*
* Returns a pointer to the last instance of the little string within the big one.
* It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strrstr(const char *big, const char *little);
/*
* PL_strnstr
*
* Returns a pointer to the first instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnstr(const char *big, const char *little, PRUint32 n);
/*
* PL_strnrstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one. It returns null if either string is null. It
* returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strnrstr(const char *big, const char *little, PRUint32 max);
/*
* PL_strcasestr
*
* Returns a pointer to the first instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcasestr(const char *big, const char *little);
/*
* PL_strcaserstr
*
* Returns a pointer to the last instance of the little string within the big one,
* ignoring case. It returns null if either string is null.
*/
PR_EXTERN(char *)
PL_strcaserstr(const char *big, const char *little);
/*
* PL_strncasestr
*
* Returns a pointer to the first instance of the little string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncasestr(const char *big, const char *little, PRUint32 max);
/*
* PL_strncaserstr
*
* Returns a pointer to the last instance of the little string within the first
* n characters of the big one, ignoring case. It returns null if either string is
* null. It returns null if the length of the little string is greater than n.
*/
PR_EXTERN(char *)
PL_strncaserstr(const char *big, const char *little, PRUint32 max);
/*
* PL_strtok_r
*
* Splits the string s1 into tokens, separated by one or more characters
* from the separator string s2. The argument lasts points to a
* user-supplied char * pointer in which PL_strtok_r stores information
* for it to continue scanning the same string.
*
* In the first call to PL_strtok_r, s1 points to a string and the value
* of *lasts is ignored. PL_strtok_r returns a pointer to the first
* token, writes '\0' into the character following the first token, and
* updates *lasts.
*
* In subsequent calls, s1 is null and lasts must stay unchanged from the
* previous call. The separator string s2 may be different from call to
* call. PL_strtok_r returns a pointer to the next token in s1. When no
* token remains in s1, PL_strtok_r returns null.
*/
PR_EXTERN(char *)
PL_strtok_r(char *s1, const char *s2, char **lasts);
/*
* Things not (yet?) included: strspn/strcspn, strsep.
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
* Any and all i18n/l10n stuff.
*/
PR_END_EXTERN_C
#endif /* _plstr_h */

View File

@@ -0,0 +1,198 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* GLOBAL FUNCTIONS:
** DESCRIPTION:
** PR Atomic operations
*/
#ifndef pratom_h___
#define pratom_h___
#include "prtypes.h"
#include "prlock.h"
PR_BEGIN_EXTERN_C
/*
** FUNCTION: PR_AtomicIncrement
** DESCRIPTION:
** Atomically increment a 32 bit value.
** INPUTS:
** val: a pointer to the value to increment
** RETURN:
** the returned value is the result of the increment
*/
NSPR_API(PRInt32) PR_AtomicIncrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicDecrement
** DESCRIPTION:
** Atomically decrement a 32 bit value.
** INPUTS:
** val: a pointer to the value to decrement
** RETURN:
** the returned value is the result of the decrement
*/
NSPR_API(PRInt32) PR_AtomicDecrement(PRInt32 *val);
/*
** FUNCTION: PR_AtomicSet
** DESCRIPTION:
** Atomically set a 32 bit value.
** INPUTS:
** val: A pointer to a 32 bit value to be set
** newval: The newvalue to assign to val
** RETURN:
** Returns the prior value
*/
NSPR_API(PRInt32) PR_AtomicSet(PRInt32 *val, PRInt32 newval);
/*
** FUNCTION: PR_AtomicAdd
** DESCRIPTION:
** Atomically add a 32 bit value.
** INPUTS:
** ptr: a pointer to the value to increment
** val: value to be added
** RETURN:
** the returned value is the result of the addition
*/
NSPR_API(PRInt32) PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
/*
** MACRO: PR_ATOMIC_INCREMENT
** MACRO: PR_ATOMIC_DECREMENT
** MACRO: PR_ATOMIC_SET
** MACRO: PR_ATOMIC_ADD
** DESCRIPTION:
** Macro versions of the atomic operations. They may be implemented
** as compiler intrinsics.
**
** IMPORTANT NOTE TO NSPR MAINTAINERS:
** Implement these macros with compiler intrinsics only on platforms
** where the PR_AtomicXXX functions are truly atomic (i.e., where the
** configuration macro _PR_HAVE_ATOMIC_OPS is defined). Otherwise,
** the macros and functions won't be compatible and can't be used
** interchangeably.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && \
(!defined(_MSC_VER) || (_MSC_VER >= 1310))
#include <intrin.h>
#ifdef _MSC_VER
#pragma intrinsic(_InterlockedIncrement)
#pragma intrinsic(_InterlockedDecrement)
#pragma intrinsic(_InterlockedExchange)
#pragma intrinsic(_InterlockedExchangeAdd)
#endif
#define PR_ATOMIC_INCREMENT(val) _InterlockedIncrement((long volatile *)(val))
#define PR_ATOMIC_DECREMENT(val) _InterlockedDecrement((long volatile *)(val))
#define PR_ATOMIC_SET(val, newval) \
_InterlockedExchange((long volatile *)(val), (long)(newval))
#define PR_ATOMIC_ADD(ptr, val) \
(_InterlockedExchangeAdd((long volatile *)(ptr), (long)(val)) + (val))
#elif ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && \
((defined(__APPLE__) && \
(defined(__ppc__) || defined(__i386__) || defined(__x86_64__))) || \
(defined(__linux__) && \
((defined(__i386__) && \
defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
defined(__ia64__) || defined(__x86_64__) || \
defined(__powerpc__) || \
(defined(__arm__) && \
defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) || \
defined(__aarch64__) || defined(__alpha) || \
(defined(__mips__) && \
defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)))))
/*
* Because the GCC manual warns that some processors may support
* reduced functionality of __sync_lock_test_and_set, we test for the
* processors that we believe support a full atomic exchange operation.
*/
#define PR_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1)
#define PR_ATOMIC_DECREMENT(val) __sync_sub_and_fetch(val, 1)
#define PR_ATOMIC_SET(val, newval) __sync_lock_test_and_set(val, newval)
#define PR_ATOMIC_ADD(ptr, val) __sync_add_and_fetch(ptr, val)
#else
#define PR_ATOMIC_INCREMENT(val) PR_AtomicIncrement(val)
#define PR_ATOMIC_DECREMENT(val) PR_AtomicDecrement(val)
#define PR_ATOMIC_SET(val, newval) PR_AtomicSet(val, newval)
#define PR_ATOMIC_ADD(ptr, val) PR_AtomicAdd(ptr, val)
#endif
/*
** LIFO linked-list (stack)
*/
typedef struct PRStackElemStr PRStackElem;
struct PRStackElemStr {
PRStackElem *prstk_elem_next; /* next pointer MUST be at offset 0;
assembly language code relies on this */
};
typedef struct PRStackStr PRStack;
/*
** FUNCTION: PR_CreateStack
** DESCRIPTION:
** Create a stack, a LIFO linked list
** INPUTS:
** stack_name: a pointer to string containing the name of the stack
** RETURN:
** A pointer to the created stack, if successful, else NULL.
*/
NSPR_API(PRStack *) PR_CreateStack(const char *stack_name);
/*
** FUNCTION: PR_StackPush
** DESCRIPTION:
** Push an element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** stack_elem: pointer to the stack element
** RETURN:
** None
*/
NSPR_API(void) PR_StackPush(PRStack *stack, PRStackElem *stack_elem);
/*
** FUNCTION: PR_StackPop
** DESCRIPTION:
** Remove the element on the top of the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** A pointer to the stack element removed from the top of the stack,
** if non-empty,
** else NULL
*/
NSPR_API(PRStackElem *) PR_StackPop(PRStack *stack);
/*
** FUNCTION: PR_DestroyStack
** DESCRIPTION:
** Destroy the stack
** INPUTS:
** stack: pointer to the stack
** RETURN:
** PR_SUCCESS - if successfully deleted
** PR_FAILURE - if the stack is not empty
** PR_GetError will return
** PR_INVALID_STATE_ERROR - stack is not empty
*/
NSPR_API(PRStatus) PR_DestroyStack(PRStack *stack);
PR_END_EXTERN_C
#endif /* pratom_h___ */

View File

@@ -0,0 +1,150 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prbit_h___
#define prbit_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** Replace compare/jump/add/shift sequence with compiler built-in/intrinsic
** functions.
*/
#if defined(_WIN32) && (_MSC_VER >= 1300) && \
(defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM))
# include <intrin.h>
# pragma intrinsic(_BitScanForward,_BitScanReverse)
__forceinline static int __prBitScanForward32(unsigned int val)
{
unsigned long idx;
_BitScanForward(&idx, (unsigned long)val);
return( (int)idx );
}
__forceinline static int __prBitScanReverse32(unsigned int val)
{
unsigned long idx;
_BitScanReverse(&idx, (unsigned long)val);
return( (int)(31-idx) );
}
# define pr_bitscan_ctz32(val) __prBitScanForward32(val)
# define pr_bitscan_clz32(val) __prBitScanReverse32(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
(defined(__i386__) || defined(__x86_64__) || defined(__arm__))
# define pr_bitscan_ctz32(val) __builtin_ctz(val)
# define pr_bitscan_clz32(val) __builtin_clz(val)
# define PR_HAVE_BUILTIN_BITSCAN32
#endif /* MSVC || GCC */
/*
** A prbitmap_t is a long integer that can be used for bitmaps
*/
typedef unsigned long prbitmap_t;
#define PR_TEST_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
#define PR_SET_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
#define PR_CLEAR_BIT(_map,_bit) \
((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1))))
/*
** Compute the log of the least power of 2 greater than or equal to n
*/
NSPR_API(PRIntn) PR_CeilingLog2(PRUint32 i);
/*
** Compute the log of the greatest power of 2 less than or equal to n
*/
NSPR_API(PRIntn) PR_FloorLog2(PRUint32 i);
/*
** Macro version of PR_CeilingLog2: Compute the log of the least power of
** 2 greater than or equal to _n. The result is returned in _log2.
*/
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = (j_ <= 1 ? 0 : 32 - pr_bitscan_clz32(j_ - 1)); \
PR_END_MACRO
#else
#define PR_CEILING_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 0; \
if ((j_) & ((j_)-1)) \
(_log2) += 1; \
if ((j_) >> 16) \
(_log2) += 16, (j_) >>= 16; \
if ((j_) >> 8) \
(_log2) += 8, (j_) >>= 8; \
if ((j_) >> 4) \
(_log2) += 4, (j_) >>= 4; \
if ((j_) >> 2) \
(_log2) += 2, (j_) >>= 2; \
if ((j_) >> 1) \
(_log2) += 1; \
PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/*
** Macro version of PR_FloorLog2: Compute the log of the greatest power of
** 2 less than or equal to _n. The result is returned in _log2.
**
** This is equivalent to finding the highest set bit in the word.
*/
#ifdef PR_HAVE_BUILTIN_BITSCAN32
#define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 31 - pr_bitscan_clz32((j_) | 1); \
PR_END_MACRO
#else
#define PR_FLOOR_LOG2(_log2,_n) \
PR_BEGIN_MACRO \
PRUint32 j_ = (PRUint32)(_n); \
(_log2) = 0; \
if ((j_) >> 16) \
(_log2) += 16, (j_) >>= 16; \
if ((j_) >> 8) \
(_log2) += 8, (j_) >>= 8; \
if ((j_) >> 4) \
(_log2) += 4, (j_) >>= 4; \
if ((j_) >> 2) \
(_log2) += 2, (j_) >>= 2; \
if ((j_) >> 1) \
(_log2) += 1; \
PR_END_MACRO
#endif /* PR_HAVE_BUILTIN_BITSCAN32 */
/*
** Macros for rotate left and right. The argument 'a' must be an unsigned
** 32-bit integer type such as PRUint32.
**
** There is no rotate operation in the C Language, so the construct
** (a << 4) | (a >> 28) is frequently used instead. Most compilers convert
** this to a rotate instruction, but MSVC doesn't without a little help.
** To get MSVC to generate a rotate instruction, we have to use the _rotl
** or _rotr intrinsic and use a pragma to make it inline.
**
** Note: MSVC in VS2005 will do an inline rotate instruction on the above
** construct.
*/
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
defined(_M_X64) || defined(_M_ARM))
#include <stdlib.h>
#pragma intrinsic(_rotl, _rotr)
#define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
#define PR_ROTATE_RIGHT32(a, bits) _rotr(a, bits)
#else
#define PR_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits))))
#define PR_ROTATE_RIGHT32(a, bits) (((a) >> (bits)) | ((a) << (32 - (bits))))
#endif
PR_END_EXTERN_C
#endif /* prbit_h___ */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prclist_h___
#define prclist_h___
#include "prtypes.h"
typedef struct PRCListStr PRCList;
/*
** Circular linked list
*/
struct PRCListStr {
PRCList *next;
PRCList *prev;
};
/*
** Insert element "_e" into the list, before "_l".
*/
#define PR_INSERT_BEFORE(_e,_l) \
PR_BEGIN_MACRO \
(_e)->next = (_l); \
(_e)->prev = (_l)->prev; \
(_l)->prev->next = (_e); \
(_l)->prev = (_e); \
PR_END_MACRO
/*
** Insert element "_e" into the list, after "_l".
*/
#define PR_INSERT_AFTER(_e,_l) \
PR_BEGIN_MACRO \
(_e)->next = (_l)->next; \
(_e)->prev = (_l); \
(_l)->next->prev = (_e); \
(_l)->next = (_e); \
PR_END_MACRO
/*
** Return the element following element "_e"
*/
#define PR_NEXT_LINK(_e) \
((_e)->next)
/*
** Return the element preceding element "_e"
*/
#define PR_PREV_LINK(_e) \
((_e)->prev)
/*
** Append an element "_e" to the end of the list "_l"
*/
#define PR_APPEND_LINK(_e,_l) PR_INSERT_BEFORE(_e,_l)
/*
** Insert an element "_e" at the head of the list "_l"
*/
#define PR_INSERT_LINK(_e,_l) PR_INSERT_AFTER(_e,_l)
/* Return the head/tail of the list */
#define PR_LIST_HEAD(_l) (_l)->next
#define PR_LIST_TAIL(_l) (_l)->prev
/*
** Remove the element "_e" from it's circular list.
*/
#define PR_REMOVE_LINK(_e) \
PR_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
PR_END_MACRO
/*
** Remove the element "_e" from it's circular list. Also initializes the
** linkage.
*/
#define PR_REMOVE_AND_INIT_LINK(_e) \
PR_BEGIN_MACRO \
(_e)->prev->next = (_e)->next; \
(_e)->next->prev = (_e)->prev; \
(_e)->next = (_e); \
(_e)->prev = (_e); \
PR_END_MACRO
/*
** Return non-zero if the given circular list "_l" is empty, zero if the
** circular list is not empty
*/
#define PR_CLIST_IS_EMPTY(_l) \
((_l)->next == (_l))
/*
** Initialize a circular list
*/
#define PR_INIT_CLIST(_l) \
PR_BEGIN_MACRO \
(_l)->next = (_l); \
(_l)->prev = (_l); \
PR_END_MACRO
#define PR_INIT_STATIC_CLIST(_l) \
{(_l), (_l)}
#endif /* prclist_h___ */

View File

@@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prcmon_h___
#define prcmon_h___
/*
** Interface to cached monitors. Cached monitors use an address to find a
** given PR monitor. In this way a monitor can be associated with another
** object without preallocating a monitor for all objects.
**
** A hash table is used to quickly map addresses to individual monitors
** and the system automatically grows the hash table as needed.
**
** Cache monitors are about 5 times slower to use than uncached monitors.
*/
#include "prmon.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
/**
** Like PR_EnterMonitor except use the "address" to find a monitor in the
** monitor cache. If successful, returns the PRMonitor now associated
** with "address". Note that you must PR_CExitMonitor the address to
** release the monitor cache entry (otherwise the monitor cache will fill
** up). This call will return NULL if the monitor cache needs to be
** expanded and the system is out of memory.
*/
NSPR_API(PRMonitor*) PR_CEnterMonitor(void *address);
/*
** Like PR_ExitMonitor except use the "address" to find a monitor in the
** monitor cache.
*/
NSPR_API(PRStatus) PR_CExitMonitor(void *address);
/*
** Like PR_Wait except use the "address" to find a monitor in the
** monitor cache.
*/
NSPR_API(PRStatus) PR_CWait(void *address, PRIntervalTime timeout);
/*
** Like PR_Notify except use the "address" to find a monitor in the
** monitor cache.
*/
NSPR_API(PRStatus) PR_CNotify(void *address);
/*
** Like PR_NotifyAll except use the "address" to find a monitor in the
** monitor cache.
*/
NSPR_API(PRStatus) PR_CNotifyAll(void *address);
/*
** Set a callback to be invoked each time a monitor is recycled from the cache
** freelist, with the monitor's cache-key passed in address.
*/
NSPR_API(void) PR_CSetOnMonitorRecycle(void (PR_CALLBACK *callback)(void *address));
PR_END_EXTERN_C
#endif /* prcmon_h___ */

View File

@@ -0,0 +1,525 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prcountr_h___
#define prcountr_h___
/*----------------------------------------------------------------------------
** prcountr.h -- NSPR Instrumentation counters
**
** The NSPR Counter Feature provides a means to "count
** something." Counters can be dynamically defined, incremented,
** decremented, set, and deleted under application program
** control.
**
** The Counter Feature is intended to be used as instrumentation,
** not as operational data. If you need a counter for operational
** data, use native integral types.
**
** Counters are 32bit unsigned intergers. On overflow, a counter
** will wrap. No exception is recognized or reported.
**
** A counter can be dynamically created using a two level naming
** convention. A "handle" is returned when the counter is
** created. The counter can subsequently be addressed by its
** handle. An API is provided to get an existing counter's handle
** given the names with which it was originally created.
** Similarly, a counter's name can be retrieved given its handle.
**
** The counter naming convention is a two-level hierarchy. The
** QName is the higher level of the hierarchy; RName is the
** lower level. RNames can be thought of as existing within a
** QName. The same RName can exist within multiple QNames. QNames
** are unique. The NSPR Counter is not a near-zero overhead
** feature. Application designers should be aware of
** serialization issues when using the Counter API. Creating a
** counter locks a large asset, potentially causing a stall. This
** suggest that applications should create counters at component
** initialization, for example, and not create and destroy them
** willy-nilly. ... You have been warned.
**
** Incrementing and Adding to counters uses atomic operations.
** The performance of these operations will vary from platform
** to platform. On platforms where atomic operations are not
** supported the overhead may be substantial.
**
** When traversing the counter database with FindNext functions,
** the instantaneous values of any given counter is that at the
** moment of extraction. The state of the entire counter database
** may not be viewed as atomic.
**
** The counter interface may be disabled (No-Op'd) at compile
** time. When DEBUG is defined at compile time, the Counter
** Feature is compiled into NSPR and applications invoking it.
** When DEBUG is not defined, the counter macros compile to
** nothing. To force the Counter Feature to be compiled into an
** optimized build, define FORCE_NSPR_COUNTERS at compile time
** for both NSPR and the application intending to use it.
**
** Application designers should use the macro form of the Counter
** Feature methods to minimize performance impact in optimized
** builds. The macros normally compile to nothing on optimized
** builds.
**
** Application designers should be aware of the effects of
** debug and optimized build differences when using result of the
** Counter Feature macros in expressions.
**
** The Counter Feature is thread-safe and SMP safe.
**
** /lth. 09-Jun-1998.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** Opaque counter handle type.
** ... don't even think of looking in here.
**
*/
typedef void * PRCounterHandle;
#define PRCOUNTER_NAME_MAX 31
#define PRCOUNTER_DESC_MAX 255
/* -----------------------------------------------------------------------
** FUNCTION: PR_DEFINE_COUNTER() -- Define a PRCounterHandle
**
** DESCRIPTION: PR_DEFINE_COUNTER() is used to define a counter
** handle.
**
*/
#define PR_DEFINE_COUNTER(name) PRCounterHandle name
/* -----------------------------------------------------------------------
** FUNCTION: PR_INIT_COUNTER_HANDLE() -- Set the value of a PRCounterHandle
**
** DESCRIPTION:
** PR_INIT_COUNTER_HANDLE() sets the value of a PRCounterHandle
** to value.
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_INIT_COUNTER_HANDLE(handle,value)\
(handle) = (PRCounterHandle)(value)
#else
#define PR_INIT_COUNTER_HANDLE(handle,value)
#endif
/* -----------------------------------------------------------------------
** FUNCTION: PR_CreateCounter() -- Create a counter
**
** DESCRIPTION: PR_CreateCounter() creates a counter object and
** initializes it to zero.
**
** The macro form takes as its first argument the name of the
** PRCounterHandle to receive the handle returned from
** PR_CreateCounter().
**
** INPUTS:
** qName: The QName for the counter object. The maximum length
** of qName is defined by PRCOUNTER_NAME_MAX
**
** rName: The RName for the counter object. The maximum length
** of qName is defined by PRCOUNTER_NAME_MAX
**
** descrioption: The description of the counter object. The
** maximum length of description is defined by
** PRCOUNTER_DESC_MAX.
**
** OUTPUTS:
**
** RETURNS:
** PRCounterHandle.
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_CREATE_COUNTER(handle,qName,rName,description)\
(handle) = PR_CreateCounter((qName),(rName),(description))
#else
#define PR_CREATE_COUNTER(handle,qName,rName,description)
#endif
NSPR_API(PRCounterHandle)
PR_CreateCounter(
const char *qName,
const char *rName,
const char *description
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_DestroyCounter() -- Destroy a counter object.
**
** DESCRIPTION: PR_DestroyCounter() removes a counter and
** unregisters its handle from the counter database.
**
** INPUTS:
** handle: the PRCounterHandle of the counter to be destroyed.
**
** OUTPUTS:
** The counter is destroyed.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_DESTROY_COUNTER(handle) PR_DestroyCounter((handle))
#else
#define PR_DESTROY_COUNTER(handle)
#endif
NSPR_API(void)
PR_DestroyCounter(
PRCounterHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetCounterHandleFromName() -- Retreive a
** counter's handle give its name.
**
** DESCRIPTION: PR_GetCounterHandleFromName() retreives a
** counter's handle from the counter database, given the name
** the counter was originally created with.
**
** INPUTS:
** qName: Counter's original QName.
** rName: Counter's original RName.
**
** OUTPUTS:
**
** RETURNS:
** PRCounterHandle or PRCounterError.
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)\
(handle) = PR_GetCounterHandleFromName((qName),(rName))
#else
#define PR_GET_COUNTER_HANDLE_FROM_NAME(handle,qName,rName)
#endif
NSPR_API(PRCounterHandle)
PR_GetCounterHandleFromName(
const char *qName,
const char *rName
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetCounterNameFromHandle() -- Retreive a
** counter's name, given its handle.
**
** DESCRIPTION: PR_GetCounterNameFromHandle() retreives a
** counter's name given its handle.
**
** INPUTS:
** qName: Where to store a pointer to qName.
** rName: Where to store a pointer to rName.
** description: Where to store a pointer to description.
**
** OUTPUTS: Pointers to the Counter Feature's copies of the names
** used when the counters were created.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description)\
PR_GetCounterNameFromHandle((handle),(qName),(rName),(description))
#else
#define PR_GET_COUNTER_NAME_FROM_HANDLE(handle,qName,rName,description )
#endif
NSPR_API(void)
PR_GetCounterNameFromHandle(
PRCounterHandle handle,
const char **qName,
const char **rName,
const char **description
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_IncrementCounter() -- Add one to the referenced
** counter.
**
** DESCRIPTION: Add one to the referenced counter.
**
** INPUTS:
** handle: The PRCounterHandle of the counter to be incremented
**
** OUTPUTS: The counter is incrementd.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_INCREMENT_COUNTER(handle) PR_IncrementCounter(handle)
#else
#define PR_INCREMENT_COUNTER(handle)
#endif
NSPR_API(void)
PR_IncrementCounter(
PRCounterHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_DecrementCounter() -- Subtract one from the
** referenced counter
**
** DESCRIPTION: Subtract one from the referenced counter.
**
** INPUTS:
** handle: The PRCounterHandle of the coutner to be
** decremented.
**
** OUTPUTS: the counter is decremented.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_DECREMENT_COUNTER(handle) PR_DecrementCounter(handle)
#else
#define PR_DECREMENT_COUNTER(handle)
#endif
NSPR_API(void)
PR_DecrementCounter(
PRCounterHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_AddToCounter() -- Add a value to a counter.
**
** DESCRIPTION: Add value to the counter referenced by handle.
**
** INPUTS:
** handle: the PRCounterHandle of the counter to be added to.
**
** value: the value to be added to the counter.
**
** OUTPUTS: new value for counter.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_ADD_TO_COUNTER(handle,value)\
PR_AddToCounter((handle),(value))
#else
#define PR_ADD_TO_COUNTER(handle,value)
#endif
NSPR_API(void)
PR_AddToCounter(
PRCounterHandle handle,
PRUint32 value
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_SubtractFromCounter() -- A value is subtracted
** from a counter.
**
** DESCRIPTION:
** Subtract a value from a counter.
**
** INPUTS:
** handle: the PRCounterHandle of the counter to be subtracted
** from.
**
** value: the value to be subtracted from the counter.
**
** OUTPUTS: new value for counter
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_SUBTRACT_FROM_COUNTER(handle,value)\
PR_SubtractFromCounter((handle),(value))
#else
#define PR_SUBTRACT_FROM_COUNTER(handle,value)
#endif
NSPR_API(void)
PR_SubtractFromCounter(
PRCounterHandle handle,
PRUint32 value
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetCounter() -- Retreive the value of a counter
**
** DESCRIPTION:
** Retreive the value of a counter.
**
** INPUTS:
** handle: the PR_CounterHandle of the counter to be retreived
**
** OUTPUTS:
**
** RETURNS: The value of the referenced counter
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_GET_COUNTER(counter,handle)\
(counter) = PR_GetCounter((handle))
#else
#define PR_GET_COUNTER(counter,handle) 0
#endif
NSPR_API(PRUint32)
PR_GetCounter(
PRCounterHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_SetCounter() -- Replace the content of counter
** with value.
**
** DESCRIPTION: The contents of the referenced counter are
** replaced by value.
**
** INPUTS:
** handle: the PRCounterHandle of the counter whose contents
** are to be replaced.
**
** value: the new value of the counter.
**
** OUTPUTS:
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_SET_COUNTER(handle,value) PR_SetCounter((handle),(value))
#else
#define PR_SET_COUNTER(handle,value)
#endif
NSPR_API(void)
PR_SetCounter(
PRCounterHandle handle,
PRUint32 value
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_FindNextCounterQname() -- Retreive the next QName counter
** handle iterator
**
** DESCRIPTION:
** PR_FindNextCounterQname() retreives the first or next Qname
** the counter data base, depending on the value of handle. When
** handle is NULL, the function attempts to retreive the first
** QName handle in the database. When handle is a handle previosly
** retreived QName handle, then the function attempts to retreive
** the next QName handle.
**
** INPUTS:
** handle: PRCounterHandle or NULL.
**
** OUTPUTS: returned
**
** RETURNS: PRCounterHandle or NULL when no more QName counter
** handles are present.
**
** RESTRICTIONS:
** A concurrent PR_CreateCounter() or PR_DestroyCounter() may
** cause unpredictable results.
**
** A PRCounterHandle returned from this function may only be used
** in another PR_FindNextCounterQname() function call; other
** operations may cause unpredictable results.
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_FIND_NEXT_COUNTER_QNAME(next,handle)\
(next) = PR_FindNextCounterQname((handle))
#else
#define PR_FIND_NEXT_COUNTER_QNAME(next,handle) NULL
#endif
NSPR_API(PRCounterHandle)
PR_FindNextCounterQname(
PRCounterHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_FindNextCounterRname() -- Retreive the next RName counter
** handle iterator
**
** DESCRIPTION:
** PR_FindNextCounterRname() retreives the first or next RNname
** handle from the counter data base, depending on the
** value of handle. When handle is NULL, the function attempts to
** retreive the first RName handle in the database. When handle is
** a handle previosly retreived RName handle, then the function
** attempts to retreive the next RName handle.
**
** INPUTS:
** handle: PRCounterHandle or NULL.
** qhandle: PRCounterHandle of a previously aquired via
** PR_FIND_NEXT_QNAME_HANDLE()
**
** OUTPUTS: returned
**
** RETURNS: PRCounterHandle or NULL when no more RName counter
** handles are present.
**
** RESTRICTIONS:
** A concurrent PR_CreateCounter() or PR_DestroyCounter() may
** cause unpredictable results.
**
** A PRCounterHandle returned from this function may only be used
** in another PR_FindNextCounterRname() function call; other
** operations may cause unpredictable results.
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_COUNTERS)
#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)\
(next) = PR_FindNextCounterRname((rhandle),(qhandle))
#else
#define PR_FIND_NEXT_COUNTER_RNAME(next,rhandle,qhandle)
#endif
NSPR_API(PRCounterHandle)
PR_FindNextCounterRname(
PRCounterHandle rhandle,
PRCounterHandle qhandle
);
PR_END_EXTERN_C
#endif /* prcountr_h___ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prcvar_h___
#define prcvar_h___
#include "prlock.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
typedef struct PRCondVar PRCondVar;
/*
** Create a new condition variable.
**
** "lock" is the lock used to protect the condition variable.
**
** Condition variables are synchronization objects that threads can use
** to wait for some condition to occur.
**
** This may fail if memory is tight or if some operating system resource
** is low. In such cases, a NULL will be returned.
*/
NSPR_API(PRCondVar*) PR_NewCondVar(PRLock *lock);
/*
** Destroy a condition variable. There must be no thread
** waiting on the condvar. The caller is responsible for guaranteeing
** that the condvar is no longer in use.
**
*/
NSPR_API(void) PR_DestroyCondVar(PRCondVar *cvar);
/*
** The thread that waits on a condition is blocked in a "waiting on
** condition" state until another thread notifies the condition or a
** caller specified amount of time expires. The lock associated with
** the condition variable will be released, which must have be held
** prior to the call to wait.
**
** Logically a notified thread is moved from the "waiting on condition"
** state and made "ready." When scheduled, it will attempt to reacquire
** the lock that it held when wait was called.
**
** The timeout has two well known values, PR_INTERVAL_NO_TIMEOUT and
** PR_INTERVAL_NO_WAIT. The former value requires that a condition be
** notified (or the thread interrupted) before it will resume from the
** wait. If the timeout has a value of PR_INTERVAL_NO_WAIT, the effect
** is to release the lock, possibly causing a rescheduling within the
** runtime, then immediately attempting to reacquire the lock and resume.
**
** Any other value for timeout will cause the thread to be rescheduled
** either due to explicit notification or an expired interval. The latter
** must be determined by treating time as one part of the monitored data
** being protected by the lock and tested explicitly for an expired
** interval.
**
** Returns PR_FAILURE if the caller has not locked the lock associated
** with the condition variable or the thread was interrupted (PR_Interrupt()).
** The particular reason can be extracted with PR_GetError().
*/
NSPR_API(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);
/*
** Notify ONE thread that is currently waiting on 'cvar'. Which thread is
** dependent on the implementation of the runtime. Common sense would dictate
** that all threads waiting on a single condition have identical semantics,
** therefore which one gets notified is not significant.
**
** The calling thead must hold the lock that protects the condition, as
** well as the invariants that are tightly bound to the condition, when
** notify is called.
**
** Returns PR_FAILURE if the caller has not locked the lock associated
** with the condition variable.
*/
NSPR_API(PRStatus) PR_NotifyCondVar(PRCondVar *cvar);
/*
** Notify all of the threads waiting on the condition variable. The order
** that the threads are notified is indeterminant. The lock that protects
** the condition must be held.
**
** Returns PR_FAILURE if the caller has not locked the lock associated
** with the condition variable.
*/
NSPR_API(PRStatus) PR_NotifyAllCondVar(PRCondVar *cvar);
PR_END_EXTERN_C
#endif /* prcvar_h___ */

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prdtoa_h___
#define prdtoa_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** PR_strtod() returns as a double-precision floating-point number
** the value represented by the character string pointed to by
** s00. The string is scanned up to the first unrecognized
** character.
**a
** If the value of se is not (char **)NULL, a pointer to
** the character terminating the scan is returned in the location pointed
** to by se. If no number can be formed, se is set to s00, and
** zero is returned.
*/
NSPR_API(PRFloat64)
PR_strtod(const char *s00, char **se);
/*
** PR_cnvtf()
** conversion routines for floating point
** prcsn - number of digits of precision to generate floating
** point value.
*/
NSPR_API(void) PR_cnvtf(char *buf, PRIntn bufsz, PRIntn prcsn, PRFloat64 fval);
/*
** PR_dtoa() converts double to a string.
**
** ARGUMENTS:
** If rve is not null, *rve is set to point to the end of the return value.
** If d is +-Infinity or NaN, then *decpt is set to 9999.
**
** mode:
** 0 ==> shortest string that yields d when read in
** and rounded to nearest.
*/
NSPR_API(PRStatus) PR_dtoa(PRFloat64 d, PRIntn mode, PRIntn ndigits,
PRIntn *decpt, PRIntn *sign, char **rve, char *buf, PRSize bufsize);
PR_END_EXTERN_C
#endif /* prdtoa_h___ */

View File

@@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prenv_h___
#define prenv_h___
#include "prtypes.h"
/*******************************************************************************/
/*******************************************************************************/
/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/
/*******************************************************************************/
/*******************************************************************************/
PR_BEGIN_EXTERN_C
/*
** PR_GetEnv() -- Retrieve value of environment variable
**
** Description:
** PR_GetEnv() is modeled on Unix getenv().
**
**
** Inputs:
** var -- The name of the environment variable
**
** Returns:
** The value of the environment variable 'var' or NULL if
** the variable is undefined.
**
** Restrictions:
** You'd think that a POSIX getenv(), putenv() would be
** consistently implemented everywhere. Surprise! It is not. On
** some platforms, a putenv() where the argument is of
** the form "name" causes the named environment variable to
** be un-set; that is: a subsequent getenv() returns NULL. On
** other platforms, the putenv() fails, on others, it is a
** no-op. Similarly, a putenv() where the argument is of the
** form "name=" causes the named environment variable to be
** un-set; a subsequent call to getenv() returns NULL. On
** other platforms, a subsequent call to getenv() returns a
** pointer to a null-string (a byte of zero).
**
** PR_GetEnv(), PR_SetEnv() provide a consistent behavior
** across all supported platforms. There are, however, some
** restrictions and some practices you must use to achieve
** consistent results everywhere.
**
** When manipulating the environment there is no way to un-set
** an environment variable across all platforms. We suggest
** you interpret the return of a pointer to null-string to
** mean the same as a return of NULL from PR_GetEnv().
**
** A call to PR_SetEnv() where the parameter is of the form
** "name" will return PR_FAILURE; the environment remains
** unchanged. A call to PR_SetEnv() where the parameter is
** of the form "name=" may un-set the envrionment variable on
** some platforms; on others it may set the value of the
** environment variable to the null-string.
**
** For example, to test for NULL return or return of the
** null-string from PR_GetEnv(), use the following code
** fragment:
**
** char *val = PR_GetEnv("foo");
** if ((NULL == val) || ('\0' == *val)) {
** ... interpret this as un-set ...
** }
**
** The caller must ensure that the string passed
** to PR_SetEnv() is persistent. That is: The string should
** not be on the stack, where it can be overwritten
** on return from the function calling PR_SetEnv().
** Similarly, the string passed to PR_SetEnv() must not be
** overwritten by other actions of the process. ... Some
** platforms use the string by reference rather than copying
** it into the environment space. ... You have been warned!
**
** Use of platform-native functions that manipulate the
** environment (getenv(), putenv(),
** SetEnvironmentVariable(), etc.) must not be used with
** NSPR's similar functions. The platform-native functions
** may not be thread safe and/or may operate on different
** conceptual environment space than that operated upon by
** NSPR's functions or other environment manipulating
** functions on the same platform. (!)
**
*/
NSPR_API(char*) PR_GetEnv(const char *var);
/*
** PR_GetEnvSecure() -- get a security-sensitive environment variable
**
** Description:
**
** PR_GetEnvSecure() is similar to PR_GetEnv(), but it returns NULL if
** the program was run with elevated privilege (e.g., setuid or setgid
** on Unix). This can be used for cases like log file paths which
** could otherwise be used for privilege escalation. Note that some
** platforms may have platform-specific privilege elevation mechanisms
** not recognized by this function; see the implementation for details.
*/
NSPR_API(char*) PR_GetEnvSecure(const char *var);
/*
** PR_SetEnv() -- set, unset or change an environment variable
**
** Description:
** PR_SetEnv() is modeled on the Unix putenv() function.
**
** Inputs:
** string -- pointer to a caller supplied
** constant, persistent string of the form name=value. Where
** name is the name of the environment variable to be set or
** changed; value is the value assigned to the variable.
**
** Returns:
** PRStatus.
**
** Restrictions:
** See the Restrictions documented in the description of
** PR_GetEnv() in this header file.
**
**
*/
NSPR_API(PRStatus) PR_SetEnv(const char *string);
/*
** PR_DuplicateEnvironment() -- Obtain a copy of the environment.
**
** Description:
** PR_DuplicateEnvironment() copies the environment so that it can be
** modified without changing the current process's environment, and
** then passed to interfaces such as POSIX execve(). In particular,
** this avoids needing to allocate memory or take locks in the child
** after a fork(); neither of these is allowed by POSIX after a
** multithreaded process calls fork(), and PR_SetEnv does both.
**
** Inputs:
** none
**
** Returns:
** A pointer to a null-terminated array of null-terminated strings,
** like the traditional global variable "environ". The array and
** the strings are allocated with PR_Malloc(), and it is the
** caller's responsibility to free them.
**
** In case of memory allocation failure, or if the operating system
** doesn't support reading the entire environment through the global
** variable "environ" or similar, returns NULL instead.
**
** Restrictions:
** Similarly to PR_GetEnv(), this function may not interoperate as
** expected with the operating system's native environment accessors.
*/
NSPR_API(char **) PR_DuplicateEnvironment(void);
PR_END_EXTERN_C
#endif /* prenv_h___ */

View File

@@ -0,0 +1,249 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prerr_h___
#define prerr_h___
/*
*
* prerr.h
* This file is automatically generated; please do not edit it.
*/
/* Memory allocation attempt failed */
#define PR_OUT_OF_MEMORY_ERROR (-6000L)
/* Invalid file descriptor */
#define PR_BAD_DESCRIPTOR_ERROR (-5999L)
/* The operation would have blocked */
#define PR_WOULD_BLOCK_ERROR (-5998L)
/* Invalid memory address argument */
#define PR_ACCESS_FAULT_ERROR (-5997L)
/* Invalid function for file type */
#define PR_INVALID_METHOD_ERROR (-5996L)
/* Invalid memory address argument */
#define PR_ILLEGAL_ACCESS_ERROR (-5995L)
/* Some unknown error has occurred */
#define PR_UNKNOWN_ERROR (-5994L)
/* Operation interrupted by another thread */
#define PR_PENDING_INTERRUPT_ERROR (-5993L)
/* function not implemented */
#define PR_NOT_IMPLEMENTED_ERROR (-5992L)
/* I/O function error */
#define PR_IO_ERROR (-5991L)
/* I/O operation timed out */
#define PR_IO_TIMEOUT_ERROR (-5990L)
/* I/O operation on busy file descriptor */
#define PR_IO_PENDING_ERROR (-5989L)
/* The directory could not be opened */
#define PR_DIRECTORY_OPEN_ERROR (-5988L)
/* Invalid function argument */
#define PR_INVALID_ARGUMENT_ERROR (-5987L)
/* Network address not available (in use?) */
#define PR_ADDRESS_NOT_AVAILABLE_ERROR (-5986L)
/* Network address type not supported */
#define PR_ADDRESS_NOT_SUPPORTED_ERROR (-5985L)
/* Already connected */
#define PR_IS_CONNECTED_ERROR (-5984L)
/* Network address is invalid */
#define PR_BAD_ADDRESS_ERROR (-5983L)
/* Local Network address is in use */
#define PR_ADDRESS_IN_USE_ERROR (-5982L)
/* Connection refused by peer */
#define PR_CONNECT_REFUSED_ERROR (-5981L)
/* Network address is presently unreachable */
#define PR_NETWORK_UNREACHABLE_ERROR (-5980L)
/* Connection attempt timed out */
#define PR_CONNECT_TIMEOUT_ERROR (-5979L)
/* Network file descriptor is not connected */
#define PR_NOT_CONNECTED_ERROR (-5978L)
/* Failure to load dynamic library */
#define PR_LOAD_LIBRARY_ERROR (-5977L)
/* Failure to unload dynamic library */
#define PR_UNLOAD_LIBRARY_ERROR (-5976L)
/* Symbol not found in any of the loaded dynamic libraries */
#define PR_FIND_SYMBOL_ERROR (-5975L)
/* Insufficient system resources */
#define PR_INSUFFICIENT_RESOURCES_ERROR (-5974L)
/* A directory lookup on a network address has failed */
#define PR_DIRECTORY_LOOKUP_ERROR (-5973L)
/* Attempt to access a TPD key that is out of range */
#define PR_TPD_RANGE_ERROR (-5972L)
/* Process open FD table is full */
#define PR_PROC_DESC_TABLE_FULL_ERROR (-5971L)
/* System open FD table is full */
#define PR_SYS_DESC_TABLE_FULL_ERROR (-5970L)
/* Network operation attempted on non-network file descriptor */
#define PR_NOT_SOCKET_ERROR (-5969L)
/* TCP-specific function attempted on a non-TCP file descriptor */
#define PR_NOT_TCP_SOCKET_ERROR (-5968L)
/* TCP file descriptor is already bound */
#define PR_SOCKET_ADDRESS_IS_BOUND_ERROR (-5967L)
/* Access Denied */
#define PR_NO_ACCESS_RIGHTS_ERROR (-5966L)
/* The requested operation is not supported by the platform */
#define PR_OPERATION_NOT_SUPPORTED_ERROR (-5965L)
/* The host operating system does not support the protocol requested */
#define PR_PROTOCOL_NOT_SUPPORTED_ERROR (-5964L)
/* Access to the remote file has been severed */
#define PR_REMOTE_FILE_ERROR (-5963L)
/* The value requested is too large to be stored in the data buffer provided */
#define PR_BUFFER_OVERFLOW_ERROR (-5962L)
/* TCP connection reset by peer */
#define PR_CONNECT_RESET_ERROR (-5961L)
/* Unused */
#define PR_RANGE_ERROR (-5960L)
/* The operation would have deadlocked */
#define PR_DEADLOCK_ERROR (-5959L)
/* The file is already locked */
#define PR_FILE_IS_LOCKED_ERROR (-5958L)
/* Write would result in file larger than the system allows */
#define PR_FILE_TOO_BIG_ERROR (-5957L)
/* The device for storing the file is full */
#define PR_NO_DEVICE_SPACE_ERROR (-5956L)
/* Unused */
#define PR_PIPE_ERROR (-5955L)
/* Unused */
#define PR_NO_SEEK_DEVICE_ERROR (-5954L)
/* Cannot perform a normal file operation on a directory */
#define PR_IS_DIRECTORY_ERROR (-5953L)
/* Symbolic link loop */
#define PR_LOOP_ERROR (-5952L)
/* File name is too long */
#define PR_NAME_TOO_LONG_ERROR (-5951L)
/* File not found */
#define PR_FILE_NOT_FOUND_ERROR (-5950L)
/* Cannot perform directory operation on a normal file */
#define PR_NOT_DIRECTORY_ERROR (-5949L)
/* Cannot write to a read-only file system */
#define PR_READ_ONLY_FILESYSTEM_ERROR (-5948L)
/* Cannot delete a directory that is not empty */
#define PR_DIRECTORY_NOT_EMPTY_ERROR (-5947L)
/* Cannot delete or rename a file object while the file system is busy */
#define PR_FILESYSTEM_MOUNTED_ERROR (-5946L)
/* Cannot rename a file to a file system on another device */
#define PR_NOT_SAME_DEVICE_ERROR (-5945L)
/* The directory object in the file system is corrupted */
#define PR_DIRECTORY_CORRUPTED_ERROR (-5944L)
/* Cannot create or rename a filename that already exists */
#define PR_FILE_EXISTS_ERROR (-5943L)
/* Directory is full. No additional filenames may be added */
#define PR_MAX_DIRECTORY_ENTRIES_ERROR (-5942L)
/* The required device was in an invalid state */
#define PR_INVALID_DEVICE_STATE_ERROR (-5941L)
/* The device is locked */
#define PR_DEVICE_IS_LOCKED_ERROR (-5940L)
/* No more entries in the directory */
#define PR_NO_MORE_FILES_ERROR (-5939L)
/* Encountered end of file */
#define PR_END_OF_FILE_ERROR (-5938L)
/* Seek error */
#define PR_FILE_SEEK_ERROR (-5937L)
/* The file is busy */
#define PR_FILE_IS_BUSY_ERROR (-5936L)
/* The I/O operation was aborted */
#define PR_OPERATION_ABORTED_ERROR (-5935L)
/* Operation is still in progress (probably a non-blocking connect) */
#define PR_IN_PROGRESS_ERROR (-5934L)
/* Operation has already been initiated (probably a non-blocking connect) */
#define PR_ALREADY_INITIATED_ERROR (-5933L)
/* The wait group is empty */
#define PR_GROUP_EMPTY_ERROR (-5932L)
/* Object state improper for request */
#define PR_INVALID_STATE_ERROR (-5931L)
/* Network is down */
#define PR_NETWORK_DOWN_ERROR (-5930L)
/* Socket shutdown */
#define PR_SOCKET_SHUTDOWN_ERROR (-5929L)
/* Connection aborted */
#define PR_CONNECT_ABORTED_ERROR (-5928L)
/* Host is unreachable */
#define PR_HOST_UNREACHABLE_ERROR (-5927L)
/* The library is not loaded */
#define PR_LIBRARY_NOT_LOADED_ERROR (-5926L)
/* The one-time function was previously called and failed. Its error code is no longer available */
#define PR_CALL_ONCE_ERROR (-5925L)
/* Placeholder for the end of the list */
#define PR_MAX_ERROR (-5924L)
extern void nspr_InitializePRErrorTable(void);
#define ERROR_TABLE_BASE_nspr (-6000L)
#endif /* prerr_h___ */

View File

@@ -0,0 +1,294 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prerror_h___
#define prerror_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef PRInt32 PRErrorCode;
#define PR_NSPR_ERROR_BASE -6000
#include "prerr.h"
/*
** Set error will preserve an error condition within a thread context.
** The values stored are the NSPR (platform independent) translation of
** the error. Also, if available, the platform specific oserror is stored.
** If there is no appropriate OS error number, a zero my be supplied.
*/
NSPR_API(void) PR_SetError(PRErrorCode errorCode, PRInt32 oserr);
/*
** The text value specified may be NULL. If it is not NULL and the text length
** is zero, the string is assumed to be a null terminated C string. Otherwise
** the text is assumed to be the length specified and possibly include NULL
** characters (e.g., a multi-national string).
**
** The text will be copied into to thread structure and remain there
** until the next call to PR_SetError.
*/
NSPR_API(void) PR_SetErrorText(
PRIntn textLength, const char *text);
/*
** Return the current threads last set error code.
*/
NSPR_API(PRErrorCode) PR_GetError(void);
/*
** Return the current threads last set os error code. This is used for
** machine specific code that desires the underlying os error.
*/
NSPR_API(PRInt32) PR_GetOSError(void);
/*
** Get the length of the error text. If a zero is returned, then there
** is no text. Otherwise, the value returned is sufficient to contain
** the error text currently available.
*/
NSPR_API(PRInt32) PR_GetErrorTextLength(void);
/*
** Copy the current threads current error text. Then actual number of bytes
** copied is returned as the result. If the result is zero, the 'text' area
** is unaffected.
*/
NSPR_API(PRInt32) PR_GetErrorText(char *text);
/*
Copyright (C) 1987, 1988 Student Information Processing Board of the
Massachusetts Institute of Technology.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
used in advertising or publicity pertaining to distribution of the software
without specific, written prior permission. M.I.T. and the M.I.T. S.I.P.B.
make no representations about the suitability of this software for any
purpose. It is provided "as is" without express or implied warranty.
*/
/*
* NOTE:
* The interfaces for error-code-translation described in the rest of
* this file are preliminary in the 3.1 release of nspr and are subject
* to change in future releases.
*/
/*
** Description: Localizable error code to string function.
**
**
** NSPR provides a mechanism for converting an error code to a
** descriptive string, in a caller-specified language.
**
** Error codes themselves are 32 bit (signed) integers. Typically,
** the high order 24 bits are an identifier of which error table the
** error code is from, and the low order 8 bits are a sequential error
** number within the table. NSPR supports error tables whose first
** error code is not a multiple of 256, such error code assignments
** should be avoided when possible.
**
** Error table 0 is defined to match the UNIX system call error table
** (sys_errlist); this allows errno values to be used directly in the
** library. Other error table numbers are typically formed by
** compacting together the first four characters of the error table
** name. The mapping between characters in the name and numeric
** values in the error code are defined in a system-independent
** fashion, so that two systems that can pass integral values between
** them can reliably pass error codes without loss of meaning; this
** should work even if the character sets used are not the
** same. (However, if this is to be done, error table 0 should be
** avoided, since the local system call error tables may differ.)
**
** Libraries defining error codes need only provide a table mapping
** error code numbers to names and default English descriptions,
** calling a routine to install the table, making it ``known'' to NSPR
** library. Once installed, a table may not be removed. Any error
** code the library generates can be converted to the corresponding
** error message. There is also a default format for error codes
** accidentally returned before making the table known, which is of
** the form "unknown code foo 32", where "foo" would be the name of
** the table.
**
** Normally, the error code conversion routine only supports the
** languages "i-default" and "en", returning the error-table-provided
** English description for both languages. The application may
** provide a localization plugin, allowing support for additional
** languages.
**
**/
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
/*
* PRLanguageCode --
*
* NSPR represents a language code as a non-negative integer.
* Languages 0 is always "i-default" the language you get without
* explicit negotiation. Language 1 is always "en", English
* which has been explicitly negotiated. Additional language
* codes are defined by an application-provided localization plugin.
*/
typedef PRUint32 PRLanguageCode;
#define PR_LANGUAGE_I_DEFAULT 0 /* i-default, the default language */
#define PR_LANGUAGE_EN 1 /* English, explicitly negotiated */
/*
* struct PRErrorMessage --
*
* An error message in an error table.
*/
struct PRErrorMessage {
const char * name; /* Macro name for error */
const char * en_text; /* Default English text */
};
/*
* struct PRErrorTable --
*
* An error table, provided by a library.
*/
struct PRErrorTable {
const struct PRErrorMessage * msgs; /* Array of error information */
const char *name; /* Name of error table source */
PRErrorCode base; /* Error code for first error in table */
int n_msgs; /* Number of codes in table */
};
/*
* struct PRErrorCallbackPrivate --
*
* A private structure for the localization plugin
*/
struct PRErrorCallbackPrivate;
/*
* struct PRErrorCallbackTablePrivate --
*
* A data structure under which the localization plugin may store information,
* associated with an error table, that is private to itself.
*/
struct PRErrorCallbackTablePrivate;
/*
* PRErrorCallbackLookupFn --
*
* A function of PRErrorCallbackLookupFn type is a localization
* plugin callback which converts an error code into a description
* in the requested language. The callback is provided the
* appropriate error table, private data for the plugin and the table.
* The callback returns the appropriate UTF-8 encoded description, or NULL
* if no description can be found.
*/
typedef const char *
PRErrorCallbackLookupFn(PRErrorCode code, PRLanguageCode language,
const struct PRErrorTable *table,
struct PRErrorCallbackPrivate *cb_private,
struct PRErrorCallbackTablePrivate *table_private);
/*
* PRErrorCallbackNewTableFn --
*
* A function PRErrorCallbackNewTableFn type is a localization plugin
* callback which is called once with each error table registered
* with NSPR. The callback is provided with the error table and
* the plugin's private structure. The callback returns any table private
* data it wishes to associate with the error table. Does not need to be thread
* safe.
*/
typedef struct PRErrorCallbackTablePrivate *
PRErrorCallbackNewTableFn(const struct PRErrorTable *table,
struct PRErrorCallbackPrivate *cb_private);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_ErrorToString
** DESCRIPTION:
** Returns the UTF-8 message for an error code in
** the requested language. May return the message
** in the default language if a translation in the requested
** language is not available. The returned string is
** valid for the duration of the process. Never returns NULL.
**
***********************************************************************/
NSPR_API(const char *) PR_ErrorToString(PRErrorCode code,
PRLanguageCode language);
/***********************************************************************
** FUNCTION: PR_ErrorToName
** DESCRIPTION:
** Returns the macro name for an error code, or NULL
** if the error code is not known. The returned string is
** valid for the duration of the process.
**
** Does not work for error table 0, the system error codes.
**
***********************************************************************/
NSPR_API(const char *) PR_ErrorToName(PRErrorCode code);
/***********************************************************************
** FUNCTION: PR_ErrorLanguages
** DESCRIPTION:
** Returns the RFC 1766 language tags for the language
** codes PR_ErrorToString() supports. The returned array is valid
** for the duration of the process. Never returns NULL. The first
** item in the returned array is the language tag for PRLanguageCode 0,
** the second is for PRLanguageCode 1, and so on. The array is terminated
** with a null pointer.
**
***********************************************************************/
NSPR_API(const char * const *) PR_ErrorLanguages(void);
/***********************************************************************
** FUNCTION: PR_ErrorInstallTable
** DESCRIPTION:
** Registers an error table with NSPR. Must be done exactly once per
** table. Memory pointed to by `table' must remain valid for the life
** of the process.
**
** NOT THREAD SAFE!
**
***********************************************************************/
NSPR_API(PRErrorCode) PR_ErrorInstallTable(const struct PRErrorTable *table);
/***********************************************************************
** FUNCTION: PR_ErrorInstallCallback
** DESCRIPTION:
** Registers an error localization plugin with NSPR. May be called
** at most one time. `languages' contains the language codes supported
** by this plugin. Languages 0 and 1 must be "i-default" and "en"
** respectively. `lookup' and `newtable' contain pointers to
** the plugin callback functions. `cb_private' contains any information
** private to the plugin functions.
**
** NOT THREAD SAFE!
**
***********************************************************************/
NSPR_API(void) PR_ErrorInstallCallback(const char * const * languages,
PRErrorCallbackLookupFn *lookup,
PRErrorCallbackNewTableFn *newtable,
struct PRErrorCallbackPrivate *cb_private);
PR_END_EXTERN_C
#endif /* prerror_h___ */

View File

@@ -0,0 +1,99 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* File: prinet.h
* Description:
* Header file used to find the system header files for socket support[1].
* This file serves the following purposes:
* - A cross-platform, "get-everything" socket header file. On
* Unix, socket support is scattered in several header files,
* while Windows has a "get-everything" socket header file[2].
* - NSPR needs the following macro definitions and function
* prototype declarations from these header files:
* AF_INET
* INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST
* ntohl(), ntohs(), htonl(), ntons().
* NSPR does not define its own versions of these macros and
* functions. It simply uses the native versions, which have
* the same names on all supported platforms.
* This file is intended to be included by NSPR public header
* files, such as prio.h. One should not include this file directly.
*
* Notes:
* 1. This file should have been an internal header. Please do not
* depend on it to pull in the system header files you need.
* 2. WARNING: This file is no longer cross-platform as it is a no-op
* for WIN32! See the comment in the WIN32 section for details.
*/
#ifndef prinet_h__
#define prinet_h__
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
#include <sys/types.h>
#include <sys/socket.h> /* AF_INET */
#include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */
#ifdef XP_OS2
#include <sys/ioctl.h>
#endif
#ifdef XP_UNIX
#ifdef AIX
/*
* On AIX 4.3, the header <arpa/inet.h> refers to struct
* ether_addr and struct sockaddr_dl that are not declared.
* The following struct declarations eliminate the compiler
* warnings.
*/
struct ether_addr;
struct sockaddr_dl;
#endif /* AIX */
#include <arpa/inet.h>
#endif /* XP_UNIX */
#include <netdb.h>
#if defined(FREEBSD) || defined(BSDI) || defined(QNX)
#include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */
#endif
/*
* OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the
* socket headers.
*/
#if defined(OS2) && !defined(INADDR_LOOPBACK)
#define INADDR_LOOPBACK 0x7f000001
#endif
/*
* Prototypes of ntohl() etc. are declared in <machine/endian.h>
* on these platforms.
*/
#if defined(BSDI) || defined(OSF1)
#include <machine/endian.h>
#endif
/* On Android, ntohl() etc. are declared in <sys/endian.h>. */
#ifdef __ANDROID__
#include <sys/endian.h>
#endif
#elif defined(WIN32)
/*
* Do not include any system header files.
*
* Originally we were including <windows.h>. It slowed down the
* compilation of files that included NSPR headers, so we removed
* the <windows.h> inclusion at customer's request, which created
* an unfortunate inconsistency with other platforms.
*/
#else
#error Unknown platform
#endif
#endif /* prinet_h__ */

View File

@@ -0,0 +1,215 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prinit_h___
#define prinit_h___
#include "prthread.h"
#include "prtypes.h"
#include "prwin16.h"
#include <stdio.h>
PR_BEGIN_EXTERN_C
/************************************************************************/
/**************************IDENTITY AND VERSIONING***********************/
/************************************************************************/
/*
** NSPR's name, this should persist until at least the turn of the
** century.
*/
#define PR_NAME "NSPR"
/*
** NSPR's version is used to determine the likelihood that the version you
** used to build your component is anywhere close to being compatible with
** what is in the underlying library.
**
** The format of the version string is
** "<major version>.<minor version>[.<patch level>] [<Beta>]"
*/
#define PR_VERSION "4.13.1"
#define PR_VMAJOR 4
#define PR_VMINOR 13
#define PR_VPATCH 1
#define PR_BETA PR_FALSE
/*
** PRVersionCheck
**
** The basic signature of the function that is called to provide version
** checking. The result will be a boolean that indicates the likelihood
** that the underling library will perform as the caller expects.
**
** The only argument is a string, which should be the verson identifier
** of the library in question. That string will be compared against an
** equivalent string that represents the actual build version of the
** exporting library.
**
** The result will be the logical union of the directly called library
** and all dependent libraries.
*/
typedef PRBool (*PRVersionCheck)(const char*);
/*
** PR_VersionCheck
**
** NSPR's existance proof of the version check function.
**
** Note that NSPR has no cooperating dependencies.
*/
NSPR_API(PRBool) PR_VersionCheck(const char *importedVersion);
/*
* Returns a const string of the NSPR library version.
*/
NSPR_API(const char*) PR_GetVersion(void);
/************************************************************************/
/*******************************INITIALIZATION***************************/
/************************************************************************/
/*
** Initialize the runtime. Attach a thread object to the currently
** executing native thread of type "type".
**
** The specificaiton of 'maxPTDs' is ignored.
*/
NSPR_API(void) PR_Init(
PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
/*
** And alternate form of initialization, one that may become the default if
** not the only mechanism, provides a method to get the NSPR runtime init-
** ialized and place NSPR between the caller and the runtime library. This
** allows main() to be treated as any other thread root function, signalling
** its compeletion by returning and allowing the runtime to coordinate the
** completion of the other threads of the runtime.
**
** The priority of the main (or primordial) thread will be PR_PRIORITY_NORMAL.
** The thread may adjust its own priority by using PR_SetPriority(), though
** at this time the support for priorities is somewhat weak.
**
** The specificaiton of 'maxPTDs' is ignored.
**
** The value returned by PR_Initialize is the value returned from the root
** function, 'prmain'.
*/
typedef PRIntn (PR_CALLBACK *PRPrimordialFn)(PRIntn argc, char **argv);
NSPR_API(PRIntn) PR_Initialize(
PRPrimordialFn prmain, PRIntn argc, char **argv, PRUintn maxPTDs);
/*
** Return PR_TRUE if PR_Init has already been called.
*/
NSPR_API(PRBool) PR_Initialized(void);
/*
* Perform a graceful shutdown of NSPR. PR_Cleanup() may be called by
* the primordial thread near the end of the main() function.
*
* PR_Cleanup() attempts to synchronize the natural termination of
* process. It does that by blocking the caller, if and only if it is
* the primordial thread, until the number of user threads has dropped
* to zero. When the primordial thread returns from main(), the process
* will immediately and silently exit. That is, it will (if necessary)
* forcibly terminate any existing threads and exit without significant
* blocking and there will be no error messages or core files.
*
* PR_Cleanup() returns PR_SUCCESS if NSPR is successfully shutdown,
* or PR_FAILURE if the calling thread of this function is not the
* primordial thread.
*/
NSPR_API(PRStatus) PR_Cleanup(void);
/*
** Disable Interrupts
** Disables timer signals used for pre-emptive scheduling.
*/
NSPR_API(void) PR_DisableClockInterrupts(void);
/*
** Enables Interrupts
** Enables timer signals used for pre-emptive scheduling.
*/
NSPR_API(void) PR_EnableClockInterrupts(void);
/*
** Block Interrupts
** Blocks the timer signal used for pre-emptive scheduling
*/
NSPR_API(void) PR_BlockClockInterrupts(void);
/*
** Unblock Interrupts
** Unblocks the timer signal used for pre-emptive scheduling
*/
NSPR_API(void) PR_UnblockClockInterrupts(void);
/*
** Create extra virtual processor threads. Generally used with MP systems.
*/
NSPR_API(void) PR_SetConcurrency(PRUintn numCPUs);
/*
** Control the method and size of the file descriptor (PRFileDesc*)
** cache used by the runtime. Setting 'high' to zero is for performance,
** any other value probably for debugging (see memo on FD caching).
*/
NSPR_API(PRStatus) PR_SetFDCacheSize(PRIntn low, PRIntn high);
/*
* Cause an immediate, nongraceful, forced termination of the process.
* It takes a PRIntn argument, which is the exit status code of the
* process.
*/
NSPR_API(void) PR_ProcessExit(PRIntn status);
/*
** Abort the process in a non-graceful manner. This will cause a core file,
** call to the debugger or other moral equivalent as well as causing the
** entire process to stop.
*/
NSPR_API(void) PR_Abort(void);
/*
****************************************************************
*
* Module initialization:
*
****************************************************************
*/
typedef struct PRCallOnceType {
PRIntn initialized;
PRInt32 inProgress;
PRStatus status;
} PRCallOnceType;
typedef PRStatus (PR_CALLBACK *PRCallOnceFN)(void);
typedef PRStatus (PR_CALLBACK *PRCallOnceWithArgFN)(void *arg);
NSPR_API(PRStatus) PR_CallOnce(
PRCallOnceType *once,
PRCallOnceFN func
);
NSPR_API(PRStatus) PR_CallOnceWithArg(
PRCallOnceType *once,
PRCallOnceWithArgFN func,
void *arg
);
PR_END_EXTERN_C
#endif /* prinit_h___ */

View File

@@ -0,0 +1,146 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prinrval.h
** Description: API to interval timing functions of NSPR.
**
**
** NSPR provides interval times that are independent of network time
** of day values. Interval times are (in theory) accurate regardless
** of host processing requirements and also very cheap to acquire. It
** is expected that getting an interval time while in a synchronized
** function (holding one's lock).
**/
#if !defined(prinrval_h)
#define prinrval_h
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
typedef PRUint32 PRIntervalTime;
/***********************************************************************
** DEFINES: PR_INTERVAL_MIN
** PR_INTERVAL_MAX
** DESCRIPTION:
** These two constants define the range (in ticks / second) of the
** platform dependent type, PRIntervalTime. These constants bound both
** the period and the resolution of a PRIntervalTime.
***********************************************************************/
#define PR_INTERVAL_MIN 1000UL
#define PR_INTERVAL_MAX 100000UL
/***********************************************************************
** DEFINES: PR_INTERVAL_NO_WAIT
** PR_INTERVAL_NO_TIMEOUT
** DESCRIPTION:
** Two reserved constants are defined in the PRIntervalTime namespace.
** They are used to indicate that the process should wait no time (return
** immediately) or wait forever (never time out), respectively.
** Note: PR_INTERVAL_NO_TIMEOUT passed as input to PR_Connect is
** interpreted as use the OS's connect timeout.
**
***********************************************************************/
#define PR_INTERVAL_NO_WAIT 0UL
#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_IntervalNow
** DESCRIPTION:
** Return the value of NSPR's free running interval timer. That timer
** can be used to establish epochs and determine intervals (be computing
** the difference between two times).
** INPUTS: void
** OUTPUTS: void
** RETURN: PRIntervalTime
**
** SIDE EFFECTS:
** None
** RESTRICTIONS:
** The units of PRIntervalTime are platform dependent. They are chosen
** such that they are appropriate for the host OS, yet provide sufficient
** resolution and period to be useful to clients.
** MEMORY: N/A
** ALGORITHM: Platform dependent
***********************************************************************/
NSPR_API(PRIntervalTime) PR_IntervalNow(void);
/***********************************************************************
** FUNCTION: PR_TicksPerSecond
** DESCRIPTION:
** Return the number of ticks per second for PR_IntervalNow's clock.
** The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX].
** INPUTS: void
** OUTPUTS: void
** RETURN: PRUint32
**
** SIDE EFFECTS:
** None
** RESTRICTIONS:
** None
** MEMORY: N/A
** ALGORITHM: N/A
***********************************************************************/
NSPR_API(PRUint32) PR_TicksPerSecond(void);
/***********************************************************************
** FUNCTION: PR_SecondsToInterval
** PR_MillisecondsToInterval
** PR_MicrosecondsToInterval
** DESCRIPTION:
** Convert standard clock units to platform dependent intervals.
** INPUTS: PRUint32
** OUTPUTS: void
** RETURN: PRIntervalTime
**
** SIDE EFFECTS:
** None
** RESTRICTIONS:
** Conversion may cause overflow, which is not reported.
** MEMORY: N/A
** ALGORITHM: N/A
***********************************************************************/
NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
/***********************************************************************
** FUNCTION: PR_IntervalToSeconds
** PR_IntervalToMilliseconds
** PR_IntervalToMicroseconds
** DESCRIPTION:
** Convert platform dependent intervals to standard clock units.
** INPUTS: PRIntervalTime
** OUTPUTS: void
** RETURN: PRUint32
**
** SIDE EFFECTS:
** None
** RESTRICTIONS:
** Conversion may cause overflow, which is not reported.
** MEMORY: N/A
** ALGORITHM: N/A
***********************************************************************/
NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
PR_END_EXTERN_C
#endif /* !defined(prinrval_h) */
/* prinrval.h */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* File: pripcsem.h
*
* Description: named semaphores for interprocess
* synchronization
*
* Unrelated processes obtain access to a shared semaphore
* by specifying its name.
*
* Our goal is to support named semaphores on at least
* Unix and Win32 platforms. The implementation will use
* one of the three native semaphore APIs: POSIX, System V,
* and Win32.
*
* Because POSIX named semaphores have kernel persistence,
* we are forced to have a delete function in this API.
*/
#ifndef pripcsem_h___
#define pripcsem_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
/*
* PRSem is an opaque structure that represents a named
* semaphore.
*/
typedef struct PRSem PRSem;
/*
* PR_OpenSemaphore --
*
* Create or open a named semaphore with the specified name.
* A handle to the semaphore is returned.
*
* If the named semaphore doesn't exist and the PR_SEM_CREATE
* flag is specified, the named semaphore is created. The
* created semaphore needs to be removed from the system with
* a PR_DeleteSemaphore call.
*
* If PR_SEM_CREATE is specified, the third argument is the
* access permission bits of the new semaphore (same
* interpretation as the mode argument to PR_Open) and the
* fourth argument is the initial value of the new semaphore.
* If PR_SEM_CREATE is not specified, the third and fourth
* arguments are ignored.
*/
#define PR_SEM_CREATE 0x1 /* create if not exist */
#define PR_SEM_EXCL 0x2 /* fail if already exists */
NSPR_API(PRSem *) PR_OpenSemaphore(
const char *name, PRIntn flags, PRIntn mode, PRUintn value);
/*
* PR_WaitSemaphore --
*
* If the value of the semaphore is > 0, decrement the value and return.
* If the value is 0, sleep until the value becomes > 0, then decrement
* the value and return.
*
* The "test and decrement" operation is performed atomically.
*/
NSPR_API(PRStatus) PR_WaitSemaphore(PRSem *sem);
/*
* PR_PostSemaphore --
*
* Increment the value of the named semaphore by 1.
*/
NSPR_API(PRStatus) PR_PostSemaphore(PRSem *sem);
/*
* PR_CloseSemaphore --
*
* Close a named semaphore handle.
*/
NSPR_API(PRStatus) PR_CloseSemaphore(PRSem *sem);
/*
* PR_DeleteSemaphore --
*
* Remove a named semaphore from the system.
*/
NSPR_API(PRStatus) PR_DeleteSemaphore(const char *name);
PR_END_EXTERN_C
#endif /* pripcsem_h___ */

View File

@@ -0,0 +1,242 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: pprio.h
**
** Description: Private definitions for I/O related structures
*/
#ifndef pprio_h___
#define pprio_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
/************************************************************************/
/************************************************************************/
#ifdef _WIN64
typedef __int64 PROsfd;
#else
typedef PRInt32 PROsfd;
#endif
/* Return the method tables for files, tcp sockets and udp sockets */
NSPR_API(const PRIOMethods*) PR_GetFileMethods(void);
NSPR_API(const PRIOMethods*) PR_GetTCPMethods(void);
NSPR_API(const PRIOMethods*) PR_GetUDPMethods(void);
NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void);
/*
** Convert a NSPR socket handle to a native socket handle.
**
** Using this function makes your code depend on the properties of the
** current NSPR implementation, which may change (although extremely
** unlikely because of NSPR's backward compatibility requirement). Avoid
** using it if you can.
**
** If you use this function, you need to understand what NSPR does to
** the native handle. For example, NSPR puts native socket handles in
** non-blocking mode or associates them with an I/O completion port (the
** WINNT build configuration only). Your use of the native handle should
** not interfere with NSPR's use of the native handle. If your code
** changes the configuration of the native handle, (e.g., changes it to
** blocking or closes it), NSPR will not work correctly.
*/
NSPR_API(PROsfd) PR_FileDesc2NativeHandle(PRFileDesc *);
NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PROsfd);
NSPR_API(PRFileDesc*) PR_AllocFileDesc(PROsfd osfd,
const PRIOMethods *methods);
NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd);
/*
** Import an existing OS file to NSPR.
*/
NSPR_API(PRFileDesc*) PR_ImportFile(PROsfd osfd);
NSPR_API(PRFileDesc*) PR_ImportPipe(PROsfd osfd);
NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PROsfd osfd);
NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PROsfd osfd);
/*
*************************************************************************
* FUNCTION: PR_CreateSocketPollFd
* DESCRIPTION:
* Create a PRFileDesc wrapper for a native socket handle, for use with
* PR_Poll only
* INPUTS:
* None
* OUTPUTS:
* None
* RETURN: PRFileDesc*
* Upon successful completion, PR_CreateSocketPollFd returns a pointer
* to the PRFileDesc created for the native socket handle
* Returns a NULL pointer if the create of a new PRFileDesc failed
*
**************************************************************************
*/
NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd);
/*
*************************************************************************
* FUNCTION: PR_DestroySocketPollFd
* DESCRIPTION:
* Destroy the PRFileDesc wrapper created by PR_CreateSocketPollFd
* INPUTS:
* None
* OUTPUTS:
* None
* RETURN: PRFileDesc*
* Upon successful completion, PR_DestroySocketPollFd returns
* PR_SUCCESS, else PR_FAILURE
*
**************************************************************************
*/
NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd);
/*
** Macros for PR_Socket
**
** Socket types: PR_SOCK_STREAM, PR_SOCK_DGRAM
*/
#ifdef WIN32
#define PR_SOCK_STREAM 1
#define PR_SOCK_DGRAM 2
#else /* WIN32 */
#define PR_SOCK_STREAM SOCK_STREAM
#define PR_SOCK_DGRAM SOCK_DGRAM
#endif /* WIN32 */
/*
** Create a new Socket; this function is obsolete.
*/
NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);
/* FUNCTION: PR_LockFile
** DESCRIPTION:
** Lock a file for exclusive access.
** RETURNS:
** PR_SUCCESS when the lock is held
** PR_FAILURE otherwise
*/
NSPR_API(PRStatus) PR_LockFile(PRFileDesc *fd);
/* FUNCTION: PR_TLockFile
** DESCRIPTION:
** Test and Lock a file for exclusive access. Do not block if the
** file cannot be locked immediately.
** RETURNS:
** PR_SUCCESS when the lock is held
** PR_FAILURE otherwise
*/
NSPR_API(PRStatus) PR_TLockFile(PRFileDesc *fd);
/* FUNCTION: PR_UnlockFile
** DESCRIPTION:
** Unlock a file which has been previously locked successfully by this
** process.
** RETURNS:
** PR_SUCCESS when the lock is released
** PR_FAILURE otherwise
*/
NSPR_API(PRStatus) PR_UnlockFile(PRFileDesc *fd);
/*
** Emulate acceptread by accept and recv.
*/
NSPR_API(PRInt32) PR_EmulateAcceptRead(PRFileDesc *sd, PRFileDesc **nd,
PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);
/*
** Emulate sendfile by reading from the file and writing to the socket.
** The file is memory-mapped if memory-mapped files are supported.
*/
NSPR_API(PRInt32) PR_EmulateSendFile(
PRFileDesc *networkSocket, PRSendFileData *sendData,
PRTransmitFileFlags flags, PRIntervalTime timeout);
#ifdef WIN32
/* FUNCTION: PR_NTFast_AcceptRead
** DESCRIPTION:
** NT has the notion of an "accept context", which is only needed in
** order to make certain calls. By default, a socket connected via
** AcceptEx can only do a limited number of things without updating
** the acceptcontext. The generic version of PR_AcceptRead always
** updates the accept context. This version does not.
**/
NSPR_API(PRInt32) PR_NTFast_AcceptRead(PRFileDesc *sd, PRFileDesc **nd,
PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t);
typedef void (*_PR_AcceptTimeoutCallback)(void *);
/* FUNCTION: PR_NTFast_AcceptRead_WithTimeoutCallback
** DESCRIPTION:
** The AcceptEx call combines the accept with the read function. However,
** our daemon threads need to be able to wakeup and reliably flush their
** log buffers if the Accept times out. However, with the current blocking
** interface to AcceptRead, there is no way for us to timeout the Accept;
** this is because when we timeout the Read, we can close the newly
** socket and continue; but when we timeout the accept itself, there is no
** new socket to timeout. So instead, this version of the function is
** provided. After the initial timeout period elapses on the accept()
** portion of the function, it will call the callback routine and then
** continue the accept. If the timeout occurs on the read, it will
** close the connection and return error.
*/
NSPR_API(PRInt32) PR_NTFast_AcceptRead_WithTimeoutCallback(
PRFileDesc *sd,
PRFileDesc **nd,
PRNetAddr **raddr,
void *buf,
PRInt32 amount,
PRIntervalTime t,
_PR_AcceptTimeoutCallback callback,
void *callback_arg);
/* FUNCTION: PR_NTFast_Accept
** DESCRIPTION:
** NT has the notion of an "accept context", which is only needed in
** order to make certain calls. By default, a socket connected via
** AcceptEx can only do a limited number of things without updating
** the acceptcontext. The generic version of PR_Accept always
** updates the accept context. This version does not.
**/
NSPR_API(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr,
PRIntervalTime timeout);
/* FUNCTION: PR_NTFast_Update
** DESCRIPTION:
** For sockets accepted with PR_NTFast_Accept or PR_NTFastAcceptRead,
** this function will update the accept context for those sockets,
** so that the socket can make general purpose socket calls.
** Without calling this, the only operations supported on the socket
** Are PR_Read, PR_Write, PR_Transmitfile, and PR_Close.
*/
NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock,
PRFileDesc *listenSock);
/* FUNCTION: PR_NT_CancelIo
** DESCRIPTION:
** Cancel IO operations on fd.
*/
NSPR_API(PRStatus) PR_NT_CancelIo(PRFileDesc *fd);
#endif /* WIN32 */
PR_END_EXTERN_C
#endif /* pprio_h___ */

View File

@@ -0,0 +1,331 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef pprthred_h___
#define pprthred_h___
/*
** API for PR private functions. These calls are to be used by internal
** developers only.
*/
#include "nspr.h"
#if defined(XP_OS2)
#define INCL_DOS
#define INCL_DOSERRORS
#define INCL_WIN
#include <os2.h>
#endif
PR_BEGIN_EXTERN_C
/*---------------------------------------------------------------------------
** THREAD PRIVATE FUNCTIONS
---------------------------------------------------------------------------*/
/*
** Associate a thread object with an existing native thread.
** "type" is the type of thread object to attach
** "priority" is the priority to assign to the thread
** "stack" defines the shape of the threads stack
**
** This can return NULL if some kind of error occurs, or if memory is
** tight. This call invokes "start(obj,arg)" and returns when the
** function returns. The thread object is automatically destroyed.
**
** This call is not normally needed unless you create your own native
** thread. PR_Init does this automatically for the primordial thread.
*/
NSPR_API(PRThread*) PR_AttachThread(PRThreadType type,
PRThreadPriority priority,
PRThreadStack *stack);
/*
** Detach the nspr thread from the currently executing native thread.
** The thread object will be destroyed and all related data attached
** to it. The exit procs will be invoked.
**
** This call is not normally needed unless you create your own native
** thread. PR_Exit will automatially detach the nspr thread object
** created by PR_Init for the primordial thread.
**
** This call returns after the nspr thread object is destroyed.
*/
NSPR_API(void) PR_DetachThread(void);
/*
** Get the id of the named thread. Each thread is assigned a unique id
** when it is created or attached.
*/
NSPR_API(PRUint32) PR_GetThreadID(PRThread *thread);
/*
** Set the procedure that is called when a thread is dumped. The procedure
** will be applied to the argument, arg, when called. Setting the procedure
** to NULL effectively removes it.
*/
typedef void (*PRThreadDumpProc)(PRFileDesc *fd, PRThread *t, void *arg);
NSPR_API(void) PR_SetThreadDumpProc(
PRThread* thread, PRThreadDumpProc dump, void *arg);
/*
** Get this thread's affinity mask. The affinity mask is a 32 bit quantity
** marking a bit for each processor this process is allowed to run on.
** The processor mask is returned in the mask argument.
** The least-significant-bit represents processor 0.
**
** Returns 0 on success, -1 on failure.
*/
NSPR_API(PRInt32) PR_GetThreadAffinityMask(PRThread *thread, PRUint32 *mask);
/*
** Set this thread's affinity mask.
**
** Returns 0 on success, -1 on failure.
*/
NSPR_API(PRInt32) PR_SetThreadAffinityMask(PRThread *thread, PRUint32 mask );
/*
** Set the default CPU Affinity mask.
**
*/
NSPR_API(PRInt32) PR_SetCPUAffinityMask(PRUint32 mask);
/*
** Show status of all threads to standard error output.
*/
NSPR_API(void) PR_ShowStatus(void);
/*
** Set thread recycle mode to on (1) or off (0)
*/
NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
/*---------------------------------------------------------------------------
** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS
---------------------------------------------------------------------------*/
/*
** Only Garbage collectible threads participate in resume all, suspend all and
** enumeration operations. They are also different during creation when
** platform specific action may be needed (For example, all Solaris GC able
** threads are bound threads).
*/
/*
** Same as PR_CreateThread except that the thread is marked as garbage
** collectible.
*/
NSPR_API(PRThread*) PR_CreateThreadGCAble(PRThreadType type,
void (*start)(void *arg),
void *arg,
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize);
/*
** Same as PR_AttachThread except that the thread being attached is marked as
** garbage collectible.
*/
NSPR_API(PRThread*) PR_AttachThreadGCAble(PRThreadType type,
PRThreadPriority priority,
PRThreadStack *stack);
/*
** Mark the thread as garbage collectible.
*/
NSPR_API(void) PR_SetThreadGCAble(void);
/*
** Unmark the thread as garbage collectible.
*/
NSPR_API(void) PR_ClearThreadGCAble(void);
/*
** This routine prevents all other GC able threads from running. This call is needed by
** the garbage collector.
*/
NSPR_API(void) PR_SuspendAll(void);
/*
** This routine unblocks all other GC able threads that were suspended from running by
** PR_SuspendAll(). This call is needed by the garbage collector.
*/
NSPR_API(void) PR_ResumeAll(void);
/*
** Return the thread stack pointer of the given thread.
** Needed by the garbage collector.
*/
NSPR_API(void *) PR_GetSP(PRThread *thread);
/*
** Save the registers that the GC would find interesting into the thread
** "t". isCurrent will be non-zero if the thread state that is being
** saved is the currently executing thread. Return the address of the
** first register to be scanned as well as the number of registers to
** scan in "np".
**
** If "isCurrent" is non-zero then it is allowed for the thread context
** area to be used as scratch storage to hold just the registers
** necessary for scanning.
**
** This function simply calls the internal function _MD_HomeGCRegisters().
*/
NSPR_API(PRWord *) PR_GetGCRegisters(PRThread *t, int isCurrent, int *np);
/*
** (Get|Set)ExecutionEnvironent
**
** Used by Java to associate it's execution environment so garbage collector
** can find it. If return is NULL, then it's probably not a collectable thread.
**
** There's no locking required around these calls.
*/
NSPR_API(void*) GetExecutionEnvironment(PRThread *thread);
NSPR_API(void) SetExecutionEnvironment(PRThread* thread, void *environment);
/*
** Enumeration function that applies "func(thread,i,arg)" to each active
** thread in the process. The enumerator returns PR_SUCCESS if the enumeration
** should continue, any other value is considered failure, and enumeration
** stops, returning the failure value from PR_EnumerateThreads.
** Needed by the garbage collector.
*/
typedef PRStatus (PR_CALLBACK *PREnumerator)(PRThread *t, int i, void *arg);
NSPR_API(PRStatus) PR_EnumerateThreads(PREnumerator func, void *arg);
/*
** Signature of a thread stack scanning function. It is applied to every
** contiguous group of potential pointers within a thread. Count denotes the
** number of pointers.
*/
typedef PRStatus
(PR_CALLBACK *PRScanStackFun)(PRThread* t,
void** baseAddr, PRUword count, void* closure);
/*
** Applies scanFun to all contiguous groups of potential pointers
** within a thread. This includes the stack, registers, and thread-local
** data. If scanFun returns a status value other than PR_SUCCESS the scan
** is aborted, and the status value is returned.
*/
NSPR_API(PRStatus)
PR_ThreadScanStackPointers(PRThread* t,
PRScanStackFun scanFun, void* scanClosure);
/*
** Calls PR_ThreadScanStackPointers for every thread.
*/
NSPR_API(PRStatus)
PR_ScanStackPointers(PRScanStackFun scanFun, void* scanClosure);
/*
** Returns a conservative estimate on the amount of stack space left
** on a thread in bytes, sufficient for making decisions about whether
** to continue recursing or not.
*/
NSPR_API(PRUword)
PR_GetStackSpaceLeft(PRThread* t);
/*---------------------------------------------------------------------------
** THREAD CPU PRIVATE FUNCTIONS
---------------------------------------------------------------------------*/
/*
** Get a pointer to the primordial CPU.
*/
NSPR_API(struct _PRCPU *) _PR_GetPrimordialCPU(void);
/*---------------------------------------------------------------------------
** THREAD SYNCHRONIZATION PRIVATE FUNCTIONS
---------------------------------------------------------------------------*/
/*
** Create a new named monitor (named for debugging purposes).
** Monitors are re-entrant locks with a built-in condition variable.
**
** This may fail if memory is tight or if some operating system resource
** is low.
*/
NSPR_API(PRMonitor*) PR_NewNamedMonitor(const char* name);
/*
** Test and then lock the lock if it's not already locked by some other
** thread. Return PR_FALSE if some other thread owned the lock at the
** time of the call.
*/
NSPR_API(PRBool) PR_TestAndLock(PRLock *lock);
/*
** Test and then enter the mutex associated with the monitor if it's not
** already entered by some other thread. Return PR_FALSE if some other
** thread owned the mutex at the time of the call.
*/
NSPR_API(PRBool) PR_TestAndEnterMonitor(PRMonitor *mon);
/*
** Return the number of times that the current thread has entered the
** mutex. Returns zero if the current thread has not entered the mutex.
*/
NSPR_API(PRIntn) PR_GetMonitorEntryCount(PRMonitor *mon);
/*
** Just like PR_CEnterMonitor except that if the monitor is owned by
** another thread NULL is returned.
*/
NSPR_API(PRMonitor*) PR_CTestAndEnterMonitor(void *address);
/*---------------------------------------------------------------------------
** PLATFORM-SPECIFIC INITIALIZATION FUNCTIONS
---------------------------------------------------------------------------*/
#if defined(IRIX)
/*
** Irix specific initialization funtion to be called before PR_Init
** is called by the application. Sets the CONF_INITUSERS and CONF_INITSIZE
** attributes of the shared arena set up by nspr.
**
** The environment variables _NSPR_IRIX_INITUSERS and _NSPR_IRIX_INITSIZE
** can also be used to set these arena attributes. If _NSPR_IRIX_INITUSERS
** is set, but not _NSPR_IRIX_INITSIZE, the value of the CONF_INITSIZE
** attribute of the nspr arena is scaled as a function of the
** _NSPR_IRIX_INITUSERS value.
**
** If the _PR_Irix_Set_Arena_Params() is called in addition to setting the
** environment variables, the values of the environment variables are used.
**
*/
NSPR_API(void) _PR_Irix_Set_Arena_Params(PRInt32 initusers, PRInt32 initsize);
#endif /* IRIX */
#if defined(XP_OS2)
/*
** These functions need to be called at the start and end of a thread.
** An EXCEPTIONREGISTRATIONRECORD must be declared on the stack and its
** address passed to the two functions.
*/
NSPR_API(void) PR_OS2_SetFloatExcpHandler(EXCEPTIONREGISTRATIONRECORD* e);
NSPR_API(void) PR_OS2_UnsetFloatExcpHandler(EXCEPTIONREGISTRATIONRECORD* e);
#endif /* XP_OS2 */
/* I think PR_GetMonitorEntryCount is useless. All you really want is this... */
#define PR_InMonitor(m) (PR_GetMonitorEntryCount(m) > 0)
/*---------------------------------------------------------------------------
** Special X-Lock hack for client
---------------------------------------------------------------------------*/
#ifdef XP_UNIX
extern void PR_XLock(void);
extern void PR_XUnlock(void);
extern PRBool PR_XIsLocked(void);
#endif /* XP_UNIX */
PR_END_EXTERN_C
#endif /* pprthred_h___ */

View File

@@ -0,0 +1,16 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prpriv_h___
#define prpriv_h___
/*
* NSPR 2.0 Private API
*/
#include "private/pprio.h"
#include "private/pprthred.h"
#endif /* prpriv_h___ */

View File

@@ -0,0 +1,230 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prlink_h___
#define prlink_h___
/*
** API to static and dynamic linking.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
typedef struct PRLibrary PRLibrary;
typedef struct PRStaticLinkTable {
const char *name;
void (*fp)(void);
} PRStaticLinkTable;
/*
** Change the default library path to the given string. The string is
** copied. This call will fail if it runs out of memory.
**
** The string provided as 'path' is copied. The caller can do whatever is
** convenient with the argument when the function is complete.
*/
NSPR_API(PRStatus) PR_SetLibraryPath(const char *path);
/*
** Return a character string which contains the path used to search for
** dynamically loadable libraries.
**
** The returned value is basically a copy of a PR_SetLibraryPath().
** The storage is allocated by the runtime and becomes the responsibilty
** of the caller.
*/
NSPR_API(char*) PR_GetLibraryPath(void);
/*
** Given a directory name "dir" and a library name "lib" construct a full
** path name that will refer to the actual dynamically loaded
** library. This does not test for existance of said file, it just
** constructs the full filename. The name constructed is system dependent
** and prepared for PR_LoadLibrary. The result must be free'd when the
** caller is done with it.
**
** The storage for the result is allocated by the runtime and becomes the
** responsibility of the caller.
*/
NSPR_API(char*) PR_GetLibraryName(const char *dir, const char *lib);
/*
**
** Free the memory allocated, for the caller, by PR_GetLibraryName
*/
NSPR_API(void) PR_FreeLibraryName(char *mem);
/*
** Given a library "name" try to load the library. The argument "name"
** is a machine-dependent name for the library, such as the full pathname
** returned by PR_GetLibraryName. If the library is already loaded,
** this function will avoid loading the library twice.
**
** If the library is loaded successfully, then a pointer to the PRLibrary
** structure representing the library is returned. Otherwise, NULL is
** returned.
**
** This increments the reference count of the library.
*/
NSPR_API(PRLibrary*) PR_LoadLibrary(const char *name);
/*
** Each operating system has its preferred way of specifying
** a file in the file system. Most operating systems use
** a pathname. Mac OS Classic, on the other hand, uses the FSSpec
** structure to specify a file. PRLibSpec allows NSPR clients
** to use the type of file specification that is most efficient
** for a particular platform.
**
** On some operating systems such as Mac OS Classic, a shared library
** may contain code fragments that can be individually loaded.
** PRLibSpec also allows NSPR clients to identify a code fragment
** in a library, if code fragments are supported by the OS.
** A code fragment can be specified by name or by an integer index.
**
** Right now PRLibSpec supports four types of library specification:
** a pathname in the native character encoding, a Mac code fragment
** by name, a Mac code fragment by index, and a UTF-16 pathname.
*/
typedef enum PRLibSpecType {
PR_LibSpec_Pathname,
PR_LibSpec_MacNamedFragment, /* obsolete (for Mac OS Classic) */
PR_LibSpec_MacIndexedFragment, /* obsolete (for Mac OS Classic) */
PR_LibSpec_PathnameU /* supported only on Win32 */
} PRLibSpecType;
struct FSSpec; /* Mac OS Classic FSSpec */
typedef struct PRLibSpec {
PRLibSpecType type;
union {
/* if type is PR_LibSpec_Pathname */
const char *pathname;
/* if type is PR_LibSpec_MacNamedFragment */
struct {
const struct FSSpec *fsspec;
const char *name;
} mac_named_fragment; /* obsolete (for Mac OS Classic) */
/* if type is PR_LibSpec_MacIndexedFragment */
struct {
const struct FSSpec *fsspec;
PRUint32 index;
} mac_indexed_fragment; /* obsolete (for Mac OS Classic) */
/* if type is PR_LibSpec_PathnameU */
const PRUnichar *pathname_u; /* supported only on Win32 */
} value;
} PRLibSpec;
/*
** The following bit flags may be or'd together and passed
** as the 'flags' argument to PR_LoadLibraryWithFlags.
** Flags not supported by the underlying OS are ignored.
*/
#define PR_LD_LAZY 0x1 /* equivalent to RTLD_LAZY on Unix */
#define PR_LD_NOW 0x2 /* equivalent to RTLD_NOW on Unix */
#define PR_LD_GLOBAL 0x4 /* equivalent to RTLD_GLOBAL on Unix */
#define PR_LD_LOCAL 0x8 /* equivalent to RTLD_LOCAL on Unix */
/* The following is equivalent to LOAD_WITH_ALTERED_SEARCH_PATH on Windows */
#define PR_LD_ALT_SEARCH_PATH 0x10
/* 0x8000 reserved for NSPR internal use */
/*
** Load the specified library, in the manner specified by 'flags'.
*/
NSPR_API(PRLibrary *)
PR_LoadLibraryWithFlags(
PRLibSpec libSpec, /* the shared library */
PRIntn flags /* flags that affect the loading */
);
/*
** Unload a previously loaded library. If the library was a static
** library then the static link table will no longer be referenced. The
** associated PRLibrary object is freed.
**
** PR_FAILURE is returned if the library cannot be unloaded.
**
** This function decrements the reference count of the library.
*/
NSPR_API(PRStatus) PR_UnloadLibrary(PRLibrary *lib);
/*
** Given the name of a procedure, return the address of the function that
** implements the procedure, or NULL if no such function can be
** found. This does not find symbols in the main program (the ".exe");
** use PR_LoadStaticLibrary to register symbols in the main program.
**
** This function does not modify the reference count of the library.
*/
NSPR_API(void*) PR_FindSymbol(PRLibrary *lib, const char *name);
/*
** Similar to PR_FindSymbol, except that the return value is a pointer to
** a function, and not a pointer to void. Casting between a data pointer
** and a function pointer is not portable according to the C standard.
** Any function pointer can be cast to any other function pointer.
**
** This function does not modify the reference count of the library.
*/
typedef void (*PRFuncPtr)(void);
NSPR_API(PRFuncPtr) PR_FindFunctionSymbol(PRLibrary *lib, const char *name);
/*
** Finds a symbol in one of the currently loaded libraries. Given the
** name of a procedure, return the address of the function that
** implements the procedure, and return the library that contains that
** symbol, or NULL if no such function can be found. This does not find
** symbols in the main program (the ".exe"); use PR_AddStaticLibrary to
** register symbols in the main program.
**
** This increments the reference count of the library.
*/
NSPR_API(void*) PR_FindSymbolAndLibrary(const char *name,
PRLibrary* *lib);
/*
** Similar to PR_FindSymbolAndLibrary, except that the return value is
** a pointer to a function, and not a pointer to void. Casting between a
** data pointer and a function pointer is not portable according to the C
** standard. Any function pointer can be cast to any other function pointer.
**
** This increments the reference count of the library.
*/
NSPR_API(PRFuncPtr) PR_FindFunctionSymbolAndLibrary(const char *name,
PRLibrary* *lib);
/*
** Register a static link table with the runtime under the name
** "name". The symbols present in the static link table will be made
** available to PR_FindSymbol. If "name" is null then the symbols will be
** made available to the library which represents the executable. The
** tables are not copied.
**
** Returns the library object if successful, null otherwise.
**
** This increments the reference count of the library.
*/
NSPR_API(PRLibrary*) PR_LoadStaticLibrary(
const char *name, const PRStaticLinkTable *table);
/*
** Return the pathname of the file that the library "name" was loaded
** from. "addr" is the address of a function defined in the library.
**
** The caller is responsible for freeing the result with PR_Free.
*/
NSPR_API(char *) PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr);
PR_END_EXTERN_C
#endif /* prlink_h___ */

View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prlock.h
** Description: API to basic locking functions of NSPR.
**
**
** NSPR provides basic locking mechanisms for thread synchronization. Locks
** are lightweight resource contention controls that prevent multiple threads
** from accessing something (code/data) simultaneously.
**/
#ifndef prlock_h___
#define prlock_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
/*
* PRLock --
*
* NSPR represents the lock as an opaque entity to the client of the
* API. All routines operate on a pointer to this opaque entity.
*/
typedef struct PRLock PRLock;
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/***********************************************************************
** FUNCTION: PR_NewLock
** DESCRIPTION:
** Returns a pointer to a newly created opaque lock object.
** INPUTS: void
** OUTPUTS: void
** RETURN: PRLock*
** If the lock can not be created because of resource constraints, NULL
** is returned.
**
***********************************************************************/
NSPR_API(PRLock*) PR_NewLock(void);
/***********************************************************************
** FUNCTION: PR_DestroyLock
** DESCRIPTION:
** Destroys a given opaque lock object.
** INPUTS: PRLock *lock
** Lock to be freed.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_DestroyLock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Lock
** DESCRIPTION:
** Lock a lock.
** INPUTS: PRLock *lock
** Lock to locked.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_Lock(PRLock *lock);
/***********************************************************************
** FUNCTION: PR_Unlock
** DESCRIPTION:
** Unlock a lock. Unlocking an unlocked lock has undefined results.
** INPUTS: PRLock *lock
** Lock to unlocked.
** OUTPUTS: void
** RETURN: PR_STATUS
** Returns PR_FAILURE if the caller does not own the lock.
***********************************************************************/
NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
/***********************************************************************
** MACRO: PR_ASSERT_CURRENT_THREAD_OWNS_LOCK
** DESCRIPTION:
** If the current thread owns |lock|, this assertion is guaranteed to
** succeed. Otherwise, the behavior of this function is undefined.
** INPUTS: PRLock *lock
** Lock to assert ownership of.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
#define PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(/* PrLock* */ lock) \
PR_AssertCurrentThreadOwnsLock(lock)
#else
#define PR_ASSERT_CURRENT_THREAD_OWNS_LOCK(/* PrLock* */ lock)
#endif
/* Don't call this function directly. */
NSPR_API(void) PR_AssertCurrentThreadOwnsLock(PRLock *lock);
PR_END_EXTERN_C
#endif /* prlock_h___ */

View File

@@ -0,0 +1,222 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prlog_h___
#define prlog_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** prlog.h -- Declare interfaces to NSPR's Logging service
**
** NSPR provides a logging service that is used by NSPR itself and is
** available to client programs.
**
** To use the service from a client program, you should create a
** PRLogModuleInfo structure by calling PR_NewLogModule(). After
** creating the LogModule, you can write to the log using the PR_LOG()
** macro.
**
** Initialization of the log service is handled by NSPR initialization.
**
** At execution time, you must enable the log service. To enable the
** log service, set the environment variable: NSPR_LOG_MODULES
** variable.
**
** NSPR_LOG_MODULES variable has the form:
**
** <moduleName>:<value>[, <moduleName>:<value>]*
**
** Where:
** <moduleName> is the name passed to PR_NewLogModule().
** <value> is a numeric constant, e.g. 5. This value is the maximum
** value of a log event, enumerated by PRLogModuleLevel, that you want
** written to the log.
**
** For example: to record all events of greater value than or equal to
** PR_LOG_ERROR for a LogModule names "gizmo", say:
**
** set NSPR_LOG_MODULES=gizmo:2
**
** Note that you must specify the numeric value of PR_LOG_ERROR.
**
** Special LogModule names are provided for controlling NSPR's log
** service at execution time. These controls should be set in the
** NSPR_LOG_MODULES environment variable at execution time to affect
** NSPR's log service for your application.
**
** The special LogModule "all" enables all LogModules. To enable all
** LogModule calls to PR_LOG(), say:
**
** set NSPR_LOG_MODULES=all:5
**
** The special LogModule name "sync" tells the NSPR log service to do
** unbuffered logging.
**
** The special LogModule name "bufsize:<size>" tells NSPR to set the
** log buffer to <size>.
**
** The environment variable NSPR_LOG_FILE specifies the log file to use
** unless the default of "stderr" is acceptable. For MS Windows
** systems, NSPR_LOG_FILE can be set to a special value: "WinDebug"
** (case sensitive). This value causes PR_LOG() output to be written
** using the Windows API OutputDebugString(). OutputDebugString()
** writes to the debugger window; some people find this helpful.
**
**
** To put log messages in your programs, use the PR_LOG macro:
**
** PR_LOG(<module>, <level>, (<printfString>, <args>*));
**
** Where <module> is the address of a PRLogModuleInfo structure, and
** <level> is one of the levels defined by the enumeration:
** PRLogModuleLevel. <args> is a printf() style of argument list. That
** is: (fmtstring, ...).
**
** Example:
**
** main() {
** PRIntn one = 1;
** PRLogModuleInfo * myLm = PR_NewLogModule("gizmo");
** PR_LOG( myLm, PR_LOG_ALWAYS, ("Log this! %d\n", one));
** return;
** }
**
** Note the use of printf() style arguments as the third agrument(s) to
** PR_LOG().
**
** After compiling and linking you application, set the environment:
**
** set NSPR_LOG_MODULES=gizmo:5
** set NSPR_LOG_FILE=logfile.txt
**
** When you execute your application, the string "Log this! 1" will be
** written to the file "logfile.txt".
**
** Note to NSPR engineers: a number of PRLogModuleInfo structures are
** defined and initialized in prinit.c. See this module for ideas on
** what to log where.
**
*/
typedef enum PRLogModuleLevel {
PR_LOG_NONE = 0, /* nothing */
PR_LOG_ALWAYS = 1, /* always printed */
PR_LOG_ERROR = 2, /* error messages */
PR_LOG_WARNING = 3, /* warning messages */
PR_LOG_DEBUG = 4, /* debug messages */
PR_LOG_NOTICE = PR_LOG_DEBUG, /* notice messages */
PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */
PR_LOG_MIN = PR_LOG_DEBUG, /* minimal debugging messages */
PR_LOG_MAX = PR_LOG_DEBUG /* maximal debugging messages */
} PRLogModuleLevel;
/*
** One of these structures is created for each module that uses logging.
** "name" is the name of the module
** "level" is the debugging level selected for that module
*/
typedef struct PRLogModuleInfo {
const char *name;
PRLogModuleLevel level;
struct PRLogModuleInfo *next;
} PRLogModuleInfo;
/*
** Create a new log module.
*/
NSPR_API(PRLogModuleInfo*) PR_NewLogModule(const char *name);
/*
** Set the file to use for logging. Returns PR_FALSE if the file cannot
** be created
*/
NSPR_API(PRBool) PR_SetLogFile(const char *name);
/*
** Set the size of the logging buffer. If "buffer_size" is zero then the
** logging becomes "synchronous" (or unbuffered).
*/
NSPR_API(void) PR_SetLogBuffering(PRIntn buffer_size);
/*
** Print a string to the log. "fmt" is a PR_snprintf format type. All
** messages printed to the log are preceeded by the name of the thread
** and a time stamp. Also, the routine provides a missing newline if one
** is not provided.
*/
NSPR_API(void) PR_LogPrint(const char *fmt, ...);
/*
** Flush the log to its file.
*/
NSPR_API(void) PR_LogFlush(void);
NSPR_API(void) PR_Assert(const char *s, const char *file, PRIntn ln)
PR_PRETEND_NORETURN;
#if defined(DEBUG) || defined(FORCE_PR_LOG)
#define PR_LOGGING 1
#define PR_LOG_TEST(_module,_level) \
((_module)->level >= (_level))
/*
** Log something.
** "module" is the address of a PRLogModuleInfo structure
** "level" is the desired logging level
** "args" is a variable length list of arguments to print, in the following
** format: ("printf style format string", ...)
*/
#define PR_LOG(_module,_level,_args) \
PR_BEGIN_MACRO \
if (PR_LOG_TEST(_module,_level)) { \
PR_LogPrint _args; \
} \
PR_END_MACRO
#else /* defined(DEBUG) || defined(FORCE_PR_LOG) */
#undef PR_LOGGING
#define PR_LOG_TEST(module,level) 0
#define PR_LOG(module,level,args)
#endif /* defined(DEBUG) || defined(FORCE_PR_LOG) */
#ifndef NO_NSPR_10_SUPPORT
#ifdef PR_LOGGING
#define PR_LOG_BEGIN PR_LOG
#define PR_LOG_END PR_LOG
#define PR_LOG_DEFINE PR_NewLogModule
#else
#define PR_LOG_BEGIN(module,level,args)
#define PR_LOG_END(module,level,args)
#define PR_LOG_DEFINE(_name) NULL
#endif /* PR_LOGGING */
#endif /* NO_NSPR_10_SUPPORT */
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
#define PR_ASSERT(_expr) \
((_expr)?((void)0):PR_Assert(# _expr,__FILE__,__LINE__))
#define PR_NOT_REACHED(_reasonStr) \
PR_Assert(_reasonStr,__FILE__,__LINE__)
#else
#define PR_ASSERT(expr) ((void) 0)
#define PR_NOT_REACHED(reasonStr)
#endif /* defined(DEBUG) || defined(FORCE_PR_ASSERT) */
PR_END_EXTERN_C
#endif /* prlog_h___ */

View File

@@ -0,0 +1,403 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prlong.h
** Description: Portable access to 64 bit numerics
**
** Long-long (64-bit signed integer type) support. Some C compilers
** don't support 64 bit integers yet, so we use these macros to
** support both machines that do and don't.
**/
#ifndef prlong_h___
#define prlong_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/***********************************************************************
** DEFINES: LL_MaxInt
** LL_MinInt
** LL_Zero
** LL_MaxUint
** DESCRIPTION:
** Various interesting constants and static variable
** initializer
***********************************************************************/
NSPR_API(PRInt64) LL_MaxInt(void);
NSPR_API(PRInt64) LL_MinInt(void);
NSPR_API(PRInt64) LL_Zero(void);
NSPR_API(PRUint64) LL_MaxUint(void);
#if defined(HAVE_LONG_LONG)
/* Keep this in sync with prtypes.h. */
#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)
#define LL_MAXINT 9223372036854775807L
#define LL_MININT (-LL_MAXINT - 1L)
#define LL_ZERO 0L
#define LL_MAXUINT 18446744073709551615UL
#define LL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
#elif defined(WIN32) && !defined(__GNUC__)
#define LL_MAXINT 9223372036854775807i64
#define LL_MININT (-LL_MAXINT - 1i64)
#define LL_ZERO 0i64
#define LL_MAXUINT 18446744073709551615ui64
#define LL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64)
#else
#define LL_MAXINT 9223372036854775807LL
#define LL_MININT (-LL_MAXINT - 1LL)
#define LL_ZERO 0LL
#define LL_MAXUINT 18446744073709551615ULL
#define LL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL)
#endif
/***********************************************************************
** MACROS: LL_*
** DESCRIPTION:
** The following macros define portable access to the 64 bit
** math facilities.
**
***********************************************************************/
/***********************************************************************
** MACROS: LL_<relational operators>
**
** LL_IS_ZERO Test for zero
** LL_EQ Test for equality
** LL_NE Test for inequality
** LL_GE_ZERO Test for zero or positive
** LL_CMP Compare two values
***********************************************************************/
#define LL_IS_ZERO(a) ((a) == 0)
#define LL_EQ(a, b) ((a) == (b))
#define LL_NE(a, b) ((a) != (b))
#define LL_GE_ZERO(a) ((a) >= 0)
#define LL_CMP(a, op, b) ((PRInt64)(a) op (PRInt64)(b))
#define LL_UCMP(a, op, b) ((PRUint64)(a) op (PRUint64)(b))
/***********************************************************************
** MACROS: LL_<logical operators>
**
** LL_AND Logical and
** LL_OR Logical or
** LL_XOR Logical exclusion
** LL_OR2 A disgusting deviation
** LL_NOT Negation (one's complement)
***********************************************************************/
#define LL_AND(r, a, b) ((r) = (a) & (b))
#define LL_OR(r, a, b) ((r) = (a) | (b))
#define LL_XOR(r, a, b) ((r) = (a) ^ (b))
#define LL_OR2(r, a) ((r) = (r) | (a))
#define LL_NOT(r, a) ((r) = ~(a))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_NEG Negation (two's complement)
** LL_ADD Summation (two's complement)
** LL_SUB Difference (two's complement)
***********************************************************************/
#define LL_NEG(r, a) ((r) = -(a))
#define LL_ADD(r, a, b) ((r) = (a) + (b))
#define LL_SUB(r, a, b) ((r) = (a) - (b))
/***********************************************************************
** MACROS: LL_<mathematical operators>
**
** LL_MUL Product (two's complement)
** LL_DIV Quotient (two's complement)
** LL_MOD Modulus (two's complement)
***********************************************************************/
#define LL_MUL(r, a, b) ((r) = (a) * (b))
#define LL_DIV(r, a, b) ((r) = (a) / (b))
#define LL_MOD(r, a, b) ((r) = (a) % (b))
/***********************************************************************
** MACROS: LL_<shifting operators>
**
** LL_SHL Shift left [0..64] bits
** LL_SHR Shift right [0..64] bits with sign extension
** LL_USHR Unsigned shift right [0..64] bits
** LL_ISHL Signed shift left [0..64] bits
***********************************************************************/
#define LL_SHL(r, a, b) ((r) = (PRInt64)(a) << (b))
#define LL_SHR(r, a, b) ((r) = (PRInt64)(a) >> (b))
#define LL_USHR(r, a, b) ((r) = (PRUint64)(a) >> (b))
#define LL_ISHL(r, a, b) ((r) = (PRInt64)(a) << (b))
/***********************************************************************
** MACROS: LL_<conversion operators>
**
** LL_L2I Convert to signed 32 bit
** LL_L2UI Convert to unsigned 32 bit
** LL_L2F Convert to floating point
** LL_L2D Convert to floating point
** LL_I2L Convert signed to 64 bit
** LL_UI2L Convert unsigned to 64 bit
** LL_F2L Convert float to 64 bit
** LL_D2L Convert float to 64 bit
***********************************************************************/
#define LL_L2I(i, l) ((i) = (PRInt32)(l))
#define LL_L2UI(ui, l) ((ui) = (PRUint32)(l))
#define LL_L2F(f, l) ((f) = (PRFloat64)(l))
#define LL_L2D(d, l) ((d) = (PRFloat64)(l))
#define LL_I2L(l, i) ((l) = (PRInt64)(i))
#define LL_UI2L(l, ui) ((l) = (PRInt64)(ui))
#define LL_F2L(l, f) ((l) = (PRInt64)(f))
#define LL_D2L(l, d) ((l) = (PRInt64)(d))
/***********************************************************************
** MACROS: LL_UDIVMOD
** DESCRIPTION:
** Produce both a quotient and a remainder given an unsigned
** INPUTS: PRUint64 a: The dividend of the operation
** PRUint64 b: The quotient of the operation
** OUTPUTS: PRUint64 *qp: pointer to quotient
** PRUint64 *rp: pointer to remainder
***********************************************************************/
#define LL_UDIVMOD(qp, rp, a, b) \
(*(qp) = ((PRUint64)(a) / (b)), \
*(rp) = ((PRUint64)(a) % (b)))
#else /* !HAVE_LONG_LONG */
#define LL_MAXINT LL_MaxInt()
#define LL_MININT LL_MinInt()
#define LL_ZERO LL_Zero()
#define LL_MAXUINT LL_MaxUint()
#ifdef IS_LITTLE_ENDIAN
#define LL_INIT(hi, lo) {PR_UINT32(lo), PR_UINT32(hi)}
#else
#define LL_INIT(hi, lo) {PR_UINT32(hi), PR_UINT32(lo)}
#endif
#define LL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))
#define LL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))
#define LL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))
#define LL_GE_ZERO(a) (((a).hi >> 31) == 0)
#define LL_CMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((PRInt32)(a).hi op (PRInt32)(b).hi))
#define LL_UCMP(a, op, b) (((a).hi == (b).hi) ? ((a).lo op (b).lo) : \
((a).hi op (b).hi))
#define LL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \
(r).hi = (a).hi & (b).hi)
#define LL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \
(r).hi = (a).hi | (b).hi)
#define LL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \
(r).hi = (a).hi ^ (b).hi)
#define LL_OR2(r, a) ((r).lo = (r).lo | (a).lo, \
(r).hi = (r).hi | (a).hi)
#define LL_NOT(r, a) ((r).lo = ~(a).lo, \
(r).hi = ~(a).hi)
#define LL_NEG(r, a) ((r).lo = -(PRInt32)(a).lo, \
(r).hi = -(PRInt32)(a).hi - ((r).lo != 0))
#define LL_ADD(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo + _b.lo; \
(r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \
}
#define LL_SUB(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
(r).lo = _a.lo - _b.lo; \
(r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \
}
#define LL_MUL(r, a, b) { \
PRInt64 _a, _b; \
_a = a; _b = b; \
LL_MUL32(r, _a.lo, _b.lo); \
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
}
#define _lo16(a) ((a) & PR_BITMASK(16))
#define _hi16(a) ((a) >> 16)
#define LL_MUL32(r, a, b) { \
PRUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
_a1 = _hi16(a), _a0 = _lo16(a); \
_b1 = _hi16(b), _b0 = _lo16(b); \
_y0 = _a0 * _b0; \
_y1 = _a0 * _b1; \
_y2 = _a1 * _b0; \
_y3 = _a1 * _b1; \
_y1 += _hi16(_y0); /* can't carry */ \
_y1 += _y2; /* might carry */ \
if (_y1 < _y2) \
_y3 += (PRUint32)(PR_BIT(16)); /* propagate */ \
(r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \
(r).hi = _y3 + _hi16(_y1); \
}
#define LL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)
NSPR_API(void) ll_udivmod(PRUint64 *qp, PRUint64 *rp, PRUint64 a, PRUint64 b);
#define LL_DIV(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
_negative ^= 1; \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(&(r), 0, _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_MOD(r, a, b) { \
PRInt64 _a, _b; \
PRUint32 _negative = (PRInt32)(a).hi < 0; \
if (_negative) { \
LL_NEG(_a, a); \
} else { \
_a = a; \
} \
if ((PRInt32)(b).hi < 0) { \
LL_NEG(_b, b); \
} else { \
_b = b; \
} \
LL_UDIVMOD(0, &(r), _a, _b); \
if (_negative) \
LL_NEG(r, r); \
}
#define LL_SHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = _a.lo << ((b) & 31); \
(r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = _a.lo << ((b) & 31); \
} \
} else { \
(r) = (a); \
} \
}
/* a is an PRInt32, b is PRInt32, r is PRInt64 */
#define LL_ISHL(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a.lo = (a); \
_a.hi = 0; \
if ((b) < 32) { \
(r).lo = (a) << ((b) & 31); \
(r).hi = ((a) >> (32 - (b))); \
} else { \
(r).lo = 0; \
(r).hi = (a) << ((b) & 31); \
} \
} else { \
(r).lo = (a); \
(r).hi = 0; \
} \
}
#define LL_SHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = (PRInt32)_a.hi >> ((b) & 31); \
} else { \
(r).lo = (PRInt32)_a.hi >> ((b) & 31); \
(r).hi = (PRInt32)_a.hi >> 31; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_USHR(r, a, b) { \
if (b) { \
PRInt64 _a; \
_a = a; \
if ((b) < 32) { \
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
(r).hi = _a.hi >> ((b) & 31); \
} else { \
(r).lo = _a.hi >> ((b) & 31); \
(r).hi = 0; \
} \
} else { \
(r) = (a); \
} \
}
#define LL_L2I(i, l) ((i) = (l).lo)
#define LL_L2UI(ui, l) ((ui) = (l).lo)
#define LL_L2F(f, l) { double _d; LL_L2D(_d, l); (f) = (PRFloat64)_d; }
#define LL_L2D(d, l) { \
int _negative; \
PRInt64 _absval; \
\
_negative = (l).hi >> 31; \
if (_negative) { \
LL_NEG(_absval, l); \
} else { \
_absval = l; \
} \
(d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \
if (_negative) \
(d) = -(d); \
}
#define LL_I2L(l, i) { PRInt32 _i = ((PRInt32)(i)) >> 31; (l).lo = (i); (l).hi = _i; }
#define LL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0)
#define LL_F2L(l, f) { double _d = (double)f; LL_D2L(l, _d); }
#define LL_D2L(l, d) { \
int _negative; \
double _absval, _d_hi; \
PRInt64 _lo_d; \
\
_negative = ((d) < 0); \
_absval = _negative ? -(d) : (d); \
\
(l).hi = _absval / 4.294967296e9; \
(l).lo = 0; \
LL_L2D(_d_hi, l); \
_absval -= _d_hi; \
_lo_d.hi = 0; \
if (_absval < 0) { \
_lo_d.lo = -_absval; \
LL_SUB(l, l, _lo_d); \
} else { \
_lo_d.lo = _absval; \
LL_ADD(l, l, _lo_d); \
} \
\
if (_negative) \
LL_NEG(l, l); \
}
#endif /* !HAVE_LONG_LONG */
PR_END_EXTERN_C
#endif /* prlong_h___ */

View File

@@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prmem.h
** Description: API to NSPR memory management functions
**
*/
#ifndef prmem_h___
#define prmem_h___
#include "prtypes.h"
#include <stdlib.h>
PR_BEGIN_EXTERN_C
/*
** Thread safe memory allocation.
**
** NOTE: pr wraps up malloc, free, calloc, realloc so they are already
** thread safe (and are not declared here - look in stdlib.h).
*/
/*
** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free have the same signatures
** as their libc equivalent malloc, calloc, realloc, and free, and have
** the same semantics. (Note that the argument type size_t is replaced
** by PRUint32.) Memory allocated by PR_Malloc, PR_Calloc, or PR_Realloc
** must be freed by PR_Free.
*/
NSPR_API(void *) PR_Malloc(PRUint32 size);
NSPR_API(void *) PR_Calloc(PRUint32 nelem, PRUint32 elsize);
NSPR_API(void *) PR_Realloc(void *ptr, PRUint32 size);
NSPR_API(void) PR_Free(void *ptr);
/*
** The following are some convenience macros defined in terms of
** PR_Malloc, PR_Calloc, PR_Realloc, and PR_Free.
*/
/***********************************************************************
** FUNCTION: PR_MALLOC()
** DESCRIPTION:
** PR_NEW() allocates an untyped item of size _size from the heap.
** INPUTS: _size: size in bytes of item to be allocated
** OUTPUTS: untyped pointer to the node allocated
** RETURN: pointer to node or error returned from malloc().
***********************************************************************/
#define PR_MALLOC(_bytes) (PR_Malloc((_bytes)))
/***********************************************************************
** FUNCTION: PR_NEW()
** DESCRIPTION:
** PR_NEW() allocates an item of type _struct from the heap.
** INPUTS: _struct: a data type
** OUTPUTS: pointer to _struct
** RETURN: pointer to _struct or error returns from malloc().
***********************************************************************/
#define PR_NEW(_struct) ((_struct *) PR_MALLOC(sizeof(_struct)))
/***********************************************************************
** FUNCTION: PR_REALLOC()
** DESCRIPTION:
** PR_REALLOC() re-allocates _ptr bytes from the heap as a _size
** untyped item.
** INPUTS: _ptr: pointer to node to reallocate
** _size: size of node to allocate
** OUTPUTS: pointer to node allocated
** RETURN: pointer to node allocated
***********************************************************************/
#define PR_REALLOC(_ptr, _size) (PR_Realloc((_ptr), (_size)))
/***********************************************************************
** FUNCTION: PR_CALLOC()
** DESCRIPTION:
** PR_CALLOC() allocates a _size bytes untyped item from the heap
** and sets the allocated memory to all 0x00.
** INPUTS: _size: size of node to allocate
** OUTPUTS: pointer to node allocated
** RETURN: pointer to node allocated
***********************************************************************/
#define PR_CALLOC(_size) (PR_Calloc(1, (_size)))
/***********************************************************************
** FUNCTION: PR_NEWZAP()
** DESCRIPTION:
** PR_NEWZAP() allocates an item of type _struct from the heap
** and sets the allocated memory to all 0x00.
** INPUTS: _struct: a data type
** OUTPUTS: pointer to _struct
** RETURN: pointer to _struct
***********************************************************************/
#define PR_NEWZAP(_struct) ((_struct*)PR_Calloc(1, sizeof(_struct)))
/***********************************************************************
** FUNCTION: PR_DELETE()
** DESCRIPTION:
** PR_DELETE() unallocates an object previosly allocated via PR_NEW()
** or PR_NEWZAP() to the heap.
** INPUTS: pointer to previously allocated object
** OUTPUTS: the referenced object is returned to the heap
** RETURN: void
***********************************************************************/
#define PR_DELETE(_ptr) { PR_Free(_ptr); (_ptr) = NULL; }
/***********************************************************************
** FUNCTION: PR_FREEIF()
** DESCRIPTION:
** PR_FREEIF() conditionally unallocates an object previously allocated
** vial PR_NEW() or PR_NEWZAP(). If the pointer to the object is
** equal to zero (0), the object is not released.
** INPUTS: pointer to previously allocated object
** OUTPUTS: the referenced object is conditionally returned to the heap
** RETURN: void
***********************************************************************/
#define PR_FREEIF(_ptr) if (_ptr) PR_DELETE(_ptr)
PR_END_EXTERN_C
#endif /* prmem_h___ */

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prmon_h___
#define prmon_h___
#include "prtypes.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
typedef struct PRMonitor PRMonitor;
/*
** Create a new monitor. Monitors are re-entrant locks with a single built-in
** condition variable.
**
** This may fail if memory is tight or if some operating system resource
** is low.
*/
NSPR_API(PRMonitor*) PR_NewMonitor(void);
/*
** Destroy a monitor. The caller is responsible for guaranteeing that the
** monitor is no longer in use. There must be no thread waiting on the monitor's
** condition variable and that the lock is not held.
**
*/
NSPR_API(void) PR_DestroyMonitor(PRMonitor *mon);
/*
** Enter the lock associated with the monitor. If the calling thread currently
** is in the monitor, the call to enter will silently succeed. In either case,
** it will increment the entry count by one.
*/
NSPR_API(void) PR_EnterMonitor(PRMonitor *mon);
/*
** Decrement the entry count associated with the monitor. If the decremented
** entry count is zero, the monitor is exited. Returns PR_FAILURE if the
** calling thread has not entered the monitor.
*/
NSPR_API(PRStatus) PR_ExitMonitor(PRMonitor *mon);
/*
** Wait for a notify on the monitor's condition variable. Sleep for "ticks"
** amount of time (if "ticks" is PR_INTERVAL_NO_TIMEOUT then the sleep is
** indefinite).
**
** While the thread is waiting it exits the monitor (as if it called
** PR_ExitMonitor as many times as it had called PR_EnterMonitor). When
** the wait has finished the thread regains control of the monitors lock
** with the same entry count as before the wait began.
**
** The thread waiting on the monitor will be resumed when the monitor is
** notified (assuming the thread is the next in line to receive the
** notify) or when the "ticks" timeout elapses.
**
** Returns PR_FAILURE if the caller has not entered the monitor.
*/
NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
/*
** Notify a thread waiting on the monitor's condition variable. If a thread
** is waiting on the condition variable (using PR_Wait) then it is awakened
** and attempts to reenter the monitor.
*/
NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
/*
** Notify all of the threads waiting on the monitor's condition variable.
** All of threads waiting on the condition are scheduled to reenter the
** monitor.
*/
NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
/*
** PR_ASSERT_CURRENT_THREAD_IN_MONITOR
** If the current thread is in |mon|, this assertion is guaranteed to
** succeed. Otherwise, the behavior of this function is undefined.
*/
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)
#define PR_ASSERT_CURRENT_THREAD_IN_MONITOR(/* PRMonitor* */ mon) \
PR_AssertCurrentThreadInMonitor(mon)
#else
#define PR_ASSERT_CURRENT_THREAD_IN_MONITOR(/* PRMonitor* */ mon)
#endif
/* Don't call this function directly. */
NSPR_API(void) PR_AssertCurrentThreadInMonitor(PRMonitor *mon);
PR_END_EXTERN_C
#endif /* prmon_h___ */

View File

@@ -0,0 +1,380 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if defined(_PRMWAIT_H)
#else
#define _PRMWAIT_H
#include "prio.h"
#include "prtypes.h"
#include "prclist.h"
PR_BEGIN_EXTERN_C
/********************************************************************************/
/********************************************************************************/
/********************************************************************************/
/****************************** WARNING ****************************/
/********************************************************************************/
/**************************** This is work in progress. *************************/
/************************** Do not make any assumptions *************************/
/************************** about the stability of this *************************/
/************************** API or the underlying imple- ************************/
/************************** mentation. ************************/
/********************************************************************************/
/********************************************************************************/
/*
** STRUCTURE: PRWaitGroup
** DESCRIPTION:
** The client may define several wait groups in order to semantically
** tie a collection of file descriptors for a single purpose. This allows
** easier dispatching of threads that returned with active file descriptors
** from the wait function.
*/
typedef struct PRWaitGroup PRWaitGroup;
/*
** ENUMERATION: PRMWStatus
** DESCRIPTION:
** This enumeration is used to indicate the completion status of
** a receive wait object. Generally stated, a positive value indicates
** that the operation is not yet complete. A zero value indicates
** success (similar to PR_SUCCESS) and any negative value is an
** indication of failure. The reason for the failure can be retrieved
** by calling PR_GetError().
**
** PR_MW_PENDING The operation is still pending. None of the other
** fields of the object are currently valid.
** PR_MW_SUCCESS The operation is complete and it was successful.
** PR_MW_FAILURE The operation failed. The reason for the failure
** can be retrieved by calling PR_GetError().
** PR_MW_TIMEOUT The amount of time allowed for by the object's
** 'timeout' field has expired w/o the operation
** otherwise coming to closure.
** PR_MW_INTERRUPT The operation was cancelled, either by the client
** calling PR_CancelWaitFileDesc() or destroying the
** entire wait group (PR_DestroyWaitGroup()).
*/
typedef enum PRMWStatus
{
PR_MW_PENDING = 1,
PR_MW_SUCCESS = 0,
PR_MW_FAILURE = -1,
PR_MW_TIMEOUT = -2,
PR_MW_INTERRUPT = -3
} PRMWStatus;
/*
** STRUCTURE: PRMemoryDescriptor
** DESCRIPTION:
** THis is a descriptor for an interval of memory. It contains a
** pointer to the first byte of that memory and the length (in
** bytes) of the interval.
*/
typedef struct PRMemoryDescriptor
{
void *start; /* pointer to first byte of memory */
PRSize length; /* length (in bytes) of memory interval */
} PRMemoryDescriptor;
/*
** STRUCTURE: PRMWaitClientData
** DESCRIPTION:
** An opague stucture for which a client MAY give provide a concrete
** definition and associate with a receive descriptor. The NSPR runtime
** does not manage this field. It is completely up to the client.
*/
typedef struct PRMWaitClientData PRMWaitClientData;
/*
** STRUCTURE: PRRecvWait
** DESCRIPTION:
** A receive wait object contains the file descriptor that is subject
** to the wait and the amount of time (beginning epoch established
** when the object is presented to the runtime) the the channel should
** block before abandoning the process.
**
** The success of the wait operation will be noted in the object's
** 'outcome' field. The fields are not valid when the NSPR runtime
** is in possession of the object.
**
** The memory descriptor describes an interval of writable memory
** in the caller's address space where data from an initial read
** can be placed. The description may indicate a null interval.
*/
typedef struct PRRecvWait
{
PRCList internal; /* internal runtime linkages */
PRFileDesc *fd; /* file descriptor associated w/ object */
PRMWStatus outcome; /* outcome of the current/last operation */
PRIntervalTime timeout; /* time allowed for entire operation */
PRInt32 bytesRecv; /* number of bytes transferred into buffer */
PRMemoryDescriptor buffer; /* where to store first segment of input data */
PRMWaitClientData *client; /* pointer to arbitrary client defined data */
} PRRecvWait;
/*
** STRUCTURE: PRMWaitEnumerator
** DESCRIPTION:
** An enumeration object is used to store the state of an existing
** enumeration over a wait group. The opaque object must be allocated
** by the client and the reference presented on each call to the
** pseudo-stateless enumerator. The enumeration objects are sharable
** only in serial fashion.
*/
typedef struct PRMWaitEnumerator PRMWaitEnumerator;
/*
** FUNCTION: PR_AddWaitFileDesc
** DESCRIPTION:
** This function will effectively add a file descriptor to the
** list of those waiting for network receive. The new descriptor
** will be semantically tied to the wait group specified.
**
** The ownership for the storage pointed to by 'desc' is temporarily
** passed over the the NSPR runtime. It will be handed back by the
** function PR_WaitRecvReady().
**
** INPUTS
** group A reference to a PRWaitGroup or NULL. Wait groups are
** created by calling PR_CreateWaitGroup() and are used
** to semantically group various file descriptors by the
** client's application.
** desc A reference to a valid PRRecvWait. The object of the
** reference must be preserved and not be modified
** until its ownership is returned to the client.
** RETURN
** PRStatus An indication of success. If equal to PR_FAILUE details
** of the failure are avaiable via PR_GetError().
**
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** Invalid 'group' identifier or duplicate 'desc' object.
** PR_OUT_OF_MEMORY_ERROR
** Insuffient memory for internal data structures.
** PR_INVALID_STATE_ERROR
** The group is being destroyed.
*/
NSPR_API(PRStatus) PR_AddWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc);
/*
** FUNCTION: PR_WaitRecvReady
** DESCRIPTION:
** PR_WaitRecvReady will block the calling thread until one of the
** file descriptors that have been added via PR_AddWaitFileDesc is
** available for input I/O.
** INPUT
** group A pointer to a valid PRWaitGroup or NULL (the null
** group. The function will block the caller until a
** channel from the wait group becomes ready for receive
** or there is some sort of error.
** RETURN
** PRReciveWait
** When the caller is resumed it is either returned a
** valid pointer to a previously added receive wait or
** a NULL. If the latter, the function has terminated
** for a reason that can be determined by calling
** PR_GetError().
** If a valid pointer is returned, the reference is to the
** file descriptor contained in the receive wait object.
** The outcome of the wait operation may still fail, and
** if it has, that fact will be noted in the object's
** outcome field. Details can be retrieved from PR_GetError().
**
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** The 'group' is not known by the runtime.
** PR_PENDING_INTERRUPT_ERROR
The thread was interrupted.
** PR_INVALID_STATE_ERROR
** The group is being destroyed.
*/
NSPR_API(PRRecvWait*) PR_WaitRecvReady(PRWaitGroup *group);
/*
** FUNCTION: PR_CancelWaitFileDesc
** DESCRIPTION:
** PR_CancelWaitFileDesc is provided as a means for cancelling operations
** on objects previously submitted by use of PR_AddWaitFileDesc(). If
** the runtime knows of the object, it will be marked as having failed
** because it was interrupted (similar to PR_Interrupt()). The first
** available thread waiting on the group will be made to return the
** PRRecvWait object with the outcome noted.
**
** INPUTS
** group The wait group under which the wait receive object was
** added.
** desc A pointer to the wait receive object that is to be
** cancelled.
** RETURN
** PRStatus If the wait receive object was located and associated
** with the specified wait group, the status returned will
** be PR_SUCCESS. There is still a race condition that would
** permit the offected object to complete normally, but it
** is assured that it will complete in the near future.
** If the receive object or wait group are invalid, the
** function will return with a status of PR_FAILURE.
**
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** The 'group' argument is not recognized as a valid group.
** PR_COLLECTION_EMPTY_ERROR
** There are no more receive wait objects in the group's
** collection.
** PR_INVALID_STATE_ERROR
** The group is being destroyed.
*/
NSPR_API(PRStatus) PR_CancelWaitFileDesc(PRWaitGroup *group, PRRecvWait *desc);
/*
** FUNCTION: PR_CancelWaitGroup
** DESCRIPTION:
** PR_CancelWaitGroup is provided as a means for cancelling operations
** on objects previously submitted by use of PR_AddWaitFileDesc(). Each
** successive call will return a pointer to a PRRecvWait object that
** was previously registered via PR_AddWaitFileDesc(). If no wait
** objects are associated with the wait group, a NULL will be returned.
** This function should be called in a loop until a NULL is returned
** to reclaim all the wait objects prior to calling PR_DestroyWaitGroup().
**
** INPUTS
** group The wait group under which the wait receive object was
** added.
** RETURN
** PRRecvWait* If the wait group is valid and at least one receive wait
** object is present in the group, that object will be
** marked as PR_MW_INTERRUPT'd and removed from the group's
** queues. Otherwise a NULL will be returned and the reason
** for the NULL may be retrieved by calling PR_GetError().
**
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** PR_GROUP_EMPTY_ERROR
*/
NSPR_API(PRRecvWait*) PR_CancelWaitGroup(PRWaitGroup *group);
/*
** FUNCTION: PR_CreateWaitGroup
** DESCRIPTION:
** A wait group is an opaque object that a client may create in order
** to semantically group various wait requests. Each wait group is
** unique, including the default wait group (NULL). A wait request
** that was added under a wait group will only be serviced by a caller
** that specified the same wait group.
**
** INPUT
** size The size of the hash table to be used to contain the
** receive wait objects. This is just the initial size.
** It will grow as it needs to, but to avoid that hassle
** one can suggest a suitable size initially. It should
** be ~30% larger than the maximum number of receive wait
** objects expected.
** RETURN
** PRWaitGroup If successful, the function will return a pointer to an
** object that was allocated by and owned by the runtime.
** The reference remains valid until it is explicitly destroyed
** by calling PR_DestroyWaitGroup().
**
** ERRORS
** PR_OUT_OF_MEMORY_ERROR
*/
NSPR_API(PRWaitGroup*) PR_CreateWaitGroup(PRInt32 size);
/*
** FUNCTION: PR_DestroyWaitGroup
** DESCRIPTION:
** Undo the effects of PR_CreateWaitGroup(). Any receive wait operations
** on the group will be treated as if the each had been the target of a
** PR_CancelWaitFileDesc().
**
** INPUT
** group Reference to a wait group previously allocated using
** PR_CreateWaitGroup().
** RETURN
** PRStatus Will be PR_SUCCESS if the wait group was valid and there
** are no receive wait objects in that group. Otherwise
** will indicate PR_FAILURE.
**
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** The 'group' argument does not reference a known object.
** PR_INVALID_STATE_ERROR
** The group still contains receive wait objects.
*/
NSPR_API(PRStatus) PR_DestroyWaitGroup(PRWaitGroup *group);
/*
** FUNCTION: PR_CreateMWaitEnumerator
** DESCRIPTION:
** The PR_CreateMWaitEnumerator() function returns a reference to an
** opaque PRMWaitEnumerator object. The enumerator object is required
** as an argument for each successive call in the stateless enumeration
** of the indicated wait group.
**
** group The wait group that the enumeration is intended to
** process. It may be be the default wait group (NULL).
** RETURN
** PRMWaitEnumerator* group
** A reference to an object that will be used to store
** intermediate state of enumerations.
** ERRORS
** Errors are indicated by the function returning a NULL.
** PR_INVALID_ARGUMENT_ERROR
** The 'group' argument does not reference a known object.
** PR_OUT_OF_MEMORY_ERROR
*/
NSPR_API(PRMWaitEnumerator*) PR_CreateMWaitEnumerator(PRWaitGroup *group);
/*
** FUNCTION: PR_DestroyMWaitEnumerator
** DESCRIPTION:
** Destroys the object created by PR_CreateMWaitEnumerator(). The reference
** used as an argument becomes invalid.
**
** INPUT
** PRMWaitEnumerator* enumerator
** The PRMWaitEnumerator object to destroy.
** RETURN
** PRStatus
** PR_SUCCESS if successful, PR_FAILURE otherwise.
** ERRORS
** PR_INVALID_ARGUMENT_ERROR
** The enumerator is invalid.
*/
NSPR_API(PRStatus) PR_DestroyMWaitEnumerator(PRMWaitEnumerator* enumerator);
/*
** FUNCTION: PR_EnumerateWaitGroup
** DESCRIPTION:
** PR_EnumerateWaitGroup is a thread safe enumerator over a wait group.
** Each call to the enumerator must present a valid PRMWaitEnumerator
** rererence and a pointer to the "previous" element returned from the
** enumeration process or a NULL.
**
** An enumeration is started by passing a NULL as the "previous" value.
** Subsequent calls to the enumerator must pass in the result of the
** previous call. The enumeration end is signaled by the runtime returning
** a NULL as the result.
**
** Modifications to the content of the wait group are allowed during
** an enumeration. The effect is that the enumeration may have to be
** "reset" and that may result in duplicates being returned from the
** enumeration.
**
** An enumeration may be abandoned at any time. The runtime is not
** keeping any state, so there are no issues in that regard.
*/
NSPR_API(PRRecvWait*) PR_EnumerateWaitGroup(
PRMWaitEnumerator *enumerator, const PRRecvWait *previous);
PR_END_EXTERN_C
#endif /* defined(_PRMWAIT_H) */
/* prmwait.h */

View File

@@ -0,0 +1,467 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prnetdb_h___
#define prnetdb_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
/*
*********************************************************************
* Translate an Internet address to/from a character string
*********************************************************************
*/
NSPR_API(PRStatus) PR_StringToNetAddr(
const char *string, PRNetAddr *addr);
NSPR_API(PRStatus) PR_NetAddrToString(
const PRNetAddr *addr, char *string, PRUint32 size);
/*
** Structures returned by network data base library. All addresses are
** supplied in host order, and returned in network order (suitable for
** use in system calls).
*/
/*
** Beware that WINSOCK.H defines h_addrtype and h_length as short.
** Client code does direct struct copies of hostent to PRHostEnt and
** hence the ifdef.
*/
typedef struct PRHostEnt {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
#ifdef WIN32
PRInt16 h_addrtype; /* host address type */
PRInt16 h_length; /* length of address */
#else
PRInt32 h_addrtype; /* host address type */
PRInt32 h_length; /* length of address */
#endif
char **h_addr_list; /* list of addresses from name server */
} PRHostEnt;
/* A safe size to use that will mostly work... */
#if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1)
#define PR_NETDB_BUF_SIZE sizeof(struct protoent_data)
#else
#define PR_NETDB_BUF_SIZE 1024
#endif
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetHostByName()
** Lookup a host by name.
**
** INPUTS:
** char *hostname Character string defining the host name of interest
** char *buf A scratch buffer for the runtime to return result.
** This buffer is allocated by the caller.
** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to
** use is PR_NETDB_BUF_SIZE.
** OUTPUTS:
** PRHostEnt *hostentry
** This structure is filled in by the runtime if
** the function returns PR_SUCCESS. This structure
** is allocated by the caller.
** RETURN:
** PRStatus PR_SUCCESS if the lookup succeeds. If it fails
** the result will be PR_FAILURE and the reason
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
NSPR_API(PRStatus) PR_GetHostByName(
const char *hostname, char *buf, PRIntn bufsize, PRHostEnt *hostentry);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetIPNodeByName()
** Lookup a host by name. Equivalent to getipnodebyname(AI_DEFAULT)
** of RFC 2553.
**
** INPUTS:
** char *hostname Character string defining the host name of interest
** PRUint16 af Address family (either PR_AF_INET or PR_AF_INET6)
** PRIntn flags Specifies the types of addresses that are searched
** for and the types of addresses that are returned.
** The only supported flag is PR_AI_DEFAULT.
** char *buf A scratch buffer for the runtime to return result.
** This buffer is allocated by the caller.
** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to
** use is PR_NETDB_BUF_SIZE.
** OUTPUTS:
** PRHostEnt *hostentry
** This structure is filled in by the runtime if
** the function returns PR_SUCCESS. This structure
** is allocated by the caller.
** RETURN:
** PRStatus PR_SUCCESS if the lookup succeeds. If it fails
** the result will be PR_FAILURE and the reason
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
#define PR_AI_ALL 0x08
#define PR_AI_V4MAPPED 0x10
#define PR_AI_ADDRCONFIG 0x20
#define PR_AI_NOCANONNAME 0x8000
#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)
NSPR_API(PRStatus) PR_GetIPNodeByName(
const char *hostname,
PRUint16 af,
PRIntn flags,
char *buf,
PRIntn bufsize,
PRHostEnt *hostentry);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetHostByAddr()
** Lookup a host entry by its network address.
**
** INPUTS:
** char *hostaddr IP address of host in question
** char *buf A scratch buffer for the runtime to return result.
** This buffer is allocated by the caller.
** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to
** use is PR_NETDB_BUF_SIZE.
** OUTPUTS:
** PRHostEnt *hostentry
** This structure is filled in by the runtime if
** the function returns PR_SUCCESS. This structure
** is allocated by the caller.
** RETURN:
** PRStatus PR_SUCCESS if the lookup succeeds. If it fails
** the result will be PR_FAILURE and the reason
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
NSPR_API(PRStatus) PR_GetHostByAddr(
const PRNetAddr *hostaddr, char *buf, PRIntn bufsize, PRHostEnt *hostentry);
/***********************************************************************
** FUNCTION: PR_EnumerateHostEnt()
** DESCRIPTION:
** A stateless enumerator over a PRHostEnt structure acquired from
** PR_GetHostByName() PR_GetHostByAddr() to evaluate the possible
** network addresses.
**
** INPUTS:
** PRIntn enumIndex Index of the enumeration. The enumeration starts
** and ends with a value of zero.
**
** PRHostEnt *hostEnt A pointer to a host entry struct that was
** previously returned by PR_GetHostByName() or
** PR_GetHostByAddr().
**
** PRUint16 port The port number to be assigned as part of the
** PRNetAddr.
**
** OUTPUTS:
** PRNetAddr *address A pointer to an address structure that will be
** filled in by the call to the enumeration if the
** result of the call is greater than zero.
**
** RETURN:
** PRIntn The value that should be used for the next call
** of the enumerator ('enumIndex'). The enumeration
** is ended if this value is returned zero.
** If a value of -1 is returned, the enumeration
** has failed. The reason for the failure can be
** retrieved by calling PR_GetError().
***********************************************************************/
NSPR_API(PRIntn) PR_EnumerateHostEnt(
PRIntn enumIndex, const PRHostEnt *hostEnt, PRUint16 port, PRNetAddr *address);
/***********************************************************************
** FUNCTION: PR_InitializeNetAddr(),
** DESCRIPTION:
** Initialize the fields of a PRNetAddr, assigning well known values as
** appropriate.
**
** INPUTS
** PRNetAddrValue val The value to be assigned to the IP Address portion
** of the network address. This can only specify the
** special well known values that are equivalent to
** INADDR_ANY and INADDR_LOOPBACK.
**
** PRUint16 port The port number to be assigned in the structure.
**
** OUTPUTS:
** PRNetAddr *addr The address to be manipulated.
**
** RETURN:
** PRStatus To indicate success or failure. If the latter, the
** reason for the failure can be retrieved by calling
** PR_GetError();
***********************************************************************/
typedef enum PRNetAddrValue
{
PR_IpAddrNull, /* do NOT overwrite the IP address */
PR_IpAddrAny, /* assign logical INADDR_ANY to IP address */
PR_IpAddrLoopback, /* assign logical INADDR_LOOPBACK */
PR_IpAddrV4Mapped /* IPv4 mapped address */
} PRNetAddrValue;
NSPR_API(PRStatus) PR_InitializeNetAddr(
PRNetAddrValue val, PRUint16 port, PRNetAddr *addr);
/***********************************************************************
** FUNCTION: PR_SetNetAddr(),
** DESCRIPTION:
** Set the fields of a PRNetAddr, assigning well known values as
** appropriate. This function is similar to PR_InitializeNetAddr
** but differs in that the address family is specified.
**
** INPUTS
** PRNetAddrValue val The value to be assigned to the IP Address portion
** of the network address. This can only specify the
** special well known values that are equivalent to
** INADDR_ANY and INADDR_LOOPBACK.
**
** PRUint16 af The address family (either PR_AF_INET or PR_AF_INET6)
**
** PRUint16 port The port number to be assigned in the structure.
**
** OUTPUTS:
** PRNetAddr *addr The address to be manipulated.
**
** RETURN:
** PRStatus To indicate success or failure. If the latter, the
** reason for the failure can be retrieved by calling
** PR_GetError();
***********************************************************************/
NSPR_API(PRStatus) PR_SetNetAddr(
PRNetAddrValue val, PRUint16 af, PRUint16 port, PRNetAddr *addr);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_IsNetAddrType()
** Determine if the network address is of the specified type.
**
** INPUTS:
** const PRNetAddr *addr A network address.
** PRNetAddrValue The type of network address
**
** RETURN:
** PRBool PR_TRUE if the network address is of the
** specified type, else PR_FALSE.
***********************************************************************/
NSPR_API(PRBool) PR_IsNetAddrType(const PRNetAddr *addr, PRNetAddrValue val);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_ConvertIPv4AddrToIPv6()
** Convert an IPv4 addr to an (IPv4-mapped) IPv6 addr
**
** INPUTS:
** PRUint32 v4addr IPv4 address
**
** OUTPUTS:
** PRIPv6Addr *v6addr The converted IPv6 address
**
** RETURN:
** void
**
***********************************************************************/
NSPR_API(void) PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr *v6addr);
/***********************************************************************
** MACRO:
** DESCRIPTION: PR_NetAddrFamily()
** Get the 'family' field of a PRNetAddr union.
**
** INPUTS:
** const PRNetAddr *addr A network address.
**
** RETURN:
** PRUint16 The 'family' field of 'addr'.
***********************************************************************/
#define PR_NetAddrFamily(addr) ((addr)->raw.family)
/***********************************************************************
** MACRO:
** DESCRIPTION: PR_NetAddrInetPort()
** Get the 'port' field of a PRNetAddr union.
**
** INPUTS:
** const PRNetAddr *addr A network address.
**
** RETURN:
** PRUint16 The 'port' field of 'addr'.
***********************************************************************/
#define PR_NetAddrInetPort(addr) \
((addr)->raw.family == PR_AF_INET6 ? (addr)->ipv6.port : (addr)->inet.port)
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetProtoByName()
** Lookup a protocol entry based on protocol's name
**
** INPUTS:
** char *protocolname Character string of the protocol's name.
** char *buf A scratch buffer for the runtime to return result.
** This buffer is allocated by the caller.
** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to
** use is PR_NETDB_BUF_SIZE.
** OUTPUTS:
** PRHostEnt *PRProtoEnt
** This structure is filled in by the runtime if
** the function returns PR_SUCCESS. This structure
** is allocated by the caller.
** RETURN:
** PRStatus PR_SUCCESS if the lookup succeeds. If it fails
** the result will be PR_FAILURE and the reason
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
typedef struct PRProtoEnt {
char *p_name; /* official protocol name */
char **p_aliases; /* alias list */
#ifdef WIN32
PRInt16 p_num; /* protocol # */
#else
PRInt32 p_num; /* protocol # */
#endif
} PRProtoEnt;
NSPR_API(PRStatus) PR_GetProtoByName(
const char* protocolname, char* buffer, PRInt32 bufsize, PRProtoEnt* result);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetProtoByNumber()
** Lookup a protocol entry based on protocol's number
**
** INPUTS:
** PRInt32 protocolnumber
** Number assigned to the protocol.
** char *buf A scratch buffer for the runtime to return result.
** This buffer is allocated by the caller.
** PRIntn bufsize Number of bytes in 'buf'. A recommnded value to
** use is PR_NETDB_BUF_SIZE.
** OUTPUTS:
** PRHostEnt *PRProtoEnt
** This structure is filled in by the runtime if
** the function returns PR_SUCCESS. This structure
** is allocated by the caller.
** RETURN:
** PRStatus PR_SUCCESS if the lookup succeeds. If it fails
** the result will be PR_FAILURE and the reason
** for the failure can be retrieved by PR_GetError().
***********************************************************************/
NSPR_API(PRStatus) PR_GetProtoByNumber(
PRInt32 protocolnumber, char* buffer, PRInt32 bufsize, PRProtoEnt* result);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetAddrInfoByName()
** Look up a host by name. Equivalent to getaddrinfo(host, NULL, ...) of
** RFC 3493.
**
** INPUTS:
** char *hostname Character string defining the host name of interest
** PRUint16 af May be PR_AF_UNSPEC or PR_AF_INET.
** PRIntn flags May be either PR_AI_ADDRCONFIG or
** PR_AI_ADDRCONFIG | PR_AI_NOCANONNAME. Include
** PR_AI_NOCANONNAME to suppress the determination of
** the canonical name corresponding to hostname.
** RETURN:
** PRAddrInfo* Handle to a data structure containing the results
** of the host lookup. Use PR_EnumerateAddrInfo to
** inspect the PRNetAddr values stored in this object.
** When no longer needed, this handle must be destroyed
** with a call to PR_FreeAddrInfo. If a lookup error
** occurs, then NULL will be returned.
***********************************************************************/
typedef struct PRAddrInfo PRAddrInfo;
NSPR_API(PRAddrInfo*) PR_GetAddrInfoByName(
const char *hostname, PRUint16 af, PRIntn flags);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_FreeAddrInfo()
** Destroy the PRAddrInfo handle allocated by PR_GetAddrInfoByName().
**
** INPUTS:
** PRAddrInfo *addrInfo
** The handle resulting from a successful call to
** PR_GetAddrInfoByName().
** RETURN:
** void
***********************************************************************/
NSPR_API(void) PR_FreeAddrInfo(PRAddrInfo *addrInfo);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_EnumerateAddrInfo()
** A stateless enumerator over a PRAddrInfo handle acquired from
** PR_GetAddrInfoByName() to inspect the possible network addresses.
**
** INPUTS:
** void *enumPtr Index pointer of the enumeration. The enumeration
** starts and ends with a value of NULL.
** const PRAddrInfo *addrInfo
** The PRAddrInfo handle returned by a successful
** call to PR_GetAddrInfoByName().
** PRUint16 port The port number to be assigned as part of the
** PRNetAddr.
** OUTPUTS:
** PRNetAddr *result A pointer to an address structure that will be
** filled in by the call to the enumeration if the
** result of the call is not NULL.
** RETURN:
** void* The value that should be used for the next call
** of the enumerator ('enumPtr'). The enumeration
** is ended if this value is NULL.
***********************************************************************/
NSPR_API(void *) PR_EnumerateAddrInfo(
void *enumPtr, const PRAddrInfo *addrInfo, PRUint16 port, PRNetAddr *result);
/***********************************************************************
** FUNCTION:
** DESCRIPTION: PR_GetCanonNameFromAddrInfo()
** Extracts the canonical name of the hostname passed to
** PR_GetAddrInfoByName().
**
** INPUTS:
** const PRAddrInfo *addrInfo
** The PRAddrInfo handle returned by a successful
** call to PR_GetAddrInfoByName().
** RETURN:
** const char * A const pointer to the canonical hostname stored
** in the given PRAddrInfo handle. This pointer is
** invalidated once the PRAddrInfo handle is destroyed
** by a call to PR_FreeAddrInfo().
***********************************************************************/
NSPR_API(const char *) PR_GetCanonNameFromAddrInfo(
const PRAddrInfo *addrInfo);
/***********************************************************************
** FUNCTIONS: PR_ntohs, PR_ntohl, PR_ntohll, PR_htons, PR_htonl, PR_htonll
**
** DESCRIPTION: API entries for the common byte ordering routines.
**
** PR_ntohs 16 bit conversion from network to host
** PR_ntohl 32 bit conversion from network to host
** PR_ntohll 64 bit conversion from network to host
** PR_htons 16 bit conversion from host to network
** PR_htonl 32 bit conversion from host to network
** PR_ntonll 64 bit conversion from host to network
**
***********************************************************************/
NSPR_API(PRUint16) PR_ntohs(PRUint16);
NSPR_API(PRUint32) PR_ntohl(PRUint32);
NSPR_API(PRUint64) PR_ntohll(PRUint64);
NSPR_API(PRUint16) PR_htons(PRUint16);
NSPR_API(PRUint32) PR_htonl(PRUint32);
NSPR_API(PRUint64) PR_htonll(PRUint64);
PR_END_EXTERN_C
#endif /* prnetdb_h___ */

View File

@@ -0,0 +1,178 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prolock_h___
#define prolock_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** 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 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
** application using Ordered Lock and NSPR must be compiled with the
** facility enabled to achieve the desired results.
**
** Application designers should use the macro interfaces to the Ordered
** Lock facility to ensure that it is compiled out in optimized builds.
**
** Application designers are responsible for defining their own
** lock hierarchy.
**
** Ordered Lock is thread-safe and SMP safe.
**
** See Also: prlock.h
**
** /lth. 10-Jun-1998.
**
*/
/*
** Opaque type for ordered lock.
** ... Don't even think of looking in here.
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
typedef void * PROrderedLock;
#else
/*
** Map PROrderedLock and methods onto PRLock when ordered locking
** is not compiled in.
**
*/
#include "prlock.h"
typedef PRLock PROrderedLock;
#endif
/* -----------------------------------------------------------------------
** FUNCTION: PR_CreateOrderedLock() -- Create an Ordered Lock
**
** DESCRIPTION: PR_CreateOrderedLock() creates an ordered lock.
**
** INPUTS:
** order: user defined order of this lock.
** name: name of the lock. For debugging purposes.
**
** OUTPUTS: returned
**
** RETURNS: PR_OrderedLock pointer
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
#define PR_CREATE_ORDERED_LOCK(order,name)\
PR_CreateOrderedLock((order),(name))
#else
#define PR_CREATE_ORDERED_LOCK(order) PR_NewLock()
#endif
NSPR_API(PROrderedLock *)
PR_CreateOrderedLock(
PRInt32 order,
const char *name
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_DestroyOrderedLock() -- Destroy an Ordered Lock
**
** DESCRIPTION: PR_DestroyOrderedLock() destroys the ordered lock
** referenced by lock.
**
** INPUTS: lock: pointer to a PROrderedLock
**
** OUTPUTS: the lock is destroyed
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyOrderedLock((lock))
#else
#define PR_DESTROY_ORDERED_LOCK(lock) PR_DestroyLock((lock))
#endif
NSPR_API(void)
PR_DestroyOrderedLock(
PROrderedLock *lock
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_LockOrderedLock() -- Lock an ordered lock
**
** DESCRIPTION: PR_LockOrderedLock() locks the ordered lock
** referenced by lock. If the order of lock is less than or equal
** to the order of the highest lock held by the locking thread,
** the function asserts.
**
** INPUTS: lock: a pointer to a PROrderedLock
**
** OUTPUTS: The lock is held or the function asserts.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
#define PR_LOCK_ORDERED_LOCK(lock) PR_LockOrderedLock((lock))
#else
#define PR_LOCK_ORDERED_LOCK(lock) PR_Lock((lock))
#endif
NSPR_API(void)
PR_LockOrderedLock(
PROrderedLock *lock
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_UnlockOrderedLock() -- unlock and Ordered Lock
**
** DESCRIPTION: PR_UnlockOrderedLock() unlocks the lock referenced
** by lock.
**
** INPUTS: lock: a pointer to a PROrderedLock
**
** OUTPUTS: the lock is unlocked
**
** RETURNS:
** PR_SUCCESS
** PR_FAILURE
**
** RESTRICTIONS:
**
*/
#if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
#define PR_UNLOCK_ORDERED_LOCK(lock) PR_UnlockOrderedLock((lock))
#else
#define PR_UNLOCK_ORDERED_LOCK(lock) PR_Unlock((lock))
#endif
NSPR_API(PRStatus)
PR_UnlockOrderedLock(
PROrderedLock *lock
);
PR_END_EXTERN_C
#endif /* prolock_h___ */

View File

@@ -0,0 +1,86 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* File: prpdce.h
* Description: This file is the API defined to allow for DCE (aka POSIX)
* thread emulation in an NSPR environment. It is not the
* intent that this be a fully supported API.
*/
#if !defined(PRPDCE_H)
#define PRPDCE_H
#include "prlock.h"
#include "prcvar.h"
#include "prtypes.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
#define _PR_NAKED_CV_LOCK (PRLock*)0xdce1dce1
/*
** Test and acquire a lock.
**
** If the lock is acquired by the calling thread, the
** return value will be PR_SUCCESS. If the lock is
** already held, by another thread or this thread, the
** result will be PR_FAILURE.
*/
NSPR_API(PRStatus) PRP_TryLock(PRLock *lock);
/*
** Create a naked condition variable
**
** A "naked" condition variable is one that is not created bound
** to a lock. The CV created with this function is the only type
** that may be used in the subsequent "naked" condition variable
** operations (see PRP_NakedWait, PRP_NakedNotify, PRP_NakedBroadcast);
*/
NSPR_API(PRCondVar*) PRP_NewNakedCondVar(void);
/*
** Destroy a naked condition variable
**
** Destroy the condition variable created by PR_NewNakedCondVar.
*/
NSPR_API(void) PRP_DestroyNakedCondVar(PRCondVar *cvar);
/*
** Wait on a condition
**
** Wait on the condition variable 'cvar'. It is asserted that
** the lock protecting the condition 'lock' is held by the
** calling thread. If more time expires than that declared in
** 'timeout' the condition will be notified. Waits can be
** interrupted by another thread.
**
** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
*/
NSPR_API(PRStatus) PRP_NakedWait(
PRCondVar *cvar, PRLock *lock, PRIntervalTime timeout);
/*
** Notify a thread waiting on a condition
**
** Notify the condition specified 'cvar'.
**
** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
*/
NSPR_API(PRStatus) PRP_NakedNotify(PRCondVar *cvar);
/*
** Notify all threads waiting on a condition
**
** Notify the condition specified 'cvar'.
**
** NB: The CV ('cvar') must be one created using PR_NewNakedCondVar.
*/
NSPR_API(PRStatus) PRP_NakedBroadcast(PRCondVar *cvar);
PR_END_EXTERN_C
#endif /* PRPDCE_H */

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prprf_h___
#define prprf_h___
/*
** API for PR printf like routines. Supports the following formats
** %d - decimal
** %u - unsigned decimal
** %x - unsigned hex
** %X - unsigned uppercase hex
** %o - unsigned octal
** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above
** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above
** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above
** %s - string
** %c - character
** %p - pointer (deals with machine dependent pointer size)
** %f - float
** %g - float
*/
#include "prtypes.h"
#include "prio.h"
#include <stdio.h>
#include <stdarg.h>
PR_BEGIN_EXTERN_C
/*
** sprintf into a fixed size buffer. Guarantees that a NUL is at the end
** of the buffer. Returns the length of the written output, NOT including
** the NUL, or (PRUint32)-1 if an error occurs.
*/
NSPR_API(PRUint32) PR_snprintf(char *out, PRUint32 outlen, const char *fmt, ...);
/*
** sprintf into a PR_MALLOC'd buffer. Return a pointer to the malloc'd
** buffer on success, NULL on failure. Call "PR_smprintf_free" to release
** the memory returned.
*/
NSPR_API(char*) PR_smprintf(const char *fmt, ...);
/*
** Free the memory allocated, for the caller, by PR_smprintf
*/
NSPR_API(void) PR_smprintf_free(char *mem);
/*
** "append" sprintf into a PR_MALLOC'd buffer. "last" is the last value of
** the PR_MALLOC'd buffer. sprintf will append data to the end of last,
** growing it as necessary using realloc. If last is NULL, PR_sprintf_append
** will allocate the initial string. The return value is the new value of
** last for subsequent calls, or NULL if there is a malloc failure.
*/
NSPR_API(char*) PR_sprintf_append(char *last, const char *fmt, ...);
/*
** sprintf into a function. The function "f" is called with a string to
** place into the output. "arg" is an opaque pointer used by the stuff
** function to hold any state needed to do the storage of the output
** data. The return value is a count of the number of characters fed to
** the stuff function, or (PRUint32)-1 if an error occurs.
*/
typedef PRIntn (*PRStuffFunc)(void *arg, const char *s, PRUint32 slen);
NSPR_API(PRUint32) PR_sxprintf(PRStuffFunc f, void *arg, const char *fmt, ...);
/*
** fprintf to a PRFileDesc
*/
NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt, ...);
/*
** va_list forms of the above.
*/
NSPR_API(PRUint32) PR_vsnprintf(char *out, PRUint32 outlen, const char *fmt, va_list ap);
NSPR_API(char*) PR_vsmprintf(const char *fmt, va_list ap);
NSPR_API(char*) PR_vsprintf_append(char *last, const char *fmt, va_list ap);
NSPR_API(PRUint32) PR_vsxprintf(PRStuffFunc f, void *arg, const char *fmt, va_list ap);
NSPR_API(PRUint32) PR_vfprintf(struct PRFileDesc* fd, const char *fmt, va_list ap);
/*
***************************************************************************
** FUNCTION: PR_sscanf
** DESCRIPTION:
** PR_sscanf() scans the input character string, performs data
** conversions, and stores the converted values in the data objects
** pointed to by its arguments according to the format control
** string.
**
** PR_sscanf() behaves the same way as the sscanf() function in the
** Standard C Library (stdio.h), with the following exceptions:
** - PR_sscanf() handles the NSPR integer and floating point types,
** such as PRInt16, PRInt32, PRInt64, and PRFloat64, whereas
** sscanf() handles the standard C types like short, int, long,
** and double.
** - PR_sscanf() has no multibyte character support, while sscanf()
** does.
** INPUTS:
** const char *buf
** a character string holding the input to scan
** const char *fmt
** the format control string for the conversions
** ...
** variable number of arguments, each of them is a pointer to
** a data object in which the converted value will be stored
** OUTPUTS: none
** RETURNS: PRInt32
** The number of values converted and stored.
** RESTRICTIONS:
** Multibyte characters in 'buf' or 'fmt' are not allowed.
***************************************************************************
*/
NSPR_API(PRInt32) PR_sscanf(const char *buf, const char *fmt, ...);
PR_END_EXTERN_C
#endif /* prprf_h___ */

View File

@@ -0,0 +1,86 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prproces_h___
#define prproces_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
/************************************************************************/
/*****************************PROCESS OPERATIONS*************************/
/************************************************************************/
typedef struct PRProcess PRProcess;
typedef struct PRProcessAttr PRProcessAttr;
NSPR_API(PRProcessAttr *) PR_NewProcessAttr(void);
NSPR_API(void) PR_ResetProcessAttr(PRProcessAttr *attr);
NSPR_API(void) PR_DestroyProcessAttr(PRProcessAttr *attr);
NSPR_API(void) PR_ProcessAttrSetStdioRedirect(
PRProcessAttr *attr,
PRSpecialFD stdioFd,
PRFileDesc *redirectFd
);
/*
* OBSOLETE -- use PR_ProcessAttrSetStdioRedirect instead.
*/
NSPR_API(void) PR_SetStdioRedirect(
PRProcessAttr *attr,
PRSpecialFD stdioFd,
PRFileDesc *redirectFd
);
NSPR_API(PRStatus) PR_ProcessAttrSetCurrentDirectory(
PRProcessAttr *attr,
const char *dir
);
NSPR_API(PRStatus) PR_ProcessAttrSetInheritableFD(
PRProcessAttr *attr,
PRFileDesc *fd,
const char *name
);
/*
** Create a new process
**
** Create a new process executing the file specified as 'path' and with
** the supplied arguments and environment.
**
** This function may fail because of illegal access (permissions),
** invalid arguments or insufficient resources.
**
** A process may be created such that the creator can later synchronize its
** termination using PR_WaitProcess().
*/
NSPR_API(PRProcess*) PR_CreateProcess(
const char *path,
char *const *argv,
char *const *envp,
const PRProcessAttr *attr);
NSPR_API(PRStatus) PR_CreateProcessDetached(
const char *path,
char *const *argv,
char *const *envp,
const PRProcessAttr *attr);
NSPR_API(PRStatus) PR_DetachProcess(PRProcess *process);
NSPR_API(PRStatus) PR_WaitProcess(PRProcess *process, PRInt32 *exitCode);
NSPR_API(PRStatus) PR_KillProcess(PRProcess *process);
PR_END_EXTERN_C
#endif /* prproces_h___ */

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** prrng.h -- NSPR Random Number Generator
**
**
** lth. 29-Oct-1999.
*/
#ifndef prrng_h___
#define prrng_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** PR_GetRandomNoise() -- Get random noise from the host platform
**
** Description:
** PR_GetRandomNoise() provides, depending on platform, a random value.
** The length of the random value is dependent on platform and the
** platform's ability to provide a random value at that moment.
**
** The intent of PR_GetRandomNoise() is to provide a "seed" value for a
** another random number generator that may be suitable for
** cryptographic operations. This implies that the random value
** provided may not be, by itself, cryptographically secure. The value
** generated by PR_GetRandomNoise() is at best, extremely difficult to
** predict and is as non-deterministic as the underlying platfrom can
** provide.
**
** Inputs:
** buf -- pointer to a caller supplied buffer to contain the
** generated random number. buf must be at least as large as
** is specified in the 'size' argument.
**
** size -- the requested size of the generated random number
**
** Outputs:
** a random number provided in 'buf'.
**
** Returns:
** PRSize value equal to the size of the random number actually
** generated, or zero. The generated size may be less than the size
** requested. A return value of zero means that PR_GetRandomNoise() is
** not implemented on this platform, or there is no available noise
** available to be returned at the time of the call.
**
** Restrictions:
** Calls to PR_GetRandomNoise() may use a lot of CPU on some platforms.
** Some platforms may block for up to a few seconds while they
** accumulate some noise. Busy machines generate lots of noise, but
** care is advised when using PR_GetRandomNoise() frequently in your
** application.
**
** History:
** Parts of the model dependent implementation for PR_GetRandomNoise()
** were taken in whole or part from code previously in Netscape's NSS
** component.
**
*/
NSPR_API(PRSize) PR_GetRandomNoise(
void *buf,
PRSize size
);
PR_END_EXTERN_C
#endif /* prrng_h___ */
/* end prrng.h */

View File

@@ -0,0 +1,88 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prrwlock.h
** Description: API to basic reader-writer lock functions of NSPR.
**
**/
#ifndef prrwlock_h___
#define prrwlock_h___
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
* PRRWLock --
*
* The reader writer lock, PRRWLock, is an opaque object to the clients
* of NSPR. All routines operate on a pointer to this opaque entity.
*/
typedef struct PRRWLock PRRWLock;
#define PR_RWLOCK_RANK_NONE 0
/***********************************************************************
** FUNCTION: PR_NewRWLock
** DESCRIPTION:
** Returns a pointer to a newly created reader-writer lock object.
** INPUTS: Lock rank
** Lock name
** OUTPUTS: void
** RETURN: PRRWLock*
** If the lock cannot be created because of resource constraints, NULL
** is returned.
**
***********************************************************************/
NSPR_API(PRRWLock*) PR_NewRWLock(PRUint32 lock_rank, const char *lock_name);
/***********************************************************************
** FUNCTION: PR_DestroyRWLock
** DESCRIPTION:
** Destroys a given RW lock object.
** INPUTS: PRRWLock *lock - Lock to be freed.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_DestroyRWLock(PRRWLock *lock);
/***********************************************************************
** FUNCTION: PR_RWLock_Rlock
** DESCRIPTION:
** Apply a read lock (non-exclusive) on a RWLock
** INPUTS: PRRWLock *lock - Lock to be read-locked.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_RWLock_Rlock(PRRWLock *lock);
/***********************************************************************
** FUNCTION: PR_RWLock_Wlock
** DESCRIPTION:
** Apply a write lock (exclusive) on a RWLock
** INPUTS: PRRWLock *lock - Lock to write-locked.
** OUTPUTS: void
** RETURN: None
***********************************************************************/
NSPR_API(void) PR_RWLock_Wlock(PRRWLock *lock);
/***********************************************************************
** FUNCTION: PR_RWLock_Unlock
** DESCRIPTION:
** Release a RW lock. Unlocking an unlocked lock has undefined results.
** INPUTS: PRRWLock *lock - Lock to unlocked.
** OUTPUTS: void
** RETURN: void
***********************************************************************/
NSPR_API(void) PR_RWLock_Unlock(PRRWLock *lock);
PR_END_EXTERN_C
#endif /* prrwlock_h___ */

View File

@@ -0,0 +1,257 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** prshm.h -- NSPR Shared Memory
**
** NSPR Named Shared Memory API provides a cross-platform named
** shared-memory interface. NSPR Named Shared Memory is modeled on
** similar constructs in Unix and Windows operating systems. Shared
** memory allows multiple processes to access one or more common shared
** memory regions, using it as an inter-process communication channel.
**
** Notes on Platform Independence:
** NSPR Named Shared Memory is built on the native services offered
** by most platforms. The NSPR Named Shared Memory API tries to
** provide a least common denominator interface so that it works
** across all supported platforms. To ensure that it works everywhere,
** some platform considerations must be accomodated and the protocol
** for using NSPR Shared Memory API must be observed.
**
** Protocol:
** Multiple shared memories can be created using NSPR's Shared Memory
** feature. For each named shared memory, as defined by the name
** given in the PR_OpenSharedMemory() call, a protocol for using the
** shared memory API is required to ensure desired behavior. Failing
** to follow the protocol may yield unpredictable results.
**
** PR_OpenSharedMemory() will create the shared memory segment, if it
** does not already exist, or open a connection that the existing
** shared memory segment if it already exists.
**
** PR_AttachSharedMemory() should be called following
** PR_OpenSharedMemory() to map the memory segment to an address in
** the application's address space.
**
** PR_AttachSharedMemory() may be called to re-map a shared memory
** segment after detaching the same PRSharedMemory object. Be
** sure to detach it when done.
**
** PR_DetachSharedMemory() should be called to un-map the shared
** memory segment from the application's address space.
**
** PR_CloseSharedMemory() should be called when no further use of the
** PRSharedMemory object is required within a process. Following a
** call to PR_CloseSharedMemory() the PRSharedMemory object is
** invalid and cannot be reused.
**
** PR_DeleteSharedMemory() should be called before process
** termination. After calling PR_DeleteSharedMemory() any further use
** of the shared memory associated with the name may cause
** unpredictable results.
**
** Files:
** The name passed to PR_OpenSharedMemory() should be a valid filename
** for a unix platform. PR_OpenSharedMemory() creates file using the
** name passed in. Some platforms may mangle the name before creating
** the file and the shared memory.
**
** The unix implementation may use SysV IPC shared memory, Posix
** shared memory, or memory mapped files; the filename may used to
** define the namespace. On Windows, the name is significant, but
** there is no file associated with name.
**
** No assumptions about the persistence of data in the named file
** should be made. Depending on platform, the shared memory may be
** mapped onto system paging space and be discarded at process
** termination.
**
** All names provided to PR_OpenSharedMemory() should be valid
** filename syntax or name syntax for shared memory for the target
** platform. Referenced directories should have permissions
** appropriate for writing.
**
** Limits:
** Different platforms have limits on both the number and size of
** shared memory resources. The default system limits on some
** platforms may be smaller than your requirements. These limits may
** be adjusted on some platforms either via boot-time options or by
** setting the size of the system paging space to accomodate more
** and/or larger shared memory segment(s).
**
** Security:
** On unix platforms, depending on implementation, contents of the
** backing store for the shared memory can be exposed via the file
** system. Set permissions and or access controls at create and attach
** time to ensure you get the desired security.
**
** On windows platforms, no special security measures are provided.
**
** Example:
** The test case pr/tests/nameshm1.c provides an example of use as
** well as testing the operation of NSPR's Named Shared Memory.
**
** lth. 18-Aug-1999.
*/
#ifndef prshm_h___
#define prshm_h___
#include "prtypes.h"
#include "prio.h"
PR_BEGIN_EXTERN_C
/*
** Declare opaque type PRSharedMemory.
*/
typedef struct PRSharedMemory PRSharedMemory;
/*
** FUNCTION: PR_OpenSharedMemory()
**
** DESCRIPTION:
** PR_OpenSharedMemory() creates a new shared-memory segment or
** associates a previously created memory segment with name.
**
** When parameter create is (PR_SHM_EXCL | PR_SHM_CREATE) and the
** shared memory already exists, the function returns NULL with the
** error set to PR_FILE_EXISTS_ERROR.
**
** When parameter create is PR_SHM_CREATE and the shared memory
** already exists, a handle to that memory segment is returned. If
** the segment does not exist, it is created and a pointer to the
** related PRSharedMemory structure is returned.
**
** When parameter create is 0, and the shared memory exists, a
** pointer to a PRSharedMemory is returned. If the shared memory does
** not exist, NULL is returned with the error set to
** PR_FILE_NOT_FOUND_ERROR.
**
** INPUTS:
** name -- the name the shared-memory segment is known as.
** size -- the size of the shared memory segment.
** flags -- Options for creating the shared memory
** mode -- Same as is passed to PR_Open()
**
** OUTPUTS:
** The shared memory is allocated.
**
** RETURNS: Pointer to opaque structure PRSharedMemory or NULL.
** NULL is returned on error. The reason for the error can be
** retrieved via PR_GetError() and PR_GetOSError();
**
*/
NSPR_API( PRSharedMemory * )
PR_OpenSharedMemory(
const char *name,
PRSize size,
PRIntn flags,
PRIntn mode
);
/* Define values for PR_OpenShareMemory(...,create) */
#define PR_SHM_CREATE 0x1 /* create if not exist */
#define PR_SHM_EXCL 0x2 /* fail if already exists */
/*
** FUNCTION: PR_AttachSharedMemory()
**
** DESCRIPTION:
** PR_AttachSharedMemory() maps the shared-memory described by
** shm to the current process.
**
** INPUTS:
** shm -- The handle returned from PR_OpenSharedMemory().
** flags -- options for mapping the shared memory.
** PR_SHM_READONLY causes the memory to be attached
** read-only.
**
** OUTPUTS:
** On success, the shared memory segment represented by shm is mapped
** into the process' address space.
**
** RETURNS: Address where shared memory is mapped, or NULL.
** NULL is returned on error. The reason for the error can be
** retrieved via PR_GetError() and PR_GetOSError();
**
**
*/
NSPR_API( void * )
PR_AttachSharedMemory(
PRSharedMemory *shm,
PRIntn flags
);
/* Define values for PR_AttachSharedMemory(...,flags) */
#define PR_SHM_READONLY 0x01
/*
** FUNCTION: PR_DetachSharedMemory()
**
** DESCRIPTION:
** PR_DetachSharedMemory() detaches the shared-memory described
** by shm.
**
** INPUTS:
** shm -- The handle returned from PR_OpenSharedMemory().
** addr -- The address at which the memory was attached.
**
** OUTPUTS:
** The shared memory mapped to an address via a previous call to
** PR_AttachSharedMemory() is unmapped.
**
** RETURNS: PRStatus
**
*/
NSPR_API( PRStatus )
PR_DetachSharedMemory(
PRSharedMemory *shm,
void *addr
);
/*
** FUNCTION: PR_CloseSharedMemory()
**
** DESCRIPTION:
** PR_CloseSharedMemory() closes the shared-memory described by
** shm.
**
** INPUTS:
** shm -- The handle returned from PR_OpenSharedMemory().
**
** OUTPUTS:
** the shared memory represented by shm is closed
**
** RETURNS: PRStatus
**
*/
NSPR_API( PRStatus )
PR_CloseSharedMemory(
PRSharedMemory *shm
);
/*
** FUNCTION: PR_DeleteSharedMemory()
**
** DESCRIPTION:
** The shared memory resource represented by name is released.
**
** INPUTS:
** name -- the name the shared-memory segment
**
** OUTPUTS:
** depending on platform, resources may be returned to the underlying
** operating system.
**
** RETURNS: PRStatus
**
*/
NSPR_API( PRStatus )
PR_DeleteSharedMemory(
const char *name
);
PR_END_EXTERN_C
#endif /* prshm_h___ */

View File

@@ -0,0 +1,239 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** prshma.h -- NSPR Anonymous Shared Memory
**
** NSPR provides an anonymous shared memory based on NSPR's PRFileMap
** type. The anonymous file-mapped shared memory provides an inheritable
** shared memory, as in: the child process inherits the shared memory.
** Compare the file-mapped anonymous shared memory to to a named shared
** memory described in prshm.h. The intent is to provide a shared
** memory that is accessable only by parent and child processes. ...
** It's a security thing.
**
** Depending on the underlying platform, the file-mapped shared memory
** may be backed by a file. ... surprise! ... On some platforms, no
** real file backs the shared memory. On platforms where the shared
** memory is backed by a file, the file's name in the filesystem is
** visible to other processes for only the duration of the creation of
** the file, hopefully a very short time. This restricts processess
** that do not inherit the shared memory from opening the file and
** reading or writing its contents. Further, when all processes
** using an anonymous shared memory terminate, the backing file is
** deleted. ... If you are not paranoid, you're not paying attention.
**
** The file-mapped shared memory requires a protocol for the parent
** process and child process to share the memory. NSPR provides two
** protocols. Use one or the other; don't mix and match.
**
** In the first protocol, the job of passing the inheritable shared
** memory is done via helper-functions with PR_CreateProcess(). In the
** second protocol, the parent process is responsible for creating the
** child process; the parent and child are mutually responsible for
** passing a FileMap string. NSPR provides helper functions for
** extracting data from the PRFileMap object. ... See the examples
** below.
**
** Both sides should adhere strictly to the protocol for proper
** operation. The pseudo-code below shows the use of a file-mapped
** shared memory by a parent and child processes. In the examples, the
** server creates the file-mapped shared memory, the client attaches to
** it.
**
** First protocol.
** Server:
**
** fm = PR_OpenAnonFileMap(dirName, size, FilemapProt);
** addr = PR_MemMap(fm);
** attr = PR_NewProcessAttr();
** PR_ProcessAttrSetInheritableFileMap( attr, fm, shmname );
** PR_CreateProcess(Client);
** PR_DestroyProcessAttr(attr);
** ... yadda ...
** PR_MemUnmap( addr );
** PR_CloseFileMap(fm);
**
**
** Client:
** ... started by server via PR_CreateProcess()
** fm = PR_GetInheritedFileMap( shmname );
** addr = PR_MemMap(fm);
** ... yadda ...
** PR_MemUnmap(addr);
** PR_CloseFileMap(fm);
**
**
** Second Protocol:
** Server:
**
** fm = PR_OpenAnonFileMap(dirName, size, FilemapProt);
** fmstring = PR_ExportFileMapAsString( fm );
** addr = PR_MemMap(fm);
** ... application specific technique to pass fmstring to child
** ... yadda ... Server uses his own magic to create child
** PR_MemUnmap( addr );
** PR_CloseFileMap(fm);
**
**
** Client:
** ... started by server via his own magic
** ... application specific technique to find fmstring from parent
** fm = PR_ImportFileMapFromString( fmstring )
** addr = PR_MemMap(fm);
** ... yadda ...
** PR_MemUnmap(addr);
** PR_CloseFileMap(fm);
**
**
** lth. 2-Jul-1999.
**
** Note: The second protocol was requested by NelsonB (7/1999); this is
** to accomodate servers which already create their own child processes
** using platform native methods.
**
*/
#ifndef prshma_h___
#define prshma_h___
#include "prtypes.h"
#include "prio.h"
#include "prproces.h"
PR_BEGIN_EXTERN_C
/*
** PR_OpenAnonFileMap() -- Creates an anonymous file-mapped shared memory
**
** Description:
** PR_OpenAnonFileMap() creates an anonymous shared memory. If the
** shared memory already exists, a handle is returned to that shared
** memory object.
**
** On Unix platforms, PR_OpenAnonFileMap() uses 'dirName' as a
** directory name, without the trailing '/', to contain the anonymous
** file. A filename is generated for the name.
**
** On Windows platforms, dirName is ignored.
**
** Inputs:
** dirName -- A directory name to contain the anonymous file.
** size -- The size of the shared memory
** prot -- How the shared memory is mapped. See prio.h
**
** Outputs:
** PRFileMap *
**
** Returns:
** Pointer to PRFileMap or NULL on error.
**
*/
NSPR_API( PRFileMap *)
PR_OpenAnonFileMap(
const char *dirName,
PRSize size,
PRFileMapProtect prot
);
/*
** PR_ProcessAttrSetInheritableFileMap() -- Prepare FileMap for export
** to my children processes via PR_CreateProcess()
**
** Description:
** PR_ProcessAttrSetInheritableFileMap() connects the PRFileMap to
** PRProcessAttr with shmname. A subsequent call to PR_CreateProcess()
** makes the PRFileMap importable by the child process.
**
** Inputs:
** attr -- PRProcessAttr, used to pass data to PR_CreateProcess()
** fm -- PRFileMap structure to be passed to the child process
** shmname -- The name for the PRFileMap; used by child.
**
** Outputs:
** PRFileMap *
**
** Returns:
** PRStatus
**
*/
NSPR_API(PRStatus)
PR_ProcessAttrSetInheritableFileMap(
PRProcessAttr *attr,
PRFileMap *fm,
const char *shmname
);
/*
** PR_GetInheritedFileMap() -- Import a PRFileMap previously exported
** by my parent process via PR_CreateProcess()
**
** Description:
** PR_GetInheritedFileMap() retrieves a PRFileMap object exported from
** its parent process via PR_CreateProcess().
**
** Inputs:
** shmname -- The name provided to PR_ProcessAttrSetInheritableFileMap()
**
** Outputs:
** PRFileMap *
**
** Returns:
** PRFileMap pointer or NULL.
**
*/
NSPR_API( PRFileMap *)
PR_GetInheritedFileMap(
const char *shmname
);
/*
** PR_ExportFileMapAsString() -- Creates a string identifying a PRFileMap
**
** Description:
** Creates an identifier, as a string, from a PRFileMap object
** previously created with PR_OpenAnonFileMap().
**
** Inputs:
** fm -- PRFileMap pointer to be represented as a string.
** bufsize -- sizeof(buf)
** buf -- a buffer of length PR_FILEMAP_STRING_BUFSIZE
**
** Outputs:
** buf contains the stringized PRFileMap identifier
**
** Returns:
** PRStatus
**
*/
NSPR_API( PRStatus )
PR_ExportFileMapAsString(
PRFileMap *fm,
PRSize bufsize,
char *buf
);
#define PR_FILEMAP_STRING_BUFSIZE 128
/*
** PR_ImportFileMapFromString() -- Creates a PRFileMap from the identifying string
**
** Description:
** PR_ImportFileMapFromString() creates a PRFileMap object from a
** string previously created by PR_ExportFileMapAsString().
**
** Inputs:
** fmstring -- string created by PR_ExportFileMapAsString()
**
** Returns:
** PRFileMap pointer or NULL.
**
*/
NSPR_API( PRFileMap * )
PR_ImportFileMapFromString(
const char *fmstring
);
PR_END_EXTERN_C
#endif /* prshma_h___ */

View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prsystem_h___
#define prsystem_h___
/*
** API to NSPR functions returning system info.
*/
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/*
** Get the host' directory separator.
** Pathnames are then assumed to be of the form:
** [<sep><root_component><sep>]*(<component><sep>)<leaf_name>
*/
NSPR_API(char) PR_GetDirectorySeparator(void);
/*
** OBSOLETE -- the function name is misspelled.
** Use PR_GetDirectorySeparator instead.
*/
NSPR_API(char) PR_GetDirectorySepartor(void);
/*
** Get the host' path separator.
** Paths are assumed to be of the form:
** <directory>[<sep><directory>]*
*/
NSPR_API(char) PR_GetPathSeparator(void);
/* Types of information available via PR_GetSystemInfo(...) */
typedef enum {
PR_SI_HOSTNAME, /* the hostname with the domain name (if any)
* removed */
PR_SI_SYSNAME,
PR_SI_RELEASE,
PR_SI_ARCHITECTURE,
PR_SI_HOSTNAME_UNTRUNCATED /* the hostname exactly as configured
* on the system */
} PRSysInfo;
/*
** If successful returns a null termintated string in 'buf' for
** the information indicated in 'cmd'. If unseccussful the reason for
** the failure can be retrieved from PR_GetError().
**
** The buffer is allocated by the caller and should be at least
** SYS_INFO_BUFFER_LENGTH bytes in length.
*/
#define SYS_INFO_BUFFER_LENGTH 256
NSPR_API(PRStatus) PR_GetSystemInfo(PRSysInfo cmd, char *buf, PRUint32 buflen);
/*
** Return the number of bytes in a page
*/
NSPR_API(PRInt32) PR_GetPageSize(void);
/*
** Return log2 of the size of a page
*/
NSPR_API(PRInt32) PR_GetPageShift(void);
/*
** PR_GetNumberOfProcessors() -- returns the number of CPUs
**
** Description:
** PR_GetNumberOfProcessors() extracts the number of processors
** (CPUs available in an SMP system) and returns the number.
**
** Parameters:
** none
**
** Returns:
** The number of available processors or -1 on error
**
*/
NSPR_API(PRInt32) PR_GetNumberOfProcessors( void );
/*
** PR_GetPhysicalMemorySize() -- returns the amount of system RAM
**
** Description:
** PR_GetPhysicalMemorySize() determines the amount of physical RAM
** in the system and returns the size in bytes.
**
** Parameters:
** none
**
** Returns:
** The amount of system RAM, or 0 on failure.
**
*/
NSPR_API(PRUint64) PR_GetPhysicalMemorySize(void);
PR_END_EXTERN_C
#endif /* prsystem_h___ */

View File

@@ -0,0 +1,272 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prthread_h___
#define prthread_h___
/*
** API for NSPR threads. On some architectures (Mac OS Classic
** notably) pre-emptibility is not guaranteed. Hard priority scheduling
** is not guaranteed, so programming using priority based synchronization
** is a no-no.
**
** NSPR threads are scheduled based loosely on their client set priority.
** In general, a thread of a higher priority has a statistically better
** chance of running relative to threads of lower priority. However,
** NSPR uses multiple strategies to provide execution vehicles for thread
** abstraction of various host platforms. As it turns out, there is little
** NSPR can do to affect the scheduling attributes of "GLOBAL" threads.
** However, a semblance of GLOBAL threads is used to implement "LOCAL"
** threads. An arbitrary number of such LOCAL threads can be assigned to
** a single GLOBAL thread.
**
** For scheduling, NSPR will attempt to run the highest priority LOCAL
** thread associated with a given GLOBAL thread. It is further assumed
** that the host OS will apply some form of "fair" scheduling on the
** GLOBAL threads.
**
** Threads have a "system flag" which when set indicates the thread
** doesn't count for determining when the process should exit (the
** process exits when the last user thread exits).
**
** Threads also have a "scope flag" which controls whether the threads
** are scheduled in the local scope or scheduled by the OS globally. This
** indicates whether a thread is permanently bound to a native OS thread.
** An unbound thread competes for scheduling resources in the same process.
**
** Another flag is "state flag" which control whether the thread is joinable.
** It allows other threads to wait for the created thread to reach completion.
**
** Threads can have "per-thread-data" attached to them. Each thread has a
** per-thread error number and error string which are updated when NSPR
** operations fail.
*/
#include "prtypes.h"
#include "prinrval.h"
PR_BEGIN_EXTERN_C
typedef struct PRThread PRThread;
typedef struct PRThreadStack PRThreadStack;
typedef enum PRThreadType {
PR_USER_THREAD,
PR_SYSTEM_THREAD
} PRThreadType;
typedef enum PRThreadScope {
PR_LOCAL_THREAD,
PR_GLOBAL_THREAD,
PR_GLOBAL_BOUND_THREAD
} PRThreadScope;
typedef enum PRThreadState {
PR_JOINABLE_THREAD,
PR_UNJOINABLE_THREAD
} PRThreadState;
typedef enum PRThreadPriority
{
PR_PRIORITY_FIRST = 0, /* just a placeholder */
PR_PRIORITY_LOW = 0, /* the lowest possible priority */
PR_PRIORITY_NORMAL = 1, /* most common expected priority */
PR_PRIORITY_HIGH = 2, /* slightly more aggressive scheduling */
PR_PRIORITY_URGENT = 3, /* it does little good to have more than one */
PR_PRIORITY_LAST = 3 /* this is just a placeholder */
} PRThreadPriority;
/*
** Create a new thread:
** "type" is the type of thread to create
** "start(arg)" will be invoked as the threads "main"
** "priority" will be created thread's priority
** "scope" will specify whether the thread is local or global
** "state" will specify whether the thread is joinable or not
** "stackSize" the size of the stack, in bytes. The value can be zero
** and then a machine specific stack size will be chosen.
**
** This can return NULL if some kind of error occurs, such as if memory is
** tight.
**
** If you want the thread to start up waiting for the creator to do
** something, enter a lock before creating the thread and then have the
** threads start routine enter and exit the same lock. When you are ready
** for the thread to run, exit the lock.
**
** If you want to detect the completion of the created thread, the thread
** should be created joinable. Then, use PR_JoinThread to synchrnoize the
** termination of another thread.
**
** When the start function returns the thread exits. If it is the last
** PR_USER_THREAD to exit then the process exits.
*/
NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
void (PR_CALLBACK *start)(void *arg),
void *arg,
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize);
/*
** Wait for thread termination:
** "thread" is the target thread
**
** This can return PR_FAILURE if no joinable thread could be found
** corresponding to the specified target thread.
**
** The calling thread is blocked until the target thread completes.
** Several threads cannot wait for the same thread to complete; one thread
** will operate successfully and others will terminate with an error PR_FAILURE.
** The calling thread will not be blocked if the target thread has already
** terminated.
*/
NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
/*
** Return the current thread object for the currently running code.
** Never returns NULL.
*/
NSPR_API(PRThread*) PR_GetCurrentThread(void);
#ifndef NO_NSPR_10_SUPPORT
#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
#endif /* NO_NSPR_10_SUPPORT */
/*
** Get the priority of "thread".
*/
NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
/*
** Change the priority of the "thread" to "priority".
**
** PR_SetThreadPriority works in a best-effort manner. On some platforms a
** special privilege, such as root access, is required to change thread
** priorities, especially to raise thread priorities. If the caller doesn't
** have enough privileges to change thread priorites, the function has no
** effect except causing a future PR_GetThreadPriority call to return
** |priority|.
*/
NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
/*
** Set the name of the current thread, which will be visible in a debugger
** and accessible via a call to PR_GetThreadName().
*/
NSPR_API(PRStatus) PR_SetCurrentThreadName(const char *name);
/*
** Return the name of "thread", if set. Otherwise return NULL.
*/
NSPR_API(const char *) PR_GetThreadName(const PRThread *thread);
/*
** This routine returns a new index for per-thread-private data table.
** The index is visible to all threads within a process. This index can
** be used with the PR_SetThreadPrivate() and PR_GetThreadPrivate() routines
** to save and retrieve data associated with the index for a thread.
**
** Each index is associationed with a destructor function ('dtor'). The function
** may be specified as NULL when the index is created. If it is not NULL, the
** function will be called when:
** - the thread exits and the private data for the associated index
** is not NULL,
** - new thread private data is set and the current private data is
** not NULL.
**
** The index independently maintains specific values for each binding thread.
** A thread can only get access to its own thread-specific-data.
**
** Upon a new index return the value associated with the index for all threads
** is NULL, and upon thread creation the value associated with all indices for
** that thread is NULL.
**
** Returns PR_FAILURE if the total number of indices will exceed the maximun
** allowed.
*/
typedef void (PR_CALLBACK *PRThreadPrivateDTOR)(void *priv);
NSPR_API(PRStatus) PR_NewThreadPrivateIndex(
PRUintn *newIndex, PRThreadPrivateDTOR destructor);
/*
** Define some per-thread-private data.
** "tpdIndex" is an index into the per-thread private data table
** "priv" is the per-thread-private data
**
** If the per-thread private data table has a previously registered
** destructor function and a non-NULL per-thread-private data value,
** the destructor function is invoked.
**
** This can return PR_FAILURE if the index is invalid.
*/
NSPR_API(PRStatus) PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);
/*
** Recover the per-thread-private data for the current thread. "tpdIndex" is
** the index into the per-thread private data table.
**
** The returned value may be NULL which is indistinguishable from an error
** condition.
**
** A thread can only get access to its own thread-specific-data.
*/
NSPR_API(void*) PR_GetThreadPrivate(PRUintn tpdIndex);
/*
** This routine sets the interrupt request for a target thread. The interrupt
** request remains in the thread's state until it is delivered exactly once
** or explicitly canceled.
**
** A thread that has been interrupted will fail all NSPR blocking operations
** that return a PRStatus (I/O, waiting on a condition, etc).
**
** PR_Interrupt may itself fail if the target thread is invalid.
*/
NSPR_API(PRStatus) PR_Interrupt(PRThread *thread);
/*
** Clear the interrupt request for the calling thread. If no such request
** is pending, this operation is a noop.
*/
NSPR_API(void) PR_ClearInterrupt(void);
/*
** Block the interrupt for the calling thread.
*/
NSPR_API(void) PR_BlockInterrupt(void);
/*
** Unblock the interrupt for the calling thread.
*/
NSPR_API(void) PR_UnblockInterrupt(void);
/*
** Make the current thread sleep until "ticks" time amount of time
** has expired. If "ticks" is PR_INTERVAL_NO_WAIT then the call is
** equivalent to calling PR_Yield. Calling PR_Sleep with an argument
** equivalent to PR_INTERVAL_NO_TIMEOUT is an error and will result
** in a PR_FAILURE error return.
*/
NSPR_API(PRStatus) PR_Sleep(PRIntervalTime ticks);
/*
** Get the scoping of this thread.
*/
NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
/*
** Get the type of this thread.
*/
NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
/*
** Get the join state of this thread.
*/
NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
PR_END_EXTERN_C
#endif /* prthread_h___ */

View File

@@ -0,0 +1,262 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
*----------------------------------------------------------------------
*
* prtime.h --
*
* NSPR date and time functions
*
*-----------------------------------------------------------------------
*/
#ifndef prtime_h___
#define prtime_h___
#include "prlong.h"
PR_BEGIN_EXTERN_C
/**********************************************************************/
/************************* TYPES AND CONSTANTS ************************/
/**********************************************************************/
#define PR_MSEC_PER_SEC 1000L
#define PR_USEC_PER_SEC 1000000L
#define PR_NSEC_PER_SEC 1000000000L
#define PR_USEC_PER_MSEC 1000L
#define PR_NSEC_PER_MSEC 1000000L
/*
* PRTime --
*
* NSPR represents basic time as 64-bit signed integers relative
* to midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
* (GMT is also known as Coordinated Universal Time, UTC.)
* The units of time are in microseconds. Negative times are allowed
* to represent times prior to the January 1970 epoch. Such values are
* intended to be exported to other systems or converted to human
* readable form.
*
* Notes on porting: PRTime corresponds to time_t in ANSI C. NSPR 1.0
* simply uses PRInt64.
*/
typedef PRInt64 PRTime;
/*
* Time zone and daylight saving time corrections applied to GMT to
* obtain the local time of some geographic location
*/
typedef struct PRTimeParameters {
PRInt32 tp_gmt_offset; /* the offset from GMT in seconds */
PRInt32 tp_dst_offset; /* contribution of DST in seconds */
} PRTimeParameters;
/*
* PRExplodedTime --
*
* Time broken down into human-readable components such as year, month,
* day, hour, minute, second, and microsecond. Time zone and daylight
* saving time corrections may be applied. If they are applied, the
* offsets from the GMT must be saved in the 'tm_params' field so that
* all the information is available to reconstruct GMT.
*
* Notes on porting: PRExplodedTime corrresponds to struct tm in
* ANSI C, with the following differences:
* - an additional field tm_usec;
* - replacing tm_isdst by tm_params;
* - the month field is spelled tm_month, not tm_mon;
* - we use absolute year, AD, not the year since 1900.
* The corresponding type in NSPR 1.0 is called PRTime. Below is
* a table of date/time type correspondence in the three APIs:
* API time since epoch time in components
* ANSI C time_t struct tm
* NSPR 1.0 PRInt64 PRTime
* NSPR 2.0 PRTime PRExplodedTime
*/
typedef struct PRExplodedTime {
PRInt32 tm_usec; /* microseconds past tm_sec (0-99999) */
PRInt32 tm_sec; /* seconds past tm_min (0-61, accomodating
up to two leap seconds) */
PRInt32 tm_min; /* minutes past tm_hour (0-59) */
PRInt32 tm_hour; /* hours past tm_day (0-23) */
PRInt32 tm_mday; /* days past tm_mon (1-31, note that it
starts from 1) */
PRInt32 tm_month; /* months past tm_year (0-11, Jan = 0) */
PRInt16 tm_year; /* absolute year, AD (note that we do not
count from 1900) */
PRInt8 tm_wday; /* calculated day of the week
(0-6, Sun = 0) */
PRInt16 tm_yday; /* calculated day of the year
(0-365, Jan 1 = 0) */
PRTimeParameters tm_params; /* time parameters used by conversion */
} PRExplodedTime;
/*
* PRTimeParamFn --
*
* A function of PRTimeParamFn type returns the time zone and
* daylight saving time corrections for some geographic location,
* given the current time in GMT. The input argument gmt should
* point to a PRExplodedTime that is in GMT, i.e., whose
* tm_params contains all 0's.
*
* For any time zone other than GMT, the computation is intended to
* consist of two steps:
* - Figure out the time zone correction, tp_gmt_offset. This number
* usually depends on the geographic location only. But it may
* also depend on the current time. For example, all of China
* is one time zone right now. But this situation may change
* in the future.
* - Figure out the daylight saving time correction, tp_dst_offset.
* This number depends on both the geographic location and the
* current time. Most of the DST rules are expressed in local
* current time. If so, one should apply the time zone correction
* to GMT before applying the DST rules.
*/
typedef PRTimeParameters (PR_CALLBACK *PRTimeParamFn)(const PRExplodedTime *gmt);
/**********************************************************************/
/****************************** FUNCTIONS *****************************/
/**********************************************************************/
/*
* The PR_Now routine returns the current time relative to the
* epoch, midnight, January 1, 1970 UTC. The units of the returned
* value are microseconds since the epoch.
*
* The values returned are not guaranteed to advance in a linear fashion
* due to the application of time correction protocols which synchronize
* computer clocks to some external time source. Consequently it should
* not be depended on for interval timing.
*
* The implementation is machine dependent.
* Cf. time_t time(time_t *tp) in ANSI C.
*/
NSPR_API(PRTime)
PR_Now(void);
/*
* Expand time binding it to time parameters provided by PRTimeParamFn.
* The calculation is envisoned to proceed in the following steps:
* - From given PRTime, calculate PRExplodedTime in GMT
* - Apply the given PRTimeParamFn to the GMT that we just calculated
* to obtain PRTimeParameters.
* - Add the PRTimeParameters offsets to GMT to get the local time
* as PRExplodedTime.
*/
NSPR_API(void) PR_ExplodeTime(
PRTime usecs, PRTimeParamFn params, PRExplodedTime *exploded);
/* Reverse operation of PR_ExplodeTime */
NSPR_API(PRTime)
PR_ImplodeTime(const PRExplodedTime *exploded);
/*
* Adjust exploded time to normalize field overflows after manipulation.
* Note that the following fields of PRExplodedTime should not be
* manipulated:
* - tm_month and tm_year: because the number of days in a month and
* number of days in a year are not constant, it is ambiguous to
* manipulate the month and year fields, although one may be tempted
* to. For example, what does "a month from January 31st" mean?
* - tm_wday and tm_yday: these fields are calculated by NSPR. Users
* should treat them as "read-only".
*/
NSPR_API(void) PR_NormalizeTime(
PRExplodedTime *exploded, PRTimeParamFn params);
/**********************************************************************/
/*********************** TIME PARAMETER FUNCTIONS *********************/
/**********************************************************************/
/* Time parameters that suit current host machine */
NSPR_API(PRTimeParameters) PR_LocalTimeParameters(const PRExplodedTime *gmt);
/* Time parameters that represent Greenwich Mean Time */
NSPR_API(PRTimeParameters) PR_GMTParameters(const PRExplodedTime *gmt);
/*
* Time parameters that represent the US Pacific Time Zone, with the
* current daylight saving time rules (for testing only)
*/
NSPR_API(PRTimeParameters) PR_USPacificTimeParameters(const PRExplodedTime *gmt);
/*
* This parses a time/date string into a PRExplodedTime
* struct. It populates all fields but it can't split
* the offset from UTC into tp_gmt_offset and tp_dst_offset in
* most cases (exceptions: PST/PDT, MST/MDT, CST/CDT, EST/EDT, GMT/BST).
* In those cases tp_gmt_offset will be the sum of these two and
* tp_dst_offset will be 0.
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*
* Many formats are handled, including:
*
* 14 Apr 89 03:20:12
* 14 Apr 89 03:20 GMT
* Fri, 17 Mar 89 4:01:33
* Fri, 17 Mar 89 4:01 GMT
* Mon Jan 16 16:12 PDT 1989
* Mon Jan 16 16:12 +0130 1989
* 6 May 1992 16:41-JST (Wednesday)
* 22-AUG-1993 10:59:12.82
* 22-AUG-1993 10:59pm
* 22-AUG-1993 12:59am
* 22-AUG-1993 12:59 PM
* Friday, August 04, 1995 3:54 PM
* 06/21/95 04:24:34 PM
* 20/06/95 21:07
* 95-06-08 19:32:48 EDT
*
* If the input string doesn't contain a description of the timezone,
* we consult the `default_to_gmt' to decide whether the string should
* be interpreted relative to the local time zone (PR_FALSE) or GMT (PR_TRUE).
* The correct value for this argument depends on what standard specified
* the time string which you are parsing.
*/
NSPR_API(PRStatus) PR_ParseTimeStringToExplodedTime (
const char *string,
PRBool default_to_gmt,
PRExplodedTime *result);
/*
* This uses PR_ParseTimeStringToExplodedTime to parse
* a time/date string and PR_ImplodeTime to transform it into
* a PRTime (microseconds after "1-Jan-1970 00:00:00 GMT").
* It returns PR_SUCCESS on success, and PR_FAILURE
* if the time/date string can't be parsed.
*/
NSPR_API(PRStatus) PR_ParseTimeString (
const char *string,
PRBool default_to_gmt,
PRTime *result);
/* Format a time value into a buffer. Same semantics as strftime() */
NSPR_API(PRUint32) PR_FormatTime(char *buf, int buflen, const char *fmt,
const PRExplodedTime *time);
/* Format a time value into a buffer. Time is always in US English format,
* regardless of locale setting.
*/
NSPR_API(PRUint32)
PR_FormatTimeUSEnglish(char *buf, PRUint32 bufSize,
const char *format, const PRExplodedTime *time);
PR_END_EXTERN_C
#endif /* prtime_h___ */

View File

@@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prtpool_h___
#define prtpool_h___
#include "prtypes.h"
#include "prthread.h"
#include "prio.h"
#include "prerror.h"
/*
* NOTE:
* THIS API IS A PRELIMINARY VERSION IN NSPR 4.0 AND IS SUBJECT TO
* CHANGE
*/
PR_BEGIN_EXTERN_C
typedef struct PRJobIoDesc {
PRFileDesc *socket;
PRErrorCode error;
PRIntervalTime timeout;
} PRJobIoDesc;
typedef struct PRThreadPool PRThreadPool;
typedef struct PRJob PRJob;
typedef void (PR_CALLBACK *PRJobFn) (void *arg);
/* Create thread pool */
NSPR_API(PRThreadPool *)
PR_CreateThreadPool(PRInt32 initial_threads, PRInt32 max_threads,
PRUint32 stacksize);
/* queue a job */
NSPR_API(PRJob *)
PR_QueueJob(PRThreadPool *tpool, PRJobFn fn, void *arg, PRBool joinable);
/* queue a job, when a socket is readable */
NSPR_API(PRJob *)
PR_QueueJob_Read(PRThreadPool *tpool, PRJobIoDesc *iod,
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a socket is writeable */
NSPR_API(PRJob *)
PR_QueueJob_Write(PRThreadPool *tpool, PRJobIoDesc *iod,
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a socket has a pending connection */
NSPR_API(PRJob *)
PR_QueueJob_Accept(PRThreadPool *tpool, PRJobIoDesc *iod,
PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when the socket connection to addr succeeds or fails */
NSPR_API(PRJob *)
PR_QueueJob_Connect(PRThreadPool *tpool, PRJobIoDesc *iod,
const PRNetAddr *addr, PRJobFn fn, void * arg, PRBool joinable);
/* queue a job, when a timer exipres */
NSPR_API(PRJob *)
PR_QueueJob_Timer(PRThreadPool *tpool, PRIntervalTime timeout,
PRJobFn fn, void * arg, PRBool joinable);
/* cancel a job */
NSPR_API(PRStatus)
PR_CancelJob(PRJob *job);
/* join a job */
NSPR_API(PRStatus)
PR_JoinJob(PRJob *job);
/* shutdown pool */
NSPR_API(PRStatus)
PR_ShutdownThreadPool(PRThreadPool *tpool);
/* join pool, wait for exit of all threads */
NSPR_API(PRStatus)
PR_JoinThreadPool(PRThreadPool *tpool);
PR_END_EXTERN_C
#endif /* prtpool_h___ */

View File

@@ -0,0 +1,646 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prtrace_h___
#define prtrace_h___
/*
** prtrace.h -- NSPR's Trace Facility.
**
** The Trace Facility provides a means to trace application
** program events within a process. When implementing an
** application program an engineer may insert a "Trace" function
** call, passing arguments to be traced. The "Trace" function
** combines the user trace data with identifying data and
** writes this data in time ordered sequence into a circular
** in-memory buffer; when the buffer fills, it wraps.
**
** Functions are provided to set and/or re-configure the size of
** the trace buffer, control what events are recorded in the
** buffer, enable and disable tracing based on specific user
** supplied data and other control functions. Methods are provided
** to record the trace entries in the in-memory trace buffer to
** a file.
**
** Tracing may cause a performance degredation to the application
** depending on the number and placement of calls to the tracing
** facility. When tracing is compiled in and all tracing is
** disabled via the runtime controls, the overhead should be
** minimal. ... Famous last words, eh?
**
** When DEBUG is defined at compile time, the Trace Facility is
** compiled as part of NSPR and any application using NSPR's
** header files will have tracing compiled in. When DEBUG is not
** defined, the Trace Facility is not compiled into NSPR nor
** exported in its header files. If the Trace Facility is
** desired in a non-debug build, then FORCE_NSPR_TRACE may be
** defined at compile time for both the optimized build of NSPR
** and the application. NSPR and any application using NSPR's
** Trace Facility must be compiled with the same level of trace
** conditioning or unresolved references may be realized at link
** time.
**
** For any of the Trace Facility methods that requires a trace
** handle as an input argument, the caller must ensure that the
** trace handle argument is valid. An invalid trace handle
** argument may cause unpredictable results.
**
** Trace Facility methods are thread-safe and SMP safe.
**
** Users of the Trace Facility should use the defined macros to
** invoke trace methods, not the function calls directly. e.g.
** PR_TRACE( h1,0,1,2, ...); not PR_Trace(h1,0,1,2, ...);
**
** Application designers should be aware of the effects of
** debug and optimized build differences when using result of the
** Trace Facility macros in expressions.
**
** See Also: prcountr.h
**
** /lth. 08-Jun-1998.
*/
#include "prtypes.h"
#include "prthread.h"
#include "prtime.h"
PR_BEGIN_EXTERN_C
/*
** Opaque type for the trace handle
** ... Don't even think about looking in here.
**
*/
typedef void * PRTraceHandle;
/*
** PRTraceEntry -- A trace entry in the in-memory trace buffer
** looks like this.
**
*/
typedef struct PRTraceEntry
{
PRThread *thread; /* The thread creating the trace entry */
PRTraceHandle handle; /* PRTraceHandle creating the trace entry */
PRTime time; /* Value of PR_Now() at time of trace entry */
PRUint32 userData[8]; /* user supplied trace data */
} PRTraceEntry;
/*
** PRTraceOption -- command operands to
** PR_[Set|Get]TraceOption(). See descriptive meanings there.
**
*/
typedef enum PRTraceOption
{
PRTraceBufSize,
PRTraceEnable,
PRTraceDisable,
PRTraceSuspend,
PRTraceResume,
PRTraceSuspendRecording,
PRTraceResumeRecording,
PRTraceLockHandles,
PRTraceUnLockHandles,
PRTraceStopRecording
} PRTraceOption;
/* -----------------------------------------------------------------------
** FUNCTION: PR_DEFINE_TRACE() -- Define a PRTraceHandle
**
** DESCRIPTION: PR_DEFINE_TRACE() is used to define a trace
** handle.
**
*/
#define PR_DEFINE_TRACE(name) PRTraceHandle name
/* -----------------------------------------------------------------------
** FUNCTION: PR_INIT_TRACE_HANDLE() -- Set the value of a PRTraceHandle
**
** DESCRIPTION:
** PR_INIT_TRACE_HANDLE() sets the value of a PRTraceHandle
** to value. e.g. PR_INIT_TRACE_HANDLE( myHandle, NULL );
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_INIT_TRACE_HANDLE(handle,value)\
(handle) = (PRCounterHandle)(value)
#else
#define PR_INIT_TRACE_HANDLE(handle,value)
#endif
/* -----------------------------------------------------------------------
** FUNCTION: PR_CreateTrace() -- Create a trace handle
**
** DESCRIPTION:
** PR_CreateTrace() creates a new trace handle. Tracing is
** enabled for this handle when it is created. The trace handle
** is intended for use in other Trace Facility calls.
**
** PR_CreateTrace() registers the QName, RName and description
** data so that this data can be retrieved later.
**
** INPUTS:
** qName: pointer to string. QName for this trace handle.
**
** rName: pointer to string. RName for this trace handle.
**
** description: pointer to string. Descriptive data about this
** trace handle.
**
** OUTPUTS:
** Creates the trace handle.
** Registers the QName and RName with the trace facility.
**
** RETURNS:
** PRTraceHandle
**
** RESTRICTIONS:
** qName is limited to 31 characters.
** rName is limited to 31 characters.
** description is limited to 255 characters.
**
*/
#define PRTRACE_NAME_MAX 31
#define PRTRACE_DESC_MAX 255
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_CREATE_TRACE(handle,qName,rName,description)\
(handle) = PR_CreateTrace((qName),(rName),(description))
#else
#define PR_CREATE_TRACE(handle,qName,rName,description)
#endif
NSPR_API(PRTraceHandle)
PR_CreateTrace(
const char *qName, /* QName for this trace handle */
const char *rName, /* RName for this trace handle */
const char *description /* description for this trace handle */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_DestroyTrace() -- Destroy a trace handle
**
** DESCRIPTION:
** PR_DestroyTrace() removes the referenced trace handle and
** associated QName, RName and description data from the Trace
** Facility.
**
** INPUTS: handle. A PRTraceHandle
**
** OUTPUTS:
** The trace handle is unregistered.
** The QName, RName and description are removed.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_DESTROY_TRACE(handle)\
PR_DestroyTrace((handle))
#else
#define PR_DESTROY_TRACE(handle)
#endif
NSPR_API(void)
PR_DestroyTrace(
PRTraceHandle handle /* Handle to be destroyed */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_Trace() -- Make a trace entry in the in-memory trace
**
** DESCRIPTION:
** PR_Trace() makes an entry in the in-memory trace buffer for
** the referenced trace handle. The next logically available
** PRTraceEntry is used; when the next trace entry would overflow
** the trace table, the table wraps.
**
** PR_Trace() for a specific trace handle may be disabled by
** calling PR_SetTraceOption() specifying PRTraceDisable for the
** trace handle to be disabled.
**
** INPUTS:
** handle: PRTraceHandle. The trace handle for this trace.
**
** userData[0..7]: unsigned 32bit integers. user supplied data
** that is copied into the PRTraceEntry
**
** OUTPUTS:
** A PRTraceEntry is (conditionally) formatted in the in-memory
** trace buffer.
**
** RETURNS: void.
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)\
PR_Trace((handle),(ud0),(ud1),(ud2),(ud3),(ud4),(ud5),(ud6),(ud7))
#else
#define PR_TRACE(handle,ud0,ud1,ud2,ud3,ud4,ud5,ud6,ud7)
#endif
NSPR_API(void)
PR_Trace(
PRTraceHandle handle, /* use this trace handle */
PRUint32 userData0, /* User supplied data word 0 */
PRUint32 userData1, /* User supplied data word 1 */
PRUint32 userData2, /* User supplied data word 2 */
PRUint32 userData3, /* User supplied data word 3 */
PRUint32 userData4, /* User supplied data word 4 */
PRUint32 userData5, /* User supplied data word 5 */
PRUint32 userData6, /* User supplied data word 6 */
PRUint32 userData7 /* User supplied data word 7 */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_SetTraceOption() -- Control the Trace Facility
**
** DESCRIPTION:
** PR_SetTraceOption() controls the Trace Facility. Depending on
** command and value, attributes of the Trace Facility may be
** changed.
**
** INPUTS:
** command: An enumerated value in the set of PRTraceOption.
** value: pointer to the data to be set. Type of the data is
** dependent on command; for each value of command, the type
** and meaning of dereferenced value is shown.
**
** PRTraceBufSize: unsigned long: the size of the trace buffer,
** in bytes.
**
** PRTraceEnable: PRTraceHandle. The trace handle to be
** enabled.
**
** PRTraceDisable: PRTraceHandle. The trace handle to be
** disabled.
**
** PRTraceSuspend: void. value must be NULL. All tracing is
** suspended.
**
** PRTraceResume: void. value must be NULL. Tracing for all
** previously enabled, prior to a PRTraceSuspend, is resumed.
**
** PRTraceStopRecording: void. value must be NULL. If recording
** (see: ** PR_RecordTraceEntries()) is being done,
** PRTraceStopRecording causes PR_RecordTraceEntries() to return
** to its caller. If recording is not being done, this function
** has no effect.
**
** PRTraceSuspendRecording: void. Must be NULL. If recording is
** being done, PRTraceSuspendRecording causes further writes to
** the trace file to be suspended. Data in the in-memory
** trace buffer that would ordinarily be written to the
** trace file will not be written. Trace entries will continue
** to be entered in the in-memory buffer. If the Trace Facility
** recording is already in a suspended state, the call has no
** effect.
**
** PRTraceResumeRecording: void. value must be NULL. If
** recording for the Trace Facility has been previously been
** suspended, this causes recording to resume. Recording resumes
** with the next in-memory buffer segment that would be written
** if trace recording had not been suspended. If recording is
** not currently suspended, the call has no effect.
**
** PRTraceLockHandles: void. value must be NULL. Locks the
** trace handle lock. While the trace handle lock is held,
** calls to PR_CreateTrace() will block until the lock is
** released.
**
** PRTraceUnlockHandles: void. value must be NULL. Unlocks the
** trace handle lock.
**
** OUTPUTS:
** The operation of the Trace Facility may be changed.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_SET_TRACE_OPTION(command,value)\
PR_SetTraceOption((command),(value))
#else
#define PR_SET_TRACE_OPTION(command,value)
#endif
NSPR_API(void)
PR_SetTraceOption(
PRTraceOption command, /* One of the enumerated values */
void *value /* command value or NULL */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetTraceOption() -- Retrieve settings from the Trace Facility
**
** DESCRIPTION:
** PR_GetTraceOption() retrieves the current setting of the
** Trace Facility control depending on command.
**
**
** PRTraceBufSize: unsigned long: the size of the trace buffer,
** in bytes.
**
**
** INPUTS:
** command: one of the enumerated values in PRTraceOptions
** valid for PR_GetTraceOption().
**
** OUTPUTS:
** dependent on command.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_GET_TRACE_OPTION(command,value)\
PR_GetTraceOption((command),(value))
#else
#define PR_GET_TRACE_OPTION(command,value)
#endif
NSPR_API(void)
PR_GetTraceOption(
PRTraceOption command, /* One of the enumerated values */
void *value /* command value or NULL */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetTraceHandleFromName() -- Retrieve an existing
** handle by name.
**
** DESCRIPTION:
** PR_GetTraceHandleFromName() retreives an existing tracehandle
** using the name specified by qName and rName.
**
** INPUTS:
** qName: pointer to string. QName for this trace handle.
**
** rName: pointer to string. RName for this trace handle.
**
**
** OUTPUTS: returned.
**
** RETURNS:
** PRTraceHandle associated with qName and rName or NULL when
** there is no match.
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)\
(handle) = PR_GetTraceHandleFromName((qName),(rName))
#else
#define PR_GET_TRACE_HANDLE_FROM_NAME(handle,qName,rName)
#endif
NSPR_API(PRTraceHandle)
PR_GetTraceHandleFromName(
const char *qName, /* QName search argument */
const char *rName /* RName search argument */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetTraceNameFromHandle() -- Retreive trace name
** by bandle.
**
** DESCRIPTION:
** PR_GetTraceNameFromHandle() retreives the existing qName,
** rName, and description for the referenced trace handle.
**
** INPUTS: handle: PRTraceHandle.
**
** OUTPUTS: pointers to the Trace Facility's copy of qName,
** rName and description. ... Don't mess with these values.
** They're mine.
**
** RETURNS: void
**
** RESTRICTIONS:
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)\
PR_GetTraceNameFromHandle((handle),(qName),(rName),(description))
#else
#define PR_GET_TRACE_NAME_FROM_HANDLE(handle,qName,rName,description)
#endif
NSPR_API(void)
PR_GetTraceNameFromHandle(
PRTraceHandle handle, /* handle as search argument */
const char **qName, /* pointer to associated QName */
const char **rName, /* pointer to associated RName */
const char **description /* pointer to associated description */
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_FindNextTraceQname() -- Retrieive a QName handle
** iterator.
**
** DESCRIPTION:
** PR_FindNextTraceQname() retreives the first or next trace
** QName handle, depending on the value of handle, from the trace
** database. The PRTraceHandle returned can be used as an
** iterator to traverse the QName handles in the Trace database.
**
** INPUTS:
** handle: When NULL, PR_FindNextQname() returns the first QName
** handle. When a handle is a valid PRTraceHandle previously
** retreived using PR_FindNextQname() the next QName handle is
** retreived.
**
** OUTPUTS: returned.
**
** RETURNS:
** PRTraceHandle or NULL when there are no trace handles.
**
** RESTRICTIONS:
** Iterating thru the trace handles via FindFirst/FindNext
** should be done under protection of the trace handle lock.
** See: PR_SetTraceOption( PRLockTraceHandles ).
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_FIND_NEXT_TRACE_QNAME(next,handle)\
(next) = PR_FindNextTraceQname((handle))
#else
#define PR_FIND_NEXT_TRACE_QNAME(next,handle)
#endif
NSPR_API(PRTraceHandle)
PR_FindNextTraceQname(
PRTraceHandle handle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_FindNextTraceRname() -- Retrieive an RName handle
** iterator.
**
** DESCRIPTION:
** PR_FindNextTraceRname() retreives the first or next trace
** RName handle, depending on the value of handle, from the trace
** database. The PRTraceHandle returned can be used as an
** iterator to traverse the RName handles in the Trace database.
**
** INPUTS:
** rhandle: When NULL, PR_FindNextRname() returns the first
** RName handle. When a handle is a valid PRTraceHandle
** previously retreived using PR_FindNextRname() the next RName
** handle is retreived.
** qhandle: A valid PRTraceHandle retruned from a previous call
** to PR_FIND_NEXT_TRACE_QNAME().
**
** OUTPUTS: returned.
**
** RETURNS:
** PRTraceHandle or NULL when there are no trace handles.
**
** RESTRICTIONS:
** Iterating thru the trace handles via FindNext should be done
** under protection of the trace handle lock. See: (
** PR_SetTraceOption( PRLockTraceHandles ).
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)\
(next) = PR_FindNextTraceRname((rhandle),(qhandle))
#else
#define PR_FIND_NEXT_TRACE_RNAME(next,rhandle,qhandle)
#endif
NSPR_API(PRTraceHandle)
PR_FindNextTraceRname(
PRTraceHandle rhandle,
PRTraceHandle qhandle
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_RecordTraceEntries() -- Write trace entries to external media
**
** DESCRIPTION:
** PR_RecordTraceEntries() causes entries in the in-memory trace
** buffer to be written to external media.
**
** When PR_RecordTraceEntries() is called from an application
** thread, the function appears to block until another thread
** calls PR_SetTraceOption() with the PRTraceStopRecording
** option. This suggests that PR_RecordTraceEntries() should be
** called from a user supplied thread whose only job is to
** record trace entries.
**
** The environment variable NSPR_TRACE_LOG controls the operation
** of this function. When NSPR_TRACE_LOG is not defined in the
** environment, no recording of trace entries occurs. When
** NSPR_TRACE_LOG is defined, the value of its definition must be
** the filename of the file to receive the trace entry buffer.
**
** PR_RecordTraceEntries() attempts to record the in-memory
** buffer to a file, subject to the setting of the environment
** variable NSPR_TRACE_LOG. It is possible because of system
** load, the thread priority of the recording thread, number of
** active trace records being written over time, and other
** variables that some trace records can be lost. ... In other
** words: don't bet the farm on getting everything.
**
** INPUTS: none
**
** OUTPUTS: none
**
** RETURNS: PR_STATUS
** PR_SUCCESS no errors were found.
** PR_FAILURE errors were found.
**
** RESTRICTIONS:
** Only one thread can call PR_RecordTraceEntries() within a
** process.
**
** On error, PR_RecordTraceEntries() may return prematurely.
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_RECORD_TRACE_ENTRIES()\
PR_RecordTraceEntries()
#else
#define PR_RECORD_TRACE_ENTRIES()
#endif
NSPR_API(void)
PR_RecordTraceEntries(
void
);
/* -----------------------------------------------------------------------
** FUNCTION: PR_GetTraceEntries() -- Retreive trace entries from
** the Trace Facility
**
** DESCRIPTION:
** PR_GetTraceEntries() retreives trace entries from the Trace
** Facility. Up to count trace entries are copied from the Trace
** Facility into buffer. Only those trace entries that have not
** been copied via a previous call to PR_GetTraceEntries() are
** copied. The actual number copied is placed in the PRInt32
** variable pointed to by found.
**
** If more than count trace entries have entered the Trace
** Facility since the last call to PR_GetTraceEntries()
** a lost data condition is returned. In this case, the most
** recent count trace entries are copied into buffer and found is
** set to count.
**
** INPUTS:
** count. The number of trace entries to be copied into buffer.
**
**
** OUTPUTS:
** buffer. An array of PRTraceEntries. The buffer is supplied
** by the caller.
**
** found: 32bit signed integer. The number of PRTraceEntries
** actually copied. found is always less than or equal to count.
**
** RETURNS:
** zero when there is no lost data.
** non-zero when some PRTraceEntries have been lost.
**
** RESTRICTIONS:
** This is a real performance pig. The copy out operation is bad
** enough, but depending on then frequency of calls to the
** function, serious performance impact to the operating
** application may be realized. ... YMMV.
**
*/
#if defined (DEBUG) || defined (FORCE_NSPR_TRACE)
#define PR_GET_TRACE_ENTRIES(buffer,count,found)\
PR_GetTraceEntries((buffer),(count),(found))
#else
#define PR_GET_TRACE_ENTRIES(buffer,count,found)
#endif
NSPR_API(PRIntn)
PR_GetTraceEntries(
PRTraceEntry *buffer, /* where to write output */
PRInt32 count, /* number to get */
PRInt32 *found /* number you got */
);
PR_END_EXTERN_C
#endif /* prtrace_h___ */

View File

@@ -0,0 +1,590 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: prtypes.h
** Description: Definitions of NSPR's basic types
**
** Prototypes and macros used to make up for deficiencies that we have found
** in ANSI environments.
**
** Since we do not wrap <stdlib.h> and all the other standard headers, authors
** of portable code will not know in general that they need these definitions.
** Instead of requiring these authors to find the dependent uses in their code
** and take the following steps only in those C files, we take steps once here
** for all C files.
**/
#ifndef prtypes_h___
#define prtypes_h___
#ifdef MDCPUCFG
#include MDCPUCFG
#else
#include "prcpucfg.h"
#endif
#include <stddef.h>
/***********************************************************************
** MACROS: PR_EXTERN
** PR_IMPLEMENT
** DESCRIPTION:
** These are only for externally visible routines and globals. For
** internal routines, just use "extern" for type checking and that
** will not export internal cross-file or forward-declared symbols.
** Define a macro for declaring procedures return types. We use this to
** deal with windoze specific type hackery for DLL definitions. Use
** PR_EXTERN when the prototype for the method is declared. Use
** PR_IMPLEMENT for the implementation of the method.
**
** Example:
** in dowhim.h
** PR_EXTERN( void ) DoWhatIMean( void );
** in dowhim.c
** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
**
**
***********************************************************************/
#if defined(WIN32)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) __declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_BEOS)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllexport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(XP_OS2) && defined(__declspec)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPORT(__type) extern __declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
#define PR_EXTERN(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#elif defined(SYMBIAN)
#define PR_EXPORT(__type) extern __declspec(dllexport) __type
#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
#ifdef __WINS__
#define PR_IMPORT(__type) extern __declspec(dllexport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
#else
#define PR_IMPORT(__type) extern __declspec(dllimport) __type
#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type
#endif
#define PR_EXTERN(__type) extern __type
#define PR_IMPLEMENT(__type) __type
#define PR_EXTERN_DATA(__type) extern __type
#define PR_IMPLEMENT_DATA(__type) __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#else /* Unix */
/* GCC 3.3 and later support the visibility attribute. */
#if (__GNUC__ >= 4) || \
(__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default")))
#else
#define PR_VISIBILITY_DEFAULT
#endif
#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type
#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type
#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type
#define PR_CALLBACK
#define PR_CALLBACK_DECL
#define PR_STATIC_CALLBACK(__x) static __x
#endif
#if defined(_NSPR_BUILD_)
#define NSPR_API(__type) PR_EXPORT(__type)
#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
#else
#define NSPR_API(__type) PR_IMPORT(__type)
#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
#endif
/***********************************************************************
** MACROS: PR_BEGIN_MACRO
** PR_END_MACRO
** DESCRIPTION:
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
***********************************************************************/
#define PR_BEGIN_MACRO do {
#define PR_END_MACRO } while (0)
/***********************************************************************
** MACROS: PR_BEGIN_EXTERN_C
** PR_END_EXTERN_C
** DESCRIPTION:
** Macro shorthands for conditional C++ extern block delimiters.
***********************************************************************/
#ifdef __cplusplus
#define PR_BEGIN_EXTERN_C extern "C" {
#define PR_END_EXTERN_C }
#else
#define PR_BEGIN_EXTERN_C
#define PR_END_EXTERN_C
#endif
/***********************************************************************
** MACROS: PR_BIT
** PR_BITMASK
** DESCRIPTION:
** Bit masking macros. XXX n must be <= 31 to be portable
***********************************************************************/
#define PR_BIT(n) ((PRUint32)1 << (n))
#define PR_BITMASK(n) (PR_BIT(n) - 1)
/***********************************************************************
** MACROS: PR_ROUNDUP
** PR_MIN
** PR_MAX
** PR_ABS
** DESCRIPTION:
** Commonly used macros for operations on compatible types.
***********************************************************************/
#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y))
#define PR_MIN(x,y) ((x)<(y)?(x):(y))
#define PR_MAX(x,y) ((x)>(y)?(x):(y))
#define PR_ABS(x) ((x)<0?-(x):(x))
/***********************************************************************
** MACROS: PR_ARRAY_SIZE
** DESCRIPTION:
** The number of elements in an array.
***********************************************************************/
#define PR_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
PR_BEGIN_EXTERN_C
/*
** Starting in NSPR 4.9.5, NSPR's exact-width integer types should match
** the exact-width integer types defined in <stdint.h>. This allows sloppy
** code to use PRInt{N} and int{N}_t interchangeably.
**
** The 8-bit and 16-bit integer types can only be defined using char and
** short. All platforms define the 32-bit integer types using int. So only
** the 64-bit integer types could be defined differently.
**
** NSPR's original strategy was to use the "shortest" 64-bit integer type:
** if long is 64-bit, then prefer it over long long. This strategy is also
** used by Linux/glibc, FreeBSD, and NetBSD.
**
** Other platforms use a different strategy: simply define the 64-bit
** integer types using long long. We define the PR_ALTERNATE_INT64_TYPEDEF
** macro on these platforms. Note that PR_ALTERNATE_INT64_TYPEDEF is for
** internal use by NSPR headers only. Do not define or test this macro in
** your code.
**
** NOTE: NSPR can't use <stdint.h> because C99 requires C++ code to define
** __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS to make all the macros
** defined in <stdint.h> available. This strange requirement is gone in
** C11. When most platforms ignore this C99 requirement, NSPR will be able
** to use <stdint.h>. A patch to do that is in NSPR bug 634793.
*/
#if defined(__APPLE__) || defined(__ANDROID__) || defined(__OpenBSD__)
#define PR_ALTERNATE_INT64_TYPEDEF
#endif
/************************************************************************
** TYPES: PRUint8
** PRInt8
** DESCRIPTION:
** The int8 types are known to be 8 bits each. There is no type that
** is equivalent to a plain "char".
************************************************************************/
#if PR_BYTES_PER_BYTE == 1
typedef unsigned char PRUint8;
/*
** 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.
*/
#if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
#else
typedef signed char PRInt8;
#endif
#else
#error No suitable type for PRInt8/PRUint8
#endif
/************************************************************************
* MACROS: PR_INT8_MAX
* PR_INT8_MIN
* PR_UINT8_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt8 or PRUint8.
************************************************************************/
#define PR_INT8_MAX 127
#define PR_INT8_MIN (-128)
#define PR_UINT8_MAX 255U
/************************************************************************
** TYPES: PRUint16
** PRInt16
** DESCRIPTION:
** The int16 types are known to be 16 bits each.
************************************************************************/
#if PR_BYTES_PER_SHORT == 2
typedef unsigned short PRUint16;
typedef short PRInt16;
#else
#error No suitable type for PRInt16/PRUint16
#endif
/************************************************************************
* MACROS: PR_INT16_MAX
* PR_INT16_MIN
* PR_UINT16_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt16 or PRUint16.
************************************************************************/
#define PR_INT16_MAX 32767
#define PR_INT16_MIN (-32768)
#define PR_UINT16_MAX 65535U
/************************************************************************
** TYPES: PRUint32
** PRInt32
** DESCRIPTION:
** The int32 types are known to be 32 bits each.
************************************************************************/
#if PR_BYTES_PER_INT == 4
typedef unsigned int PRUint32;
typedef int PRInt32;
#define PR_INT32(x) x
#define PR_UINT32(x) x ## U
#elif PR_BYTES_PER_LONG == 4
typedef unsigned long PRUint32;
typedef long PRInt32;
#define PR_INT32(x) x ## L
#define PR_UINT32(x) x ## UL
#else
#error No suitable type for PRInt32/PRUint32
#endif
/************************************************************************
* MACROS: PR_INT32_MAX
* PR_INT32_MIN
* PR_UINT32_MAX
* DESCRIPTION:
* The maximum and minimum values of a PRInt32 or PRUint32.
************************************************************************/
#define PR_INT32_MAX PR_INT32(2147483647)
#define PR_INT32_MIN (-PR_INT32_MAX - 1)
#define PR_UINT32_MAX PR_UINT32(4294967295)
/************************************************************************
** TYPES: PRUint64
** PRInt64
** DESCRIPTION:
** The int64 types are known to be 64 bits each. Care must be used when
** declaring variables of type PRUint64 or PRInt64. Different hardware
** architectures and even different compilers have varying support for
** 64 bit values. The only guaranteed portability requires the use of
** the LL_ macros (see prlong.h).
**
** MACROS: PR_INT64
** PR_UINT64
** DESCRIPTION:
** The PR_INT64 and PR_UINT64 macros provide a portable way for
** specifying 64-bit integer constants. They can only be used if
** PRInt64 and PRUint64 are defined as compiler-supported 64-bit
** integer types (i.e., if HAVE_LONG_LONG is defined, which is true
** for all the supported compilers topday). If PRInt64 and PRUint64
** are defined as structs, the LL_INIT macro defined in prlong.h has
** to be used.
**
** MACROS: PR_INT64_MAX
** PR_INT64_MIN
** PR_UINT64_MAX
** DESCRIPTION:
** The maximum and minimum values of a PRInt64 or PRUint64.
************************************************************************/
#ifdef HAVE_LONG_LONG
/* Keep this in sync with prlong.h. */
#if PR_BYTES_PER_LONG == 8 && !defined(PR_ALTERNATE_INT64_TYPEDEF)
typedef long PRInt64;
typedef unsigned long PRUint64;
#define PR_INT64(x) x ## L
#define PR_UINT64(x) x ## UL
#elif defined(WIN32) && !defined(__GNUC__)
typedef __int64 PRInt64;
typedef unsigned __int64 PRUint64;
#define PR_INT64(x) x ## i64
#define PR_UINT64(x) x ## ui64
#else
typedef long long PRInt64;
typedef unsigned long long PRUint64;
#define PR_INT64(x) x ## LL
#define PR_UINT64(x) x ## ULL
#endif /* PR_BYTES_PER_LONG == 8 */
#define PR_INT64_MAX PR_INT64(0x7fffffffffffffff)
#define PR_INT64_MIN (-PR_INT64_MAX - 1)
#define PR_UINT64_MAX PR_UINT64(-1)
#else /* !HAVE_LONG_LONG */
typedef struct {
#ifdef IS_LITTLE_ENDIAN
PRUint32 lo, hi;
#else
PRUint32 hi, lo;
#endif
} PRInt64;
typedef PRInt64 PRUint64;
#define PR_INT64_MAX (PRInt64){0x7fffffff, 0xffffffff}
#define PR_INT64_MIN (PRInt64){0xffffffff, 0xffffffff}
#define PR_UINT64_MAX (PRUint64){0xffffffff, 0xffffffff}
#endif /* !HAVE_LONG_LONG */
/************************************************************************
** TYPES: PRUintn
** PRIntn
** DESCRIPTION:
** The PRIntn types are most appropriate for automatic variables. They are
** guaranteed to be at least 16 bits, though various architectures may
** define them to be wider (e.g., 32 or even 64 bits). These types are
** never valid for fields of a structure.
************************************************************************/
#if PR_BYTES_PER_INT >= 2
typedef int PRIntn;
typedef unsigned int PRUintn;
#else
#error 'sizeof(int)' not sufficient for platform use
#endif
/************************************************************************
** TYPES: PRFloat64
** DESCRIPTION:
** NSPR's floating point type is always 64 bits.
************************************************************************/
typedef double PRFloat64;
/************************************************************************
** TYPES: PRSize
** DESCRIPTION:
** A type for representing the size of objects.
************************************************************************/
typedef size_t PRSize;
/************************************************************************
** TYPES: PROffset32, PROffset64
** DESCRIPTION:
** A type for representing byte offsets from some location.
************************************************************************/
typedef PRInt32 PROffset32;
typedef PRInt64 PROffset64;
/************************************************************************
** TYPES: PRPtrDiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer subtraction.
************************************************************************/
typedef ptrdiff_t PRPtrdiff;
/************************************************************************
** TYPES: PRUptrdiff
** DESCRIPTION:
** A type for pointer difference. Variables of this type are suitable
** for storing a pointer or pointer sutraction.
************************************************************************/
#ifdef _WIN64
typedef PRUint64 PRUptrdiff;
#else
typedef unsigned long PRUptrdiff;
#endif
/************************************************************************
** TYPES: PRBool
** DESCRIPTION:
** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
** for clarity of target type in assignments and actual arguments. Use
** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
** just as you would C int-valued conditions.
************************************************************************/
typedef PRIntn PRBool;
#define PR_TRUE 1
#define PR_FALSE 0
/************************************************************************
** TYPES: PRPackedBool
** DESCRIPTION:
** Use PRPackedBool within structs where bitfields are not desirable
** but minimum and consistant overhead matters.
************************************************************************/
typedef PRUint8 PRPackedBool;
/*
** Status code used by some routines that have a single point of failure or
** special status return.
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
#ifndef __PRUNICHAR__
#define __PRUNICHAR__
#ifdef WIN32
typedef wchar_t PRUnichar;
#else
typedef PRUint16 PRUnichar;
#endif
#endif
/*
** WARNING: The undocumented data types PRWord and PRUword are
** only used in the garbage collection and arena code. Do not
** use PRWord and PRUword in new code.
**
** A PRWord is an integer that is the same size as a void*.
** It implements the notion of a "word" in the Java Virtual
** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine
** Specification, Addison-Wesley, September 1996.
** http://java.sun.com/docs/books/vmspec/index.html.)
*/
#ifdef _WIN64
typedef PRInt64 PRWord;
typedef PRUint64 PRUword;
#else
typedef long PRWord;
typedef unsigned long PRUword;
#endif
/*
* PR_PRETEND_NORETURN, specified at the end of a function declaration,
* indicates that for the purposes of static analysis, this function does not
* return. (The function definition does not need to be annotated.)
*
* void PR_Assert(const char *s, const char *file, PRIntn ln)
* PR_PRETEND_NORETURN;
*
* Some static analyzers, like scan-build from clang, can use this information
* to eliminate false positives. From the upstream documentation of
* scan-build:
* This attribute is useful for annotating assertion handlers that actually
* can return, but for the purpose of using the analyzer we want to pretend
* that such functions do not return.
*/
#ifdef __clang_analyzer__
#if __has_extension(attribute_analyzer_noreturn)
#define PR_PRETEND_NORETURN __attribute__((analyzer_noreturn))
#endif
#endif
#ifndef PR_PRETEND_NORETURN
#define PR_PRETEND_NORETURN /* no support */
#endif
#if defined(NO_NSPR_10_SUPPORT)
#else
/********* ???????????????? FIX ME ??????????????????????????? *****/
/********************** Some old definitions until pr=>ds transition is done ***/
/********************** Also, we are still using NSPR 1.0. GC ******************/
/*
** Fundamental NSPR macros, used nearly everywhere.
*/
#define PR_PUBLIC_API PR_IMPLEMENT
/*
** Macro body brackets so that macros with compound statement definitions
** behave syntactically more like functions when called.
*/
#define NSPR_BEGIN_MACRO do {
#define NSPR_END_MACRO } while (0)
/*
** Macro shorthands for conditional C++ extern block delimiters.
*/
#ifdef NSPR_BEGIN_EXTERN_C
#undef NSPR_BEGIN_EXTERN_C
#endif
#ifdef NSPR_END_EXTERN_C
#undef NSPR_END_EXTERN_C
#endif
#ifdef __cplusplus
#define NSPR_BEGIN_EXTERN_C extern "C" {
#define NSPR_END_EXTERN_C }
#else
#define NSPR_BEGIN_EXTERN_C
#define NSPR_END_EXTERN_C
#endif
#include "obsolete/protypes.h"
/********* ????????????? End Fix me ?????????????????????????????? *****/
#endif /* NO_NSPR_10_SUPPORT */
/*
** Compile-time assert. "condition" must be a constant expression.
** The macro can be used only in places where an "extern" declaration is
** allowed.
*/
#define PR_STATIC_ASSERT(condition) \
extern void pr_static_assert(int arg[(condition) ? 1 : -1])
PR_END_EXTERN_C
#endif /* prtypes_h___ */

View File

@@ -0,0 +1,105 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* author: jstewart */
#if defined(_PRVERSION_H)
#else
#define _PRVERSION_H
#include "prtypes.h"
PR_BEGIN_EXTERN_C
/* All components participating in the PR version protocol must expose
* a structure and a function. The structure is defined below and named
* according to the naming conventions outlined further below. The function
* is called libVersionPoint and returns a pointer to this structure.
*/
/* on NT, always pack the structure the same. */
#ifdef _WIN32
#pragma pack(push, 8)
#endif
typedef struct {
/*
* The first field defines which version of this structure is in use.
* At this time, only version 2 is specified. If this value is not
* 2, you must read no further into the structure.
*/
PRInt32 version;
/* for Version 2, this is the body format. */
PRInt64 buildTime; /* 64 bits - usecs since midnight, 1/1/1970 */
char * buildTimeString;/* a human readable version of the time */
PRUint8 vMajor; /* Major version of this component */
PRUint8 vMinor; /* Minor version of this component */
PRUint8 vPatch; /* Patch level of this component */
PRBool beta; /* true if this is a beta component */
PRBool debug; /* true if this is a debug component */
PRBool special; /* true if this component is a special build */
char * filename; /* The original filename */
char * description; /* description of this component */
char * security; /* level of security in this component */
char * copyright; /* The copyright for this file */
char * comment; /* free form field for misc usage */
char * specialString; /* the special variant for this build */
} PRVersionDescription;
/* on NT, restore the previous packing */
#ifdef _WIN32
#pragma pack(pop)
#endif
/*
* All components must define an entrypoint named libVersionPoint which
* is of type versionEntryPointType.
*
* For example, for a library named libfoo, we would have:
*
* PRVersionDescription prVersionDescription_libfoo =
* {
* ...
* };
*
* PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint(void)
* {
* return &prVersionDescription_libfoo;
* }
*/
typedef const PRVersionDescription *(*versionEntryPointType)(void);
/*
* Where you declare your libVersionPoint, do it like this:
* PR_IMPLEMENT(const PRVersionDescription *) libVersionPoint(void) {
* fill it in...
* }
*/
/*
* NAMING CONVENTION FOR struct
*
* all components should also expose a static PRVersionDescription
* The name of the struct should be calculated as follows:
* Take the value of filename. (If filename is not specified, calculate
* a short, unique string.) Convert all non-alphanumeric characters
* to '_'. To this, prepend "PRVersionDescription_". Thus for libfoo.so,
* the symbol name is "PRVersionDescription_libfoo_so".
* so the file should have
* PRVersionDescription PRVersionDescription_libfoo_so { fill it in };
* on NT, this file should be declspec export.
*/
PR_END_EXTERN_C
#endif /* defined(_PRVERSION_H) */
/* prvrsion.h */

View File

@@ -0,0 +1,164 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef prwin16_h___
#define prwin16_h___
/*
** Condition use of this header on platform.
*/
#if (defined(XP_PC) && !defined(_WIN32) && !defined(XP_OS2) && defined(MOZILLA_CLIENT)) || defined(WIN16)
#include <stdio.h>
PR_BEGIN_EXTERN_C
/*
** Win16 stdio special case.
** To get stdio to work for Win16, all calls to printf() and related
** things must be called from the environment of the .EXE; calls to
** printf() from the .DLL send output to the bit-bucket.
**
** To make sure that PR_fprintf(), and related functions, work correctly,
** the actual stream I/O to stdout, stderr, stdin must be done in the
** .EXE. To do this, a hack is placed in _MD_Write() such that the
** fd for stdio handles results in a call to the .EXE.
**
** file w16stdio.c contains the functions that get called from NSPR
** to do the actual I/O. w16stdio.o must be statically linked with
** any application needing stdio for Win16.
**
** The address of these functions must be made available to the .DLL
** so he can call back to the .EXE. To do this, function
** PR_MD_RegisterW16StdioCallbacks() is called from the .EXE.
** The arguments are the functions defined in w16stdio.c
** At runtime, MD_Write() calls the registered functions, if any
** were registered.
**
** prinit.h contains a macro PR_STDIO_INIT() that calls the registration
** function for Win16; For other platforms, the macro is a No-Op.
**
** Note that stdio is not operational at all on Win16 GUI applications.
** This special case exists to provide stdio capability from the NSPR
** .DLL for command line applications only. NSPR's test cases are
** almost exclusively command line applications.
**
** See also: w16io.c, w16stdio.c
*/
typedef PRInt32 (PR_CALLBACK *PRStdinRead)( void *buf, PRInt32 amount);
typedef PRInt32 (PR_CALLBACK *PRStdoutWrite)( void *buf, PRInt32 amount);
typedef PRInt32 (PR_CALLBACK *PRStderrWrite)( void *buf, PRInt32 amount);
NSPR_API(PRStatus)
PR_MD_RegisterW16StdioCallbacks(
PRStdinRead inReadf, /* i: function pointer for stdin read */
PRStdoutWrite outWritef, /* i: function pointer for stdout write */
PRStderrWrite errWritef /* i: function pointer for stderr write */
);
NSPR_API(PRInt32)
_PL_W16StdioWrite( void *buf, PRInt32 amount );
NSPR_API(PRInt32)
_PL_W16StdioRead( void *buf, PRInt32 amount );
#define PR_STDIO_INIT() PR_MD_RegisterW16StdioCallbacks( \
_PL_W16StdioRead, _PL_W16StdioWrite, _PL_W16StdioWrite ); \
PR_INIT_CALLBACKS();
/*
** Win16 hackery.
**
*/
struct PRMethodCallbackStr {
int (PR_CALLBACK *auxOutput)(const char *outputString);
size_t (PR_CALLBACK *strftime)(char *s, size_t len, const char *fmt, const struct tm *p);
void * (PR_CALLBACK *malloc)( size_t size );
void * (PR_CALLBACK *calloc)(size_t n, size_t size );
void * (PR_CALLBACK *realloc)( void* old_blk, size_t size );
void (PR_CALLBACK *free)( void *ptr );
void * (PR_CALLBACK *getenv)( const char *name);
int (PR_CALLBACK *putenv)( const char *assoc);
/* void * (PR_CALLBACK *perror)( const char *prefix ); */
};
NSPR_API(void) PR_MDRegisterCallbacks(struct PRMethodCallbackStr *);
int PR_CALLBACK _PL_W16CallBackPuts( const char *outputString );
size_t PR_CALLBACK _PL_W16CallBackStrftime(
char *s,
size_t len,
const char *fmt,
const struct tm *p );
void * PR_CALLBACK _PL_W16CallBackMalloc( size_t size );
void * PR_CALLBACK _PL_W16CallBackCalloc( size_t n, size_t size );
void * PR_CALLBACK _PL_W16CallBackRealloc(
void *old_blk,
size_t size );
void PR_CALLBACK _PL_W16CallBackFree( void *ptr );
void * PR_CALLBACK _PL_W16CallBackGetenv( const char *name );
int PR_CALLBACK _PL_W16CallBackPutenv( const char *assoc );
/*
** Hackery!
**
** These functions are provided as static link points.
** This is to satisfy the quick port of Gromit to NSPR 2.0
** ... Don't do this! ... alas, It may never go away.
**
*/
NSPR_API(int) PR_MD_printf(const char *, ...);
NSPR_API(void) PR_MD_exit(int);
NSPR_API(size_t) PR_MD_strftime(char *, size_t, const char *, const struct tm *);
NSPR_API(int) PR_MD_sscanf(const char *, const char *, ...);
NSPR_API(void*) PR_MD_malloc( size_t size );
NSPR_API(void*) PR_MD_calloc( size_t n, size_t size );
NSPR_API(void*) PR_MD_realloc( void* old_blk, size_t size );
NSPR_API(void) PR_MD_free( void *ptr );
NSPR_API(char*) PR_MD_getenv( const char *name );
NSPR_API(int) PR_MD_putenv( const char *assoc );
NSPR_API(int) PR_MD_fprintf(FILE *fPtr, const char *fmt, ...);
#define PR_INIT_CALLBACKS() \
{ \
static struct PRMethodCallbackStr cbf = { \
_PL_W16CallBackPuts, \
_PL_W16CallBackStrftime, \
_PL_W16CallBackMalloc, \
_PL_W16CallBackCalloc, \
_PL_W16CallBackRealloc, \
_PL_W16CallBackFree, \
_PL_W16CallBackGetenv, \
_PL_W16CallBackPutenv, \
}; \
PR_MDRegisterCallbacks( &cbf ); \
}
/*
** Get the exception context for Win16 MFC applications threads
*/
NSPR_API(void *) PR_W16GetExceptionContext(void);
/*
** Set the exception context for Win16 MFC applications threads
*/
NSPR_API(void) PR_W16SetExceptionContext(void *context);
PR_END_EXTERN_C
#else
/*
** For platforms other than Win16, define
** PR_STDIO_INIT() as a No-Op.
*/
#define PR_STDIO_INIT()
#endif /* WIN16 || MOZILLA_CLIENT */
#endif /* prwin16_h___ */