home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _sony.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  6KB  |  186 lines

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