home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _nec.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  5KB  |  178 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_nec_defs_h___
  20. #define nspr_nec_defs_h___
  21.  
  22. /*
  23.  * Internal configuration macros
  24.  */
  25.  
  26. #define PR_LINKER_ARCH  "nec"
  27. #define _PR_SI_SYSNAME "NEC"
  28. #define _PR_SI_ARCHITECTURE "mips"
  29. #define PR_DLL_SUFFIX        ".so"
  30.  
  31. #define _PR_STACK_VMBASE        0x50000000
  32. #define _MD_DEFAULT_STACK_SIZE  65536L
  33. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  34.  
  35. #undef  HAVE_STACK_GROWING_UP
  36. #define HAVE_DLL
  37. #define USE_DLFCN
  38. #define NEED_TIME_R
  39. #define NEED_STRFTIME_LOCK
  40. #define _PR_POLL_AVAILABLE
  41. #define _PR_USE_POLL
  42. #define _PR_NO_LARGE_FILES
  43. #define _PR_STAT_HAS_ST_ATIM_UNION
  44.  
  45. #include <ucontext.h>
  46. #include <sys/regset.h>
  47.  
  48. #define PR_NUM_GCREGS   NGREG
  49. #define PR_CONTEXT_TYPE ucontext_t
  50.  
  51. #define CONTEXT(_thread) (&(_thread)->md.context)
  52.  
  53. #define _MD_GET_SP(_t)    (_t)->md.context.uc_mcontext.gregs[CXT_SP]
  54.  
  55. /*
  56. ** Initialize the thread context preparing it to execute "e(o,a)"
  57. */
  58. #define _MD_INIT_CONTEXT(thread, _sp, _main, status)               \
  59. {                                                                   \
  60.     *status = PR_TRUE; \
  61.     getcontext(CONTEXT(thread));                                    \
  62.     CONTEXT(thread)->uc_stack.ss_sp = (char*) (thread)->stack->stackBottom; \
  63.     CONTEXT(thread)->uc_stack.ss_size = (thread)->stack->stackSize; \
  64.     _MD_GET_SP(thread) = (greg_t) _sp - 64;             \
  65.     makecontext(CONTEXT(thread), _main, 0);              \
  66. }
  67.  
  68. #define _MD_SWITCH_CONTEXT(_thread)      \
  69.     if (!getcontext(CONTEXT(_thread))) { \
  70.         (_thread)->md.errcode = errno;      \
  71.         _PR_Schedule();                  \
  72.     }
  73.  
  74. /*
  75. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  76. */
  77. #define _MD_RESTORE_CONTEXT(_thread)   \
  78. {                                      \
  79.     ucontext_t *uc = CONTEXT(_thread); \
  80.     uc->uc_mcontext.gregs[CXT_V0] = 1; \
  81.     uc->uc_mcontext.gregs[CXT_A3] = 0; \
  82.     errno = (_thread)->md.errcode;     \
  83.     _MD_SET_CURRENT_THREAD(_thread);   \
  84.     setcontext(uc);                    \
  85. }
  86.  
  87. /* Machine-dependent (MD) data structures */
  88.  
  89. struct _MDThread {
  90.     PR_CONTEXT_TYPE context;
  91.     int id;
  92.     int errcode;
  93. };
  94.  
  95. struct _MDThreadStack {
  96.     PRInt8 notused;
  97. };
  98.  
  99. struct _MDLock {
  100.     PRInt8 notused;
  101. };
  102.  
  103. struct _MDSemaphore {
  104.     PRInt8 notused;
  105. };
  106.  
  107. struct _MDCVar {
  108.     PRInt8 notused;
  109. };
  110.  
  111. struct _MDSegment {
  112.     PRInt8 notused;
  113. };
  114.  
  115. /*
  116.  * md-specific cpu structure field
  117.  */
  118. #define _PR_MD_MAX_OSFD FD_SETSIZE
  119.  
  120. struct _MDCPU_Unix {
  121.     PRCList ioQ;
  122.     PRUint32 ioq_timeout;
  123.     PRInt32 ioq_max_osfd;
  124.     PRInt32 ioq_osfd_cnt;
  125. #ifndef _PR_USE_POLL
  126.     fd_set fd_read_set, fd_write_set, fd_exception_set;
  127.     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  128.                 fd_exception_cnt[_PR_MD_MAX_OSFD];
  129. #else
  130.     struct pollfd *ioq_pollfds;
  131.     int ioq_pollfds_size;
  132. #endif    /* _PR_USE_POLL */
  133. };
  134.  
  135. #define _PR_IOQ(_cpu)            ((_cpu)->md.md_unix.ioQ)
  136. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  137. #define _PR_FD_READ_SET(_cpu)        ((_cpu)->md.md_unix.fd_read_set)
  138. #define _PR_FD_READ_CNT(_cpu)        ((_cpu)->md.md_unix.fd_read_cnt)
  139. #define _PR_FD_WRITE_SET(_cpu)        ((_cpu)->md.md_unix.fd_write_set)
  140. #define _PR_FD_WRITE_CNT(_cpu)        ((_cpu)->md.md_unix.fd_write_cnt)
  141. #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.md_unix.fd_exception_set)
  142. #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.md_unix.fd_exception_cnt)
  143. #define _PR_IOQ_TIMEOUT(_cpu)        ((_cpu)->md.md_unix.ioq_timeout)
  144. #define _PR_IOQ_MAX_OSFD(_cpu)        ((_cpu)->md.md_unix.ioq_max_osfd)
  145. #define _PR_IOQ_OSFD_CNT(_cpu)        ((_cpu)->md.md_unix.ioq_osfd_cnt)
  146. #define _PR_IOQ_POLLFDS(_cpu)        ((_cpu)->md.md_unix.ioq_pollfds)
  147. #define _PR_IOQ_POLLFDS_SIZE(_cpu)    ((_cpu)->md.md_unix.ioq_pollfds_size)
  148.  
  149. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
  150.  
  151. struct _MDCPU {
  152.     struct _MDCPU_Unix md_unix;
  153. };
  154.  
  155. #define _MD_INIT_LOCKS()
  156. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  157. #define _MD_FREE_LOCK(lock)
  158. #define _MD_LOCK(lock)
  159. #define _MD_UNLOCK(lock)
  160. #define _MD_INIT_IO()
  161. #define _MD_IOQ_LOCK()
  162. #define _MD_IOQ_UNLOCK()
  163.  
  164. #define _MD_EARLY_INIT          _MD_EarlyInit
  165. #define _MD_FINAL_INIT            _PR_UnixInit
  166. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  167. #define _MD_INIT_THREAD         _MD_InitializeThread
  168. #define _MD_EXIT_THREAD(thread)
  169. #define _MD_CLEAN_THREAD(_thread)
  170.  
  171. #define _MD_SELECT _select
  172. #define _MD_POLL _poll
  173.  
  174. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  175. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  176.  
  177. #endif /* nspr_nec_defs_h___ */
  178.