Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "primpl.h" |
michael@0 | 7 | |
michael@0 | 8 | #include <mach/mach_time.h> |
michael@0 | 9 | |
michael@0 | 10 | void _MD_EarlyInit(void) |
michael@0 | 11 | { |
michael@0 | 12 | } |
michael@0 | 13 | |
michael@0 | 14 | /* |
michael@0 | 15 | * The multiplier (as a fraction) for converting the Mach absolute time |
michael@0 | 16 | * unit to nanoseconds. |
michael@0 | 17 | */ |
michael@0 | 18 | static mach_timebase_info_data_t machTimebaseInfo; |
michael@0 | 19 | |
michael@0 | 20 | void _PR_Mach_IntervalInit(void) |
michael@0 | 21 | { |
michael@0 | 22 | kern_return_t rv; |
michael@0 | 23 | |
michael@0 | 24 | rv = mach_timebase_info(&machTimebaseInfo); |
michael@0 | 25 | PR_ASSERT(rv == KERN_SUCCESS); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | PRIntervalTime _PR_Mach_GetInterval(void) |
michael@0 | 29 | { |
michael@0 | 30 | uint64_t time; |
michael@0 | 31 | |
michael@0 | 32 | /* |
michael@0 | 33 | * mach_absolute_time returns the time in the Mach absolute time unit. |
michael@0 | 34 | * Convert it to milliseconds. See Mac Technical Q&A QA1398. |
michael@0 | 35 | */ |
michael@0 | 36 | time = mach_absolute_time(); |
michael@0 | 37 | time = time * machTimebaseInfo.numer / machTimebaseInfo.denom / |
michael@0 | 38 | PR_NSEC_PER_MSEC; |
michael@0 | 39 | return (PRIntervalTime)time; |
michael@0 | 40 | } /* _PR_Mach_GetInterval */ |
michael@0 | 41 | |
michael@0 | 42 | PRIntervalTime _PR_Mach_TicksPerSecond(void) |
michael@0 | 43 | { |
michael@0 | 44 | return 1000; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) |
michael@0 | 48 | { |
michael@0 | 49 | #if !defined(_PR_PTHREADS) |
michael@0 | 50 | if (isCurrent) { |
michael@0 | 51 | (void) setjmp(CONTEXT(t)); |
michael@0 | 52 | } |
michael@0 | 53 | *np = sizeof(CONTEXT(t)) / sizeof(PRWord); |
michael@0 | 54 | return (PRWord *) CONTEXT(t); |
michael@0 | 55 | #else |
michael@0 | 56 | *np = 0; |
michael@0 | 57 | return NULL; |
michael@0 | 58 | #endif |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | #if !defined(_PR_PTHREADS) |
michael@0 | 62 | void |
michael@0 | 63 | _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) |
michael@0 | 64 | { |
michael@0 | 65 | return; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | PRStatus |
michael@0 | 69 | _MD_InitializeThread(PRThread *thread) |
michael@0 | 70 | { |
michael@0 | 71 | return PR_SUCCESS; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | PRStatus |
michael@0 | 75 | _MD_WAIT(PRThread *thread, PRIntervalTime ticks) |
michael@0 | 76 | { |
michael@0 | 77 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 78 | _PR_MD_SWITCH_CONTEXT(thread); |
michael@0 | 79 | return PR_SUCCESS; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | PRStatus |
michael@0 | 83 | _MD_WAKEUP_WAITER(PRThread *thread) |
michael@0 | 84 | { |
michael@0 | 85 | if (thread) { |
michael@0 | 86 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 87 | } |
michael@0 | 88 | return PR_SUCCESS; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | /* These functions should not be called for Darwin */ |
michael@0 | 92 | void |
michael@0 | 93 | _MD_YIELD(void) |
michael@0 | 94 | { |
michael@0 | 95 | PR_NOT_REACHED("_MD_YIELD should not be called for Darwin."); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | PRStatus |
michael@0 | 99 | _MD_CREATE_THREAD( |
michael@0 | 100 | PRThread *thread, |
michael@0 | 101 | void (*start) (void *), |
michael@0 | 102 | PRThreadPriority priority, |
michael@0 | 103 | PRThreadScope scope, |
michael@0 | 104 | PRThreadState state, |
michael@0 | 105 | PRUint32 stackSize) |
michael@0 | 106 | { |
michael@0 | 107 | PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin."); |
michael@0 | 108 | return PR_FAILURE; |
michael@0 | 109 | } |
michael@0 | 110 | #endif /* ! _PR_PTHREADS */ |
michael@0 | 111 | |
michael@0 | 112 | /* darwin.c */ |
michael@0 | 113 |