_sony.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is the Netscape Portable Runtime (NSPR).
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998-2000
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #ifndef nspr_sony_defs_h___
  38. #define nspr_sony_defs_h___
  39. #define PR_LINKER_ARCH "sony"
  40. #define _PR_SI_SYSNAME "SONY"
  41. #define _PR_SI_ARCHITECTURE "mips"
  42. #define PR_DLL_SUFFIX ".so"
  43. #define _PR_VMBASE 0x30000000
  44. #define _PR_STACK_VMBASE 0x50000000
  45. #define _MD_DEFAULT_STACK_SIZE 65536L
  46. #define _MD_MMAP_FLAGS MAP_PRIVATE
  47. #define _MD_GET_INTERVAL _PR_UNIX_GetInterval
  48. #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
  49. #if defined(_PR_LOCAL_THREADS_ONLY)
  50. #include <ucontext.h>
  51. #include <sys/regset.h>
  52. #define PR_NUM_GCREGS NGREG
  53. #define PR_CONTEXT_TYPE ucontext_t
  54. #define CONTEXT(_thread) (&(_thread)->md.context)
  55. #define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gregs[CXT_SP]
  56. /*
  57. ** Initialize the thread context preparing it to execute _main()
  58. */
  59. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  60. { \
  61. *status = PR_TRUE; \
  62. getcontext(CONTEXT(_thread)); \
  63. CONTEXT(_thread)->uc_stack.ss_sp = (char*) (_thread)->stack->stackBottom; \
  64. CONTEXT(_thread)->uc_stack.ss_size = (_thread)->stack->stackSize; \
  65. _MD_GET_SP(_thread) = (greg_t) (_sp) - 64; \
  66. makecontext(CONTEXT(_thread), _main, 0); \
  67. }
  68. #define _MD_SWITCH_CONTEXT(_thread) \
  69. if (!getcontext(CONTEXT(_thread))) { \
  70. (_thread)->md.errcode = errno; \
  71. _PR_Schedule(); \
  72. }
  73. /*
  74. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  75. */
  76. #define _MD_RESTORE_CONTEXT(_thread) \
  77. { \
  78. ucontext_t *uc = CONTEXT(_thread); \
  79. uc->uc_mcontext.gregs[CXT_V0] = 1; \
  80. uc->uc_mcontext.gregs[CXT_A3] = 0; \
  81. _MD_SET_CURRENT_THREAD(_thread); \
  82. errno = (_thread)->md.errcode; \
  83. setcontext(uc); \
  84. }
  85. /* Machine-dependent (MD) data structures */
  86. struct _MDThread {
  87. PR_CONTEXT_TYPE context;
  88. int id;
  89. int errcode;
  90. };
  91. struct _MDThreadStack {
  92. PRInt8 notused;
  93. };
  94. struct _MDLock {
  95. PRInt8 notused;
  96. };
  97. struct _MDSemaphore {
  98. PRInt8 notused;
  99. };
  100. struct _MDCVar {
  101. PRInt8 notused;
  102. };
  103. struct _MDSegment {
  104. PRInt8 notused;
  105. };
  106. /*
  107. * md-specific cpu structure field
  108. */
  109. #define _PR_MD_MAX_OSFD FD_SETSIZE
  110. struct _MDCPU_Unix {
  111. PRCList ioQ;
  112. PRUint32 ioq_timeout;
  113. PRInt32 ioq_max_osfd;
  114. PRInt32 ioq_osfd_cnt;
  115. #ifndef _PR_USE_POLL
  116. fd_set fd_read_set, fd_write_set, fd_exception_set;
  117. PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  118. fd_exception_cnt[_PR_MD_MAX_OSFD];
  119. #else
  120. struct pollfd *ioq_pollfds;
  121. int ioq_pollfds_size;
  122. #endif /* _PR_USE_POLL */
  123. };
  124. #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
  125. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  126. #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
  127. #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
  128. #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
  129. #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
  130. #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
  131. #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
  132. #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
  133. #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
  134. #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
  135. #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
  136. #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
  137. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
  138. struct _MDCPU {
  139. struct _MDCPU_Unix md_unix;
  140. };
  141. #define _MD_INIT_LOCKS()
  142. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  143. #define _MD_FREE_LOCK(lock)
  144. #define _MD_LOCK(lock)
  145. #define _MD_UNLOCK(lock)
  146. #define _MD_INIT_IO()
  147. #define _MD_IOQ_LOCK()
  148. #define _MD_IOQ_UNLOCK()
  149. #define _MD_EARLY_INIT _MD_EarlyInit
  150. #define _MD_FINAL_INIT _PR_UnixInit
  151. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  152. #define _MD_INIT_THREAD _MD_InitializeThread
  153. #define _MD_EXIT_THREAD(thread)
  154. #define _MD_SUSPEND_THREAD(thread)
  155. #define _MD_RESUME_THREAD(thread)
  156. #define _MD_CLEAN_THREAD(_thread)
  157. /* The following defines unwrapped versions of select() and poll(). */
  158. extern int _select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  159. #define _MD_SELECT _select
  160. #include <sys/poll.h>
  161. extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
  162. #define _MD_POLL _poll
  163. #endif /* _PR_LOCAL_THREADS_ONLY */
  164. #undef HAVE_STACK_GROWING_UP
  165. #define HAVE_DLL
  166. #define USE_DLFCN
  167. #define NEED_TIME_R
  168. #define NEED_STRFTIME_LOCK
  169. /*
  170. ** Missing function prototypes
  171. */
  172. extern int gethostname(char *name, int namelen);
  173. #endif /* nspr_sony_defs_h___ */