OLD | NEW |
(Empty) | |
| 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 PR_BEGIN_EXTERN_C |
| 56 |
| 57 /**********************************************************************/ |
| 58 /************************* TYPES AND CONSTANTS ************************/ |
| 59 /**********************************************************************/ |
| 60 |
| 61 typedef PRUint32 PRIntervalTime; |
| 62 |
| 63 /*********************************************************************** |
| 64 ** DEFINES: PR_INTERVAL_MIN |
| 65 ** PR_INTERVAL_MAX |
| 66 ** DESCRIPTION: |
| 67 ** These two constants define the range (in ticks / second) of the |
| 68 ** platform dependent type, PRIntervalTime. These constants bound both |
| 69 ** the period and the resolution of a PRIntervalTime. |
| 70 ***********************************************************************/ |
| 71 #define PR_INTERVAL_MIN 1000UL |
| 72 #define PR_INTERVAL_MAX 100000UL |
| 73 |
| 74 /*********************************************************************** |
| 75 ** DEFINES: PR_INTERVAL_NO_WAIT |
| 76 ** PR_INTERVAL_NO_TIMEOUT |
| 77 ** DESCRIPTION: |
| 78 ** Two reserved constants are defined in the PRIntervalTime namespace. |
| 79 ** They are used to indicate that the process should wait no time (return |
| 80 ** immediately) or wait forever (never time out), respectively. |
| 81 ***********************************************************************/ |
| 82 #define PR_INTERVAL_NO_WAIT 0UL |
| 83 #define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL |
| 84 |
| 85 /**********************************************************************/ |
| 86 /****************************** FUNCTIONS *****************************/ |
| 87 /**********************************************************************/ |
| 88 |
| 89 /*********************************************************************** |
| 90 ** FUNCTION: PR_IntervalNow |
| 91 ** DESCRIPTION: |
| 92 ** Return the value of NSPR's free running interval timer. That timer |
| 93 ** can be used to establish epochs and determine intervals (be computing |
| 94 ** the difference between two times). |
| 95 ** INPUTS: void |
| 96 ** OUTPUTS: void |
| 97 ** RETURN: PRIntervalTime |
| 98 ** |
| 99 ** SIDE EFFECTS: |
| 100 ** None |
| 101 ** RESTRICTIONS: |
| 102 ** The units of PRIntervalTime are platform dependent. They are chosen |
| 103 ** such that they are appropriate for the host OS, yet provide sufficient |
| 104 ** resolution and period to be useful to clients. |
| 105 ** MEMORY: N/A |
| 106 ** ALGORITHM: Platform dependent |
| 107 ***********************************************************************/ |
| 108 NSPR_API(PRIntervalTime) PR_IntervalNow(void); |
| 109 |
| 110 /*********************************************************************** |
| 111 ** FUNCTION: PR_TicksPerSecond |
| 112 ** DESCRIPTION: |
| 113 ** Return the number of ticks per second for PR_IntervalNow's clock. |
| 114 ** The value will be in the range [PR_INTERVAL_MIN..PR_INTERVAL_MAX]. |
| 115 ** INPUTS: void |
| 116 ** OUTPUTS: void |
| 117 ** RETURN: PRUint32 |
| 118 ** |
| 119 ** SIDE EFFECTS: |
| 120 ** None |
| 121 ** RESTRICTIONS: |
| 122 ** None |
| 123 ** MEMORY: N/A |
| 124 ** ALGORITHM: N/A |
| 125 ***********************************************************************/ |
| 126 NSPR_API(PRUint32) PR_TicksPerSecond(void); |
| 127 |
| 128 /*********************************************************************** |
| 129 ** FUNCTION: PR_SecondsToInterval |
| 130 ** PR_MillisecondsToInterval |
| 131 ** PR_MicrosecondsToInterval |
| 132 ** DESCRIPTION: |
| 133 ** Convert standard clock units to platform dependent intervals. |
| 134 ** INPUTS: PRUint32 |
| 135 ** OUTPUTS: void |
| 136 ** RETURN: PRIntervalTime |
| 137 ** |
| 138 ** SIDE EFFECTS: |
| 139 ** None |
| 140 ** RESTRICTIONS: |
| 141 ** Conversion may cause overflow, which is not reported. |
| 142 ** MEMORY: N/A |
| 143 ** ALGORITHM: N/A |
| 144 ***********************************************************************/ |
| 145 NSPR_API(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds); |
| 146 NSPR_API(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli); |
| 147 NSPR_API(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro); |
| 148 |
| 149 /*********************************************************************** |
| 150 ** FUNCTION: PR_IntervalToSeconds |
| 151 ** PR_IntervalToMilliseconds |
| 152 ** PR_IntervalToMicroseconds |
| 153 ** DESCRIPTION: |
| 154 ** Convert platform dependent intervals to standard clock units. |
| 155 ** INPUTS: PRIntervalTime |
| 156 ** OUTPUTS: void |
| 157 ** RETURN: PRUint32 |
| 158 ** |
| 159 ** SIDE EFFECTS: |
| 160 ** None |
| 161 ** RESTRICTIONS: |
| 162 ** Conversion may cause overflow, which is not reported. |
| 163 ** MEMORY: N/A |
| 164 ** ALGORITHM: N/A |
| 165 ***********************************************************************/ |
| 166 NSPR_API(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks); |
| 167 NSPR_API(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks); |
| 168 NSPR_API(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks); |
| 169 |
| 170 PR_END_EXTERN_C |
| 171 |
| 172 |
| 173 #endif /* !defined(prinrval_h) */ |
| 174 |
| 175 /* prinrval.h */ |
OLD | NEW |