mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 14:58:34 +00:00
add js to tree
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3693 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
855c7b9a77
commit
fff98f6316
1137 files changed
+386873
No files matched your search
@@ -0,0 +1 @@
|
||||
Makefile
|
||||
@@ -0,0 +1,8 @@
|
||||
/.cvsignore/1.2/Sat May 12 02:03:58 2001//
|
||||
/Makefile.in/1.10/Sun Apr 25 15:00:56 2004//
|
||||
/pprio.h/3.16/Fri Oct 21 18:21:41 2005//
|
||||
/pprmwait.h/3.7/Thu Jan 20 19:02:09 2005//
|
||||
/pprthred.h/3.9/Sun Apr 25 15:00:56 2004//
|
||||
/primpl.h/3.85/Fri Oct 21 18:21:41 2005//
|
||||
/prpriv.h/3.5/Sun Apr 25 15:00:56 2004//
|
||||
D
|
||||
@@ -0,0 +1 @@
|
||||
mozilla/nsprpub/pr/include/private
|
||||
@@ -0,0 +1 @@
|
||||
:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
RELEASE_HEADERS = pprio.h pprthred.h prpriv.h
|
||||
RELEASE_HEADERS := $(addprefix $(srcdir)/, $(RELEASE_HEADERS))
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)/private
|
||||
|
||||
HEADERS = $(RELEASE_HEADERS) $(srcdir)/pprmwait.h $(srcdir)/primpl.h
|
||||
|
||||
include_subdir = private
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(RELEASE_HEADERS)
|
||||
$(INSTALL) -m 444 $(RELEASE_HEADERS) $(dist_includedir)/private
|
||||
@@ -0,0 +1,271 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
** 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.
|
||||
** This function will be obsoleted with the next release; avoid using it.
|
||||
*/
|
||||
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 */
|
||||
|
||||
/*
|
||||
** Need external access to this on Mac so we can first set up our faux
|
||||
** environment vars
|
||||
*/
|
||||
#ifdef XP_MAC
|
||||
NSPR_API(void) PR_Init_Log(void);
|
||||
#endif
|
||||
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* pprio_h___ */
|
||||
@@ -0,0 +1,135 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#if defined(_PPRMWAIT_H)
|
||||
#else
|
||||
#define _PPRMWAIT_H
|
||||
|
||||
#include "prlock.h"
|
||||
#include "prcvar.h"
|
||||
#include "prclist.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#define MAX_POLLING_INTERVAL 100
|
||||
#define _PR_POLL_COUNT_FUDGE 64
|
||||
#define _PR_DEFAULT_HASH_LENGTH 59
|
||||
|
||||
/*
|
||||
* Our hash table resolves collisions by open addressing with
|
||||
* double hashing. See Cormen, Leiserson, and Rivest,
|
||||
* Introduction to Algorithms, p. 232, The MIT Press, 1990.
|
||||
*/
|
||||
|
||||
#define _MW_HASH(a, m) ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m))
|
||||
#define _MW_HASH2(a, m) (1 + ((((PRUptrdiff)(a) >> 4) ^ ((PRUptrdiff)(a) >> 10)) % (m - 2)))
|
||||
#define _MW_ABORTED(_rv) \
|
||||
((PR_FAILURE == (_rv)) && (PR_PENDING_INTERRUPT_ERROR == PR_GetError()))
|
||||
|
||||
typedef enum {_prmw_success, _prmw_rehash, _prmw_error} _PR_HashStory;
|
||||
|
||||
typedef struct _PRWaiterHash
|
||||
{
|
||||
PRUint16 count; /* current number in hash table */
|
||||
PRUint16 length; /* current size of the hash table */
|
||||
PRRecvWait *recv_wait; /* hash table of receive wait objects */
|
||||
} _PRWaiterHash;
|
||||
|
||||
typedef enum {_prmw_running, _prmw_stopping, _prmw_stopped} PRMWGroupState;
|
||||
|
||||
struct PRWaitGroup
|
||||
{
|
||||
PRCList group_link; /* all groups are linked to each other */
|
||||
PRCList io_ready; /* list of I/O requests that are ready */
|
||||
PRMWGroupState state; /* state of this group (so we can shut down) */
|
||||
|
||||
PRLock *ml; /* lock for synchronizing this wait group */
|
||||
PRCondVar *io_taken; /* calling threads notify when they take I/O */
|
||||
PRCondVar *io_complete; /* calling threads wait here for completions */
|
||||
PRCondVar *new_business; /* polling thread waits here more work */
|
||||
PRCondVar *mw_manage; /* used to manage group lists */
|
||||
PRThread* poller; /* thread that's actually doing the poll() */
|
||||
PRUint16 waiting_threads; /* number of threads waiting for recv */
|
||||
PRUint16 polling_count; /* number of elements in the polling list */
|
||||
PRUint32 p_timestamp; /* pseudo-time group had element removed */
|
||||
PRPollDesc *polling_list; /* list poller builds for polling */
|
||||
PRIntervalTime last_poll; /* last time we polled */
|
||||
_PRWaiterHash *waiter; /* pointer to hash table of wait receive objects */
|
||||
|
||||
#ifdef WINNT
|
||||
/*
|
||||
* On NT, idle threads are responsible for getting completed i/o.
|
||||
* They need to add completed i/o to the io_ready list. Since
|
||||
* idle threads cannot use nspr locks, we have to use an md lock
|
||||
* to protect the io_ready list.
|
||||
*/
|
||||
_MDLock mdlock; /* protect io_ready, waiter, and wait_list */
|
||||
PRCList wait_list; /* used in place of io_complete. reuse
|
||||
* waitQLinks in the PRThread structure. */
|
||||
#endif /* WINNT */
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
***********************************************************************
|
||||
******************** Wait group enumerations **************************
|
||||
***********************************************************************
|
||||
**********************************************************************/
|
||||
typedef struct _PRGlobalState
|
||||
{
|
||||
PRCList group_list; /* master of the group list */
|
||||
PRWaitGroup *group; /* the default (NULL) group */
|
||||
} _PRGlobalState;
|
||||
|
||||
#ifdef WINNT
|
||||
extern PRStatus NT_HashRemoveInternal(PRWaitGroup *group, PRFileDesc *fd);
|
||||
#endif
|
||||
|
||||
typedef enum {_PR_ENUM_UNSEALED=0, _PR_ENUM_SEALED=0x0eadface} _PREnumSeal;
|
||||
|
||||
struct PRMWaitEnumerator
|
||||
{
|
||||
PRWaitGroup *group; /* group this enumerator is bound to */
|
||||
PRThread *thread; /* thread in midst of an enumeration */
|
||||
_PREnumSeal seal; /* trying to detect deleted objects */
|
||||
PRUint32 p_timestamp; /* when enumeration was (re)started */
|
||||
PRRecvWait **waiter; /* pointer into hash table */
|
||||
PRUintn index; /* position in hash table */
|
||||
void *pad[4]; /* some room to grow */
|
||||
};
|
||||
|
||||
#endif /* defined(_PPRMWAIT_H) */
|
||||
|
||||
/* pprmwait.h */
|
||||
@@ -0,0 +1,373 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#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 THREAD SYNCHRONIZATION FUNCTIONS
|
||||
---------------------------------------------------------------------------*/
|
||||
#if defined(XP_MAC)
|
||||
|
||||
NSPR_API(void) PR_Mac_WaitForAsyncNotify(PRIntervalTime timeout);
|
||||
NSPR_API(void) PR_Mac_PostAsyncNotify(PRThread *thread);
|
||||
|
||||
#endif /* XP_MAC */
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
** 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___ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef prpriv_h___
|
||||
#define prpriv_h___
|
||||
|
||||
/*
|
||||
* NSPR 2.0 Private API
|
||||
*/
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "private/pprio.h"
|
||||
#include "private/pprthred.h"
|
||||
#else
|
||||
#include "pprio.h"
|
||||
#include "pprthred.h"
|
||||
#endif
|
||||
|
||||
#endif /* prpriv_h___ */
|
||||
Reference in new issue
Block a user