home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _hpux.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  6KB  |  222 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_xhppa_defs_h___
  20. #define nspr_xhppa_defs_h___
  21.  
  22. /*
  23.  * Internal configuration macros
  24.  */
  25.  
  26. #define PR_LINKER_ARCH    "hpux"
  27. #define _PR_SI_SYSNAME   "HPUX"
  28. #define _PR_SI_ARCHITECTURE "hppa1.1"
  29. #define PR_DLL_SUFFIX        ".sl"
  30.  
  31. #define _PR_VMBASE        0x30000000 
  32. #define _PR_STACK_VMBASE    0x50000000
  33. #define _MD_DEFAULT_STACK_SIZE    65536L
  34. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  35.  
  36. #define NEED_TIME_R
  37.  
  38. #define HAVE_STACK_GROWING_UP
  39. #undef    HAVE_WEAK_IO_SYMBOLS
  40. #undef    HAVE_WEAK_MALLOC_SYMBOLS
  41. #define    HAVE_DLL
  42. #define USE_HPSHL
  43. #ifndef HAVE_STRERROR
  44. #define HAVE_STRERROR
  45. #endif
  46. #define _PR_POLL_AVAILABLE
  47. #define _PR_USE_POLL
  48. #define _PR_STAT_HAS_ONLY_ST_ATIME
  49.  
  50. #undef _PR_HAVE_ATOMIC_OPS
  51.  
  52. #if !defined(_PR_PTHREADS)
  53.  
  54. #include <syscall.h>
  55. #include <setjmp.h>
  56.  
  57. #define USE_SETJMP
  58.  
  59. #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
  60. #define PR_NUM_GCREGS _JBLEN
  61. /* Caveat: This makes jmp_buf full of doubles. */
  62. #define CONTEXT(_th) ((_th)->md.jb)
  63.  
  64.     /* Stack needs two frames (64 bytes) at the bottom */ \
  65. #define _MD_SET_THR_SP(_t, _sp)     ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
  66. #define SAVE_CONTEXT(_th)           _setjmp(CONTEXT(_th))
  67. #define GOTO_CONTEXT(_th)           _longjmp(CONTEXT(_th), 1)
  68.  
  69. #if !defined(PTHREADS_USER)
  70.  
  71. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  72. { \
  73.     *(status) = PR_TRUE; \
  74.     if (_setjmp(CONTEXT(_thread))) (*_main)(); \
  75.     /* Stack needs two frames (64 bytes) at the bottom */ \
  76.     (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
  77. }
  78.  
  79. #define _MD_SWITCH_CONTEXT(_thread) \
  80.     if (!_setjmp(CONTEXT(_thread))) { \
  81.     (_thread)->md.errcode = errno; \
  82.     _PR_Schedule(); \
  83.     }
  84.  
  85. /*
  86. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  87. */
  88. #define _MD_RESTORE_CONTEXT(_thread) \
  89. { \
  90.     errno = (_thread)->md.errcode; \
  91.     _MD_SET_CURRENT_THREAD(_thread); \
  92.     _longjmp(CONTEXT(_thread), 1); \
  93. }
  94.  
  95. /* Machine-dependent (MD) data structures.  HP-UX has no native threads. */
  96.  
  97. struct _MDThread {
  98.     jmp_buf jb;
  99.     int id;
  100.     int errcode;
  101. };
  102.  
  103. struct _MDThreadStack {
  104.     PRInt8 notused;
  105. };
  106.  
  107. struct _MDLock {
  108.     PRInt8 notused;
  109. };
  110.  
  111. struct _MDSemaphore {
  112.     PRInt8 notused;
  113. };
  114.  
  115. struct _MDCVar {
  116.     PRInt8 notused;
  117. };
  118.  
  119. struct _MDSegment {
  120.     PRInt8 notused;
  121. };
  122.  
  123. /*
  124.  * md-specific cpu structure field
  125.  */
  126. #define _PR_MD_MAX_OSFD FD_SETSIZE
  127.  
  128. struct _MDCPU_Unix {
  129.     PRCList ioQ;
  130.     PRUint32 ioq_timeout;
  131.     PRInt32 ioq_max_osfd;
  132.     PRInt32 ioq_osfd_cnt;
  133. #ifndef _PR_USE_POLL
  134.     fd_set fd_read_set, fd_write_set, fd_exception_set;
  135.     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  136.                 fd_exception_cnt[_PR_MD_MAX_OSFD];
  137. #else
  138.     struct pollfd *ioq_pollfds;
  139.     int ioq_pollfds_size;
  140. #endif    /* _PR_USE_POLL */
  141. };
  142.  
  143. #define _PR_IOQ(_cpu)            ((_cpu)->md.md_unix.ioQ)
  144. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  145. #define _PR_FD_READ_SET(_cpu)        ((_cpu)->md.md_unix.fd_read_set)
  146. #define _PR_FD_READ_CNT(_cpu)        ((_cpu)->md.md_unix.fd_read_cnt)
  147. #define _PR_FD_WRITE_SET(_cpu)        ((_cpu)->md.md_unix.fd_write_set)
  148. #define _PR_FD_WRITE_CNT(_cpu)        ((_cpu)->md.md_unix.fd_write_cnt)
  149. #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.md_unix.fd_exception_set)
  150. #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.md_unix.fd_exception_cnt)
  151. #define _PR_IOQ_TIMEOUT(_cpu)        ((_cpu)->md.md_unix.ioq_timeout)
  152. #define _PR_IOQ_MAX_OSFD(_cpu)        ((_cpu)->md.md_unix.ioq_max_osfd)
  153. #define _PR_IOQ_OSFD_CNT(_cpu)        ((_cpu)->md.md_unix.ioq_osfd_cnt)
  154. #define _PR_IOQ_POLLFDS(_cpu)        ((_cpu)->md.md_unix.ioq_pollfds)
  155. #define _PR_IOQ_POLLFDS_SIZE(_cpu)    ((_cpu)->md.md_unix.ioq_pollfds_size)
  156.  
  157. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
  158.  
  159. struct _MDCPU {
  160.     struct _MDCPU_Unix md_unix;
  161. };
  162.  
  163. #define _MD_INIT_LOCKS()
  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. #define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
  173. #define _MD_INIT_THREAD                 _MD_InitializeThread
  174. #define _MD_EXIT_THREAD(thread)
  175. #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
  176. #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
  177. #define _MD_CLEAN_THREAD(_thread)
  178.  
  179. #else /* PTHREADS_USER    */
  180.  
  181. #include "_nspr_pthread.h"
  182.  
  183. #endif /* PTHREADS_USER    */
  184.  
  185. #endif  /* !defined(_PR_PTHREADS) */
  186.  
  187. #if !defined(PTHREADS_USER)
  188. #define _MD_EARLY_INIT                     _MD_EarlyInit
  189. #define _MD_FINAL_INIT                    _PR_UnixInit
  190. #endif 
  191.  
  192. #if defined(HPUX_LW_TIMER)
  193. extern void _PR_HPUX_LW_IntervalInit(void);
  194. extern PRIntervalTime _PR_HPUX_LW_GetInterval(void);
  195. #define _MD_INTERVAL_INIT                 _PR_HPUX_LW_IntervalInit
  196. #define _MD_GET_INTERVAL                  _PR_HPUX_LW_GetInterval
  197. #define _MD_INTERVAL_PER_SEC()            1000
  198. #else
  199. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  200. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  201. #endif
  202.  
  203. /*
  204.  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  205.  * unwrapped version.
  206.  */
  207. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  208.  
  209. #include <poll.h>
  210. #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
  211.  
  212. #ifdef HPUX11
  213. extern void _MD_hpux_map_sendfile_error(int err);
  214. #if !defined(_PR_PTHREADS)
  215. extern PRInt32 _PR_HPUXTransmitFile(PRFileDesc *sd, PRFileDesc *fd,
  216.         const void *headers, PRInt32 hlen,
  217.         PRTransmitFileFlags flags, PRIntervalTime timeout);
  218. #endif /* !_PR_PTHREADS */
  219. #endif /* HPUX11 */
  220.  
  221. #endif /* nspr_xhppa_defs_h___ */
  222.