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