_aix.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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_aix_defs_h___
  6. #define nspr_aix_defs_h___
  7. #include <sys/types.h>
  8. #if defined(_PR_PTHREADS) || defined(PTHREADS_USER)
  9. #include <pthread.h>
  10. #endif
  11. /*
  12. * To pick up fd_set and the poll events.
  13. */
  14. #include <sys/select.h>
  15. #include <sys/poll.h>
  16. /*
  17. * Internal configuration macros
  18. */
  19. #define PR_LINKER_ARCH "aix"
  20. #define _PR_SI_SYSNAME "AIX"
  21. #define _PR_SI_ARCHITECTURE "rs6000"
  22. #define PR_DLL_SUFFIX ".so"
  23. #define _PR_VMBASE 0x30000000
  24. #define _PR_STACK_VMBASE 0x50000000
  25. #define _MD_DEFAULT_STACK_SIZE (2*65536L)
  26. #define _MD_MINIMUM_STACK_SIZE (2*65536L)
  27. #define _MD_MMAP_FLAGS MAP_PRIVATE
  28. #define NEED_TIME_R
  29. #undef HAVE_STACK_GROWING_UP
  30. #undef HAVE_WEAK_IO_SYMBOLS
  31. #undef HAVE_WEAK_MALLOC_SYMBOLS
  32. #define HAVE_DLL
  33. #define USE_DLFCN
  34. #define _PR_HAVE_SOCKADDR_LEN
  35. #define _PR_POLL_AVAILABLE
  36. #define _PR_USE_POLL
  37. #define _PR_STAT_HAS_ONLY_ST_ATIME
  38. #ifdef _PR_INET6
  39. #define _PR_HAVE_INET_NTOP
  40. #define _PR_HAVE_GETHOSTBYNAME2
  41. #ifdef _AIX51 /* AIX 4.3.3 does not have AI_NUMERICHOST. */
  42. #define _PR_HAVE_GETADDRINFO
  43. #endif
  44. #endif
  45. #define _PR_HAVE_SYSV_SEMAPHORES
  46. #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
  47. #define _PR_ACCEPT_INHERIT_NONBLOCK
  48. /* Timer operations */
  49. #if defined(AIX_TIMERS)
  50. #define _MD_INTERVAL_INIT()
  51. extern PRIntervalTime _MD_AixGetInterval(void);
  52. #define _MD_GET_INTERVAL _MD_AixGetInterval
  53. extern PRIntervalTime _MD_AixIntervalPerSec(void);
  54. #define _MD_INTERVAL_PER_SEC _MD_AixIntervalPerSec
  55. #else /* defined(AIX_TIMERS) */
  56. #define _MD_INTERVAL_USE_GTOD
  57. #endif /* defined(AIX_TIMERS) */
  58. #ifdef AIX_HAVE_ATOMIC_OP_H
  59. /* The atomic operations */
  60. #include <sys/atomic_op.h>
  61. #define _PR_HAVE_ATOMIC_OPS
  62. #ifndef IS_64
  63. #define _PR_HAVE_ATOMIC_CAS
  64. #endif
  65. #define _MD_INIT_ATOMIC()
  66. #define _MD_ATOMIC_INCREMENT(val) ((PRInt32)fetch_and_add((atomic_p)val, 1) + 1)
  67. #define _MD_ATOMIC_ADD(ptr, val) ((PRInt32)fetch_and_add((atomic_p)ptr, val) + val)
  68. #define _MD_ATOMIC_DECREMENT(val) ((PRInt32)fetch_and_add((atomic_p)val, -1) - 1)
  69. #define _MD_ATOMIC_SET(val, newval) _AIX_AtomicSet(val, newval)
  70. #endif /* AIX_HAVE_ATOMIC_OP_H */
  71. #define USE_SETJMP
  72. #include <setjmp.h>
  73. #define _MD_GET_SP(_t) (_t)->md.jb[3]
  74. #define _MD_SET_THR_SP(_t, _sp) ((_t)->md.jb[3] = (int) (_sp - 2 * 64))
  75. #define PR_NUM_GCREGS _JBLEN
  76. #define CONTEXT(_th) ((_th)->md.jb)
  77. #define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th))
  78. #define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1)
  79. #ifdef PTHREADS_USER
  80. #include "_nspr_pthread.h"
  81. #else
  82. /*
  83. ** Initialize the thread context preparing it to execute _main.
  84. */
  85. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  86. PR_BEGIN_MACRO \
  87. *status = PR_TRUE; \
  88. if (setjmp(CONTEXT(_thread))) { \
  89. (*_main)(); \
  90. } \
  91. _MD_GET_SP(_thread) = (int) (_sp - 2 * 64); \
  92. PR_END_MACRO
  93. #define _MD_SWITCH_CONTEXT(_thread) \
  94. if (!setjmp(CONTEXT(_thread))) { \
  95. (_thread)->md.errcode = errno; \
  96. _PR_Schedule(); \
  97. }
  98. /*
  99. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  100. */
  101. #define _MD_RESTORE_CONTEXT(_thread) \
  102. { \
  103. errno = (_thread)->md.errcode; \
  104. _MD_SET_CURRENT_THREAD(_thread); \
  105. longjmp(CONTEXT(_thread), 1); \
  106. }
  107. /* Machine-dependent (MD) data structures */
  108. struct _MDThread {
  109. jmp_buf jb;
  110. int id;
  111. int errcode;
  112. };
  113. struct _MDThreadStack {
  114. PRInt8 notused;
  115. };
  116. struct _MDLock {
  117. PRInt8 notused;
  118. };
  119. struct _MDSemaphore {
  120. PRInt8 notused;
  121. };
  122. struct _MDCVar {
  123. PRInt8 notused;
  124. };
  125. struct _MDSegment {
  126. PRInt8 notused;
  127. };
  128. /*
  129. * md-specific cpu structure field
  130. */
  131. #define _PR_MD_MAX_OSFD FD_SETSIZE
  132. struct _MDCPU_Unix {
  133. PRCList ioQ;
  134. PRUint32 ioq_timeout;
  135. PRInt32 ioq_max_osfd;
  136. PRInt32 ioq_osfd_cnt;
  137. #ifndef _PR_USE_POLL
  138. fd_set fd_read_set, fd_write_set, fd_exception_set;
  139. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  140. fd_exception_cnt[_PR_MD_MAX_OSFD];
  141. #else
  142. struct pollfd *ioq_pollfds;
  143. int ioq_pollfds_size;
  144. #endif /* _PR_USE_POLL */
  145. };
  146. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  147. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  148. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  149. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  150. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  151. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  152. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  153. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  154. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  155. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  156. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  157. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  158. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  159. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  160. struct _MDCPU {
  161. struct _MDCPU_Unix md_unix;
  162. };
  163. #if !defined(_PR_PTHREADS)
  164. #define _MD_INIT_LOCKS()
  165. #endif
  166. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  167. #define _MD_FREE_LOCK(lock)
  168. #define _MD_LOCK(lock)
  169. #define _MD_UNLOCK(lock)
  170. #define _MD_INIT_IO()
  171. #define _MD_IOQ_LOCK()
  172. #define _MD_IOQ_UNLOCK()
  173. #define _MD_EARLY_INIT _MD_EarlyInit
  174. #define _MD_FINAL_INIT _PR_UnixInit
  175. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  176. #define _MD_INIT_THREAD _MD_InitializeThread
  177. #define _MD_EXIT_THREAD(thread)
  178. #define _MD_SUSPEND_THREAD(thread)
  179. #define _MD_RESUME_THREAD(thread)
  180. #define _MD_CLEAN_THREAD(_thread)
  181. #endif /* PTHREADS_USER */
  182. #ifdef AIX_RENAME_SELECT
  183. #define _MD_SELECT select
  184. #define _MD_POLL poll
  185. #endif
  186. extern void _MD_aix_map_sendfile_error(int err);
  187. #endif /* nspr_aix_defs_h___ */