home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _nec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  138 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.  
  41. #include <ucontext.h>
  42. #include <sys/regset.h>
  43.  
  44. #define PR_NUM_GCREGS   NGREG
  45. #define PR_CONTEXT_TYPE ucontext_t
  46.  
  47. #define CONTEXT(_thread) (&(_thread)->md.context)
  48.  
  49. #define _MD_GET_SP(_t)    (_t)->md.context.uc_mcontext.gregs[CXT_SP]
  50.  
  51. /*
  52. ** Initialize the thread context preparing it to execute "e(o,a)"
  53. */
  54. #define _MD_INIT_CONTEXT(thread, _sp, _main, status)               \
  55. {                                                                   \
  56.     *status = PR_TRUE; \
  57.     getcontext(CONTEXT(thread));                                    \
  58.     CONTEXT(thread)->uc_stack.ss_sp = (char*) (thread)->stack->stackBottom; \
  59.     CONTEXT(thread)->uc_stack.ss_size = (thread)->stack->stackSize; \
  60.     _MD_GET_SP(thread) = (greg_t) _sp - 64;             \
  61.     makecontext(CONTEXT(thread), _main, 0);              \
  62. }
  63.  
  64. #define _MD_SWITCH_CONTEXT(_thread)      \
  65.     if (!getcontext(CONTEXT(_thread))) { \
  66.         (_thread)->md.errcode = errno;      \
  67.         _PR_Schedule();                  \
  68.     }
  69.  
  70. /*
  71. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  72. */
  73. #define _MD_RESTORE_CONTEXT(_thread)   \
  74. {                                      \
  75.     ucontext_t *uc = CONTEXT(_thread); \
  76.     uc->uc_mcontext.gregs[CXT_V0] = 1; \
  77.     uc->uc_mcontext.gregs[CXT_A3] = 0; \
  78.     errno = (_thread)->md.errcode;     \
  79.     _MD_SET_CURRENT_THREAD(_thread);   \
  80.     setcontext(uc);                    \
  81. }
  82.  
  83. /* Machine-dependent (MD) data structures */
  84.  
  85. struct _MDThread {
  86.     PR_CONTEXT_TYPE context;
  87.     int id;
  88.     int errcode;
  89. };
  90.  
  91. struct _MDThreadStack {
  92.     PRInt8 notused;
  93. };
  94.  
  95. struct _MDLock {
  96.     PRInt8 notused;
  97. };
  98.  
  99. struct _MDSemaphore {
  100.     PRInt8 notused;
  101. };
  102.  
  103. struct _MDCVar {
  104.     PRInt8 notused;
  105. };
  106.  
  107. struct _MDSegment {
  108.     PRInt8 notused;
  109. };
  110.  
  111. struct _MDCPU {
  112.     struct _MDCPU_Unix md_unix;
  113. };
  114.  
  115. #define _MD_INIT_LOCKS()
  116. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  117. #define _MD_FREE_LOCK(lock)
  118. #define _MD_LOCK(lock)
  119. #define _MD_UNLOCK(lock)
  120. #define _MD_INIT_IO()
  121. #define _MD_IOQ_LOCK()
  122. #define _MD_IOQ_UNLOCK()
  123.  
  124. #define _MD_EARLY_INIT          _MD_EarlyInit
  125. #define _MD_FINAL_INIT            _PR_UnixInit
  126. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  127. #define _MD_INIT_THREAD         _MD_InitializeThread
  128. #define _MD_EXIT_THREAD(thread)
  129. #define _MD_CLEAN_THREAD(_thread)
  130.  
  131. #define _MD_SELECT _select
  132. #define _MD_POLL _poll
  133.  
  134. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  135. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  136.  
  137. #endif /* nspr_nec_defs_h___ */
  138.