Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "primpl.h" |
michael@0 | 7 | |
michael@0 | 8 | #include <signal.h> |
michael@0 | 9 | #include <poll.h> |
michael@0 | 10 | #include <sys/syscall.h> |
michael@0 | 11 | |
michael@0 | 12 | void _MD_EarlyInit(void) |
michael@0 | 13 | { |
michael@0 | 14 | /* |
michael@0 | 15 | * Ignore FPE because coercion of a NaN to an int causes SIGFPE |
michael@0 | 16 | * to be raised. |
michael@0 | 17 | */ |
michael@0 | 18 | struct sigaction act; |
michael@0 | 19 | |
michael@0 | 20 | act.sa_handler = SIG_IGN; |
michael@0 | 21 | sigemptyset(&act.sa_mask); |
michael@0 | 22 | act.sa_flags = SA_RESTART; |
michael@0 | 23 | sigaction(SIGFPE, &act, 0); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) |
michael@0 | 27 | { |
michael@0 | 28 | #ifndef _PR_PTHREADS |
michael@0 | 29 | if (isCurrent) { |
michael@0 | 30 | (void) sigsetjmp(CONTEXT(t), 1); |
michael@0 | 31 | } |
michael@0 | 32 | *np = sizeof(CONTEXT(t)) / sizeof(PRWord); |
michael@0 | 33 | return (PRWord *) CONTEXT(t); |
michael@0 | 34 | #else |
michael@0 | 35 | *np = 0; |
michael@0 | 36 | return NULL; |
michael@0 | 37 | #endif |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | #ifndef _PR_PTHREADS |
michael@0 | 41 | void |
michael@0 | 42 | _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) |
michael@0 | 43 | { |
michael@0 | 44 | return; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | PRStatus |
michael@0 | 48 | _MD_InitializeThread(PRThread *thread) |
michael@0 | 49 | { |
michael@0 | 50 | return PR_SUCCESS; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | PRStatus |
michael@0 | 54 | _MD_WAIT(PRThread *thread, PRIntervalTime ticks) |
michael@0 | 55 | { |
michael@0 | 56 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 57 | _PR_MD_SWITCH_CONTEXT(thread); |
michael@0 | 58 | return PR_SUCCESS; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | PRStatus |
michael@0 | 62 | _MD_WAKEUP_WAITER(PRThread *thread) |
michael@0 | 63 | { |
michael@0 | 64 | if (thread) { |
michael@0 | 65 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 66 | } |
michael@0 | 67 | return PR_SUCCESS; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | /* These functions should not be called for NetBSD */ |
michael@0 | 71 | void |
michael@0 | 72 | _MD_YIELD(void) |
michael@0 | 73 | { |
michael@0 | 74 | PR_NOT_REACHED("_MD_YIELD should not be called for NetBSD."); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | PRStatus |
michael@0 | 78 | _MD_CREATE_THREAD( |
michael@0 | 79 | PRThread *thread, |
michael@0 | 80 | void (*start) (void *), |
michael@0 | 81 | PRThreadPriority priority, |
michael@0 | 82 | PRThreadScope scope, |
michael@0 | 83 | PRThreadState state, |
michael@0 | 84 | PRUint32 stackSize) |
michael@0 | 85 | { |
michael@0 | 86 | PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for NetBSD."); |
michael@0 | 87 | return PR_FAILURE; |
michael@0 | 88 | } |
michael@0 | 89 | #endif /* ! _PR_PTHREADS */ |