home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _osf1.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  6KB  |  210 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. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  35.  
  36. #undef  HAVE_STACK_GROWING_UP
  37. #undef     HAVE_WEAK_IO_SYMBOLS
  38. #undef     HAVE_WEAK_MALLOC_SYMBOLS
  39. #define HAVE_DLL
  40. #define HAVE_BSD_FLOCK
  41.  
  42. #define NEED_TIME_R
  43. #define USE_DLFCN
  44.  
  45. #define _PR_HAVE_ATOMIC_OPS
  46. #define _PR_HAVE_ATOMIC_CAS
  47. #define _PR_POLL_AVAILABLE
  48. #define _PR_USE_POLL
  49. #define _PR_STAT_HAS_ONLY_ST_ATIME
  50. #define _PR_HAVE_LARGE_OFF_T
  51.  
  52. #define USE_SETJMP
  53.  
  54. #include <setjmp.h>
  55.  
  56. /*
  57.  * A jmp_buf is actually a struct sigcontext.  The sc_sp field of
  58.  * struct sigcontext is the stack pointer.
  59.  */
  60. #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp)
  61. #define PR_NUM_GCREGS _JBLEN
  62. #define CONTEXT(_th) ((_th)->md.context)
  63.  
  64. /*
  65. ** Initialize a thread context to run "_main()" when started
  66. */
  67. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)          \
  68. {                                      \
  69.         *status = PR_TRUE;              \
  70.     if (setjmp(CONTEXT(_thread))) {                \
  71.     (*_main)();                        \
  72.     }                                \
  73.     _MD_GET_SP(_thread) = (long) ((_sp) - 64);            \
  74.     _MD_GET_SP(_thread) &= ~15;                    \
  75. }
  76.  
  77. #define _MD_SWITCH_CONTEXT(_thread)  \
  78.     if (!setjmp(CONTEXT(_thread))) { \
  79.     (_thread)->md.errcode = errno;  \
  80.     _PR_Schedule();             \
  81.     }
  82.  
  83. /*
  84. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  85. */
  86. #define _MD_RESTORE_CONTEXT(_thread) \
  87. {                     \
  88.     errno = (_thread)->md.errcode;     \
  89.     _MD_SET_CURRENT_THREAD(_thread);    \
  90.     longjmp(CONTEXT(_thread), 1);    \
  91. }
  92.  
  93. /* Machine-dependent (MD) data structures */
  94.  
  95. struct _MDThread {
  96.     jmp_buf context;
  97.     int id;
  98.     int errcode;
  99. };
  100.  
  101. struct _MDThreadStack {
  102.     PRInt8 notused;
  103. };
  104.  
  105. struct _MDLock {
  106.     PRInt8 notused;
  107. };
  108.  
  109. struct _MDSemaphore {
  110.     PRInt8 notused;
  111. };
  112.  
  113. struct _MDCVar {
  114.     PRInt8 notused;
  115. };
  116.  
  117. struct _MDSegment {
  118.     PRInt8 notused;
  119. };
  120.  
  121. /*
  122.  * md-specific cpu structure field
  123.  */
  124. #define _PR_MD_MAX_OSFD FD_SETSIZE
  125.  
  126. struct _MDCPU_Unix {
  127.     PRCList ioQ;
  128.     PRUint32 ioq_timeout;
  129.     PRInt32 ioq_max_osfd;
  130.     PRInt32 ioq_osfd_cnt;
  131. #ifndef _PR_USE_POLL
  132.     fd_set fd_read_set, fd_write_set, fd_exception_set;
  133.     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  134.                 fd_exception_cnt[_PR_MD_MAX_OSFD];
  135. #else
  136.     struct pollfd *ioq_pollfds;
  137.     int ioq_pollfds_size;
  138. #endif    /* _PR_USE_POLL */
  139. };
  140.  
  141. #define _PR_IOQ(_cpu)            ((_cpu)->md.md_unix.ioQ)
  142. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  143. #define _PR_FD_READ_SET(_cpu)        ((_cpu)->md.md_unix.fd_read_set)
  144. #define _PR_FD_READ_CNT(_cpu)        ((_cpu)->md.md_unix.fd_read_cnt)
  145. #define _PR_FD_WRITE_SET(_cpu)        ((_cpu)->md.md_unix.fd_write_set)
  146. #define _PR_FD_WRITE_CNT(_cpu)        ((_cpu)->md.md_unix.fd_write_cnt)
  147. #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.md_unix.fd_exception_set)
  148. #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.md_unix.fd_exception_cnt)
  149. #define _PR_IOQ_TIMEOUT(_cpu)        ((_cpu)->md.md_unix.ioq_timeout)
  150. #define _PR_IOQ_MAX_OSFD(_cpu)        ((_cpu)->md.md_unix.ioq_max_osfd)
  151. #define _PR_IOQ_OSFD_CNT(_cpu)        ((_cpu)->md.md_unix.ioq_osfd_cnt)
  152. #define _PR_IOQ_POLLFDS(_cpu)        ((_cpu)->md.md_unix.ioq_pollfds)
  153. #define _PR_IOQ_POLLFDS_SIZE(_cpu)    ((_cpu)->md.md_unix.ioq_pollfds_size)
  154.  
  155. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
  156.  
  157. struct _MDCPU {
  158.     struct _MDCPU_Unix md_unix;
  159. };
  160.  
  161. #ifndef _PR_PTHREADS
  162. #define _MD_INIT_LOCKS()
  163. #endif
  164. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  165. #define _MD_FREE_LOCK(lock)
  166. #define _MD_LOCK(lock)
  167. #define _MD_UNLOCK(lock)
  168. #define _MD_INIT_IO()
  169. #define _MD_IOQ_LOCK()
  170. #define _MD_IOQ_UNLOCK()
  171.  
  172. /*
  173.  * The following are copied from _sunos.h, _aix.h.  This means
  174.  * some of them should probably be moved into _unixos.h.  But
  175.  * _irix.h seems to be quite different in regard to these macros.
  176.  */
  177. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  178. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  179.  
  180. #define _MD_EARLY_INIT        _MD_EarlyInit
  181. #define _MD_FINAL_INIT        _PR_UnixInit
  182. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  183. #define _MD_INIT_THREAD         _MD_InitializeThread
  184. #define _MD_EXIT_THREAD(thread)
  185. #define    _MD_SUSPEND_THREAD(thread)
  186. #define    _MD_RESUME_THREAD(thread)
  187. #define _MD_CLEAN_THREAD(_thread)
  188.  
  189. /* The following defines unwrapped versions of select() and poll(). */
  190. extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  191. #define _MD_SELECT              __select
  192.  
  193. #include <sys/poll.h>
  194. #define _MD_POLL __poll
  195. extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout);
  196.  
  197. /*
  198.  * Atomic operations
  199.  */
  200. #ifdef _PR_HAVE_ATOMIC_OPS
  201. #include <machine/builtins.h>
  202. #define _MD_INIT_ATOMIC()
  203. #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1)
  204. #define _MD_ATOMIC_ADD(ptr, val)  (__ATOMIC_ADD_LONG(ptr, val) + val)
  205. #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1)
  206. #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval)
  207. #endif /* _PR_HAVE_ATOMIC_OPS */
  208.  
  209. #endif /* nspr_osf1_defs_h___ */
  210.