VirtualBox

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

Last change on this file since 102233 was 102233, checked in by vboxsync, 14 months ago

libs/xpcom: Remove useless init code in nsprpub, bugref:10545

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 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
53#include "md/prosdep.h"
54
55PR_BEGIN_EXTERN_C
56
57typedef struct _MDLock _MDLock;
58typedef struct _MDCVar _MDCVar;
59
60typedef struct PRLock PRLock;
61typedef struct PRCondVar PRCondVar;
62
63/*
64** The following definitions are unique to implementing NSPR using pthreads.
65** Since pthreads defines most of the thread and thread synchronization
66** stuff, this is a pretty small set.
67*/
68
69#define PT_CV_NOTIFIED_LENGTH 6
70typedef struct _PT_Notified _PT_Notified;
71struct _PT_Notified
72{
73 PRIntn length; /* # of used entries in this structure */
74 struct
75 {
76 PRCondVar *cv; /* the condition variable notified */
77 PRIntn times; /* and the number of times notified */
78 } cv[PT_CV_NOTIFIED_LENGTH];
79 _PT_Notified *link; /* link to another of these | NULL */
80};
81
82/************************************************************************/
83/*************************************************************************
84** The remainder of the definitions are shared by pthreads and the classic
85** NSPR code. These too may be conditionalized.
86*************************************************************************/
87/************************************************************************/
88
89struct PRLock {
90 pthread_mutex_t mutex; /* the underlying lock */
91 _PT_Notified notified; /* array of conditions notified */
92 PRBool locked; /* whether the mutex is locked */
93 pthread_t owner; /* if locked, current lock owner */
94};
95
96extern void _PR_InitLocks(void);
97
98struct PRCondVar {
99 PRLock *lock; /* associated lock that protects the condition */
100 pthread_cond_t cv; /* underlying pthreads condition */
101 volatile int32_t notify_pending; /* CV has destroy pending notification */
102};
103
104/************************************************************************/
105
106struct PRMonitor {
107 const char* name; /* monitor name for debugging */
108 PRLock lock; /* the lock structure */
109 pthread_t owner; /* the owner of the lock or invalid */
110 PRCondVar *cvar; /* condition variable queue */
111 PRUint32 entryCount; /* # of times re-entered */
112};
113
114/************************************************************************/
115
116extern PRBool _pr_initialized;
117extern void _PR_ImplicitInitialization(void);
118
119/*************************************************************************
120* External machine-dependent code provided by each OS. * *
121*************************************************************************/
122
123/* Time intervals */
124
125extern PRIntervalTime _PR_MD_GET_INTERVAL(void);
126#define _PR_MD_GET_INTERVAL _MD_GET_INTERVAL
127
128extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);
129#define _PR_MD_INTERVAL_PER_SEC _MD_INTERVAL_PER_SEC
130
131PR_END_EXTERN_C
132
133#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