]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_asn1/lib/prinrval.h
Security-57740.1.18.tar.gz
[apple/security.git] / OSX / libsecurity_asn1 / lib / prinrval.h
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * The contents of this file are subject to the Mozilla Public
4 * License Version 1.1 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of
6 * the License at http://www.mozilla.org/MPL/
7 *
8 * Software distributed under the License is distributed on an "AS
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the License for the specific language governing
11 * rights and limitations under the License.
12 *
13 * The Original Code is the Netscape Portable Runtime (NSPR).
14 *
15 * The Initial Developer of the Original Code is Netscape
16 * Communications Corporation. Portions created by Netscape are
17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All
18 * Rights Reserved.
19 *
20 * Contributor(s):
21 *
22 * Alternatively, the contents of this file may be used under the
23 * terms of the GNU General Public License Version 2 or later (the
24 * "GPL"), in which case the provisions of the GPL are applicable
25 * instead of those above. If you wish to allow use of your
26 * version of this file only under the terms of the GPL and not to
27 * allow others to use your version of this file under the MPL,
28 * indicate your decision by deleting the provisions above and
29 * replace them with the notice and other provisions required by
30 * the GPL. If you do not delete the provisions above, a recipient
31 * may use your version of this file under either the MPL or the
32 * GPL.
33 */
34
35 /*
36 ** File: prinrval.h
37 ** Description: API to interval timing functions of NSPR.
38 **
39 **
40 ** NSPR provides interval times that are independent of network time
41 ** of day values. Interval times are (in theory) accurate regardless
42 ** of host processing requirements and also very cheap to acquire. It
43 ** is expected that getting an interval time while in a synchronized
44 ** function (holding one's lock).
45 **/
46
47 #if !defined(prinrval_h)
48 #define prinrval_h
49
50 #include <security_asn1/prtypes.h>
51
52 PR_BEGIN_EXTERN_C
53
54 /**********************************************************************/
55 /************************* TYPES AND CONSTANTS ************************/
56 /**********************************************************************/
57
58 typedef PRUint32 PRIntervalTime;
59
60 /***********************************************************************
61 ** DEFINES: PR_INTERVAL_MIN
62 ** PR_INTERVAL_MAX
63 ** DESCRIPTION:
64 ** These two constants define the range (in ticks / second) of the
65 ** platform dependent type, PRIntervalTime. These constants bound both
66 ** the period and the resolution of a PRIntervalTime.
67 ***********************************************************************/
68 #define PR_INTERVAL_MIN 1000UL
69 #define PR_INTERVAL_MAX 100000UL
70
71 /***********************************************************************
72 ** DEFINES: PR_INTERVAL_NO_WAIT
73 ** PR_INTERVAL_NO_TIMEOUT
74 ** DESCRIPTION:
75 ** Two reserved constants are defined in the PRIntervalTime namespace.
76 ** They are used to indicate that the process should wait no time (return
77 ** immediately) or wait forever (never time out), respectively.
78 ***********************************************************************/
79 #define PR_INTERVAL_NO_WAIT 0UL
80 #define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
81
82 /**********************************************************************/
83 /****************************** FUNCTIONS *****************************/
84 /**********************************************************************/
85
86 /***********************************************************************
87 ** FUNCTION: PR_IntervalNow
88 ** DESCRIPTION:
89 ** Return the value of NSPR's free running interval timer. That timer
90 ** can be used to establish epochs and determine intervals (be computing
91 ** the difference between two times).
92 ** INPUTS: void
93 ** OUTPUTS: void
94 ** RETURN: PRIntervalTime
95 **
96 ** SIDE EFFECTS:
97 ** None
98 ** RESTRICTIONS:
99 ** The units of PRIntervalTime are platform dependent. They are chosen
100 ** such that they are appropriate for the host OS, yet provide sufficient
101 ** resolution and period to be useful to clients.
102 ** MEMORY: N/A
103 ** ALGORITHM: Platform dependent
104 ***********************************************************************/
105 NSPR_API(PRIntervalTime) PR_IntervalNow(void);
106
107 /***********************************************************************
108 ** FUNCTION: PR_TicksPerSecond
109 ** DESCRIPTION:
110 ** Return the number of ticks per second for PR_IntervalNow's clock.
111 ** The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX].
112 ** INPUTS: void
113 ** OUTPUTS: void
114 ** RETURN: PRUint32
115 **
116 ** SIDE EFFECTS:
117 ** None
118 ** RESTRICTIONS:
119 ** None
120 ** MEMORY: N/A
121 ** ALGORITHM: N/A
122 ***********************************************************************/
123 NSPR_API(PRUint32) PR_TicksPerSecond(void);
124
125 /***********************************************************************
126 ** FUNCTION: PR_SecondsToInterval
127 ** PR_MillisecondsToInterval
128 ** PR_MicrosecondsToInterval
129 ** DESCRIPTION:
130 ** Convert standard clock units to platform dependent intervals.
131 ** INPUTS: PRUint32
132 ** OUTPUTS: void
133 ** RETURN: PRIntervalTime
134 **
135 ** SIDE EFFECTS:
136 ** None
137 ** RESTRICTIONS:
138 ** Conversion may cause overflow, which is not reported.
139 ** MEMORY: N/A
140 ** ALGORITHM: N/A
141 ***********************************************************************/
142 NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds);
143 NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli);
144 NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro);
145
146 /***********************************************************************
147 ** FUNCTION: PR_IntervalToSeconds
148 ** PR_IntervalToMilliseconds
149 ** PR_IntervalToMicroseconds
150 ** DESCRIPTION:
151 ** Convert platform dependent intervals to standard clock units.
152 ** INPUTS: PRIntervalTime
153 ** OUTPUTS: void
154 ** RETURN: PRUint32
155 **
156 ** SIDE EFFECTS:
157 ** None
158 ** RESTRICTIONS:
159 ** Conversion may cause overflow, which is not reported.
160 ** MEMORY: N/A
161 ** ALGORITHM: N/A
162 ***********************************************************************/
163 NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks);
164 NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks);
165 NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks);
166
167 PR_END_EXTERN_C
168
169
170 #endif /* !defined(prinrval_h) */
171
172 /* prinrval.h */