_riscos.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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_riscos_defs_h___
  6. #define nspr_riscos_defs_h___
  7. /*
  8. ** Internal configuration macros
  9. */
  10. #define PR_LINKER_ARCH "riscos"
  11. #define _PR_SI_SYSNAME "RISCOS"
  12. #define _PR_SI_ARCHITECTURE "arm"
  13. #define PR_DLL_SUFFIX ".so"
  14. #define _PR_POLL_AVAILABLE
  15. #define _PR_USE_POLL
  16. #define _PR_HAVE_SOCKADDR_LEN
  17. #undef HAVE_BSD_FLOCK
  18. #define _PR_NO_LARGE_FILES
  19. #define _PR_STAT_HAS_ONLY_ST_ATIME
  20. #define _PR_HAVE_POSIX_SEMAPHORES
  21. #include <sys/select.h>
  22. #include <sys/poll.h>
  23. #include <kernel.h>
  24. #undef HAVE_STACK_GROWING_UP
  25. #define HAVE_DLL
  26. #define USE_DLFCN
  27. #define NEED_STRFTIME_LOCK
  28. #define NEED_TIME_R
  29. #define PT_NO_SIGTIMEDWAIT
  30. #ifndef HAVE_STRERROR
  31. #define HAVE_STRERROR
  32. #endif
  33. #define USE_SETJMP
  34. #include <setjmp.h>
  35. #define _SETJMP setjmp
  36. #define _LONGJMP longjmp
  37. #define _PR_CONTEXT_TYPE jmp_buf
  38. #define _PR_NUM_GCREGS _JBLEN
  39. #define _MD_GET_SP(_t) (_t)->md.context[7]
  40. #define CONTEXT(_th) ((_th)->md.context)
  41. /*
  42. ** Initialize the thread context preparing it to execute _main.
  43. */
  44. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  45. { \
  46. *status = PR_TRUE; \
  47. if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
  48. _MD_GET_SP(_thread) = (int) ((_sp) - 128); \
  49. }
  50. #define _MD_SWITCH_CONTEXT(_thread) \
  51. if (!_SETJMP(CONTEXT(_thread))) { \
  52. (_thread)->md.errcode = errno; \
  53. _PR_Schedule(); \
  54. }
  55. /*
  56. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  57. */
  58. #define _MD_RESTORE_CONTEXT(_thread) \
  59. { \
  60. errno = (_thread)->md.errcode; \
  61. _MD_SET_CURRENT_THREAD(_thread); \
  62. _LONGJMP(CONTEXT(_thread), 1); \
  63. }
  64. /*
  65. ** Machine-dependent (MD) data structures.
  66. */
  67. struct _MDThread {
  68. _PR_CONTEXT_TYPE context;
  69. int id;
  70. int errcode;
  71. };
  72. struct _MDThreadStack {
  73. PRInt8 notused;
  74. };
  75. struct _MDLock {
  76. PRInt8 notused;
  77. };
  78. struct _MDSemaphore {
  79. PRInt8 notused;
  80. };
  81. struct _MDCVar {
  82. PRInt8 notused;
  83. };
  84. struct _MDSegment {
  85. PRInt8 notused;
  86. };
  87. /*
  88. ** md-specific cpu structure field
  89. */
  90. #define _PR_MD_MAX_OSFD FD_SETSIZE
  91. struct _MDCPU_Unix {
  92. PRCList ioQ;
  93. PRUint32 ioq_timeout;
  94. PRInt32 ioq_max_osfd;
  95. PRInt32 ioq_osfd_cnt;
  96. #ifndef _PR_USE_POLL
  97. fd_set fd_read_set, fd_write_set, fd_exception_set;
  98. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD], fd_write_cnt[_PR_MD_MAX_OSFD], fd_exception_cnt[_PR_MD_MAX_OSFD];
  99. #else
  100. struct pollfd *ioq_pollfds;
  101. int ioq_pollfds_size;
  102. #endif
  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. #define _MD_INTERVAL_USE_GTOD
  130. #define _MD_EARLY_INIT _MD_EarlyInit
  131. #define _MD_FINAL_INIT _PR_UnixInit
  132. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  133. #define _MD_INIT_THREAD _MD_InitializeThread
  134. #define _MD_EXIT_THREAD(thread)
  135. #define _MD_SUSPEND_THREAD(thread)
  136. #define _MD_RESUME_THREAD(thread)
  137. #define _MD_CLEAN_THREAD(_thread)
  138. /*
  139. ** We wrapped the select() call. _MD_SELECT refers to the built-in,
  140. ** unwrapped version.
  141. */
  142. #include <sys/time.h>
  143. #include <sys/types.h>
  144. #include <sys/select.h>
  145. #define _MD_SELECT select
  146. #endif /* nspr_riscos_defs_h___ */