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.
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/. */
6 #include "primpl.h"
8 #include <mach/mach_time.h>
10 void _MD_EarlyInit(void)
11 {
12 }
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;
20 void _PR_Mach_IntervalInit(void)
21 {
22 kern_return_t rv;
24 rv = mach_timebase_info(&machTimebaseInfo);
25 PR_ASSERT(rv == KERN_SUCCESS);
26 }
28 PRIntervalTime _PR_Mach_GetInterval(void)
29 {
30 uint64_t time;
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 */
42 PRIntervalTime _PR_Mach_TicksPerSecond(void)
43 {
44 return 1000;
45 }
47 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
48 {
49 #if !defined(_PR_PTHREADS)
50 if (isCurrent) {
51 (void) setjmp(CONTEXT(t));
52 }
53 *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
54 return (PRWord *) CONTEXT(t);
55 #else
56 *np = 0;
57 return NULL;
58 #endif
59 }
61 #if !defined(_PR_PTHREADS)
62 void
63 _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
64 {
65 return;
66 }
68 PRStatus
69 _MD_InitializeThread(PRThread *thread)
70 {
71 return PR_SUCCESS;
72 }
74 PRStatus
75 _MD_WAIT(PRThread *thread, PRIntervalTime ticks)
76 {
77 PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
78 _PR_MD_SWITCH_CONTEXT(thread);
79 return PR_SUCCESS;
80 }
82 PRStatus
83 _MD_WAKEUP_WAITER(PRThread *thread)
84 {
85 if (thread) {
86 PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
87 }
88 return PR_SUCCESS;
89 }
91 /* These functions should not be called for Darwin */
92 void
93 _MD_YIELD(void)
94 {
95 PR_NOT_REACHED("_MD_YIELD should not be called for Darwin.");
96 }
98 PRStatus
99 _MD_CREATE_THREAD(
100 PRThread *thread,
101 void (*start) (void *),
102 PRThreadPriority priority,
103 PRThreadScope scope,
104 PRThreadState state,
105 PRUint32 stackSize)
106 {
107 PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin.");
108 return PR_FAILURE;
109 }
110 #endif /* ! _PR_PTHREADS */
112 /* darwin.c */