_nto.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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_nto_defs_h___
  6. #define nspr_nto_defs_h___
  7. /*
  8. ** Internal configuration macros
  9. */
  10. #define PR_LINKER_ARCH "nto"
  11. #define _PR_SI_SYSNAME "NTO"
  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_MINIMUM_STACK_SIZE 131072L
  18. #define _MD_MMAP_FLAGS MAP_PRIVATE
  19. #ifndef HAVE_WEAK_IO_SYMBOLS
  20. #define HAVE_WEAK_IO_SYMBOLS
  21. #endif
  22. #undef _PR_POLL_AVAILABLE
  23. #undef _PR_USE_POLL
  24. #define _PR_HAVE_SOCKADDR_LEN
  25. #undef HAVE_BSD_FLOCK
  26. #define HAVE_FCNTL_FILE_LOCKING
  27. #define _PR_NO_LARGE_FILES
  28. #define _PR_STAT_HAS_ONLY_ST_ATIME
  29. #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
  30. #define _PR_HAVE_POSIX_SEMAPHORES
  31. #undef FD_SETSIZE
  32. #define FD_SETSIZE 4096
  33. #include <sys/time.h>
  34. #include <sys/types.h>
  35. #include <sys/select.h>
  36. #undef HAVE_STACK_GROWING_UP
  37. #define HAVE_DLL
  38. #define USE_DLFCN
  39. #define NEED_STRFTIME_LOCK
  40. #define NEED_TIME_R
  41. #define _PR_NEED_STRCASECMP
  42. #ifndef HAVE_STRERROR
  43. #define HAVE_STRERROR
  44. #endif
  45. #define USE_SETJMP
  46. #include <setjmp.h>
  47. #define _SETJMP setjmp
  48. #define _LONGJMP longjmp
  49. #define _PR_CONTEXT_TYPE jmp_buf
  50. #define _PR_NUM_GCREGS _JBLEN
  51. #define _MD_GET_SP(_t) (_t)->md.context[7]
  52. #define CONTEXT(_th) ((_th)->md.context)
  53. /*
  54. ** Initialize the thread context preparing it to execute _main.
  55. */
  56. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  57. { \
  58. *status = PR_TRUE; \
  59. if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
  60. _MD_GET_SP(_thread) = (int) ((_sp) - 128); \
  61. }
  62. #define _MD_SWITCH_CONTEXT(_thread) \
  63. if (!_SETJMP(CONTEXT(_thread))) { \
  64. (_thread)->md.errcode = errno; \
  65. _PR_Schedule(); \
  66. }
  67. /*
  68. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  69. */
  70. #define _MD_RESTORE_CONTEXT(_thread) \
  71. { \
  72. errno = (_thread)->md.errcode; \
  73. _MD_SET_CURRENT_THREAD(_thread); \
  74. _LONGJMP(CONTEXT(_thread), 1); \
  75. }
  76. /*
  77. ** Machine-dependent (MD) data structures.
  78. */
  79. struct _MDThread {
  80. _PR_CONTEXT_TYPE context;
  81. int id;
  82. int errcode;
  83. };
  84. struct _MDThreadStack {
  85. PRInt8 notused;
  86. };
  87. struct _MDLock {
  88. PRInt8 notused;
  89. };
  90. struct _MDSemaphore {
  91. PRInt8 notused;
  92. };
  93. struct _MDCVar {
  94. PRInt8 notused;
  95. };
  96. struct _MDSegment {
  97. PRInt8 notused;
  98. };
  99. /*
  100. ** md-specific cpu structure field
  101. */
  102. #define _PR_MD_MAX_OSFD FD_SETSIZE
  103. struct _MDCPU_Unix {
  104. PRCList ioQ;
  105. PRUint32 ioq_timeout;
  106. PRInt32 ioq_max_osfd;
  107. PRInt32 ioq_osfd_cnt;
  108. #ifndef _PR_USE_POLL
  109. fd_set fd_read_set, fd_write_set, fd_exception_set;
  110. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];
  111. #else
  112. struct pollfd *ioq_pollfds;
  113. int ioq_pollfds_size;
  114. #endif
  115. };
  116. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  117. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  118. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  119. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  120. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  121. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  122. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  123. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  124. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  125. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  126. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  127. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  128. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  129. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  130. struct _MDCPU {
  131. struct _MDCPU_Unix md_unix;
  132. };
  133. #define _MD_INIT_LOCKS()
  134. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  135. #define _MD_FREE_LOCK(lock)
  136. #define _MD_LOCK(lock)
  137. #define _MD_UNLOCK(lock)
  138. #define _MD_INIT_IO()
  139. #define _MD_IOQ_LOCK()
  140. #define _MD_IOQ_UNLOCK()
  141. #define _MD_INTERVAL_USE_GTOD
  142. #define _MD_EARLY_INIT _MD_EarlyInit
  143. #define _MD_FINAL_INIT _PR_UnixInit
  144. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  145. #define _MD_INIT_THREAD _MD_InitializeThread
  146. #define _MD_EXIT_THREAD(thread)
  147. #define _MD_SUSPEND_THREAD(thread)
  148. #define _MD_RESUME_THREAD(thread)
  149. #define _MD_CLEAN_THREAD(_thread)
  150. /*
  151. ** We wrapped the select() call. _MD_SELECT refers to the built-in,
  152. ** unwrapped version.
  153. */
  154. #define _MD_SELECT select
  155. #define SA_RESTART 0
  156. #endif /* nspr_nto_defs_h___ */