OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* This Source Code Form is subject to the terms of the Mozilla Public | 2 /* This Source Code Form is subject to the terms of the Mozilla Public |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 /* | 6 /* |
7 * file: prinrval.c | 7 * file: prinrval.c |
8 * description: implementation for the kernel interval timing functions | 8 * description: implementation for the kernel interval timing functions |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #ifdef DEBUG | 25 #ifdef DEBUG |
26 { | 26 { |
27 PRIntervalTime ticksPerSec = PR_TicksPerSecond(); | 27 PRIntervalTime ticksPerSec = PR_TicksPerSecond(); |
28 | 28 |
29 PR_ASSERT(ticksPerSec >= PR_INTERVAL_MIN); | 29 PR_ASSERT(ticksPerSec >= PR_INTERVAL_MIN); |
30 PR_ASSERT(ticksPerSec <= PR_INTERVAL_MAX); | 30 PR_ASSERT(ticksPerSec <= PR_INTERVAL_MAX); |
31 } | 31 } |
32 #endif /* DEBUG */ | 32 #endif /* DEBUG */ |
33 } | 33 } |
34 | 34 |
35 /* | |
36 * This version of interval times is based on the time of day | |
37 * capability offered by system. This isn't valid for two reasons: | |
38 * 1) The time of day is neither linear nor montonically increasing | |
39 * 2) The units here are milliseconds. That's not appropriate for our use. | |
40 */ | |
41 | |
42 PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) | 35 PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) |
43 { | 36 { |
44 if (!_pr_initialized) _PR_ImplicitInitialization(); | 37 if (!_pr_initialized) _PR_ImplicitInitialization(); |
45 return _PR_MD_GET_INTERVAL(); | 38 return _PR_MD_GET_INTERVAL(); |
46 } /* PR_IntervalNow */ | 39 } /* PR_IntervalNow */ |
47 | 40 |
48 PR_EXTERN(PRUint32) PR_TicksPerSecond(void) | 41 PR_EXTERN(PRUint32) PR_TicksPerSecond(void) |
49 { | 42 { |
50 if (!_pr_initialized) _PR_ImplicitInitialization(); | 43 if (!_pr_initialized) _PR_ImplicitInitialization(); |
51 return _PR_MD_INTERVAL_PER_SEC(); | 44 return _PR_MD_INTERVAL_PER_SEC(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 LL_USHR(rounding, tps, 1); | 109 LL_USHR(rounding, tps, 1); |
117 LL_MUL(tock, tock, usecPerSec); | 110 LL_MUL(tock, tock, usecPerSec); |
118 LL_ADD(tock, tock, rounding); | 111 LL_ADD(tock, tock, rounding); |
119 LL_DIV(tock, tock, tps); | 112 LL_DIV(tock, tock, tps); |
120 LL_L2UI(micro, tock); | 113 LL_L2UI(micro, tock); |
121 return micro; | 114 return micro; |
122 } /* PR_IntervalToMicroseconds */ | 115 } /* PR_IntervalToMicroseconds */ |
123 | 116 |
124 /* prinrval.c */ | 117 /* prinrval.c */ |
125 | 118 |
OLD | NEW |