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