_bsdi.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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_bsdi_defs_h___
  6. #define nspr_bsdi_defs_h___
  7. /*
  8. * Internal configuration macros
  9. */
  10. #include <sys/param.h> /* for _BSDI_VERSION */
  11. #define PR_LINKER_ARCH "bsdi"
  12. #define _PR_SI_SYSNAME "BSDI"
  13. #if defined(__i386__)
  14. #define _PR_SI_ARCHITECTURE "x86"
  15. #elif defined(__sparc__)
  16. #define _PR_SI_ARCHITECTURE "sparc"
  17. #else
  18. #error "Unknown CPU architecture"
  19. #endif
  20. #define PR_DLL_SUFFIX ".so"
  21. #define _PR_STACK_VMBASE 0x50000000
  22. #define _MD_DEFAULT_STACK_SIZE 65536L
  23. #define _MD_MMAP_FLAGS MAP_PRIVATE
  24. #define HAVE_BSD_FLOCK
  25. #define NEED_TIME_R
  26. #define _PR_HAVE_SOCKADDR_LEN
  27. #define _PR_NO_LARGE_FILES
  28. #define USE_SETJMP
  29. /* BSD/OS 4.3 and newer all have IPv6 support */
  30. #if _BSDI_VERSION >= 200105
  31. #define _PR_INET6
  32. #define _PR_HAVE_INET_NTOP
  33. #define _PR_HAVE_GETIPNODEBYNAME
  34. #define _PR_HAVE_GETIPNODEBYADDR
  35. #define _PR_HAVE_GETADDRINFO
  36. #define _PR_INET6_PROBE
  37. #endif
  38. #ifndef _PR_PTHREADS
  39. #include <setjmp.h>
  40. #if defined(_PR_BSDI_JMPBUF_IS_ARRAY)
  41. #define _MD_GET_SP(_t) (_t)->md.context[2]
  42. #elif defined(_PR_BSDI_JMPBUF_IS_STRUCT)
  43. #define _MD_GET_SP(_t) (_t)->md.context[0].jb_esp
  44. #else
  45. #error "Unknown BSDI jmp_buf type"
  46. #endif
  47. #define PR_NUM_GCREGS _JBLEN
  48. #define PR_CONTEXT_TYPE jmp_buf
  49. #define CONTEXT(_th) ((_th)->md.context)
  50. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  51. { \
  52. *status = PR_TRUE; \
  53. if (setjmp(CONTEXT(_thread))) { \
  54. _main(); \
  55. } \
  56. _MD_GET_SP(_thread) = (int) (_sp - 64); \
  57. }
  58. #define _MD_SWITCH_CONTEXT(_thread) \
  59. if (!setjmp(CONTEXT(_thread))) { \
  60. (_thread)->md.errcode = errno; \
  61. _PR_Schedule(); \
  62. }
  63. /*
  64. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  65. */
  66. #define _MD_RESTORE_CONTEXT(_thread) \
  67. { \
  68. errno = (_thread)->md.errcode; \
  69. _MD_SET_CURRENT_THREAD(_thread); \
  70. longjmp(CONTEXT(_thread), 1); \
  71. }
  72. /* Machine-dependent (MD) data structures */
  73. struct _MDThread {
  74. PR_CONTEXT_TYPE context;
  75. int id;
  76. int errcode;
  77. };
  78. struct _MDThreadStack {
  79. PRInt8 notused;
  80. };
  81. struct _MDLock {
  82. PRInt8 notused;
  83. };
  84. struct _MDSemaphore {
  85. PRInt8 notused;
  86. };
  87. struct _MDCVar {
  88. PRInt8 notused;
  89. };
  90. struct _MDSegment {
  91. PRInt8 notused;
  92. };
  93. /*
  94. * md-specific cpu structure field
  95. */
  96. #define _PR_MD_MAX_OSFD FD_SETSIZE
  97. struct _MDCPU_Unix {
  98. PRCList ioQ;
  99. PRUint32 ioq_timeout;
  100. PRInt32 ioq_max_osfd;
  101. PRInt32 ioq_osfd_cnt;
  102. #ifndef _PR_USE_POLL
  103. fd_set fd_read_set, fd_write_set, fd_exception_set;
  104. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  105. fd_exception_cnt[_PR_MD_MAX_OSFD];
  106. #else
  107. struct pollfd *ioq_pollfds;
  108. int ioq_pollfds_size;
  109. #endif /* _PR_USE_POLL */
  110. };
  111. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  112. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  113. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  114. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  115. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  116. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  117. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  118. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  119. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  120. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  121. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  122. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  123. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  124. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  125. struct _MDCPU {
  126. struct _MDCPU_Unix md_unix;
  127. };
  128. #define _MD_INIT_LOCKS()
  129. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  130. #define _MD_FREE_LOCK(lock)
  131. #define _MD_LOCK(lock)
  132. #define _MD_UNLOCK(lock)
  133. #define _MD_INIT_IO()
  134. #define _MD_IOQ_LOCK()
  135. #define _MD_IOQ_UNLOCK()
  136. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  137. #define _MD_INIT_THREAD _MD_InitializeThread
  138. #define _MD_EXIT_THREAD(thread)
  139. #define _MD_CLEAN_THREAD(_thread)
  140. #endif /* ! _PR_PTHREADS */
  141. #define _MD_EARLY_INIT _MD_EarlyInit
  142. #define _MD_FINAL_INIT _PR_UnixInit
  143. #include <sys/syscall.h>
  144. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  145. #define _MD_INTERVAL_USE_GTOD
  146. #endif /* nspr_bsdi_defs_h___ */