Issue #1338 - Part 1: Update NSPR to 4.24

This commit is contained in:
wolfbeast 2020-01-02 21:01:38 +01:00 • committed by Roy Tam
commit 1a92143e68
454 changed files with 42944 additions and 48647 deletions

View file

@ -4,9 +4,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
** File: pprio.h
** File: pprio.h
**
** Description: Private definitions for I/O related structures
** Description: Private definitions for I/O related structures
*/
#ifndef pprio_h___
@ -51,10 +51,10 @@ NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void);
NSPR_API(PROsfd) PR_FileDesc2NativeHandle(PRFileDesc *);
NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PROsfd);
NSPR_API(PRFileDesc*) PR_AllocFileDesc(PROsfd osfd,
const PRIOMethods *methods);
const PRIOMethods *methods);
NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd);
/*
** Import an existing OS file to NSPR.
** Import an existing OS file to NSPR.
*/
NSPR_API(PRFileDesc*) PR_ImportFile(PROsfd osfd);
NSPR_API(PRFileDesc*) PR_ImportPipe(PROsfd osfd);
@ -67,7 +67,7 @@ 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
* PR_Poll only
* INPUTS:
* None
* OUTPUTS:
@ -80,7 +80,7 @@ NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PROsfd osfd);
**************************************************************************
*/
NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd);
NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd);
/*
*************************************************************************
@ -93,7 +93,7 @@ NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PROsfd osfd);
* None
* RETURN: PRFileDesc*
* Upon successful completion, PR_DestroySocketPollFd returns
* PR_SUCCESS, else PR_FAILURE
* PR_SUCCESS, else PR_FAILURE
*
**************************************************************************
*/
@ -122,7 +122,7 @@ NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd);
/*
** Create a new Socket; this function is obsolete.
*/
NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);
NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);
/* FUNCTION: PR_LockFile
** DESCRIPTION:
@ -157,7 +157,7 @@ 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);
PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);
/*
** Emulate sendfile by reading from the file and writing to the socket.
@ -177,7 +177,7 @@ NSPR_API(PRInt32) PR_EmulateSendFile(
** 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);
PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t);
typedef void (*_PR_AcceptTimeoutCallback)(void *);
@ -187,23 +187,23 @@ typedef void (*_PR_AcceptTimeoutCallback)(void *);
** 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
** 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
** 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);
PRFileDesc *sd,
PRFileDesc **nd,
PRNetAddr **raddr,
void *buf,
PRInt32 amount,
PRIntervalTime t,
_PR_AcceptTimeoutCallback callback,
void *callback_arg);
/* FUNCTION: PR_NTFast_Accept
** DESCRIPTION:
@ -213,8 +213,8 @@ NSPR_API(PRInt32) PR_NTFast_AcceptRead_WithTimeoutCallback(
** 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);
NSPR_API(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr,
PRIntervalTime timeout);
/* FUNCTION: PR_NTFast_Update
** DESCRIPTION:
@ -224,8 +224,8 @@ NSPR_API(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr,
** 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);
NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock,
PRFileDesc *listenSock);
/* FUNCTION: PR_NT_CancelIo

View file

@ -27,9 +27,9 @@ PR_BEGIN_EXTERN_C
/*
** 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
** "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
@ -39,8 +39,8 @@ PR_BEGIN_EXTERN_C
** thread. PR_Init does this automatically for the primordial thread.
*/
NSPR_API(PRThread*) PR_AttachThread(PRThreadType type,
PRThreadPriority priority,
PRThreadStack *stack);
PRThreadPriority priority,
PRThreadStack *stack);
/*
** Detach the nspr thread from the currently executing native thread.
@ -81,7 +81,7 @@ NSPR_API(void) PR_SetThreadDumpProc(
NSPR_API(PRInt32) PR_GetThreadAffinityMask(PRThread *thread, PRUint32 *mask);
/*
** Set this thread's affinity mask.
** Set this thread's affinity mask.
**
** Returns 0 on success, -1 on failure.
*/
@ -105,11 +105,11 @@ NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
/*---------------------------------------------------------------------------
** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS
** THREAD PRIVATE FUNCTIONS FOR GARBAGE COLLECTIBLE THREADS
---------------------------------------------------------------------------*/
/*
** Only Garbage collectible threads participate in resume all, suspend all and
/*
** 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).
@ -120,20 +120,20 @@ NSPR_API(void) PR_SetThreadRecycleMode(PRUint32 flag);
** collectible.
*/
NSPR_API(PRThread*) PR_CreateThreadGCAble(PRThreadType type,
void (*start)(void *arg),
void *arg,
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize);
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
** 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);
PRThreadPriority priority,
PRThreadStack *stack);
/*
** Mark the thread as garbage collectible.
@ -146,19 +146,19 @@ NSPR_API(void) PR_SetThreadGCAble(void);
NSPR_API(void) PR_ClearThreadGCAble(void);
/*
** This routine prevents all other GC able threads from running. This call is needed by
** 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
** 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.
** Return the thread stack pointer of the given thread.
** Needed by the garbage collector.
*/
NSPR_API(void *) PR_GetSP(PRThread *thread);
@ -199,26 +199,26 @@ NSPR_API(void) SetExecutionEnvironment(PRThread* thread, void *environment);
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.
** number of pointers.
*/
typedef PRStatus
typedef PRStatus
(PR_CALLBACK *PRScanStackFun)(PRThread* t,
void** baseAddr, PRUword count, void* closure);
void** baseAddr, PRUword count, void* closure);
/*
** Applies scanFun to all contiguous groups of potential pointers
** 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.
** 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)
@ -226,14 +226,14 @@ 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
** 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
** THREAD CPU PRIVATE FUNCTIONS
---------------------------------------------------------------------------*/
/*
@ -283,26 +283,6 @@ 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.
@ -314,7 +294,7 @@ 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)
#define PR_InMonitor(m) (PR_GetMonitorEntryCount(m) > 0)
/*---------------------------------------------------------------------------
** Special X-Lock hack for client

View file

@ -10,10 +10,6 @@
#include <pthread.h>
#endif
#if defined(_PR_BTHREADS)
#include <kernel/OS.h>
#endif
#ifdef WIN32
/*
* Allow use of functions and symbols first defined in Win2k.
@ -51,19 +47,19 @@ typedef struct PRSegment PRSegment;
*************************************************************************/
/*
NSPR 2.0 must implement its function across a range of platforms
NSPR 2.0 must implement its function across a range of platforms
including: MAC, Windows/16, Windows/95, Windows/NT, and several
variants of Unix. Each implementation shares common code as well
variants of Unix. Each implementation shares common code as well
as having platform dependent portions. This standard describes how
the model dependent portions are to be implemented.
In header file pr/include/primpl.h, each publicly declared
In header file pr/include/primpl.h, each publicly declared
platform dependent function is declared as:
NSPR_API void _PR_MD_FUNCTION( long arg1, long arg2 );
#define _PR_MD_FUNCTION _MD_FUNCTION
In header file pr/include/md/<platform>/_<platform>.h,
In header file pr/include/md/<platform>/_<platform>.h,
each #define'd macro is redefined as one of:
#define _MD_FUNCTION <blanks>
@ -73,26 +69,26 @@ each #define'd macro is redefined as one of:
Where:
<blanks> is no definition at all. In this case, the function is not implemented
and is never called for this platform.
For example:
<blanks> is no definition at all. In this case, the function is not implemented
and is never called for this platform.
For example:
#define _MD_INIT_CPUS()
<expanded macro> is a C language macro expansion.
For example:
<expanded macro> is a C language macro expansion.
For example:
#define _MD_CLEAN_THREAD(_thread) \
PR_BEGIN_MACRO \
PR_DestroyCondVar(_thread->md.asyncIOCVar); \
PR_DestroyLock(_thread->md.asyncIOLock); \
PR_END_MACRO
<osFunction> is some function implemented by the host operating system.
For example:
<osFunction> is some function implemented by the host operating system.
For example:
#define _MD_EXIT exit
<_MD_function> is the name of a function implemented for this platform in
pr/src/md/<platform>/<soruce>.c file.
For example:
<_MD_function> is the name of a function implemented for this platform in
pr/src/md/<platform>/<soruce>.c file.
For example:
#define _MD_GETFILEINFO _MD_GetFileInfo
In <source>.c, the implementation is:
@ -137,7 +133,7 @@ struct _PT_Notified
};
/*
* bits defined for pthreads 'state' field
* bits defined for pthreads 'state' field
*/
#define PT_THREAD_DETACHED 0x01 /* thread can't be joined */
#define PT_THREAD_GLOBAL 0x02 /* a global thread (unlikely) */
@ -149,16 +145,16 @@ struct _PT_Notified
#define PT_THREAD_FOREIGN 0x80 /* thread is not one of ours */
#define PT_THREAD_BOUND 0x100 /* a bound-global thread */
#define _PT_THREAD_INTERRUPTED(thr) \
(!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))
#define _PT_THREAD_BLOCK_INTERRUPT(thr) \
(thr->interrupt_blocked = 1)
#define _PT_THREAD_UNBLOCK_INTERRUPT(thr) \
(thr->interrupt_blocked = 0)
#define _PT_THREAD_INTERRUPTED(thr) \
(!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))
#define _PT_THREAD_BLOCK_INTERRUPT(thr) \
(thr->interrupt_blocked = 1)
#define _PT_THREAD_UNBLOCK_INTERRUPT(thr) \
(thr->interrupt_blocked = 0)
#define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE)
/*
/*
** Possible values for thread's suspend field
** Note that the first two can be the same as they are really mutually exclusive,
** i.e. both cannot be happening at the same time. We have two symbolic names
@ -209,13 +205,13 @@ NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);
*/
#ifdef _PR_LOCAL_THREADS_ONLY
#define _PR_MD_SUSPEND_THREAD(thread)
#define _PR_MD_RESUME_THREAD(thread)
#define _PR_MD_SUSPEND_CPU(cpu)
#define _PR_MD_RESUME_CPU(cpu)
#define _PR_MD_BEGIN_SUSPEND_ALL()
#define _PR_MD_END_SUSPEND_ALL()
#define _PR_MD_BEGIN_RESUME_ALL()
#define _PR_MD_SUSPEND_THREAD(thread)
#define _PR_MD_RESUME_THREAD(thread)
#define _PR_MD_SUSPEND_CPU(cpu)
#define _PR_MD_RESUME_CPU(cpu)
#define _PR_MD_BEGIN_SUSPEND_ALL()
#define _PR_MD_END_SUSPEND_ALL()
#define _PR_MD_BEGIN_RESUME_ALL()
#define _PR_MD_END_RESUME_ALL()
#define _PR_MD_INIT_ATTACHED_THREAD(thread) PR_FAILURE
@ -256,7 +252,7 @@ struct _PRCPU {
PRThread *thread; /* native thread for this CPUThread */
PRThread *idle_thread; /* user-level idle thread for this CPUThread */
PRIntervalTime last_clock; /* the last time we went into
PRIntervalTime last_clock; /* the last time we went into
* _PR_ClockInterrupt() on this CPU
*/
@ -274,12 +270,12 @@ typedef struct _PRInterruptTable {
#define _PR_CPU_PTR(_qp) \
((_PRCPU*) ((char*) (_qp) - offsetof(_PRCPU,links)))
#if !defined(IRIX) && !defined(WIN32) && !defined(XP_OS2) \
#if !defined(WIN32) && !defined(XP_OS2) \
&& !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))
#define _MD_GET_ATTACHED_THREAD() (_PR_MD_CURRENT_THREAD())
#endif
#ifdef _PR_LOCAL_THREADS_ONLY
#ifdef _PR_LOCAL_THREADS_ONLY
NSPR_API(struct _PRCPU *) _pr_currentCPU;
NSPR_API(PRThread *) _pr_currentThread;
@ -357,7 +353,7 @@ extern PRInt32 _native_threads_only;
_PR_MD_SET_INTSOFF(_is); \
PR_END_MACRO
#ifdef _PR_LOCAL_THREADS_ONLY
#ifdef _PR_LOCAL_THREADS_ONLY
#define _PR_IS_NATIVE_THREAD(thread) 0
#define _PR_THREAD_LOCK(_thread)
@ -387,10 +383,10 @@ extern PRInt32 _native_threads_only;
PR_END_MACRO
#define _PR_ADD_SLEEPQ(_thread, _timeout) \
_PR_AddSleepQ(_thread, _timeout);
_PR_AddSleepQ(_thread, _timeout);
#define _PR_DEL_SLEEPQ(_thread, _propogate) \
_PR_DelSleepQ(_thread, _propogate);
_PR_DelSleepQ(_thread, _propogate);
#define _PR_ADD_JOINQ(_thread, _cpu) \
PR_APPEND_LINK(&(_thread)->links, &_PR_WAITINGTOJOINQ(_cpu));
@ -422,7 +418,7 @@ extern PRInt32 _native_threads_only;
PR_BEGIN_MACRO \
_PR_MD_LOCK(&(_cpu)->queue->runQLock );\
PR_END_MACRO
#define _PR_RUNQ_UNLOCK(_cpu) \
PR_BEGIN_MACRO \
_PR_MD_UNLOCK(&(_cpu)->queue->runQLock );\
@ -471,12 +467,12 @@ extern PRInt32 _native_threads_only;
#define _PR_ADD_SLEEPQ(_thread, _timeout) \
PR_ASSERT((_thread)->queueCount == 0); \
(_thread)->queueCount = QUEUE_SLEEP; \
_PR_AddSleepQ(_thread, _timeout);
_PR_AddSleepQ(_thread, _timeout);
#define _PR_DEL_SLEEPQ(_thread, _propogate) \
PR_ASSERT((_thread)->queueCount == QUEUE_SLEEP);\
(_thread)->queueCount = 0; \
_PR_DelSleepQ(_thread, _propogate);
_PR_DelSleepQ(_thread, _propogate);
#define _PR_ADD_JOINQ(_thread, _cpu) \
PR_ASSERT((_thread)->queueCount == 0); \
@ -529,7 +525,7 @@ NSPR_API(void) _PR_PauseCPU(void);
_PR_MD_LOCK(&(_lock)->ilock);
#define _PR_LOCK_UNLOCK(_lock) \
_PR_MD_UNLOCK(&(_lock)->ilock);
extern void _PR_UnblockLockWaiter(PRLock *lock);
extern PRStatus _PR_InitLock(PRLock *lock);
extern void _PR_FreeLock(PRLock *lock);
@ -540,7 +536,7 @@ extern void _PR_FreeLock(PRLock *lock);
/************************************************************************/
#define _PR_CVAR_LOCK(_cvar) \
_PR_MD_LOCK(&(_cvar)->ilock);
_PR_MD_LOCK(&(_cvar)->ilock);
#define _PR_CVAR_UNLOCK(_cvar) \
_PR_MD_UNLOCK(&(_cvar)->ilock);
@ -565,7 +561,7 @@ NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
#define _PR_IDLE_THREAD 0x200 /* this is an idle thread */
#define _PR_GCABLE_THREAD 0x400 /* this is a collectable thread */
#define _PR_BOUND_THREAD 0x800 /* a bound thread */
#define _PR_INTERRUPT_BLOCKED 0x1000 /* interrupts blocked */
#define _PR_INTERRUPT_BLOCKED 0x1000 /* interrupts blocked */
/* PRThread.state */
#define _PR_UNBORN 0
@ -583,7 +579,7 @@ NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
#define _PR_STACK_MAPPED 0x2 /* vm is mapped */
#define _PR_STACK_PRIMORDIAL 0x4 /* stack for primordial thread */
/*
/*
** If the default stcksize from the client is zero, we need to pick a machine
** dependent value. This is only for standard user threads. For custom threads,
** 0 has a special meaning.
@ -591,7 +587,7 @@ NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
*/
#ifndef _MD_MINIMUM_STACK_SIZE
#define _MD_MINIMUM_STACK_SIZE 0
#define _MD_MINIMUM_STACK_SIZE 0
#endif
#if (!defined(HAVE_CUSTOM_USER_THREADS))
@ -610,12 +606,12 @@ NSPR_API(void) _PR_Notify(PRMonitor *mon, PRBool all, PRBool sticky);
#define _PR_IS_GCABLE_THREAD(thr) ((thr)->flags & _PR_GCABLE_THREAD)
#define _PR_PENDING_INTERRUPT(thr) \
(!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))
#define _PR_THREAD_BLOCK_INTERRUPT(thr) \
(thr->flags |= _PR_INTERRUPT_BLOCKED)
#define _PR_THREAD_UNBLOCK_INTERRUPT(thr) \
(thr->flags &= ~_PR_INTERRUPT_BLOCKED)
#define _PR_PENDING_INTERRUPT(thr) \
(!((thr)->flags & _PR_INTERRUPT_BLOCKED) && ((thr)->flags & _PR_INTERRUPT))
#define _PR_THREAD_BLOCK_INTERRUPT(thr) \
(thr->flags |= _PR_INTERRUPT_BLOCKED)
#define _PR_THREAD_UNBLOCK_INTERRUPT(thr) \
(thr->flags &= ~_PR_INTERRUPT_BLOCKED)
#define _PR_THREAD_PTR(_qp) \
((PRThread*) ((char*) (_qp) - offsetof(PRThread,links)))
@ -697,28 +693,28 @@ extern void _PR_SetThreadPriority(
PRThread* thread, PRThreadPriority priority);
/***********************************************************************
** FUNCTION: _PR_NewSegment()
** FUNCTION: _PR_NewSegment()
** DESCRIPTION:
** Allocate a memory segment. The "size" value is rounded up to the
** native system page size and a page aligned portion of memory is
** returned. This memory is not part of the malloc heap. If "vaddr" is
** not NULL then PR tries to allocate the segment at the desired virtual
** address.
** INPUTS: size: size of the desired memory segment
** INPUTS: size: size of the desired memory segment
** vaddr: address at which the newly aquired segment is to be
** mapped into memory.
** OUTPUTS: a memory segment is allocated, a PRSegment is allocated
** RETURN: pointer to PRSegment
** OUTPUTS: a memory segment is allocated, a PRSegment is allocated
** RETURN: pointer to PRSegment
***********************************************************************/
extern PRSegment* _PR_NewSegment(PRUint32 size, void *vaddr);
/***********************************************************************
** FUNCTION: _PR_DestroySegment()
** FUNCTION: _PR_DestroySegment()
** DESCRIPTION:
** The memory segment and the PRSegment are freed
** INPUTS: seg: pointer to PRSegment to be freed
** OUTPUTS: the the PRSegment and its associated memory segment are freed
** RETURN: void
** INPUTS: seg: pointer to PRSegment to be freed
** OUTPUTS: the the PRSegment and its associated memory segment are freed
** RETURN: void
***********************************************************************/
extern void _PR_DestroySegment(PRSegment *seg);
@ -739,7 +735,7 @@ NSPR_API(PRThread*) _PR_CreateThread(PRThreadType type,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize,
PRUint32 flags);
PRUint32 flags);
extern void _PR_NativeDestroyThread(PRThread *thread);
extern void _PR_UserDestroyThread(PRThread *thread);
@ -948,10 +944,6 @@ extern void _PR_MD_BEGIN_RESUME_ALL(void);
extern void _PR_MD_END_RESUME_ALL(void);
#define _PR_MD_END_RESUME_ALL _MD_END_RESUME_ALL
#if defined(IRIX)
NSPR_API(void) _PR_IRIX_CHILD_PROCESS(void);
#endif /* IRIX */
#endif /* !_PR_LOCAL_THREADS_ONLY */
extern void _PR_MD_CLEAN_THREAD(PRThread *thread);
@ -962,19 +954,19 @@ extern void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread *);
#define _PR_MD_CREATE_PRIMORDIAL_USER_THREAD _MD_CREATE_PRIMORDIAL_USER_THREAD
extern PRThread* _PR_MD_CREATE_USER_THREAD(
PRUint32 stacksize,
void (*start)(void *),
void *arg);
PRUint32 stacksize,
void (*start)(void *),
void *arg);
#define _PR_MD_CREATE_USER_THREAD _MD_CREATE_USER_THREAD
#endif
extern PRStatus _PR_MD_CREATE_THREAD(
PRThread *thread,
void (*start) (void *),
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize);
PRThread *thread,
void (*start) (void *),
PRThreadPriority priority,
PRThreadScope scope,
PRThreadState state,
PRUint32 stackSize);
#define _PR_MD_CREATE_THREAD _MD_CREATE_THREAD
extern void _PR_MD_JOIN_THREAD(_MDThread *md);
@ -1141,32 +1133,32 @@ extern PRInt32 _PR_MD_LISTEN(PRFileDesc *fd, PRIntn backlog);
extern PRInt32 _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how);
#define _PR_MD_SHUTDOWN _MD_SHUTDOWN
extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount,
PRIntn flags, PRIntervalTime timeout);
extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount,
PRIntn flags, PRIntervalTime timeout);
#define _PR_MD_RECV _MD_RECV
extern PRInt32 _PR_MD_SEND(
PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
PRIntervalTime timeout);
#define _PR_MD_SEND _MD_SEND
extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,
PRNetAddr **raddr, void *buf, PRInt32 amount,
PRIntervalTime timeout);
extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,
PRNetAddr **raddr, void *buf, PRInt32 amount,
PRIntervalTime timeout);
#define _PR_MD_ACCEPT_READ _MD_ACCEPT_READ
#ifdef WIN32
extern PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr,
PRUint32 *addrlen, PRIntervalTime timeout,
PRBool fast,
_PR_AcceptTimeoutCallback callback,
void *callbackArg);
extern PROsfd _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr,
PRUint32 *addrlen, PRIntervalTime timeout,
PRBool fast,
_PR_AcceptTimeoutCallback callback,
void *callbackArg);
extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,
PRNetAddr **raddr, void *buf, PRInt32 amount,
PRIntervalTime timeout, PRBool fast,
_PR_AcceptTimeoutCallback callback,
void *callbackArg);
extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PROsfd *newSock,
PRNetAddr **raddr, void *buf, PRInt32 amount,
PRIntervalTime timeout, PRBool fast,
_PR_AcceptTimeoutCallback callback,
void *callbackArg);
extern void _PR_MD_UPDATE_ACCEPT_CONTEXT(PROsfd s, PROsfd ls);
#define _PR_MD_UPDATE_ACCEPT_CONTEXT _MD_UPDATE_ACCEPT_CONTEXT
@ -1180,8 +1172,8 @@ extern const PRTime _pr_filetime_offset;
#endif /* WIN32 */
extern PRInt32 _PR_MD_SENDFILE(
PRFileDesc *sock, PRSendFileData *sfd,
PRInt32 flags, PRIntervalTime timeout);
PRFileDesc *sock, PRSendFileData *sfd,
PRInt32 flags, PRIntervalTime timeout);
#define _PR_MD_SENDFILE _MD_SENDFILE
extern PRStatus _PR_MD_GETSOCKNAME(
@ -1237,7 +1229,7 @@ extern PRInt32 _PR_MD_PIPEAVAILABLE(PRFileDesc *fd);
#define _PR_MD_PIPEAVAILABLE _MD_PIPEAVAILABLE
extern PRInt32 _PR_MD_PR_POLL(PRPollDesc *pds, PRIntn npds,
PRIntervalTime timeout);
PRIntervalTime timeout);
#define _PR_MD_PR_POLL _MD_PR_POLL
/*
@ -1265,8 +1257,8 @@ extern PRStatus _PR_MD_SET_FD_INHERITABLE(PRFileDesc *fd, PRBool inheritable);
PR_SetError( PR_PENDING_INTERRUPT_ERROR, 0); \
} else { \
PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \
}
}
extern void *_PR_MD_GET_SP(PRThread *thread);
#define _PR_MD_GET_SP _MD_GET_SP
@ -1368,32 +1360,32 @@ extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr);
*/
#if defined(XP_UNIX) || defined(XP_OS2)
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: ((_addr)->raw.family == PR_AF_INET6 \
? sizeof(struct _md_sockaddr_in6) \
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: ((_addr)->raw.family == PR_AF_INET6 \
? sizeof(struct _md_sockaddr_in6) \
: sizeof((_addr)->local)))
#else
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: sizeof(struct _md_sockaddr_in6))
#endif /* defined(XP_UNIX) */
#else
#if defined(XP_UNIX) || defined(XP_OS2)
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: ((_addr)->raw.family == PR_AF_INET6 \
? sizeof((_addr)->ipv6) \
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: ((_addr)->raw.family == PR_AF_INET6 \
? sizeof((_addr)->ipv6) \
: sizeof((_addr)->local)))
#else
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
#define PR_NETADDR_SIZE(_addr) \
((_addr)->raw.family == PR_AF_INET \
? sizeof((_addr)->inet) \
: sizeof((_addr)->ipv6))
#endif /* defined(XP_UNIX) */
@ -1411,14 +1403,14 @@ struct PRLock {
PRBool locked; /* whether the mutex is locked */
pthread_t owner; /* if locked, current lock owner */
#elif defined(_PR_BTHREADS)
sem_id semaphoreID; /* the underlying lock */
int32 benaphoreCount; /* number of people in lock */
thread_id owner; /* current lock owner */
sem_id semaphoreID; /* the underlying lock */
int32 benaphoreCount; /* number of people in lock */
thread_id owner; /* current lock owner */
#else /* not pthreads or Be threads */
PRCList links; /* linkage for PRThread.lockList */
struct PRThread *owner; /* current lock owner */
PRCList waitQ; /* list of threads waiting for lock */
PRThreadPriority priority; /* priority of lock */
PRThreadPriority priority; /* priority of lock */
PRThreadPriority boostPriority; /* boosted priority of lock owner */
_MDLock ilock; /* Internal Lock to protect user-level fields */
#endif
@ -1541,7 +1533,7 @@ struct PRThreadStack {
PRUint32 stackSize; /* size of usable portion of the stack */
PRSegment *seg;
PRThread* thr; /* back pointer to thread owning this stack */
PRThread* thr; /* back pointer to thread owning this stack */
#if defined(_PR_PTHREADS)
#else /* defined(_PR_PTHREADS) */
@ -1653,19 +1645,19 @@ struct PRThread {
_PRCPU *cpu; /* cpu to which this thread is bound */
PRUint32 threadAllocatedOnStack;/* boolean */
/* When an async IO is in progress and a second async IO cannot be
/* When an async IO is in progress and a second async IO cannot be
* initiated, the io_pending flag is set to true. Some platforms will
* not use the io_pending flag. If the io_pending flag is true, then
* io_fd is the OS-file descriptor on which IO is pending.
*/
PRBool io_pending;
PRInt32 io_fd;
/* If a timeout occurs or if an outstanding IO is interrupted and the
* OS doesn't support a real cancellation (NT or MAC), then the
* OS doesn't support a real cancellation (NT or MAC), then the
* io_suspended flag will be set to true. The thread will be resumed
* but may run into trouble issuing additional IOs until the io_pending
* flag can be cleared
* flag can be cleared
*/
PRBool io_suspended;
@ -1743,8 +1735,8 @@ struct PRFilePrivate {
_MDFileDesc md;
#ifdef _PR_NEED_SECRET_AF
PRUint16 af; /* If the platform's implementation of accept()
* requires knowing the address family of the
* socket, we save the address family here. */
* requires knowing the address family of the
* socket, we save the address family here. */
#endif
#if defined(_WIN64)
@ -1778,10 +1770,10 @@ struct PRDir {
};
#ifdef MOZ_UNICODE
struct PRDirUTF16 {
PRDirEntry d;
_MDDirUTF16 md;
};
struct PRDirUTF16 {
PRDirEntry d;
_MDDirUTF16 md;
};
#endif /* MOZ_UNICODE */
extern void _PR_InitLocks(void);
@ -1921,7 +1913,7 @@ extern PRStatus _PR_MD_WAIT_PROCESS(PRProcess *process, PRInt32 *exitCode);
#define _PR_MD_WAIT_PROCESS _MD_WAIT_PROCESS
extern PRStatus _PR_MD_KILL_PROCESS(PRProcess *process);
#define _PR_MD_KILL_PROCESS _MD_KILL_PROCESS
#define _PR_MD_KILL_PROCESS _MD_KILL_PROCESS
/* Current Time */
NSPR_API(PRTime) _PR_MD_NOW(void);
@ -2024,7 +2016,7 @@ extern PRStatus _PR_MD_SYNC_MEM_MAP(
/*
** Declare PRSharedMemory.
*/
struct PRSharedMemory
struct PRSharedMemory
{
char *ipcname; /* after conversion to native */
PRSize size; /* from open */
@ -2042,8 +2034,8 @@ struct PRSharedMemory
PRUint32 ident; /* guard word at end of struct */
#define _PR_SHM_IDENT 0xdeadbad
};
extern PRSharedMemory * _MD_OpenSharedMemory(
extern PRSharedMemory * _MD_OpenSharedMemory(
const char *name,
PRSize size,
PRIntn flags,
@ -2063,7 +2055,7 @@ extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm );
extern PRStatus _MD_DeleteSharedMemory( const char *name );
#define _PR_MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory
extern PRFileMap* _md_OpenAnonFileMap(
extern PRFileMap* _md_OpenAnonFileMap(
const char *dirName,
PRSize size,
PRFileMapProtect prot
@ -2140,27 +2132,10 @@ extern PRSize _pr_CopyLowBits( void *dest, PRSize dstlen, void *src, PRSize srcl
/* end PR_GetRandomNoise() related */
#ifdef XP_BEOS
extern PRLock *_connectLock;
typedef struct _ConnectListNode {
PRInt32 osfd;
PRNetAddr addr;
PRUint32 addrlen;
PRIntervalTime timeout;
} ConnectListNode;
extern ConnectListNode connectList[64];
extern PRUint32 connectCount;
#endif /* XP_BEOS */
#if defined(_WIN64) && defined(WIN95)
typedef struct _PRFileDescList {
PRFileDesc *fd;
struct _PRFileDescList *next;
PRFileDesc *fd;
struct _PRFileDescList *next;
} PRFileDescList;
extern PRLock *_fd_waiting_for_overlapped_done_lock;