_hpux.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nspr_xhppa_defs_h___
  6. #define nspr_xhppa_defs_h___
  7. /*
  8. * Internal configuration macros
  9. */
  10. #define PR_LINKER_ARCH "hpux"
  11. #define _PR_SI_SYSNAME "HPUX"
  12. #ifdef __ia64
  13. #define _PR_SI_ARCHITECTURE "ia64"
  14. #define PR_DLL_SUFFIX ".so"
  15. #else
  16. /*
  17. * _PR_SI_ARCHITECTURE must be "hppa1.1" for backward compatibility.
  18. * It was changed to "hppa" in NSPR 4.6.2, but was changed back in
  19. * NSPR 4.6.4.
  20. */
  21. #define _PR_SI_ARCHITECTURE "hppa1.1"
  22. #define PR_DLL_SUFFIX ".sl"
  23. #endif
  24. #define _PR_VMBASE 0x30000000
  25. #define _PR_STACK_VMBASE 0x50000000
  26. /*
  27. * _USE_BIG_FDS increases the size of fd_set from 256 bytes to
  28. * about 7500 bytes. PR_Poll allocates three fd_sets on the
  29. * stack, so it is safer to also increase the default thread
  30. * stack size.
  31. */
  32. #define _MD_DEFAULT_STACK_SIZE (2*65536L)
  33. #define _MD_MINIMUM_STACK_SIZE (2*65536L)
  34. #define _MD_MMAP_FLAGS MAP_PRIVATE
  35. #define NEED_TIME_R
  36. #define HAVE_STACK_GROWING_UP
  37. #undef HAVE_WEAK_IO_SYMBOLS
  38. #undef HAVE_WEAK_MALLOC_SYMBOLS
  39. #define HAVE_DLL
  40. #ifdef IS_64
  41. #define USE_DLFCN
  42. #else
  43. #define USE_HPSHL
  44. #endif
  45. #ifndef HAVE_STRERROR
  46. #define HAVE_STRERROR
  47. #endif
  48. #define _PR_POLL_AVAILABLE
  49. #define _PR_USE_POLL
  50. #define _PR_STAT_HAS_ONLY_ST_ATIME
  51. #define _PR_HAVE_POSIX_SEMAPHORES
  52. #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
  53. #define _PR_ACCEPT_INHERIT_NONBLOCK
  54. #if defined(__ia64)
  55. #define _PR_HAVE_ATOMIC_OPS
  56. #define _MD_INIT_ATOMIC()
  57. extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
  58. #define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement
  59. extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
  60. #define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement
  61. extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
  62. #define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd
  63. extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
  64. #define _MD_ATOMIC_SET _PR_ia64_AtomicSet
  65. #endif
  66. #define _PR_HAVE_GETIPNODEBYNAME
  67. #define _PR_HAVE_GETIPNODEBYADDR
  68. #define _PR_HAVE_GETADDRINFO
  69. #ifdef _PR_INET6
  70. #define _PR_HAVE_INET_NTOP
  71. #else
  72. #define _PR_INET6_PROBE
  73. /* for HP-UX 11.11 without IPv6 */
  74. #ifndef AF_INET6
  75. #define AF_INET6 22
  76. #define AI_CANONNAME 2
  77. #define AI_NUMERICHOST 4
  78. #define AI_NUMERICSERV 8
  79. #define AI_V4MAPPED 0x00000010
  80. #define AI_ADDRCONFIG 0x00000040
  81. #define AI_ALL 0x00000020
  82. #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
  83. #define NI_NUMERICHOST 2
  84. struct addrinfo {
  85. int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
  86. int ai_family; /* PF_xxx */
  87. int ai_socktype; /* SOCK_xxx */
  88. int ai_protocol; /* IPPROTO_xxx for IPv4 and IPv6 */
  89. socklen_t ai_addrlen; /* length of ai_addr */
  90. char *ai_canonname; /* canonical name for host */
  91. struct sockaddr *ai_addr; /* binary address */
  92. struct addrinfo *ai_next; /* next structure in linked list */
  93. };
  94. #endif /* for HP-UX 11.11 without IPv6 */
  95. #define _PR_HAVE_MD_SOCKADDR_IN6
  96. /* isomorphic to struct in6_addr on HP-UX B.11.23 */
  97. struct _md_in6_addr {
  98. union {
  99. PRUint8 _S6_u8[16];
  100. PRUint16 _S6_u16[8];
  101. PRUint32 _S6_u32[4];
  102. PRUint32 __S6_align;
  103. } _s6_un;
  104. };
  105. /* isomorphic to struct sockaddr_in6 on HP-UX B.11.23 */
  106. struct _md_sockaddr_in6 {
  107. PRUint16 sin6_family;
  108. PRUint16 sin6_port;
  109. PRUint32 sin6_flowinfo;
  110. struct _md_in6_addr sin6_addr;
  111. PRUint32 sin6_scope_id;
  112. };
  113. #endif
  114. #if !defined(_PR_PTHREADS)
  115. #include <syscall.h>
  116. #include <setjmp.h>
  117. #define USE_SETJMP
  118. #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
  119. #define PR_NUM_GCREGS _JBLEN
  120. /* Caveat: This makes jmp_buf full of doubles. */
  121. #define CONTEXT(_th) ((_th)->md.jb)
  122. /* Stack needs two frames (64 bytes) at the bottom */ \
  123. #define _MD_SET_THR_SP(_t, _sp) ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
  124. #define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th))
  125. #define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1)
  126. #if !defined(PTHREADS_USER)
  127. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  128. { \
  129. *(status) = PR_TRUE; \
  130. if (_setjmp(CONTEXT(_thread))) (*_main)(); \
  131. /* Stack needs two frames (64 bytes) at the bottom */ \
  132. (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
  133. }
  134. #define _MD_SWITCH_CONTEXT(_thread) \
  135. if (!_setjmp(CONTEXT(_thread))) { \
  136. (_thread)->md.errcode = errno; \
  137. _PR_Schedule(); \
  138. }
  139. /*
  140. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  141. */
  142. #define _MD_RESTORE_CONTEXT(_thread) \
  143. { \
  144. errno = (_thread)->md.errcode; \
  145. _MD_SET_CURRENT_THREAD(_thread); \
  146. _longjmp(CONTEXT(_thread), 1); \
  147. }
  148. /* Machine-dependent (MD) data structures. HP-UX has no native threads. */
  149. struct _MDThread {
  150. jmp_buf jb;
  151. int id;
  152. int errcode;
  153. };
  154. struct _MDThreadStack {
  155. PRInt8 notused;
  156. };
  157. struct _MDLock {
  158. PRInt8 notused;
  159. };
  160. struct _MDSemaphore {
  161. PRInt8 notused;
  162. };
  163. struct _MDCVar {
  164. PRInt8 notused;
  165. };
  166. struct _MDSegment {
  167. PRInt8 notused;
  168. };
  169. /*
  170. * md-specific cpu structure field
  171. */
  172. #define _PR_MD_MAX_OSFD FD_SETSIZE
  173. struct _MDCPU_Unix {
  174. PRCList ioQ;
  175. PRUint32 ioq_timeout;
  176. PRInt32 ioq_max_osfd;
  177. PRInt32 ioq_osfd_cnt;
  178. #ifndef _PR_USE_POLL
  179. fd_set fd_read_set, fd_write_set, fd_exception_set;
  180. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  181. fd_exception_cnt[_PR_MD_MAX_OSFD];
  182. #else
  183. struct pollfd *ioq_pollfds;
  184. int ioq_pollfds_size;
  185. #endif /* _PR_USE_POLL */
  186. };
  187. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  188. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  189. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  190. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  191. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  192. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  193. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  194. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  195. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  196. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  197. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  198. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  199. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  200. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  201. struct _MDCPU {
  202. struct _MDCPU_Unix md_unix;
  203. };
  204. #define _MD_INIT_LOCKS()
  205. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  206. #define _MD_FREE_LOCK(lock)
  207. #define _MD_LOCK(lock)
  208. #define _MD_UNLOCK(lock)
  209. #define _MD_INIT_IO()
  210. #define _MD_IOQ_LOCK()
  211. #define _MD_IOQ_UNLOCK()
  212. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  213. #define _MD_INIT_THREAD _MD_InitializeThread
  214. #define _MD_EXIT_THREAD(thread)
  215. #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
  216. #define _MD_RESUME_THREAD(thread) _MD_resume_thread
  217. #define _MD_CLEAN_THREAD(_thread)
  218. #else /* PTHREADS_USER */
  219. #include "_nspr_pthread.h"
  220. #endif /* PTHREADS_USER */
  221. #endif /* !defined(_PR_PTHREADS) */
  222. #if !defined(PTHREADS_USER)
  223. #define _MD_EARLY_INIT _MD_EarlyInit
  224. #define _MD_FINAL_INIT _PR_UnixInit
  225. #endif
  226. #if defined(HPUX_LW_TIMER)
  227. extern void _PR_HPUX_LW_IntervalInit(void);
  228. extern PRIntervalTime _PR_HPUX_LW_GetInterval(void);
  229. #define _MD_INTERVAL_INIT _PR_HPUX_LW_IntervalInit
  230. #define _MD_GET_INTERVAL _PR_HPUX_LW_GetInterval
  231. #define _MD_INTERVAL_PER_SEC() 1000
  232. #else
  233. #define _MD_INTERVAL_USE_GTOD
  234. #endif
  235. /*
  236. * We wrapped the select() call. _MD_SELECT refers to the built-in,
  237. * unwrapped version.
  238. */
  239. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  240. #include <poll.h>
  241. #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
  242. #ifdef HPUX11
  243. extern void _MD_hpux_map_sendfile_error(int err);
  244. #endif /* HPUX11 */
  245. #endif /* nspr_xhppa_defs_h___ */