_qnx.h 4.7 KB

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