home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / md / unix / scoos.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  155 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20.  * SCO ODT 5.0 - originally created by mikep
  21.  */
  22. #include "primpl.h"
  23.  
  24. #include <setjmp.h>
  25.  
  26. void _MD_EarlyInit(void)
  27. {
  28. }
  29.  
  30. PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np)
  31. {
  32.     if (isCurrent) {
  33.     (void) setjmp(CONTEXT(t));
  34.     }
  35.     *np = sizeof(CONTEXT(t)) / sizeof(PRWord);
  36.     return (PRWord *) CONTEXT(t);
  37. }
  38.  
  39. #ifdef ALARMS_BREAK_TCP /* I don't think they do */
  40.  
  41. PRInt32 _MD_connect(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen,
  42.                         PRIntervalTime timeout)
  43. {
  44.     PRInt32 rv;
  45.  
  46.     _MD_BLOCK_CLOCK_INTERRUPTS();
  47.     rv = _connect(osfd,addr,addrlen);
  48.     _MD_UNBLOCK_CLOCK_INTERRUPTS();
  49. }
  50.  
  51. PRInt32 _MD_accept(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen,
  52.                         PRIntervalTime timeout)
  53. {
  54.     PRInt32 rv;
  55.  
  56.     _MD_BLOCK_CLOCK_INTERRUPTS();
  57.     rv = _accept(osfd,addr,addrlen);
  58.     _MD_UNBLOCK_CLOCK_INTERRUPTS();
  59.     return(rv);
  60. }
  61. #endif
  62.  
  63. /*
  64.  * These are also implemented in pratom.c using NSPR locks.  Any reason
  65.  * this might be better or worse?  If you like this better, define
  66.  * _PR_HAVE_ATOMIC_OPS in include/md/unixware.h
  67.  */
  68. #ifdef _PR_HAVE_ATOMIC_OPS
  69. /* Atomic operations */
  70. #include  <stdio.h>
  71. static FILE *_uw_semf;
  72.  
  73. void
  74. _MD_INIT_ATOMIC(void)
  75. {
  76.     /* Sigh.  Sure wish SYSV semaphores weren't such a pain to use */
  77.     if ((_uw_semf = tmpfile()) == NULL)
  78.         PR_ASSERT(0);
  79.  
  80.     return;
  81. }
  82.  
  83. void
  84. _MD_ATOMIC_INCREMENT(PRInt32 *val)
  85. {
  86.     flockfile(_uw_semf);
  87.     (*val)++;
  88.     unflockfile(_uw_semf);
  89. }
  90.  
  91. void
  92. _MD_ATOMIC_DECREMENT(PRInt32 *val)
  93. {
  94.     flockfile(_uw_semf);
  95.     (*val)--;
  96.     unflockfile(_uw_semf);
  97. }
  98.  
  99. void
  100. _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval)
  101. {
  102.     flockfile(_uw_semf);
  103.     *val = newval;
  104.     unflockfile(_uw_semf);
  105. }
  106. #endif
  107.  
  108. void
  109. _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri)
  110. {
  111.     return;
  112. }
  113.  
  114. PRStatus
  115. _MD_InitializeThread(PRThread *thread)
  116. {
  117.     return PR_SUCCESS;
  118. }
  119.  
  120. PRStatus
  121. _MD_WAIT(PRThread *thread, PRIntervalTime ticks)
  122. {
  123.     PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
  124.     _PR_MD_SWITCH_CONTEXT(thread);
  125.     return PR_SUCCESS;
  126. }
  127.  
  128. PRStatus
  129. _MD_WAKEUP_WAITER(PRThread *thread)
  130. {
  131.     if (thread) {
  132.     PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE));
  133.     }
  134.     return PR_SUCCESS;
  135. }
  136.  
  137. /* These functions should not be called for SCO */
  138. void
  139. _MD_YIELD(void)
  140. {
  141.     PR_NOT_REACHED("_MD_YIELD should not be called for SCO.");
  142. }
  143.  
  144. PRStatus
  145. _MD_CREATE_THREAD(
  146.     PRThread *thread,
  147.     void (*start) (void *),
  148.     PRThreadPriority priority,
  149.     PRThreadScope scope,
  150.     PRThreadState state,
  151.     PRUint32 stackSize)
  152. {
  153.     PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for SCO.");
  154. }
  155.