home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _hpux.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  173 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. #define HAVE_STRERROR
  44.  
  45. #undef _PR_HAVE_ATOMIC_OPS
  46.  
  47. #if !defined(_PR_PTHREADS)
  48.  
  49. #include <syscall.h>
  50. #include <setjmp.h>
  51.  
  52. #define USE_SETJMP
  53.  
  54. #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
  55. #define PR_NUM_GCREGS _JBLEN
  56. /* Caveat: This makes jmp_buf full of doubles. */
  57. #define CONTEXT(_th) ((_th)->md.jb)
  58.  
  59.     /* Stack needs two frames (64 bytes) at the bottom */ \
  60. #define _MD_SET_THR_SP(_t, _sp)     ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
  61. #define SAVE_CONTEXT(_th)           _setjmp(CONTEXT(_th))
  62. #define GOTO_CONTEXT(_th)           _longjmp(CONTEXT(_th), 1)
  63.  
  64. #if !defined(PTHREADS_USER)
  65.  
  66. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  67. { \
  68.     *(status) = PR_TRUE; \
  69.     if (_setjmp(CONTEXT(_thread))) (*_main)(); \
  70.     /* Stack needs two frames (64 bytes) at the bottom */ \
  71.     (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
  72. }
  73.  
  74. #define _MD_SWITCH_CONTEXT(_thread) \
  75.     if (!_setjmp(CONTEXT(_thread))) { \
  76.     (_thread)->md.errcode = errno; \
  77.     _PR_Schedule(); \
  78.     }
  79.  
  80. /*
  81. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  82. */
  83. #define _MD_RESTORE_CONTEXT(_thread) \
  84. { \
  85.     errno = (_thread)->md.errcode; \
  86.     _MD_SET_CURRENT_THREAD(_thread); \
  87.     _longjmp(CONTEXT(_thread), 1); \
  88. }
  89.  
  90. /* Machine-dependent (MD) data structures.  HP-UX has no native threads. */
  91.  
  92. struct _MDThread {
  93.     jmp_buf jb;
  94.     int id;
  95.     int errcode;
  96. };
  97.  
  98. struct _MDThreadStack {
  99.     PRInt8 notused;
  100. };
  101.  
  102. struct _MDLock {
  103.     PRInt8 notused;
  104. };
  105.  
  106. struct _MDSemaphore {
  107.     PRInt8 notused;
  108. };
  109.  
  110. struct _MDCVar {
  111.     PRInt8 notused;
  112. };
  113.  
  114. struct _MDSegment {
  115.     PRInt8 notused;
  116. };
  117.  
  118. struct _MDCPU {
  119.     struct _MDCPU_Unix md_unix;
  120. };
  121.  
  122. #define _MD_INIT_LOCKS()
  123. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  124. #define _MD_FREE_LOCK(lock)
  125. #define _MD_LOCK(lock)
  126. #define _MD_UNLOCK(lock)
  127. #define _MD_INIT_IO()
  128. #define _MD_IOQ_LOCK()
  129. #define _MD_IOQ_UNLOCK()
  130.  
  131. #define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
  132. #define _MD_INIT_THREAD                 _MD_InitializeThread
  133. #define _MD_EXIT_THREAD(thread)
  134. #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
  135. #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
  136. #define _MD_CLEAN_THREAD(_thread)
  137.  
  138. #else /* PTHREADS_USER    */
  139.  
  140. #include "_nspr_pthread.h"
  141.  
  142. #endif /* PTHREADS_USER    */
  143.  
  144. #endif  /* !defined(_PR_PTHREADS) */
  145.  
  146. #if !defined(PTHREADS_USER)
  147. #define _MD_EARLY_INIT                     _MD_EarlyInit
  148. #define _MD_FINAL_INIT                    _PR_UnixInit
  149. #endif 
  150.  
  151. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  152. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  153.  
  154. /*
  155.  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  156.  * unwrapped version.
  157.  */
  158. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  159. #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
  160.  
  161. extern void _MD_hpux_install_sigfpe_handler(void);
  162.  
  163. #ifdef HPUX11
  164. extern void _MD_hpux_map_sendfile_error(int err);
  165. #if !defined(_PR_PTHREADS)
  166. extern PRInt32 _PR_HPUXTransmitFile(PRFileDesc *sd, PRFileDesc *fd,
  167.         const void *headers, PRInt32 hlen,
  168.         PRTransmitFileFlags flags, PRIntervalTime timeout);
  169. #endif /* !_PR_PTHREADS */
  170. #endif /* HPUX11 */
  171.  
  172. #endif /* nspr_xhppa_defs_h___ */
  173.