/* -*- 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
*
* 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 primpl_h___
#define primpl_h___
/*
* has:
* #define sigaction _sigaction_sys
* To be safe, we include pthread.h first.
*/
#if defined(_PR_PTHREADS)
#include <pthread.h>
#endif
#if defined(_PR_BTHREADS)
#endif
#ifdef WINNT
/* Need to force service-pack 3 extensions to be defined by
*/
#ifndef _WIN32_WINNT
#endif /* _WIN32_WINNT */
#endif /* WINNT */
#include "nspr.h"
#include "prpriv.h"
#ifdef XP_MAC
#include "prosdep.h"
#include "probslet.h"
#else
#include "obsolete/probslet.h"
#endif /* XP_MAC */
#ifdef _PR_HAVE_POSIX_SEMAPHORES
#include <semaphore.h>
#elif defined(_PR_HAVE_SYSV_SEMAPHORES)
#endif
/*************************************************************************
***** A Word about Model Dependent Function Naming Convention ***********
*************************************************************************/
/*
NSPR 2.0 must implement its function across a range of platforms
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.
platform dependent function is declared as:
NSPR_API void _PR_MD_FUNCTION( long arg1, long arg2 );
#define _PR_MD_FUNCTION _MD_FUNCTION
each #define'd macro is redefined as one of:
#define _MD_FUNCTION <blanks>
#define _MD_FUNCTION <expanded macro>
#define _MD_FUNCTION <osFunction>
#define _MD_FUNCTION <_MD_Function>
Where:
<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:
#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:
#define _MD_EXIT exit
<_MD_function> is the name of a function implemented for this platform in
For example:
#define _MD_GETFILEINFO _MD_GetFileInfo
In <source>.c, the implementation is:
PR_IMPLEMENT(PRInt32) _MD_GetFileInfo(const char *fn, PRFileInfo *info);
*/
#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
#ifdef MOZ_UNICODE
#endif /* MOZ_UNICODE */
#if defined(_PR_PTHREADS)
/*
** The following definitions are unique to implementing NSPR using pthreads.
** Since pthreads defines most of the thread and thread synchronization
** stuff, this is a pretty small set.
*/
struct _PT_Notified
{
struct
{
};
/*
* bits defined for pthreads 'state' field
*/
(thr->interrupt_blocked = 0)
#ifdef GC_LEAK_DETECTOR
/* All threads are GCable. */
#else
#endif /* GC_LEAK_DETECTOR */
/*
** 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
** just as a mnemonic.
**/
#if defined(DEBUG)
typedef struct PTDebug
{
} PTDebug;
#endif /* defined(DEBUG) */
#else /* defined(_PR_PTHREADS) */
/*
** This section is contains those parts needed to implement NSPR on
** platforms in general. One would assume that the pthreads implementation
** included lots of the same types, at least conceptually.
*/
/*
* Local threads only. No multiple CPU support and hence all the
* following routines are no-op.
*/
#ifdef _PR_LOCAL_THREADS_ONLY
#define _PR_MD_BEGIN_SUSPEND_ALL()
#define _PR_MD_END_SUSPEND_ALL()
#define _PR_MD_BEGIN_RESUME_ALL()
#define _PR_MD_END_RESUME_ALL()
#endif
struct _PRCPUQueue {
};
struct _PRCPU {
union {
} u;
* _PR_ClockInterrupt() on this CPU
*/
};
typedef struct _PRInterruptTable {
const char *name;
void (*handler)(void);
&& !(defined(SOLARIS) && defined(_PR_GLOBAL_THREADS_ONLY))
#endif
#ifdef _PR_LOCAL_THREADS_ONLY
#ifndef XP_MAC
#endif
/* The unbalanced curly braces in these two macros are intentional */
#endif /* _PR_LOCAL_THREADS_ONLY */
extern PRInt32 _native_threads_only;
#if defined(_PR_GLOBAL_THREADS_ONLY)
#define _MD_GET_INTSOFF() 0
#define _PR_CPU_LIST_LOCK()
#define _PR_CPU_LIST_UNLOCK()
#else
#ifdef XP_MAC
#else /* XP_MAC */
(_is) = _PR_MD_GET_INTSOFF(); \
_PR_MD_SET_INTSOFF(1); \
#endif /* XP_MAC */
_PR_IntsOn((_PR_MD_CURRENT_CPU())); \
#ifdef _PR_LOCAL_THREADS_ONLY
#define _PR_CPU_LIST_LOCK()
#define _PR_CPU_LIST_UNLOCK()
#define _PR_IS_NATIVE_THREAD_SUPPORTED() 0
#else /* _PR_LOCAL_THREADS_ONLY */
/* These are for the "combined" thread model */
(_thread)->queueCount = 0; \
(_thread)->queueCount = 0; \
(_thread)->queueCount = 0; \
(_thread)->queueCount = 0; \
#endif /* _PR_LOCAL_THREADS_ONLY */
#endif /* _PR_GLOBAL_THREADS_ONLY */
extern _PRInterruptTable _pr_interruptTable[];
/* Bits for _pr_interruptState.u.missed[0,1] */
NSPR_API(void) _PR_WakeupCPU(void);
NSPR_API(void) _PR_PauseCPU(void);
/************************************************************************/
/************************************************************************/
extern PRStatus _PR_WaitCondVar(
/* PRThread.flags */
/* PRThread.state */
#define _PR_UNBORN 0
/* PRThreadStack.flags */
/*
** 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.
** Adjust stackSize. Round up to a page boundary.
*/
#ifndef _MD_MINIMUM_STACK_SIZE
#define _MD_MINIMUM_STACK_SIZE 0
#endif
#if (!defined(HAVE_CUSTOM_USER_THREADS))
if (stackSize == 0) \
if (stackSize < _MD_MINIMUM_STACK_SIZE) \
stackSize <<= _pr_pageShift; \
#else
#endif
#ifdef GC_LEAK_DETECTOR
/* All threads are GCable. */
#else
#endif /* GC_LEAK_DETECTOR */
extern PRCList _pr_active_local_threadQ;
extern PRCList _pr_active_global_threadQ;
extern _MDLock _pr_cpuLock;
extern PRInt32 _pr_md_idle_cpus;
extern PRLock *_pr_deadQLock;
extern PRUint32 _pr_numNativeDead;
extern PRUint32 _pr_numUserDead;
extern PRCList _pr_deadNativeQ;
extern PRCList _pr_deadUserQ;
extern struct _PRCPU *_pr_primordialCPU;
* before the primordial thread
* can exit. */
* notifying the primordial thread
* when all other user threads
* have terminated. */
extern PRUintn _pr_maxPTDs;
extern PRLock *_pr_terminationCVLock;
/*************************************************************************
* Internal routines either called by PR itself or from machine-dependent *
* code. *
*************************************************************************/
extern void _PR_ClockInterrupt(void);
extern void _PR_Schedule(void);
extern void _PR_SetThreadPriority(
/***********************************************************************
** 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
** 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
***********************************************************************/
/***********************************************************************
** 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
***********************************************************************/
void *arg,
extern PRThread* _PRI_AttachThread(
extern void _PRI_DetachThread(void);
NSPR_API(void) _PR_MD_INIT_CPUS();
NSPR_API(void) _PR_MD_WAKEUP_CPUS();
/* Interrupts related */
NSPR_API(void) _PR_MD_START_INTERRUPTS(void);
NSPR_API(void) _PR_MD_STOP_INTERRUPTS(void);
NSPR_API(void) _PR_MD_ENABLE_CLOCK_INTERRUPTS(void);
NSPR_API(void) _PR_MD_DISABLE_CLOCK_INTERRUPTS(void);
NSPR_API(void) _PR_MD_BLOCK_CLOCK_INTERRUPTS(void);
NSPR_API(void) _PR_MD_UNBLOCK_CLOCK_INTERRUPTS(void);
/* The _PR_MD_WAIT_LOCK and _PR_MD_WAKEUP_WAITER functions put to sleep and
* awaken a thread which is waiting on a lock or cvar.
*/
#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
NSPR_API(void) _PR_MD_CLOCK_INTERRUPT(void);
#endif
/* Stack debugging */
/* CPU related */
/*
* Returns the number of threads awoken or 0 if a timeout occurred;
*/
extern void _PR_MD_CLEANUP_BEFORE_EXIT(void);
/* Locks related */
NSPR_API(void) _PR_MD_INIT_LOCKS(void);
/* Return 0 on success, a nonzero value on failure. */
NSPR_API(void) _PR_MD_IOQ_LOCK(void);
NSPR_API(void) _PR_MD_IOQ_UNLOCK(void);
#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
/* Semaphore related -- only for native threads */
#ifdef HAVE_CVAR_BUILT_ON_SEM
#endif /* HAVE_CVAR_BUILT_ON_SEM */
#endif
/* Condition Variables related -- only for native threads */
#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
NSPR_API(void) _PR_MD_WAIT_CV(
#endif /* _PR_LOCAL_THREADS_ONLY */
/* Threads related */
#ifndef _PR_LOCAL_THREADS_ONLY /* not if only local threads supported */
extern void _PR_MD_BEGIN_SUSPEND_ALL(void);
extern void _PR_MD_END_SUSPEND_ALL(void);
extern void _PR_MD_BEGIN_RESUME_ALL(void);
extern void _PR_MD_END_RESUME_ALL(void);
#if defined(IRIX)
NSPR_API(void) _PR_IRIX_CHILD_PROCESS(void);
#endif /* IRIX */
#endif /* !_PR_LOCAL_THREADS_ONLY */
#ifdef HAVE_CUSTOM_USER_THREADS
extern void _PR_MD_CREATE_PRIMORDIAL_USER_THREAD(PRThread *);
extern PRThread* _PR_MD_CREATE_USER_THREAD(
void (*start)(void *),
void *arg);
#endif
extern PRStatus _PR_MD_CREATE_THREAD(
void (*start) (void *),
extern void _PR_MD_END_THREAD(void);
extern void _PR_MD_YIELD(void);
NSPR_API(void) _PR_MD_SUSPENDALL(void);
NSPR_API(void) _PR_MD_RESUMEALL(void);
extern void _PR_MD_INIT_CONTEXT(
/* Segment related */
extern void _PR_MD_INIT_SEGS(void);
/* Directory enumeration related */
/* Named semaphores related */
extern PRSem * _PR_MD_OPEN_SEMAPHORE(
/* I/O related */
#ifdef XP_MAC
#endif
/* File I/O related */
extern PRInt32 _PR_MD_WRITEV(
#ifdef MOZ_UNICODE
/* UTF16 File I/O related */
#endif /* MOZ_UNICODE */
/* Socket I/O related */
extern void _PR_MD_INIT_IO(void);
extern PRInt32 _PR_MD_CONNECT(
extern PRInt32 _PR_MD_ACCEPT(
extern PRInt32 _PR_MD_SEND(
#ifdef WIN32
void *callbackArg);
void *callbackArg);
#endif /* WIN32 */
extern PRInt32 _PR_MD_SENDFILE(
extern PRStatus _PR_MD_GETSOCKNAME(
extern PRStatus _PR_MD_GETPEERNAME(
extern PRStatus _PR_MD_GETSOCKOPT(
extern PRStatus _PR_MD_SETSOCKOPT(
extern PRInt32 _PR_MD_RECVFROM(
extern PRInt32 _PR_MD_SENDTO(
/*
* Initialize fd->secret->inheritable for a newly created fd.
* If 'imported' is false, the osfd (i.e., fd->secret->md.osfd)
* was created by NSPR and hence has the OS-dependent default
* inheritable attribute. If 'imported' is true, the osfd was
* not created by NSPR and hence a system call is required to
* query its inheritable attribute. Since we may never need to
* know the inheritable attribute of a fd, a platform may choose
* to initialize fd->secret->inheritable of an imported fd to
* _PR_TRI_UNKNOWN and only pay the cost of the system call
* (in _PR_MD_QUERY_FD_INHERITABLE) when necessary.
*/
if (_PR_PENDING_INTERRUPT(me)) { \
} else { \
PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \
}
#endif /* defined(_PR_PTHREADS) */
/************************************************************************/
/*************************************************************************
** The remainder of the definitions are shared by pthreads and the classic
** NSPR code. These too may be conditionalized.
*************************************************************************/
/************************************************************************/
/*****************************************************************************/
/************************** File descriptor caching **************************/
/*****************************************************************************/
extern void _PR_InitFdCache(void);
extern void _PR_CleanupFdCache(void);
extern PRFileDesc *_PR_Getfd(void);
/*
* These flags are used by NSPR temporarily in the poll
* descriptor's out_flags field to record the mapping of
* NSPR's poll flags to the system poll flags.
*
* If _PR_POLL_READ_SYS_WRITE bit is set, it means the
* PR_POLL_READ flag specified by the topmost layer is
* mapped to the WRITE flag at the system layer. Similarly
* for the other three _PR_POLL_XXX_SYS_YYY flags. It is
* assumed that the PR_POLL_EXCEPT flag doesn't get mapped
* to other flags.
*/
/*
** These methods are coerced into file descriptor methods table
** when the intended service is inappropriate for the particular
** type of file descriptor.
*/
extern PRIntn _PR_InvalidInt(void);
extern PRInt16 _PR_InvalidInt16(void);
extern PRInt64 _PR_InvalidInt64(void);
extern PRStatus _PR_InvalidStatus(void);
extern PRFileDesc *_PR_InvalidDesc(void);
extern PRIOMethods _pr_faulty_methods;
/*
** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union
** whose 'family' field is set. It returns the size of the union
** member corresponding to the specified address family.
*/
#if defined(_PR_INET6)
#elif defined(_PR_HAVE_MD_SOCKADDR_IN6)
/*
** Under the following conditions:
** 1. _PR_INET6 is not defined;
** 2. _PR_INET6_PROBE is defined;
** 3. struct sockaddr_in6 has nonstandard fields at the end
** (e.g., on Solaris 8),
** (_addr)->ipv6 is smaller than struct sockaddr_in6, and
** hence we can't pass sizeof((_addr)->ipv6) to socket
** functions such as connect because they would fail with
** EINVAL.
**
** To pass the correct socket address length to socket
** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and
** define struct _md_sockaddr_in6 to be isomorphic to
** struct sockaddr_in6.
*/
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
? sizeof(struct _md_sockaddr_in6) \
#else
: sizeof(struct _md_sockaddr_in6)
#endif /* defined(XP_UNIX) */
#else
#if defined(XP_UNIX) || defined(XP_OS2_EMX)
#else
#endif /* defined(XP_UNIX) */
#endif /* defined(_PR_INET6) */
extern PRStatus _PR_MapOptionName(
extern void _PR_InitThreads(
struct PRLock {
#if defined(_PR_PTHREADS)
#elif defined(_PR_BTHREADS)
#else /* not pthreads or Be threads */
#endif
};
extern void _PR_InitLocks(void);
struct PRCondVar {
#if defined(_PR_PTHREADS)
#elif defined(_PR_BTHREADS)
#else /* not pthreads or Be threads */
#endif
};
/************************************************************************/
struct PRMonitor {
#if defined(_PR_PTHREADS)
#else /* defined(_PR_PTHREADS) */
#endif /* defined(_PR_PTHREADS) */
};
/************************************************************************/
struct PRSemaphore {
#if defined(_PR_BTHREADS)
#else
#if defined(_PR_PTHREADS)
#else /* defined(_PR_PTHREADS) */
#endif /* defined(_PR_PTHREADS) */
#endif /* defined(_PR_BTHREADS) */
};
NSPR_API(void) _PR_InitSem(void);
/*************************************************************************/
struct PRSem {
#ifdef _PR_HAVE_POSIX_SEMAPHORES
#elif defined(_PR_HAVE_SYSV_SEMAPHORES)
int semid;
#else
#endif
};
/*************************************************************************/
struct PRStackStr {
/* head MUST be at offset 0; assembly language code relies on this */
#if defined(AIX)
#else
#endif
char *prstk_name;
};
/************************************************************************/
/* XXX this needs to be exported (sigh) */
struct PRThreadStack {
#if defined(_PR_PTHREADS)
#else /* defined(_PR_PTHREADS) */
#endif /* defined(_PR_PTHREADS) */
};
extern void _PR_DestroyThreadPrivate(PRThread*);
struct PRThread {
/*
** Per thread private data
*/
#if defined(_PR_PTHREADS)
#ifdef PT_NO_SIGTIMEDWAIT
#endif
#if defined(_PR_POLL_WITH_SELECT)
#endif
#elif defined(_PR_BTHREADS)
#else /* not pthreads or Be threads */
* Protects the following fields:
* state
* priority
* links
* wait
* cpu
*/
struct _wait {
} wait;
* This flag has relevance only when
* multiple NSPR CPUs are created.
* When a thread is de-scheduled, there
* is a narrow window of time in which
* the thread is put on the run queue
* but the scheduler is actually using
* the stack of this thread. It is safe
* to run this thread on a different CPU
* only when its stack is not in use on
* any other CPU. The no_sched flag is
* set during this interval to prevent
* the thread from being scheduled on a
* different CPU.
*/
/* thread termination condition variable for join */
/* 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.
*/
/* 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
* 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
*/
#endif
};
struct PRProcessAttr {
char *currentDirectory;
char *fdInheritBuffer;
};
struct PRProcess {
};
struct PRFileMap {
};
/************************************************************************/
/*
** File descriptors of the NSPR layer can be in one of the
** following states (stored in the 'state' field of struct
** PRFilePrivate):
** - _PR_FILEDESC_OPEN: The OS fd is open.
** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
** is still open but is unusable. The only operation allowed
** on the PRFileDesc is PR_Close().
** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
** structure is freed.
*/
/*
** A boolean type with an additional "unknown" state
*/
typedef enum {
_PR_TRI_FALSE = 0,
struct PRFilePrivate {
* -1: a native lockfile call is in progress
* > 0: # times the file is locked */
#ifdef _PR_HAVE_PEEK_BUFFER
char *peekBuffer;
#endif
#if !defined(XP_UNIX) /* BugZilla: 4090 */
#endif
#ifdef _PR_STRICT_ADDR_LEN
* length of the sockaddr structure for the
* address family of the socket to socket
* functions like accept(), we need to save
* the address family of the socket. */
#endif
};
struct PRDir {
PRDirEntry d;
};
#ifdef MOZ_UNICODE
struct PRDirUTF16 {
PRDirEntry d;
};
#endif /* MOZ_UNICODE */
extern void _PR_InitSegs(void);
extern void _PR_InitStacks(void);
extern void _PR_InitTPD(void);
extern void _PR_InitMem(void);
extern void _PR_InitEnv(void);
extern void _PR_InitCMon(void);
extern void _PR_InitIO(void);
extern void _PR_InitLog(void);
extern void _PR_InitNet(void);
extern void _PR_InitClock(void);
extern void _PR_InitLinker(void);
extern void _PR_InitAtomic(void);
extern void _PR_InitCPUs(void);
extern void _PR_InitDtoa(void);
extern void _PR_InitMW(void);
extern void _PR_InitRWLocks(void);
extern void _PR_CleanupCallOnce(void);
extern void _PR_CleanupMW(void);
extern void _PR_CleanupDtoa(void);
extern void _PR_ShutdownLinker(void);
extern void _PR_CleanupEnv(void);
extern void _PR_CleanupIO(void);
extern void _PR_CleanupNet(void);
extern void _PR_CleanupLayerCache(void);
extern void _PR_CleanupStacks(void);
#ifdef WINNT
extern void _PR_CleanupCPUs(void);
#endif
extern void _PR_CleanupThreads(void);
extern void _PR_CleanupTPD(void);
extern void _PR_Cleanup(void);
extern void _PR_LogCleanup(void);
extern void _PR_InitLayerCache(void);
#ifdef GC_LEAK_DETECTOR
extern void _PR_InitGarbageCollector(void);
#endif
extern PRBool _pr_initialized;
extern void _PR_ImplicitInitialization(void);
/************************************************************************/
struct PRSegment {
void *vaddr;
#if defined(_PR_PTHREADS)
#else /* defined(_PR_PTHREADS) */
#endif /* defined(_PR_PTHREADS) */
};
/* PRSegment.flags */
/************************************************************************/
extern PRInt32 _pr_pageSize;
extern PRInt32 _pr_pageShift;
extern PRLogModuleInfo *_pr_clock_lm;
extern PRLogModuleInfo *_pr_cmon_lm;
extern PRLogModuleInfo *_pr_io_lm;
extern PRLogModuleInfo *_pr_cvar_lm;
extern PRLogModuleInfo *_pr_mon_lm;
extern PRLogModuleInfo *_pr_linker_lm;
extern PRLogModuleInfo *_pr_sched_lm;
extern PRLogModuleInfo *_pr_thread_lm;
extern PRLogModuleInfo *_pr_gc_lm;
extern PRFileDesc *_pr_stdin;
extern PRFileDesc *_pr_stdout;
extern PRFileDesc *_pr_stderr;
/* Zone allocator */
/*
** The zone allocator code has hardcoded pthread types and
** functions, so it can only be used in the pthreads version.
** This can be fixed by replacing the hardcoded pthread types
** and functions with macros that expand to the native thread
** types and functions on each platform.
*/
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
#define _PR_ZONE_ALLOCATOR
#endif
#ifdef _PR_ZONE_ALLOCATOR
extern void _PR_InitZones(void);
extern void _PR_DestroyZones(void);
#endif
/* Overriding malloc, free, etc. */
#if !defined(_PR_NO_PREEMPT) && defined(XP_UNIX) \
&& !defined(_PR_PTHREADS) && !defined(_PR_GLOBAL_THREADS_ONLY) \
&& !defined(PURIFY) \
&& !defined(DARWIN) \
&& !defined(NEXTSTEP) \
&& !defined(QNX) \
&& !(defined (UNIXWARE) && defined (USE_SVR4_THREADS))
#define _PR_OVERRIDE_MALLOC
#endif
/*************************************************************************
* External machine-dependent code provided by each OS. * *
*************************************************************************/
/* Initialization related */
extern void _PR_MD_EARLY_INIT(void);
extern void _PR_MD_INTERVAL_INIT(void);
NSPR_API(void) _PR_MD_FINAL_INIT(void);
/* Process control */
extern PRProcess * _PR_MD_CREATE_PROCESS(
const char *path,
char *const *argv,
char *const *envp,
const PRProcessAttr *attr);
#ifdef _MD_CREATE_PROCESS_DETACHED
#endif
/* Current Time */
/* Environment related */
extern char* _PR_MD_GET_ENV(const char *name);
/* Atomic operations */
extern void _PR_MD_INIT_ATOMIC(void);
/* Garbage collection */
/*
** 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.
*/
/* Time intervals */
extern PRIntervalTime _PR_MD_GET_INTERVAL(void);
extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);
/* Affinity masks */
/* File locking */
/* Memory-mapped files */
extern PRInt32 _PR_MD_GET_MEM_MAP_ALIGNMENT(void);
extern void * _PR_MD_MEM_MAP(
/* Named Shared Memory */
/*
** Declare PRSharedMemory.
*/
struct PRSharedMemory
{
#if defined(PR_HAVE_POSIX_NAMED_SHARED_MEMORY)
int id;
#elif defined(PR_HAVE_SYSV_NAMED_SHARED_MEMORY)
int id;
#elif defined(PR_HAVE_WIN32_NAMED_SHARED_MEMORY)
#else
#endif
PRUint32 ident; /* guard word at end of struct */
};
extern PRSharedMemory * _MD_OpenSharedMemory(
const char *name,
);
extern PRFileMap* _md_OpenAnonFileMap(
const char *dirName,
);
extern PRStatus _md_ExportFileMapAsString(
char *buf
);
extern PRFileMap * _md_ImportFileMapFromString(
const char *fmstring
);
/* Interprocess communications (IPC) */
/*
* The maximum length of an NSPR IPC name, including the
* terminating null byte.
*/
/*
* Types of NSPR IPC objects
*/
typedef enum {
} _PRIPCType;
/*
* Make a native IPC name from an NSPR IPC name.
*/
extern PRStatus _PR_MakeNativeIPCName(
const char *name, /* NSPR IPC name */
char *result, /* result buffer */
);
/* Socket call error code */
/* Get name of current host */
/* File descriptor inheritance */
/*
* If fd->secret->inheritable is _PR_TRI_UNKNOWN and we need to
* know the inheritable attribute of the fd, call this function
* to find that out. This typically requires a system call.
*/
/* --- PR_GetRandomNoise() related things --- */
/* end PR_GetRandomNoise() related */
#ifdef XP_BEOS
extern PRLock *_connectLock;
typedef struct _ConnectListNode {
extern PRUint32 connectCount;
#endif /* XP_BEOS */
#endif /* primpl_h___ */