freebsd.c (1814B)
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/. */ 5 6 #include "primpl.h" 7 8 #include <signal.h> 9 10 void _MD_EarlyInit(void) { 11 /* 12 * Ignore FPE because coercion of a NaN to an int causes SIGFPE 13 * to be raised. 14 */ 15 struct sigaction act; 16 17 act.sa_handler = SIG_IGN; 18 sigemptyset(&act.sa_mask); 19 act.sa_flags = SA_RESTART; 20 sigaction(SIGFPE, &act, 0); 21 } 22 23 PRWord* _MD_HomeGCRegisters(PRThread* t, int isCurrent, int* np) { 24 #ifndef _PR_PTHREADS 25 if (isCurrent) { 26 (void)sigsetjmp(CONTEXT(t), 1); 27 } 28 *np = sizeof(CONTEXT(t)) / sizeof(PRWord); 29 return (PRWord*)CONTEXT(t); 30 #else 31 *np = 0; 32 return NULL; 33 #endif 34 } 35 36 #ifndef _PR_PTHREADS 37 void _MD_SET_PRIORITY(_MDThread* thread, PRUintn newPri) { return; } 38 39 PRStatus _MD_InitializeThread(PRThread* thread) { return PR_SUCCESS; } 40 41 PRStatus _MD_WAIT(PRThread* thread, PRIntervalTime ticks) { 42 PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 43 _PR_MD_SWITCH_CONTEXT(thread); 44 return PR_SUCCESS; 45 } 46 47 PRStatus _MD_WAKEUP_WAITER(PRThread* thread) { 48 if (thread) { 49 PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 50 } 51 return PR_SUCCESS; 52 } 53 54 /* These functions should not be called for FreeBSD */ 55 void _MD_YIELD(void) { 56 PR_NOT_REACHED("_MD_YIELD should not be called for FreeBSD."); 57 } 58 59 PRStatus _MD_CREATE_THREAD(PRThread* thread, void (*start)(void*), 60 PRThreadPriority priority, PRThreadScope scope, 61 PRThreadState state, PRUint32 stackSize) { 62 PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for FreeBSD."); 63 return PR_FAILURE; 64 } 65 #endif /* ! _PR_PTHREADS */