VirtualBox

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

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

libs/xpcom: Remove use PR_Now() and get rid of it, bugref:10545

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