Mercurial > trustbridge > nss-cmake-static
comparison nspr/pr/src/misc/prinrval.c @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
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 | |
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/. */ | |
5 | |
6 /* | |
7 * file: prinrval.c | |
8 * description: implementation for the kernel interval timing functions | |
9 */ | |
10 | |
11 #include "primpl.h" | |
12 | |
13 /* | |
14 *----------------------------------------------------------------------- | |
15 * | |
16 * _PR_InitClock -- | |
17 * | |
18 * | |
19 *----------------------------------------------------------------------- | |
20 */ | |
21 | |
22 void _PR_InitClock(void) | |
23 { | |
24 _PR_MD_INTERVAL_INIT(); | |
25 #ifdef DEBUG | |
26 { | |
27 PRIntervalTime ticksPerSec = PR_TicksPerSecond(); | |
28 | |
29 PR_ASSERT(ticksPerSec >= PR_INTERVAL_MIN); | |
30 PR_ASSERT(ticksPerSec <= PR_INTERVAL_MAX); | |
31 } | |
32 #endif /* DEBUG */ | |
33 } | |
34 | |
35 PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) | |
36 { | |
37 if (!_pr_initialized) _PR_ImplicitInitialization(); | |
38 return _PR_MD_GET_INTERVAL(); | |
39 } /* PR_IntervalNow */ | |
40 | |
41 PR_EXTERN(PRUint32) PR_TicksPerSecond(void) | |
42 { | |
43 if (!_pr_initialized) _PR_ImplicitInitialization(); | |
44 return _PR_MD_INTERVAL_PER_SEC(); | |
45 } /* PR_TicksPerSecond */ | |
46 | |
47 PR_IMPLEMENT(PRIntervalTime) PR_SecondsToInterval(PRUint32 seconds) | |
48 { | |
49 return seconds * PR_TicksPerSecond(); | |
50 } /* PR_SecondsToInterval */ | |
51 | |
52 PR_IMPLEMENT(PRIntervalTime) PR_MillisecondsToInterval(PRUint32 milli) | |
53 { | |
54 PRIntervalTime ticks; | |
55 PRUint64 tock, tps, msecPerSec, rounding; | |
56 LL_UI2L(tock, milli); | |
57 LL_I2L(msecPerSec, PR_MSEC_PER_SEC); | |
58 LL_I2L(rounding, (PR_MSEC_PER_SEC >> 1)); | |
59 LL_I2L(tps, PR_TicksPerSecond()); | |
60 LL_MUL(tock, tock, tps); | |
61 LL_ADD(tock, tock, rounding); | |
62 LL_DIV(tock, tock, msecPerSec); | |
63 LL_L2UI(ticks, tock); | |
64 return ticks; | |
65 } /* PR_MillisecondsToInterval */ | |
66 | |
67 PR_IMPLEMENT(PRIntervalTime) PR_MicrosecondsToInterval(PRUint32 micro) | |
68 { | |
69 PRIntervalTime ticks; | |
70 PRUint64 tock, tps, usecPerSec, rounding; | |
71 LL_UI2L(tock, micro); | |
72 LL_I2L(usecPerSec, PR_USEC_PER_SEC); | |
73 LL_I2L(rounding, (PR_USEC_PER_SEC >> 1)); | |
74 LL_I2L(tps, PR_TicksPerSecond()); | |
75 LL_MUL(tock, tock, tps); | |
76 LL_ADD(tock, tock, rounding); | |
77 LL_DIV(tock, tock, usecPerSec); | |
78 LL_L2UI(ticks, tock); | |
79 return ticks; | |
80 } /* PR_MicrosecondsToInterval */ | |
81 | |
82 PR_IMPLEMENT(PRUint32) PR_IntervalToSeconds(PRIntervalTime ticks) | |
83 { | |
84 return ticks / PR_TicksPerSecond(); | |
85 } /* PR_IntervalToSeconds */ | |
86 | |
87 PR_IMPLEMENT(PRUint32) PR_IntervalToMilliseconds(PRIntervalTime ticks) | |
88 { | |
89 PRUint32 milli; | |
90 PRUint64 tock, tps, msecPerSec, rounding; | |
91 LL_UI2L(tock, ticks); | |
92 LL_I2L(msecPerSec, PR_MSEC_PER_SEC); | |
93 LL_I2L(tps, PR_TicksPerSecond()); | |
94 LL_USHR(rounding, tps, 1); | |
95 LL_MUL(tock, tock, msecPerSec); | |
96 LL_ADD(tock, tock, rounding); | |
97 LL_DIV(tock, tock, tps); | |
98 LL_L2UI(milli, tock); | |
99 return milli; | |
100 } /* PR_IntervalToMilliseconds */ | |
101 | |
102 PR_IMPLEMENT(PRUint32) PR_IntervalToMicroseconds(PRIntervalTime ticks) | |
103 { | |
104 PRUint32 micro; | |
105 PRUint64 tock, tps, usecPerSec, rounding; | |
106 LL_UI2L(tock, ticks); | |
107 LL_I2L(usecPerSec, PR_USEC_PER_SEC); | |
108 LL_I2L(tps, PR_TicksPerSecond()); | |
109 LL_USHR(rounding, tps, 1); | |
110 LL_MUL(tock, tock, usecPerSec); | |
111 LL_ADD(tock, tock, rounding); | |
112 LL_DIV(tock, tock, tps); | |
113 LL_L2UI(micro, tock); | |
114 return micro; | |
115 } /* PR_IntervalToMicroseconds */ | |
116 | |
117 /* prinrval.c */ | |
118 |