]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_asn1/lib/prinrval.h
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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/
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.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
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
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
37 ** Description: API to interval timing functions of NSPR.
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).
47 #if !defined(prinrval_h)
50 #include <security_asn1/prtypes.h>
54 /**********************************************************************/
55 /************************* TYPES AND CONSTANTS ************************/
56 /**********************************************************************/
58 typedef PRUint32 PRIntervalTime
;
60 /***********************************************************************
61 ** DEFINES: PR_INTERVAL_MIN
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
71 /***********************************************************************
72 ** DEFINES: PR_INTERVAL_NO_WAIT
73 ** PR_INTERVAL_NO_TIMEOUT
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
82 /**********************************************************************/
83 /****************************** FUNCTIONS *****************************/
84 /**********************************************************************/
86 /***********************************************************************
87 ** FUNCTION: PR_IntervalNow
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).
94 ** RETURN: PRIntervalTime
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.
103 ** ALGORITHM: Platform dependent
104 ***********************************************************************/
105 NSPR_API(PRIntervalTime
) PR_IntervalNow(void);
107 /***********************************************************************
108 ** FUNCTION: PR_TicksPerSecond
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].
122 ***********************************************************************/
123 NSPR_API(PRUint32
) PR_TicksPerSecond(void);
125 /***********************************************************************
126 ** FUNCTION: PR_SecondsToInterval
127 ** PR_MillisecondsToInterval
128 ** PR_MicrosecondsToInterval
130 ** Convert standard clock units to platform dependent intervals.
133 ** RETURN: PRIntervalTime
138 ** Conversion may cause overflow, which is not reported.
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
);
146 /***********************************************************************
147 ** FUNCTION: PR_IntervalToSeconds
148 ** PR_IntervalToMilliseconds
149 ** PR_IntervalToMicroseconds
151 ** Convert platform dependent intervals to standard clock units.
152 ** INPUTS: PRIntervalTime
159 ** Conversion may cause overflow, which is not reported.
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
);
170 #endif /* !defined(prinrval_h) */