_unixware.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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_unixware_defs_h___
  6. #define nspr_unixware_defs_h___
  7. /*
  8. * Internal configuration macros
  9. */
  10. #define PR_LINKER_ARCH "unixware"
  11. #define _PR_SI_SYSNAME "UnixWare"
  12. #define _PR_SI_ARCHITECTURE "x86"
  13. #define PR_DLL_SUFFIX ".so"
  14. #define _PR_VMBASE 0x30000000
  15. #define _PR_STACK_VMBASE 0x50000000
  16. #define _MD_DEFAULT_STACK_SIZE 65536L
  17. #define _MD_MMAP_FLAGS MAP_PRIVATE
  18. #ifndef HAVE_WEAK_IO_SYMBOLS
  19. #define HAVE_WEAK_IO_SYMBOLS
  20. #endif
  21. #define _PR_POLL_AVAILABLE
  22. #define _PR_USE_POLL
  23. #define _PR_STAT_HAS_ST_ATIM_UNION
  24. #undef HAVE_STACK_GROWING_UP
  25. #define HAVE_NETCONFIG
  26. #define HAVE_DLL
  27. #define USE_DLFCN
  28. #define HAVE_STRERROR
  29. #define NEED_STRFTIME_LOCK
  30. #define NEED_TIME_R
  31. #define _PR_NEED_STRCASECMP
  32. #define USE_SETJMP
  33. #include <setjmp.h>
  34. #define _SETJMP setjmp
  35. #define _LONGJMP longjmp
  36. #define _PR_CONTEXT_TYPE jmp_buf
  37. #define _MD_GET_SP(_t) (_t)->md.context[4]
  38. #define _PR_NUM_GCREGS _JBLEN
  39. #define CONTEXT(_th) ((_th)->md.context)
  40. /*
  41. ** Initialize the thread context preparing it to execute _main.
  42. */
  43. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  44. { \
  45. *status = PR_TRUE; \
  46. if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
  47. _MD_GET_SP(_thread) = (int) ((_sp) - 128); \
  48. }
  49. #define _MD_SWITCH_CONTEXT(_thread) \
  50. if (!_SETJMP(CONTEXT(_thread))) { \
  51. (_thread)->md.errcode = errno; \
  52. _PR_Schedule(); \
  53. }
  54. /*
  55. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  56. */
  57. #define _MD_RESTORE_CONTEXT(_thread) \
  58. { \
  59. errno = (_thread)->md.errcode; \
  60. _MD_SET_CURRENT_THREAD(_thread); \
  61. _LONGJMP(CONTEXT(_thread), 1); \
  62. }
  63. /* Machine-dependent (MD) data structures.
  64. * Don't use SVR4 native threads (yet).
  65. */
  66. struct _MDThread {
  67. _PR_CONTEXT_TYPE context;
  68. int id;
  69. int errcode;
  70. };
  71. struct _MDThreadStack {
  72. PRInt8 notused;
  73. };
  74. struct _MDLock {
  75. PRInt8 notused;
  76. };
  77. struct _MDSemaphore {
  78. PRInt8 notused;
  79. };
  80. struct _MDCVar {
  81. PRInt8 notused;
  82. };
  83. struct _MDSegment {
  84. PRInt8 notused;
  85. };
  86. /*
  87. * md-specific cpu structure field
  88. */
  89. #define _PR_MD_MAX_OSFD FD_SETSIZE
  90. struct _MDCPU_Unix {
  91. PRCList ioQ;
  92. PRUint32 ioq_timeout;
  93. PRInt32 ioq_max_osfd;
  94. PRInt32 ioq_osfd_cnt;
  95. #ifndef _PR_USE_POLL
  96. fd_set fd_read_set, fd_write_set, fd_exception_set;
  97. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  98. fd_exception_cnt[_PR_MD_MAX_OSFD];
  99. #else
  100. struct pollfd *ioq_pollfds;
  101. int ioq_pollfds_size;
  102. #endif /* _PR_USE_POLL */
  103. };
  104. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  105. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  106. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  107. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  108. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  109. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  110. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  111. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  112. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  113. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  114. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  115. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  116. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  117. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  118. struct _MDCPU {
  119. struct _MDCPU_Unix md_unix;
  120. };
  121. #define _MD_INIT_LOCKS()
  122. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  123. #define _MD_FREE_LOCK(lock)
  124. #define _MD_LOCK(lock)
  125. #define _MD_UNLOCK(lock)
  126. #define _MD_INIT_IO()
  127. #define _MD_IOQ_LOCK()
  128. #define _MD_IOQ_UNLOCK()
  129. /*
  130. * The following are copied from _sunos.h, _aix.h. This means
  131. * some of them should probably be moved into _unixos.h. But
  132. * _irix.h seems to be quite different in regard to these macros.
  133. */
  134. #define _MD_INTERVAL_USE_GTOD
  135. #define _MD_EARLY_INIT _MD_EarlyInit
  136. #define _MD_FINAL_INIT _PR_UnixInit
  137. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  138. #define _MD_INIT_THREAD _MD_InitializeThread
  139. #define _MD_EXIT_THREAD(thread)
  140. #define _MD_SUSPEND_THREAD(thread)
  141. #define _MD_RESUME_THREAD(thread)
  142. #define _MD_CLEAN_THREAD(_thread)
  143. /*
  144. * We wrapped the select() call. _MD_SELECT refers to the built-in,
  145. * unwrapped version.
  146. */
  147. #include <sys/time.h>
  148. #include <sys/types.h>
  149. #include <sys/select.h>
  150. extern int _select(int nfds, fd_set *readfds, fd_set *writefds,
  151. fd_set *execptfds, struct timeval *timeout);
  152. #define _MD_SELECT _select
  153. #define _MD_POLL _poll
  154. extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
  155. #endif /* nspr_unixware_defs_h___ */