VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prinrval.h@ 43314

Last change on this file since 43314 was 11551, checked in by vboxsync, 16 years ago

API/xpcom: prefix any C symbols in VBoxXPCOM.so, to avoid namespace pollution. Enabled only on Linux at the moment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 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/*
39** File: prinrval.h
40** Description: API to interval timing functions of NSPR.
41**
42**
43** NSPR provides interval times that are independent of network time
44** of day values. Interval times are (in theory) accurate regardless
45** of host processing requirements and also very cheap to acquire. It
46** is expected that getting an interval time while in a synchronized
47** function (holding one's lock).
48**/
49
50#if !defined(prinrval_h)
51#define prinrval_h
52
53#include "prtypes.h"
54
55#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
56#define PR_IntervalNow VBoxNsprPR_IntervalNow
57#define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
58#define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
59#define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
60#define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
61#define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
62#define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
63#define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
64#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
65
66PR_BEGIN_EXTERN_C
67
68/**********************************************************************/
69/************************* TYPES AND CONSTANTS ************************/
70/**********************************************************************/
71
72typedef PRUint32 PRIntervalTime;
73
74/***********************************************************************
75** DEFINES: PR_INTERVAL_MIN
76** PR_INTERVAL_MAX
77** DESCRIPTION:
78** These two constants define the range (in ticks / second) of the
79** platform dependent type, PRIntervalTime. These constants bound both
80** the period and the resolution of a PRIntervalTime.
81***********************************************************************/
82#define PR_INTERVAL_MIN 1000UL
83#define PR_INTERVAL_MAX 100000UL
84
85/***********************************************************************
86** DEFINES: PR_INTERVAL_NO_WAIT
87** PR_INTERVAL_NO_TIMEOUT
88** DESCRIPTION:
89** Two reserved constants are defined in the PRIntervalTime namespace.
90** They are used to indicate that the process should wait no time (return
91** immediately) or wait forever (never time out), respectively.
92***********************************************************************/
93#define PR_INTERVAL_NO_WAIT 0UL
94#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
95
96/**********************************************************************/
97/****************************** FUNCTIONS *****************************/
98/**********************************************************************/
99
100/***********************************************************************
101** FUNCTION: PR_IntervalNow
102** DESCRIPTION:
103** Return the value of NSPR's free running interval timer. That timer
104** can be used to establish epochs and determine intervals (be computing
105** the difference between two times).
106** INPUTS: void
107** OUTPUTS: void
108** RETURN: PRIntervalTime
109**
110** SIDE EFFECTS:
111** None
112** RESTRICTIONS:
113** The units of PRIntervalTime are platform dependent. They are chosen
114** such that they are appropriate for the host OS, yet provide sufficient
115** resolution and period to be useful to clients.
116** MEMORY: N/A
117** ALGORITHM: Platform dependent
118***********************************************************************/
119NSPR_API(PRIntervalTime) PR_IntervalNow(void);
120
121/***********************************************************************
122** FUNCTION: PR_TicksPerSecond
123** DESCRIPTION:
124** Return the number of ticks per second for PR_IntervalNow's clock.
125** The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX].
126** INPUTS: void
127** OUTPUTS: void
128** RETURN: PRUint32
129**
130** SIDE EFFECTS:
131** None
132** RESTRICTIONS:
133** None
134** MEMORY: N/A
135** ALGORITHM: N/A
136***********************************************************************/
137NSPR_API(PRUint32) PR_TicksPerSecond(void);
138
139/***********************************************************************
140** FUNCTION: PR_SecondsToInterval
141** PR_MillisecondsToInterval
142** PR_MicrosecondsToInterval
143** DESCRIPTION:
144** Convert standard clock units to platform dependent intervals.
145** INPUTS: PRUint32
146** OUTPUTS: void
147** RETURN: PRIntervalTime
148**
149** SIDE EFFECTS:
150** None
151** RESTRICTIONS:
152** Conversion may cause overflow, which is not reported.
153** MEMORY: N/A
154** ALGORITHM: N/A
155***********************************************************************/
156NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
157NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
158NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
159
160/***********************************************************************
161** FUNCTION: PR_IntervalToSeconds
162** PR_IntervalToMilliseconds
163** PR_IntervalToMicroseconds
164** DESCRIPTION:
165** Convert platform dependent intervals to standard clock units.
166** INPUTS: PRIntervalTime
167** OUTPUTS: void
168** RETURN: PRUint32
169**
170** SIDE EFFECTS:
171** None
172** RESTRICTIONS:
173** Conversion may cause overflow, which is not reported.
174** MEMORY: N/A
175** ALGORITHM: N/A
176***********************************************************************/
177NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
178NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
179NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
180
181PR_END_EXTERN_C
182
183
184#endif /* !defined(prinrval_h) */
185
186/* prinrval.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