michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "primpl.h" michael@0: michael@0: #include michael@0: michael@0: void _MD_EarlyInit(void) michael@0: { michael@0: } michael@0: michael@0: /* michael@0: * The multiplier (as a fraction) for converting the Mach absolute time michael@0: * unit to nanoseconds. michael@0: */ michael@0: static mach_timebase_info_data_t machTimebaseInfo; michael@0: michael@0: void _PR_Mach_IntervalInit(void) michael@0: { michael@0: kern_return_t rv; michael@0: michael@0: rv = mach_timebase_info(&machTimebaseInfo); michael@0: PR_ASSERT(rv == KERN_SUCCESS); michael@0: } michael@0: michael@0: PRIntervalTime _PR_Mach_GetInterval(void) michael@0: { michael@0: uint64_t time; michael@0: michael@0: /* michael@0: * mach_absolute_time returns the time in the Mach absolute time unit. michael@0: * Convert it to milliseconds. See Mac Technical Q&A QA1398. michael@0: */ michael@0: time = mach_absolute_time(); michael@0: time = time * machTimebaseInfo.numer / machTimebaseInfo.denom / michael@0: PR_NSEC_PER_MSEC; michael@0: return (PRIntervalTime)time; michael@0: } /* _PR_Mach_GetInterval */ michael@0: michael@0: PRIntervalTime _PR_Mach_TicksPerSecond(void) michael@0: { michael@0: return 1000; michael@0: } michael@0: michael@0: PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) michael@0: { michael@0: #if !defined(_PR_PTHREADS) michael@0: if (isCurrent) { michael@0: (void) setjmp(CONTEXT(t)); michael@0: } michael@0: *np = sizeof(CONTEXT(t)) / sizeof(PRWord); michael@0: return (PRWord *) CONTEXT(t); michael@0: #else michael@0: *np = 0; michael@0: return NULL; michael@0: #endif michael@0: } michael@0: michael@0: #if !defined(_PR_PTHREADS) michael@0: void michael@0: _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) michael@0: { michael@0: return; michael@0: } michael@0: michael@0: PRStatus michael@0: _MD_InitializeThread(PRThread *thread) michael@0: { michael@0: return PR_SUCCESS; michael@0: } michael@0: michael@0: PRStatus michael@0: _MD_WAIT(PRThread *thread, PRIntervalTime ticks) michael@0: { michael@0: PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); michael@0: _PR_MD_SWITCH_CONTEXT(thread); michael@0: return PR_SUCCESS; michael@0: } michael@0: michael@0: PRStatus michael@0: _MD_WAKEUP_WAITER(PRThread *thread) michael@0: { michael@0: if (thread) { michael@0: PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); michael@0: } michael@0: return PR_SUCCESS; michael@0: } michael@0: michael@0: /* These functions should not be called for Darwin */ michael@0: void michael@0: _MD_YIELD(void) michael@0: { michael@0: PR_NOT_REACHED("_MD_YIELD should not be called for Darwin."); michael@0: } michael@0: michael@0: PRStatus michael@0: _MD_CREATE_THREAD( michael@0: PRThread *thread, michael@0: void (*start) (void *), michael@0: PRThreadPriority priority, michael@0: PRThreadScope scope, michael@0: PRThreadState state, michael@0: PRUint32 stackSize) michael@0: { michael@0: PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Darwin."); michael@0: return PR_FAILURE; michael@0: } michael@0: #endif /* ! _PR_PTHREADS */ michael@0: michael@0: /* darwin.c */ michael@0: