1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/md/unix/linux.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "primpl.h" 1.10 + 1.11 +void _MD_EarlyInit(void) 1.12 +{ 1.13 +} 1.14 + 1.15 +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) 1.16 +{ 1.17 +#ifndef _PR_PTHREADS 1.18 + if (isCurrent) { 1.19 + (void) setjmp(CONTEXT(t)); 1.20 + } 1.21 + *np = sizeof(CONTEXT(t)) / sizeof(PRWord); 1.22 + return (PRWord *) CONTEXT(t); 1.23 +#else 1.24 + *np = 0; 1.25 + return NULL; 1.26 +#endif 1.27 +} 1.28 + 1.29 +#ifdef _PR_PTHREADS 1.30 + 1.31 +extern void _MD_unix_terminate_waitpid_daemon(void); 1.32 + 1.33 +void _MD_CleanupBeforeExit(void) 1.34 +{ 1.35 + _MD_unix_terminate_waitpid_daemon(); 1.36 +} 1.37 + 1.38 +#else /* ! _PR_PTHREADS */ 1.39 + 1.40 +void 1.41 +_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) 1.42 +{ 1.43 + return; 1.44 +} 1.45 + 1.46 +PRStatus 1.47 +_MD_InitializeThread(PRThread *thread) 1.48 +{ 1.49 + /* 1.50 + * set the pointers to the stack-pointer and frame-pointer words in the 1.51 + * context structure; this is for debugging use. 1.52 + */ 1.53 + thread->md.sp = _MD_GET_SP_PTR(thread); 1.54 + thread->md.fp = _MD_GET_FP_PTR(thread); 1.55 + return PR_SUCCESS; 1.56 +} 1.57 + 1.58 +PRStatus 1.59 +_MD_WAIT(PRThread *thread, PRIntervalTime ticks) 1.60 +{ 1.61 + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 1.62 + _PR_MD_SWITCH_CONTEXT(thread); 1.63 + return PR_SUCCESS; 1.64 +} 1.65 + 1.66 +PRStatus 1.67 +_MD_WAKEUP_WAITER(PRThread *thread) 1.68 +{ 1.69 + if (thread) { 1.70 + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 1.71 + } 1.72 + return PR_SUCCESS; 1.73 +} 1.74 + 1.75 +/* These functions should not be called for Linux */ 1.76 +void 1.77 +_MD_YIELD(void) 1.78 +{ 1.79 + PR_NOT_REACHED("_MD_YIELD should not be called for Linux."); 1.80 +} 1.81 + 1.82 +PRStatus 1.83 +_MD_CREATE_THREAD( 1.84 + PRThread *thread, 1.85 + void (*start) (void *), 1.86 + PRThreadPriority priority, 1.87 + PRThreadScope scope, 1.88 + PRThreadState state, 1.89 + PRUint32 stackSize) 1.90 +{ 1.91 + PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for Linux."); 1.92 + return PR_FAILURE; 1.93 +} 1.94 +#endif /* ! _PR_PTHREADS */