1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/md/unix/scoos.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,149 @@ 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 +/* 1.10 + * SCO ODT 5.0 - originally created by mikep 1.11 + */ 1.12 +#include "primpl.h" 1.13 + 1.14 +#include <setjmp.h> 1.15 + 1.16 +void _MD_EarlyInit(void) 1.17 +{ 1.18 +} 1.19 + 1.20 +PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) 1.21 +{ 1.22 + if (isCurrent) { 1.23 + (void) setjmp(CONTEXT(t)); 1.24 + } 1.25 + *np = sizeof(CONTEXT(t)) / sizeof(PRWord); 1.26 + return (PRWord *) CONTEXT(t); 1.27 +} 1.28 + 1.29 +#ifdef ALARMS_BREAK_TCP /* I don't think they do */ 1.30 + 1.31 +PRInt32 _MD_connect(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen, 1.32 + PRIntervalTime timeout) 1.33 +{ 1.34 + PRInt32 rv; 1.35 + 1.36 + _MD_BLOCK_CLOCK_INTERRUPTS(); 1.37 + rv = _connect(osfd,addr,addrlen); 1.38 + _MD_UNBLOCK_CLOCK_INTERRUPTS(); 1.39 +} 1.40 + 1.41 +PRInt32 _MD_accept(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen, 1.42 + PRIntervalTime timeout) 1.43 +{ 1.44 + PRInt32 rv; 1.45 + 1.46 + _MD_BLOCK_CLOCK_INTERRUPTS(); 1.47 + rv = _accept(osfd,addr,addrlen); 1.48 + _MD_UNBLOCK_CLOCK_INTERRUPTS(); 1.49 + return(rv); 1.50 +} 1.51 +#endif 1.52 + 1.53 +/* 1.54 + * These are also implemented in pratom.c using NSPR locks. Any reason 1.55 + * this might be better or worse? If you like this better, define 1.56 + * _PR_HAVE_ATOMIC_OPS in include/md/unixware.h 1.57 + */ 1.58 +#ifdef _PR_HAVE_ATOMIC_OPS 1.59 +/* Atomic operations */ 1.60 +#include <stdio.h> 1.61 +static FILE *_uw_semf; 1.62 + 1.63 +void 1.64 +_MD_INIT_ATOMIC(void) 1.65 +{ 1.66 + /* Sigh. Sure wish SYSV semaphores weren't such a pain to use */ 1.67 + if ((_uw_semf = tmpfile()) == NULL) 1.68 + PR_ASSERT(0); 1.69 + 1.70 + return; 1.71 +} 1.72 + 1.73 +void 1.74 +_MD_ATOMIC_INCREMENT(PRInt32 *val) 1.75 +{ 1.76 + flockfile(_uw_semf); 1.77 + (*val)++; 1.78 + unflockfile(_uw_semf); 1.79 +} 1.80 + 1.81 +void 1.82 +_MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val) 1.83 +{ 1.84 + flockfile(_uw_semf); 1.85 + (*ptr) += val; 1.86 + unflockfile(_uw_semf); 1.87 +} 1.88 + 1.89 +void 1.90 +_MD_ATOMIC_DECREMENT(PRInt32 *val) 1.91 +{ 1.92 + flockfile(_uw_semf); 1.93 + (*val)--; 1.94 + unflockfile(_uw_semf); 1.95 +} 1.96 + 1.97 +void 1.98 +_MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) 1.99 +{ 1.100 + flockfile(_uw_semf); 1.101 + *val = newval; 1.102 + unflockfile(_uw_semf); 1.103 +} 1.104 +#endif 1.105 + 1.106 +void 1.107 +_MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) 1.108 +{ 1.109 + return; 1.110 +} 1.111 + 1.112 +PRStatus 1.113 +_MD_InitializeThread(PRThread *thread) 1.114 +{ 1.115 + return PR_SUCCESS; 1.116 +} 1.117 + 1.118 +PRStatus 1.119 +_MD_WAIT(PRThread *thread, PRIntervalTime ticks) 1.120 +{ 1.121 + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 1.122 + _PR_MD_SWITCH_CONTEXT(thread); 1.123 + return PR_SUCCESS; 1.124 +} 1.125 + 1.126 +PRStatus 1.127 +_MD_WAKEUP_WAITER(PRThread *thread) 1.128 +{ 1.129 + if (thread) { 1.130 + PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); 1.131 + } 1.132 + return PR_SUCCESS; 1.133 +} 1.134 + 1.135 +/* These functions should not be called for SCO */ 1.136 +void 1.137 +_MD_YIELD(void) 1.138 +{ 1.139 + PR_NOT_REACHED("_MD_YIELD should not be called for SCO."); 1.140 +} 1.141 + 1.142 +PRStatus 1.143 +_MD_CREATE_THREAD( 1.144 + PRThread *thread, 1.145 + void (*start) (void *), 1.146 + PRThreadPriority priority, 1.147 + PRThreadScope scope, 1.148 + PRThreadState state, 1.149 + PRUint32 stackSize) 1.150 +{ 1.151 + PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for SCO."); 1.152 +}