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