home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _osf1.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  170 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_osf1_defs_h___
  20. #define nspr_osf1_defs_h___
  21.  
  22. /*
  23.  * Internal configuration macros
  24.  */
  25.  
  26. #define PR_LINKER_ARCH    "osf"
  27. #define _PR_SI_SYSNAME    "OSF"
  28. #define _PR_SI_ARCHITECTURE "alpha"
  29. #define PR_DLL_SUFFIX        ".so"
  30.  
  31. #define _PR_VMBASE        0x30000000
  32. #define _PR_STACK_VMBASE    0x50000000
  33. #define _MD_DEFAULT_STACK_SIZE    131072L
  34. /*
  35.  * OSF1 needs the MAP_FIXED flag to ensure that mmap returns a pointer
  36.  * with the upper 32 bits zero.  This is because Java sticks a pointer
  37.  * into an int.
  38.  */
  39. #define _MD_MMAP_FLAGS          MAP_PRIVATE|MAP_FIXED
  40.  
  41. #undef  HAVE_STACK_GROWING_UP
  42. #undef     HAVE_WEAK_IO_SYMBOLS
  43. #undef     HAVE_WEAK_MALLOC_SYMBOLS
  44. #define HAVE_DLL
  45. #define HAVE_BSD_FLOCK
  46.  
  47. #define NEED_TIME_R
  48. #define USE_DLFCN
  49.  
  50. #define USE_SETJMP
  51.  
  52. #include <setjmp.h>
  53.  
  54. /*
  55.  * A jmp_buf is actually a struct sigcontext.  The sc_sp field of
  56.  * struct sigcontext is the stack pointer.
  57.  */
  58. #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp)
  59. #define PR_NUM_GCREGS _JBLEN
  60. #define CONTEXT(_th) ((_th)->md.context)
  61.  
  62. /*
  63. ** Initialize a thread context to run "_main()" when started
  64. */
  65. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)          \
  66. {                                      \
  67.         *status = PR_TRUE;              \
  68.     if (setjmp(CONTEXT(_thread))) {                \
  69.     (*_main)();                        \
  70.     }                                \
  71.     _MD_GET_SP(_thread) = (long) ((_sp) - 64);            \
  72.     _MD_GET_SP(_thread) &= ~15;                    \
  73. }
  74.  
  75. #define _MD_SWITCH_CONTEXT(_thread)  \
  76.     if (!setjmp(CONTEXT(_thread))) { \
  77.     (_thread)->md.errcode = errno;  \
  78.     _PR_Schedule();             \
  79.     }
  80.  
  81. /*
  82. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  83. */
  84. #define _MD_RESTORE_CONTEXT(_thread) \
  85. {                     \
  86.     errno = (_thread)->md.errcode;     \
  87.     _MD_SET_CURRENT_THREAD(_thread);    \
  88.     longjmp(CONTEXT(_thread), 1);    \
  89. }
  90.  
  91. /* Machine-dependent (MD) data structures */
  92.  
  93. struct _MDThread {
  94.     jmp_buf context;
  95.     int id;
  96.     int errcode;
  97. };
  98.  
  99. struct _MDThreadStack {
  100.     PRInt8 notused;
  101. };
  102.  
  103. struct _MDLock {
  104.     PRInt8 notused;
  105. };
  106.  
  107. struct _MDSemaphore {
  108.     PRInt8 notused;
  109. };
  110.  
  111. struct _MDCVar {
  112.     PRInt8 notused;
  113. };
  114.  
  115. struct _MDSegment {
  116.     PRInt8 notused;
  117. };
  118.  
  119. struct _MDCPU {
  120.     struct _MDCPU_Unix md_unix;
  121. };
  122.  
  123. #ifndef _PR_PTHREADS
  124. #define _MD_INIT_LOCKS()
  125. #endif
  126. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  127. #define _MD_FREE_LOCK(lock)
  128. #define _MD_LOCK(lock)
  129. #define _MD_UNLOCK(lock)
  130. #define _MD_INIT_IO()
  131. #define _MD_IOQ_LOCK()
  132. #define _MD_IOQ_UNLOCK()
  133.  
  134. /*
  135.  * The following are copied from _sunos.h, _aix.h.  This means
  136.  * some of them should probably be moved into _unixos.h.  But
  137.  * _irix.h seems to be quite different in regard to these macros.
  138.  */
  139. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  140. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  141.  
  142. #define _MD_EARLY_INIT        _MD_EarlyInit
  143. #define _MD_FINAL_INIT        _PR_UnixInit
  144. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  145. #define _MD_INIT_THREAD         _MD_InitializeThread
  146. #define _MD_EXIT_THREAD(thread)
  147. #define    _MD_SUSPEND_THREAD(thread)
  148. #define    _MD_RESUME_THREAD(thread)
  149. #define _MD_CLEAN_THREAD(_thread)
  150.  
  151. /* The following defines unwrapped versions of select() and poll(). */
  152. extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  153. #define _MD_SELECT              __select
  154.  
  155. #include <sys/poll.h>
  156. #define _MD_POLL __poll
  157. extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout);
  158.  
  159. /*
  160.  * Atomic operations
  161.  */
  162. #include <machine/builtins.h>
  163. #define _PR_HAVE_ATOMIC_OPS
  164. #define _MD_INIT_ATOMIC()
  165. #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1)
  166. #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1)
  167. #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval)
  168.  
  169. #endif /* nspr_osf1_defs_h___ */
  170.