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 #include "primpl.h" | 6 #include "primpl.h" |
7 | 7 |
| 8 #include <mach/mach_time.h> |
| 9 |
8 void _MD_EarlyInit(void) | 10 void _MD_EarlyInit(void) |
9 { | 11 { |
10 } | 12 } |
11 | 13 |
| 14 /* |
| 15 * The multiplier (as a fraction) for converting the Mach absolute time |
| 16 * unit to nanoseconds. |
| 17 */ |
| 18 static mach_timebase_info_data_t machTimebaseInfo; |
| 19 |
| 20 void _PR_Mach_IntervalInit(void) |
| 21 { |
| 22 kern_return_t rv; |
| 23 |
| 24 rv = mach_timebase_info(&machTimebaseInfo); |
| 25 PR_ASSERT(rv == KERN_SUCCESS); |
| 26 } |
| 27 |
| 28 PRIntervalTime _PR_Mach_GetInterval(void) |
| 29 { |
| 30 uint64_t time; |
| 31 |
| 32 /* |
| 33 * mach_absolute_time returns the time in the Mach absolute time unit. |
| 34 * Convert it to milliseconds. See Mac Technical Q&A QA1398. |
| 35 */ |
| 36 time = mach_absolute_time(); |
| 37 time = time * machTimebaseInfo.numer / machTimebaseInfo.denom / |
| 38 PR_NSEC_PER_MSEC; |
| 39 return (PRIntervalTime)time; |
| 40 } /* _PR_Mach_GetInterval */ |
| 41 |
| 42 PRIntervalTime _PR_Mach_TicksPerSecond(void) |
| 43 { |
| 44 return 1000; |
| 45 } |
| 46 |
12 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) | 47 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) |
13 { | 48 { |
14 #if !defined(_PR_PTHREADS) | 49 #if !defined(_PR_PTHREADS) |
15 if (isCurrent) { | 50 if (isCurrent) { |
16 (void) setjmp(CONTEXT(t)); | 51 (void) setjmp(CONTEXT(t)); |
17 } | 52 } |
18 *np = sizeof(CONTEXT(t)) / sizeof(PRWord); | 53 *np = sizeof(CONTEXT(t)) / sizeof(PRWord); |
19 return (PRWord *) CONTEXT(t); | 54 return (PRWord *) CONTEXT(t); |
20 #else | 55 #else |
21 *np = 0; | 56 *np = 0; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 PRThreadState state, | 104 PRThreadState state, |
70 PRUint32 stackSize) | 105 PRUint32 stackSize) |
71 { | 106 { |
72 PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin."); | 107 PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin."); |
73 return PR_FAILURE; | 108 return PR_FAILURE; |
74 } | 109 } |
75 #endif /* ! _PR_PTHREADS */ | 110 #endif /* ! _PR_PTHREADS */ |
76 | 111 |
77 /* darwin.c */ | 112 /* darwin.c */ |
78 | 113 |
OLD | NEW |