Back to index

lightning-sunbird  0.9+nobinonly
scoos.c
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039  * SCO ODT 5.0 - originally created by mikep
00040  */
00041 #include "primpl.h"
00042 
00043 #include <setjmp.h>
00044 
00045 void _MD_EarlyInit(void)
00046 {
00047 }
00048 
00049 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
00050 {
00051     if (isCurrent) {
00052        (void) setjmp(CONTEXT(t));
00053     }
00054     *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
00055     return (PRWord *) CONTEXT(t);
00056 }
00057 
00058 #ifdef ALARMS_BREAK_TCP /* I don't think they do */
00059 
00060 PRInt32 _MD_connect(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen,
00061                         PRIntervalTime timeout)
00062 {
00063     PRInt32 rv;
00064 
00065     _MD_BLOCK_CLOCK_INTERRUPTS();
00066     rv = _connect(osfd,addr,addrlen);
00067     _MD_UNBLOCK_CLOCK_INTERRUPTS();
00068 }
00069 
00070 PRInt32 _MD_accept(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen,
00071                         PRIntervalTime timeout)
00072 {
00073     PRInt32 rv;
00074 
00075     _MD_BLOCK_CLOCK_INTERRUPTS();
00076     rv = _accept(osfd,addr,addrlen);
00077     _MD_UNBLOCK_CLOCK_INTERRUPTS();
00078     return(rv);
00079 }
00080 #endif
00081 
00082 /*
00083  * These are also implemented in pratom.c using NSPR locks.  Any reason
00084  * this might be better or worse?  If you like this better, define
00085  * _PR_HAVE_ATOMIC_OPS in include/md/unixware.h
00086  */
00087 #ifdef _PR_HAVE_ATOMIC_OPS
00088 /* Atomic operations */
00089 #include  <stdio.h>
00090 static FILE *_uw_semf;
00091 
00092 void
00093 _MD_INIT_ATOMIC(void)
00094 {
00095     /* Sigh.  Sure wish SYSV semaphores weren't such a pain to use */
00096     if ((_uw_semf = tmpfile()) == NULL)
00097         PR_ASSERT(0);
00098 
00099     return;
00100 }
00101 
00102 void
00103 _MD_ATOMIC_INCREMENT(PRInt32 *val)
00104 {
00105     flockfile(_uw_semf);
00106     (*val)++;
00107     unflockfile(_uw_semf);
00108 }
00109 
00110 void
00111 _MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val)
00112 {
00113     flockfile(_uw_semf);
00114     (*ptr) += val;
00115     unflockfile(_uw_semf);
00116 }
00117 
00118 void
00119 _MD_ATOMIC_DECREMENT(PRInt32 *val)
00120 {
00121     flockfile(_uw_semf);
00122     (*val)--;
00123     unflockfile(_uw_semf);
00124 }
00125 
00126 void
00127 _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
00128 {
00129     flockfile(_uw_semf);
00130     *val = newval;
00131     unflockfile(_uw_semf);
00132 }
00133 #endif
00134 
00135 void
00136 _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
00137 {
00138     return;
00139 }
00140 
00141 PRStatus
00142 _MD_InitializeThread(PRThread *thread)
00143 {
00144        return PR_SUCCESS;
00145 }
00146 
00147 PRStatus
00148 _MD_WAIT(PRThread *thread, PRIntervalTime ticks)
00149 {
00150     PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
00151     _PR_MD_SWITCH_CONTEXT(thread);
00152     return PR_SUCCESS;
00153 }
00154 
00155 PRStatus
00156 _MD_WAKEUP_WAITER(PRThread *thread)
00157 {
00158     if (thread) {
00159        PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
00160     }
00161     return PR_SUCCESS;
00162 }
00163 
00164 /* These functions should not be called for SCO */
00165 void
00166 _MD_YIELD(void)
00167 {
00168     PR_NOT_REACHED("_MD_YIELD should not be called for SCO.");
00169 }
00170 
00171 PRStatus
00172 _MD_CREATE_THREAD(
00173     PRThread *thread,
00174     void (*start) (void *),
00175     PRThreadPriority priority,
00176     PRThreadScope scope,
00177     PRThreadState state,
00178     PRUint32 stackSize)
00179 {
00180     PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for SCO.");
00181 }