VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h@ 101813

Last change on this file since 101813 was 101813, checked in by vboxsync, 15 months ago

libs/xpcom: Get rid of unused code for the _PR_POLL_WITH_SELECT case which we never use, bugref:10545

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.9 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef primpl_h___
39#define primpl_h___
40
41/*
42 * HP-UX 10.10's pthread.h (DCE threads) includes dce/cma.h, which
43 * has:
44 * #define sigaction _sigaction_sys
45 * This macro causes chaos if signal.h gets included before pthread.h.
46 * To be safe, we include pthread.h first.
47 */
48
49#include <pthread.h>
50
51#include "nspr.h"
52#include "prpriv.h"
53
54typedef struct PRSegment PRSegment;
55
56#ifdef XP_MAC
57#include "prosdep.h"
58#include "probslet.h"
59#else
60#include "md/prosdep.h"
61#include "obsolete/probslet.h"
62#endif /* XP_MAC */
63
64#ifdef _PR_HAVE_POSIX_SEMAPHORES
65#include <semaphore.h>
66#elif defined(_PR_HAVE_SYSV_SEMAPHORES)
67#include <sys/sem.h>
68#endif
69
70/*************************************************************************
71***** A Word about Model Dependent Function Naming Convention ***********
72*************************************************************************/
73
74/*
75NSPR 2.0 must implement its function across a range of platforms
76including: MAC, Windows/16, Windows/95, Windows/NT, and several
77variants of Unix. Each implementation shares common code as well
78as having platform dependent portions. This standard describes how
79the model dependent portions are to be implemented.
80
81In header file pr/include/primpl.h, each publicly declared
82platform dependent function is declared as:
83
84NSPR_API void _PR_MD_FUNCTION( long arg1, long arg2 );
85#define _PR_MD_FUNCTION _MD_FUNCTION
86
87In header file pr/include/md/<platform>/_<platform>.h,
88each #define'd macro is redefined as one of:
89
90#define _MD_FUNCTION <blanks>
91#define _MD_FUNCTION <expanded macro>
92#define _MD_FUNCTION <osFunction>
93#define _MD_FUNCTION <_MD_Function>
94
95Where:
96
97<blanks> is no definition at all. In this case, the function is not implemented
98and is never called for this platform.
99For example:
100#define _MD_INIT_CPUS()
101
102<expanded macro> is a C language macro expansion.
103For example:
104#define _MD_CLEAN_THREAD(_thread) \
105 PR_BEGIN_MACRO \
106 PR_DestroyCondVar(_thread->md.asyncIOCVar); \
107 PR_DestroyLock(_thread->md.asyncIOLock); \
108 PR_END_MACRO
109
110<osFunction> is some function implemented by the host operating system.
111For example:
112#define _MD_EXIT exit
113
114<_MD_function> is the name of a function implemented for this platform in
115pr/src/md/<platform>/<soruce>.c file.
116For example:
117#define _MD_GETFILEINFO _MD_GetFileInfo
118
119In <source>.c, the implementation is:
120PR_IMPLEMENT(PRInt32) _MD_GetFileInfo(const char *fn, PRFileInfo *info);
121*/
122
123#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
124#define PT_FPrintStats VBoxNsprPT_FPrintStats
125#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
126
127PR_BEGIN_EXTERN_C
128
129typedef struct _MDLock _MDLock;
130typedef struct _MDCVar _MDCVar;
131typedef struct _MDSegment _MDSegment;
132typedef struct _MDThread _MDThread;
133typedef struct _MDThreadStack _MDThreadStack;
134typedef struct _MDSemaphore _MDSemaphore;
135typedef struct _MDDir _MDDir;
136typedef struct _MDFileDesc _MDFileDesc;
137typedef struct _MDProcess _MDProcess;
138typedef struct _MDFileMap _MDFileMap;
139
140/*
141** The following definitions are unique to implementing NSPR using pthreads.
142** Since pthreads defines most of the thread and thread synchronization
143** stuff, this is a pretty small set.
144*/
145
146#define PT_CV_NOTIFIED_LENGTH 6
147typedef struct _PT_Notified _PT_Notified;
148struct _PT_Notified
149{
150 PRIntn length; /* # of used entries in this structure */
151 struct
152 {
153 PRCondVar *cv; /* the condition variable notified */
154 PRIntn times; /* and the number of times notified */
155 } cv[PT_CV_NOTIFIED_LENGTH];
156 _PT_Notified *link; /* link to another of these | NULL */
157};
158
159/*
160 * bits defined for pthreads 'state' field
161 */
162#define PT_THREAD_DETACHED 0x01 /* thread can't be joined */
163#define PT_THREAD_GLOBAL 0x02 /* a global thread (unlikely) */
164#define PT_THREAD_SYSTEM 0x04 /* system (not user) thread */
165#define PT_THREAD_PRIMORD 0x08 /* this is the primordial thread */
166#define PT_THREAD_ABORTED 0x10 /* thread has been interrupted */
167#define PT_THREAD_GCABLE 0x20 /* thread is garbage collectible */
168#define PT_THREAD_SUSPENDED 0x40 /* thread has been suspended */
169#define PT_THREAD_FOREIGN 0x80 /* thread is not one of ours */
170#define PT_THREAD_BOUND 0x100 /* a bound-global thread */
171
172#define _PT_THREAD_INTERRUPTED(thr) \
173 (!(thr->interrupt_blocked) && (thr->state & PT_THREAD_ABORTED))
174#define _PT_THREAD_BLOCK_INTERRUPT(thr) \
175 (thr->interrupt_blocked = 1)
176#define _PT_THREAD_UNBLOCK_INTERRUPT(thr) \
177 (thr->interrupt_blocked = 0)
178
179#define _PT_IS_GCABLE_THREAD(thr) ((thr)->state & PT_THREAD_GCABLE)
180
181/*
182** Possible values for thread's suspend field
183** Note that the first two can be the same as they are really mutually exclusive,
184** i.e. both cannot be happening at the same time. We have two symbolic names
185** just as a mnemonic.
186**/
187#define PT_THREAD_RESUMED 0x80 /* thread has been resumed */
188#define PT_THREAD_SETGCABLE 0x100 /* set the GCAble flag */
189
190#if defined(DEBUG)
191
192typedef struct PTDebug
193{
194 PRTime timeStarted;
195 PRUintn locks_created, locks_destroyed;
196 PRUintn locks_acquired, locks_released;
197 PRUintn cvars_created, cvars_destroyed;
198 PRUintn cvars_notified, delayed_cv_deletes;
199} PTDebug;
200
201#endif /* defined(DEBUG) */
202
203NSPR_API(void) PT_FPrintStats(PRFileDesc *fd, const char *msg);
204
205/************************************************************************/
206/*************************************************************************
207** The remainder of the definitions are shared by pthreads and the classic
208** NSPR code. These too may be conditionalized.
209*************************************************************************/
210/************************************************************************/
211
212extern PROffset32 _PR_MD_LSEEK(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);
213#define _PR_MD_LSEEK _MD_LSEEK
214
215extern PROffset64 _PR_MD_LSEEK64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);
216#define _PR_MD_LSEEK64 _MD_LSEEK64
217
218extern PRInt32 _PR_MD_GETFILEINFO(const char *fn, PRFileInfo *info);
219#define _PR_MD_GETFILEINFO _MD_GETFILEINFO
220
221extern PRInt32 _PR_MD_GETFILEINFO64(const char *fn, PRFileInfo64 *info);
222#define _PR_MD_GETFILEINFO64 _MD_GETFILEINFO64
223
224extern PRInt32 _PR_MD_GETOPENFILEINFO(const PRFileDesc *fd, PRFileInfo *info);
225#define _PR_MD_GETOPENFILEINFO _MD_GETOPENFILEINFO
226
227extern PRInt32 _PR_MD_GETOPENFILEINFO64(const PRFileDesc *fd, PRFileInfo64 *info);
228#define _PR_MD_GETOPENFILEINFO64 _MD_GETOPENFILEINFO64
229
230
231/*****************************************************************************/
232/************************** File descriptor caching **************************/
233/*****************************************************************************/
234extern void _PR_InitFdCache(void);
235extern void _PR_CleanupFdCache(void);
236extern PRFileDesc *_PR_Getfd(void);
237extern void _PR_Putfd(PRFileDesc *fd);
238
239/*
240 * These flags are used by NSPR temporarily in the poll
241 * descriptor's out_flags field to record the mapping of
242 * NSPR's poll flags to the system poll flags.
243 *
244 * If _PR_POLL_READ_SYS_WRITE bit is set, it means the
245 * PR_POLL_READ flag specified by the topmost layer is
246 * mapped to the WRITE flag at the system layer. Similarly
247 * for the other three _PR_POLL_XXX_SYS_YYY flags. It is
248 * assumed that the PR_POLL_EXCEPT flag doesn't get mapped
249 * to other flags.
250 */
251#define _PR_POLL_READ_SYS_READ 0x1
252#define _PR_POLL_READ_SYS_WRITE 0x2
253#define _PR_POLL_WRITE_SYS_READ 0x4
254#define _PR_POLL_WRITE_SYS_WRITE 0x8
255
256/*
257** These methods are coerced into file descriptor methods table
258** when the intended service is inappropriate for the particular
259** type of file descriptor.
260*/
261extern PRIntn _PR_InvalidInt(void);
262extern PRInt16 _PR_InvalidInt16(void);
263extern PRInt64 _PR_InvalidInt64(void);
264extern PRStatus _PR_InvalidStatus(void);
265extern PRFileDesc *_PR_InvalidDesc(void);
266
267extern PRIOMethods _pr_faulty_methods;
268
269/*
270** The PR_NETADDR_SIZE macro can only be called on a PRNetAddr union
271** whose 'family' field is set. It returns the size of the union
272** member corresponding to the specified address family.
273*/
274
275extern PRUintn _PR_NetAddrSize(const PRNetAddr* addr);
276
277#if defined(_PR_INET6)
278
279#define PR_NETADDR_SIZE(_addr) _PR_NetAddrSize(_addr)
280
281#elif defined(_PR_HAVE_MD_SOCKADDR_IN6)
282
283/*
284** Under the following conditions:
285** 1. _PR_INET6 is not defined;
286** 2. _PR_INET6_PROBE is defined;
287** 3. struct sockaddr_in6 has nonstandard fields at the end
288** (e.g., on Solaris 8),
289** (_addr)->ipv6 is smaller than struct sockaddr_in6, and
290** hence we can't pass sizeof((_addr)->ipv6) to socket
291** functions such as connect because they would fail with
292** EINVAL.
293**
294** To pass the correct socket address length to socket
295** functions, define the macro _PR_HAVE_MD_SOCKADDR_IN6 and
296** define struct _md_sockaddr_in6 to be isomorphic to
297** struct sockaddr_in6.
298*/
299
300#if defined(XP_UNIX) || defined(XP_OS2_EMX)
301#define PR_NETADDR_SIZE(_addr) \
302 ((_addr)->raw.family == PR_AF_INET \
303 ? sizeof((_addr)->inet) \
304 : ((_addr)->raw.family == PR_AF_INET6 \
305 ? sizeof(struct _md_sockaddr_in6) \
306 : sizeof((_addr)->local)))
307#else
308#define PR_NETADDR_SIZE(_addr) \
309 ((_addr)->raw.family == PR_AF_INET \
310 ? sizeof((_addr)->inet) \
311 : sizeof(struct _md_sockaddr_in6)
312#endif /* defined(XP_UNIX) */
313
314#else
315
316#if defined(XP_UNIX) || defined(XP_OS2_EMX)
317#define PR_NETADDR_SIZE(_addr) \
318 ((_addr)->raw.family == PR_AF_INET \
319 ? sizeof((_addr)->inet) \
320 : ((_addr)->raw.family == PR_AF_INET6 \
321 ? sizeof((_addr)->ipv6) \
322 : sizeof((_addr)->local)))
323#else
324#define PR_NETADDR_SIZE(_addr) \
325 ((_addr)->raw.family == PR_AF_INET \
326 ? sizeof((_addr)->inet) \
327 : sizeof((_addr)->ipv6))
328#endif /* defined(XP_UNIX) */
329
330#endif /* defined(_PR_INET6) */
331
332extern PRStatus _PR_MapOptionName(
333 PRSockOption optname, PRInt32 *level, PRInt32 *name);
334extern void _PR_InitThreads(
335 PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
336
337struct PRLock {
338 pthread_mutex_t mutex; /* the underlying lock */
339 _PT_Notified notified; /* array of conditions notified */
340 PRBool locked; /* whether the mutex is locked */
341 pthread_t owner; /* if locked, current lock owner */
342};
343
344extern void _PR_InitLocks(void);
345
346struct PRCondVar {
347 PRLock *lock; /* associated lock that protects the condition */
348 pthread_cond_t cv; /* underlying pthreads condition */
349 PRInt32 notify_pending; /* CV has destroy pending notification */
350};
351
352/************************************************************************/
353
354struct PRMonitor {
355 const char* name; /* monitor name for debugging */
356 PRLock lock; /* the lock structure */
357 pthread_t owner; /* the owner of the lock or invalid */
358 PRCondVar *cvar; /* condition variable queue */
359 PRUint32 entryCount; /* # of times re-entered */
360};
361
362/************************************************************************/
363
364struct PRSemaphore {
365 PRCondVar *cvar; /* associated lock and condition variable queue */
366 PRUintn count; /* the value of the counting semaphore */
367 PRUint32 waiters; /* threads waiting on the semaphore */
368};
369
370NSPR_API(void) _PR_InitSem(void);
371
372/*************************************************************************/
373
374struct PRSem {
375#ifdef _PR_HAVE_POSIX_SEMAPHORES
376 sem_t *sem;
377#elif defined(_PR_HAVE_SYSV_SEMAPHORES)
378 int semid;
379#elif defined(WIN32)
380 HANDLE sem;
381#else
382 PRInt8 notused;
383#endif
384};
385
386/*************************************************************************/
387
388struct PRStackStr {
389 /* head MUST be at offset 0; assembly language code relies on this */
390#if defined(AIX)
391 volatile PRStackElem prstk_head;
392#else
393 PRStackElem prstk_head;
394#endif
395
396 PRLock *prstk_lock;
397 char *prstk_name;
398};
399
400/************************************************************************/
401
402/* XXX this needs to be exported (sigh) */
403struct PRThreadStack {
404 PRCList links;
405 PRUintn flags;
406
407 char *allocBase; /* base of stack's allocated memory */
408 PRUint32 allocSize; /* size of stack's allocated memory */
409 char *stackBottom; /* bottom of stack from C's point of view */
410 char *stackTop; /* top of stack from C's point of view */
411 PRUint32 stackSize; /* size of usable portion of the stack */
412
413 PRSegment *seg;
414 PRThread* thr; /* back pointer to thread owning this stack */
415};
416
417extern void _PR_DestroyThreadPrivate(PRThread*);
418
419typedef void (PR_CALLBACK *_PRStartFn)(void *);
420
421struct PRThread {
422 PRUint32 state; /* thread's creation state */
423 PRThreadPriority priority; /* apparent priority, loosly defined */
424
425 void *arg; /* argument to the client's entry point */
426 _PRStartFn startFunc; /* the root of the client's thread */
427
428 PRThreadStack *stack; /* info about thread's stack (for GC) */
429 void *environment; /* pointer to execution environment */
430
431 PRThreadDumpProc dump; /* dump thread info out */
432 void *dumpArg; /* argument for the dump function */
433
434 /*
435 ** Per thread private data
436 */
437 PRUint32 tpdLength; /* thread's current vector length */
438 void **privateData; /* private data vector or NULL */
439 PRErrorCode errorCode; /* current NSPR error code | zero */
440 PRInt32 osErrorCode; /* mapping of errorCode | zero */
441 PRIntn errorStringLength; /* textLength from last call to PR_SetErrorText() */
442 PRInt32 errorStringSize; /* malloc()'d size of buffer | zero */
443 char *errorString; /* current error string | NULL */
444
445 pthread_t id; /* pthread identifier for the thread */
446 PRBool okToDelete; /* ok to delete the PRThread struct? */
447 PRCondVar *waiting; /* where the thread is waiting | NULL */
448 void *sp; /* recorded sp for garbage collection */
449 PRThread *next, *prev; /* simple linked list of all threads */
450 PRUint32 suspend; /* used to store suspend and resume flags */
451#ifdef PT_NO_SIGTIMEDWAIT
452 pthread_mutex_t suspendResumeMutex;
453 pthread_cond_t suspendResumeCV;
454#endif
455 PRUint32 interrupt_blocked; /* interrupt blocked */
456 struct pollfd *syspoll_list; /* Unix polling list used by PR_Poll */
457 PRUint32 syspoll_count; /* number of elements in syspoll_list */
458};
459
460struct PRProcessAttr {
461 PRFileDesc *stdinFd;
462 PRFileDesc *stdoutFd;
463 PRFileDesc *stderrFd;
464 char *currentDirectory;
465 char *fdInheritBuffer;
466 PRSize fdInheritBufferSize;
467 PRSize fdInheritBufferUsed;
468};
469
470struct PRProcess {
471 _MDProcess md;
472};
473
474struct PRFileMap {
475 PRFileDesc *fd;
476 PRFileMapProtect prot;
477 _MDFileMap md;
478};
479
480/************************************************************************/
481
482/*
483** File descriptors of the NSPR layer can be in one of the
484** following states (stored in the 'state' field of struct
485** PRFilePrivate):
486** - _PR_FILEDESC_OPEN: The OS fd is open.
487** - _PR_FILEDESC_CLOSED: The OS fd is closed. The PRFileDesc
488** is still open but is unusable. The only operation allowed
489** on the PRFileDesc is PR_Close().
490** - _PR_FILEDESC_FREED: The OS fd is closed and the PRFileDesc
491** structure is freed.
492*/
493
494#define _PR_FILEDESC_OPEN 0xaaaaaaaa /* 1010101... */
495#define _PR_FILEDESC_CLOSED 0x55555555 /* 0101010... */
496#define _PR_FILEDESC_FREED 0x11111111
497
498/*
499** A boolean type with an additional "unknown" state
500*/
501
502typedef enum {
503 _PR_TRI_TRUE = 1,
504 _PR_TRI_FALSE = 0,
505 _PR_TRI_UNKNOWN = -1
506} _PRTriStateBool;
507
508struct PRFilePrivate {
509 PRInt32 state;
510 PRBool nonblocking;
511 _PRTriStateBool inheritable;
512 PRFileDesc *next;
513 PRIntn lockCount; /* 0: not locked
514 * -1: a native lockfile call is in progress
515 * > 0: # times the file is locked */
516#ifdef _PR_HAVE_PEEK_BUFFER
517 char *peekBuffer;
518 PRInt32 peekBufSize;
519 PRInt32 peekBytes;
520#endif
521#if !defined(XP_UNIX) /* BugZilla: 4090 */
522 PRBool appendMode;
523#endif
524 _MDFileDesc md;
525#ifdef _PR_STRICT_ADDR_LEN
526 PRUint16 af; /* If the platform requires passing the exact
527 * length of the sockaddr structure for the
528 * address family of the socket to socket
529 * functions like accept(), we need to save
530 * the address family of the socket. */
531#endif
532};
533
534struct PRDir {
535 PRDirEntry d;
536 _MDDir md;
537};
538
539extern void _PR_InitSegs(void);
540extern void _PR_InitStacks(void);
541extern void _PR_InitTPD(void);
542extern void _PR_InitMem(void);
543extern void _PR_InitEnv(void);
544extern void _PR_InitCMon(void);
545extern void _PR_InitIO(void);
546extern void _PR_InitLog(void);
547extern void _PR_InitNet(void);
548extern void _PR_InitClock(void);
549extern void _PR_InitLinker(void);
550extern void _PR_InitAtomic(void);
551extern void _PR_InitCPUs(void);
552extern void _PR_InitDtoa(void);
553extern void _PR_InitMW(void);
554extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
555extern void _PR_CleanupThread(PRThread *thread);
556extern void _PR_CleanupCallOnce(void);
557extern void _PR_CleanupMW(void);
558extern void _PR_CleanupDtoa(void);
559extern void _PR_ShutdownLinker(void);
560extern void _PR_CleanupEnv(void);
561extern void _PR_CleanupIO(void);
562extern void _PR_CleanupNet(void);
563extern void _PR_CleanupLayerCache(void);
564extern void _PR_CleanupStacks(void);
565#ifdef WINNT
566extern void _PR_CleanupCPUs(void);
567#endif
568extern void _PR_CleanupThreads(void);
569extern void _PR_CleanupTPD(void);
570extern void _PR_Cleanup(void);
571extern void _PR_LogCleanup(void);
572extern void _PR_InitLayerCache(void);
573
574extern PRBool _pr_initialized;
575extern void _PR_ImplicitInitialization(void);
576extern PRBool _PR_Obsolete(const char *obsolete, const char *preferred);
577
578/************************************************************************/
579
580struct PRSegment {
581 void *vaddr;
582 PRUint32 size;
583 PRUintn flags;
584};
585
586/* PRSegment.flags */
587#define _PR_SEG_VM 0x1
588
589/************************************************************************/
590
591extern PRInt32 _pr_pageSize;
592extern PRInt32 _pr_pageShift;
593
594extern PRLogModuleInfo *_pr_clock_lm;
595extern PRLogModuleInfo *_pr_cmon_lm;
596extern PRLogModuleInfo *_pr_io_lm;
597extern PRLogModuleInfo *_pr_cvar_lm;
598extern PRLogModuleInfo *_pr_mon_lm;
599extern PRLogModuleInfo *_pr_linker_lm;
600extern PRLogModuleInfo *_pr_sched_lm;
601extern PRLogModuleInfo *_pr_thread_lm;
602extern PRLogModuleInfo *_pr_gc_lm;
603
604extern PRFileDesc *_pr_stdin;
605extern PRFileDesc *_pr_stdout;
606extern PRFileDesc *_pr_stderr;
607
608
609/*************************************************************************
610* External machine-dependent code provided by each OS. * *
611*************************************************************************/
612
613/* Initialization related */
614extern void _PR_MD_EARLY_INIT(void);
615#define _PR_MD_EARLY_INIT _MD_EARLY_INIT
616
617extern void _PR_MD_INTERVAL_INIT(void);
618#define _PR_MD_INTERVAL_INIT _MD_INTERVAL_INIT
619
620NSPR_API(void) _PR_MD_FINAL_INIT(void);
621#define _PR_MD_FINAL_INIT _MD_FINAL_INIT
622
623/* Process control */
624
625extern PRProcess * _PR_MD_CREATE_PROCESS(
626 const char *path,
627 char *const *argv,
628 char *const *envp,
629 const PRProcessAttr *attr);
630#define _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESS
631
632#ifdef _MD_CREATE_PROCESS_DETACHED
633# define _PR_MD_CREATE_PROCESS_DETACHED _MD_CREATE_PROCESS_DETACHED
634#endif
635
636extern PRStatus _PR_MD_DETACH_PROCESS(PRProcess *process);
637#define _PR_MD_DETACH_PROCESS _MD_DETACH_PROCESS
638
639extern PRStatus _PR_MD_WAIT_PROCESS(PRProcess *process, PRInt32 *exitCode);
640#define _PR_MD_WAIT_PROCESS _MD_WAIT_PROCESS
641
642extern PRStatus _PR_MD_KILL_PROCESS(PRProcess *process);
643#define _PR_MD_KILL_PROCESS _MD_KILL_PROCESS
644
645/* Current Time */
646NSPR_API(PRTime) _PR_MD_NOW(void);
647#define _PR_MD_NOW _MD_NOW
648
649/* Environment related */
650extern char* _PR_MD_GET_ENV(const char *name);
651#define _PR_MD_GET_ENV _MD_GET_ENV
652
653extern PRIntn _PR_MD_PUT_ENV(const char *name);
654#define _PR_MD_PUT_ENV _MD_PUT_ENV
655
656/* Atomic operations */
657
658extern void _PR_MD_INIT_ATOMIC(void);
659#define _PR_MD_INIT_ATOMIC _MD_INIT_ATOMIC
660
661extern PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *);
662#define _PR_MD_ATOMIC_INCREMENT _MD_ATOMIC_INCREMENT
663
664extern PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *, PRInt32);
665#define _PR_MD_ATOMIC_ADD _MD_ATOMIC_ADD
666
667extern PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *);
668#define _PR_MD_ATOMIC_DECREMENT _MD_ATOMIC_DECREMENT
669
670extern PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *, PRInt32);
671#define _PR_MD_ATOMIC_SET _MD_ATOMIC_SET
672
673/* Time intervals */
674
675extern PRIntervalTime _PR_MD_GET_INTERVAL(void);
676#define _PR_MD_GET_INTERVAL _MD_GET_INTERVAL
677
678extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);
679#define _PR_MD_INTERVAL_PER_SEC _MD_INTERVAL_PER_SEC
680
681/* Affinity masks */
682
683extern PRInt32 _PR_MD_SETTHREADAFFINITYMASK(PRThread *thread, PRUint32 mask );
684#define _PR_MD_SETTHREADAFFINITYMASK _MD_SETTHREADAFFINITYMASK
685
686extern PRInt32 _PR_MD_GETTHREADAFFINITYMASK(PRThread *thread, PRUint32 *mask);
687#define _PR_MD_GETTHREADAFFINITYMASK _MD_GETTHREADAFFINITYMASK
688
689/* File locking */
690
691extern PRStatus _PR_MD_LOCKFILE(PRInt32 osfd);
692#define _PR_MD_LOCKFILE _MD_LOCKFILE
693
694extern PRStatus _PR_MD_TLOCKFILE(PRInt32 osfd);
695#define _PR_MD_TLOCKFILE _MD_TLOCKFILE
696
697extern PRStatus _PR_MD_UNLOCKFILE(PRInt32 osfd);
698#define _PR_MD_UNLOCKFILE _MD_UNLOCKFILE
699
700/* Memory-mapped files */
701
702extern PRStatus _PR_MD_CREATE_FILE_MAP(PRFileMap *fmap, PRInt64 size);
703#define _PR_MD_CREATE_FILE_MAP _MD_CREATE_FILE_MAP
704
705extern PRInt32 _PR_MD_GET_MEM_MAP_ALIGNMENT(void);
706#define _PR_MD_GET_MEM_MAP_ALIGNMENT _MD_GET_MEM_MAP_ALIGNMENT
707
708extern void * _PR_MD_MEM_MAP(
709 PRFileMap *fmap,
710 PROffset64 offset,
711 PRUint32 len);
712#define _PR_MD_MEM_MAP _MD_MEM_MAP
713
714extern PRStatus _PR_MD_MEM_UNMAP(void *addr, PRUint32 size);
715#define _PR_MD_MEM_UNMAP _MD_MEM_UNMAP
716
717extern PRStatus _PR_MD_CLOSE_FILE_MAP(PRFileMap *fmap);
718#define _PR_MD_CLOSE_FILE_MAP _MD_CLOSE_FILE_MAP
719
720/* Named Shared Memory */
721
722/*
723** Declare PRSharedMemory.
724*/
725struct PRSharedMemory
726{
727 char *ipcname; /* after conversion to native */
728 PRSize size; /* from open */
729 PRIntn mode; /* from open */
730 PRIntn flags; /* from open */
731#if defined(PR_HAVE_POSIX_NAMED_SHARED_MEMORY)
732 int id;
733#elif defined(PR_HAVE_SYSV_NAMED_SHARED_MEMORY)
734 int id;
735#elif defined(PR_HAVE_WIN32_NAMED_SHARED_MEMORY)
736 HANDLE handle;
737#else
738 PRUint32 nothing; /* placeholder, nothing behind here */
739#endif
740 PRUint32 ident; /* guard word at end of struct */
741#define _PR_SHM_IDENT 0xdeadbad
742};
743
744extern PRSharedMemory * _MD_OpenSharedMemory(
745 const char *name,
746 PRSize size,
747 PRIntn flags,
748 PRIntn mode
749);
750#define _PR_MD_OPEN_SHARED_MEMORY _MD_OpenSharedMemory
751
752extern void * _MD_AttachSharedMemory( PRSharedMemory *shm, PRIntn flags );
753#define _PR_MD_ATTACH_SHARED_MEMORY _MD_AttachSharedMemory
754
755extern PRStatus _MD_DetachSharedMemory( PRSharedMemory *shm, void *addr );
756#define _PR_MD_DETACH_SHARED_MEMORY _MD_DetachSharedMemory
757
758extern PRStatus _MD_CloseSharedMemory( PRSharedMemory *shm );
759#define _PR_MD_CLOSE_SHARED_MEMORY _MD_CloseSharedMemory
760
761extern PRStatus _MD_DeleteSharedMemory( const char *name );
762#define _PR_MD_DELETE_SHARED_MEMORY _MD_DeleteSharedMemory
763
764extern PRFileMap* _md_OpenAnonFileMap(
765 const char *dirName,
766 PRSize size,
767 PRFileMapProtect prot
768);
769#define _PR_MD_OPEN_ANON_FILE_MAP _md_OpenAnonFileMap
770
771extern PRStatus _md_ExportFileMapAsString(
772 PRFileMap *fm,
773 PRSize bufSize,
774 char *buf
775);
776#define _PR_MD_EXPORT_FILE_MAP_AS_STRING _md_ExportFileMapAsString
777
778extern PRFileMap * _md_ImportFileMapFromString(
779 const char *fmstring
780);
781#define _PR_MD_IMPORT_FILE_MAP_FROM_STRING _md_ImportFileMapFromString
782
783
784
785/* Interprocess communications (IPC) */
786
787/*
788 * The maximum length of an NSPR IPC name, including the
789 * terminating null byte.
790 */
791#define PR_IPC_NAME_SIZE 1024
792
793/*
794 * Types of NSPR IPC objects
795 */
796typedef enum {
797 _PRIPCSem, /* semaphores */
798 _PRIPCShm /* shared memory segments */
799} _PRIPCType;
800
801/*
802 * Make a native IPC name from an NSPR IPC name.
803 */
804extern PRStatus _PR_MakeNativeIPCName(
805 const char *name, /* NSPR IPC name */
806 char *result, /* result buffer */
807 PRIntn size, /* size of result buffer */
808 _PRIPCType type /* type of IPC object */
809);
810
811/* Socket call error code */
812
813NSPR_API(PRInt32) _PR_MD_GET_SOCKET_ERROR(void);
814#define _PR_MD_GET_SOCKET_ERROR _MD_GET_SOCKET_ERROR
815
816/* Get name of current host */
817extern PRStatus _PR_MD_GETHOSTNAME(char *name, PRUint32 namelen);
818#define _PR_MD_GETHOSTNAME _MD_GETHOSTNAME
819
820/* File descriptor inheritance */
821
822/*
823 * If fd->secret->inheritable is _PR_TRI_UNKNOWN and we need to
824 * know the inheritable attribute of the fd, call this function
825 * to find that out. This typically requires a system call.
826 */
827extern void _PR_MD_QUERY_FD_INHERITABLE(PRFileDesc *fd);
828#define _PR_MD_QUERY_FD_INHERITABLE _MD_QUERY_FD_INHERITABLE
829
830#ifdef XP_BEOS
831
832extern PRLock *_connectLock;
833
834typedef struct _ConnectListNode {
835 PRInt32 osfd;
836 PRNetAddr addr;
837 PRUint32 addrlen;
838 PRIntervalTime timeout;
839} ConnectListNode;
840
841extern ConnectListNode connectList[64];
842
843extern PRUint32 connectCount;
844
845#endif /* XP_BEOS */
846
847PR_END_EXTERN_C
848
849#endif /* primpl_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette