home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _sunos4.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.8 KB  |  180 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. #ifndef nspr_sunos_defs_h___
  20. #define nspr_sunos_defs_h___
  21.  
  22. #include "md/sunos4.h"
  23.  
  24. /* On SunOS 4, memset is declared in memory.h */
  25. #include <memory.h>
  26. #include <errno.h>
  27. #include <sys/syscall.h>
  28.  
  29. /*
  30.  * Internal configuration macros
  31.  */
  32.  
  33. #define PR_LINKER_ARCH    "sunos"
  34. #define _PR_SI_SYSNAME    "SUNOS"
  35. #define _PR_SI_ARCHITECTURE "sparc"
  36. #define PR_DLL_SUFFIX        ".so.1.0"
  37.  
  38. /*
  39. ** For sunos type machines, don't specify an address because the
  40. ** NetBSD/SPARC O.S. does the wrong thing.
  41. */
  42. #define _PR_VMBASE        0x30000000
  43. #define _PR_STACK_VMBASE    0x50000000
  44. #define _MD_DEFAULT_STACK_SIZE    65536L
  45. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  46.  
  47. #undef  HAVE_STACK_GROWING_UP
  48. #undef    HAVE_WEAK_IO_SYMBOLS
  49. #undef    HAVE_WEAK_MALLOC_SYMBOLS
  50. #define    HAVE_DLL
  51. #define    USE_DLFCN
  52. #define NEED_STRFTIME_LOCK
  53. #define NEED_TIME_R
  54. #define HAVE_BSD_FLOCK
  55.  
  56. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  57. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  58.  
  59. #define USE_SETJMP
  60.  
  61. #include <setjmp.h>
  62.  
  63. #define _MD_GET_SP(_t)    (_t)->md.context[2]
  64.  
  65. #define PR_NUM_GCREGS    _JBLEN
  66.  
  67. #define CONTEXT(_th) ((_th)->md.context)
  68.  
  69. /*
  70. ** Initialize the thread context preparing it to execute _main.
  71. */
  72. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)          \
  73.     PR_BEGIN_MACRO                      \
  74.     int *context = (_thread)->md.context;          \
  75.         *status = PR_TRUE;              \
  76.     asm("ta 3");                    \
  77.     (void) setjmp(context);                  \
  78.     (_thread)->md.context[2] = (int) ((_sp) - 64); \
  79.     (_thread)->md.context[2] &= ~7;        \
  80.     (_thread)->md.context[3] = (int) _main;  \
  81.     (_thread)->md.context[4] = (int) _main + 4;  \
  82.     PR_END_MACRO
  83.  
  84. #define _MD_SWITCH_CONTEXT(_thread)  \
  85.     asm("ta 3");            \
  86.     if (!setjmp(CONTEXT(_thread))) { \
  87.     (_thread)->md.errcode = errno;  \
  88.     _PR_Schedule();             \
  89.     }
  90.  
  91. /*
  92. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  93. */
  94. #define _MD_RESTORE_CONTEXT(_thread) \
  95. {                     \
  96.     errno = (_thread)->md.errcode;         \
  97.     _MD_SET_CURRENT_THREAD(_thread);     \
  98.     longjmp(CONTEXT(_thread), 1);    \
  99. }
  100.  
  101. #pragma unknown_control_flow(longjmp)
  102. #pragma unknown_control_flow(setjmp)
  103. #pragma unknown_control_flow(_PR_Schedule)
  104.  
  105. /*
  106. ** Missing function prototypes
  107. */
  108.  
  109. extern int socket (int domain, int type, int protocol);
  110. extern int getsockname (int s, struct sockaddr *name, int *namelen);
  111. extern int getpeername (int s, struct sockaddr *name, int *namelen);
  112. extern int getsockopt (int s, int level, int optname, char* optval, int* optlen);
  113. extern int setsockopt (int s, int level, int optname, const char* optval, int optlen);
  114. extern int accept (int s, struct sockaddr *addr, int *addrlen);
  115. extern int listen (int s, int backlog);
  116. extern int brk(void *);
  117. extern void *sbrk(int);
  118.  
  119.  
  120. /* Machine-dependent (MD) data structures.  SunOS 4 has no native threads. */
  121.  
  122. struct _MDThread {
  123.     jmp_buf context;
  124.     int id;
  125.     int errcode;
  126. };
  127.  
  128. struct _MDThreadStack {
  129.     PRInt8 notused;
  130. };
  131.  
  132. struct _MDLock {
  133.     PRInt8 notused;
  134. };
  135.  
  136. struct _MDSemaphore {
  137.     PRInt8 notused;
  138. };
  139.  
  140. struct _MDCVar {
  141.     PRInt8 notused;
  142. };
  143.  
  144. struct _MDSegment {
  145.     PRInt8 notused;
  146. };
  147.  
  148. struct _MDCPU {
  149.     struct _MDCPU_Unix md_unix;
  150. };
  151.  
  152. #define _MD_INIT_LOCKS()
  153. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  154. #define _MD_FREE_LOCK(lock)
  155. #define _MD_LOCK(lock)
  156. #define _MD_UNLOCK(lock)
  157. #define _MD_INIT_IO()
  158. #define _MD_IOQ_LOCK()
  159. #define _MD_IOQ_UNLOCK()
  160.  
  161. /* These are copied from _solaris.h */
  162.  
  163. #define _MD_EARLY_INIT          _MD_EarlyInit
  164. #define _MD_FINAL_INIT            _PR_UnixInit
  165. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  166. #define _MD_INIT_THREAD         _MD_InitializeThread
  167. #define _MD_EXIT_THREAD(thread)
  168. #define    _MD_SUSPEND_THREAD(thread)
  169. #define    _MD_RESUME_THREAD(thread)
  170. #define _MD_CLEAN_THREAD(_thread)
  171.  
  172. /*
  173.  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  174.  * unwrapped version.
  175.  */
  176. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  177. #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
  178.  
  179. #endif /* nspr_sparc_defs_h___ */
  180.