home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _bsdi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.3 KB  |  139 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_bsdi_defs_h___
  20. #define nspr_bsdi_defs_h___
  21.  
  22. /*
  23.  * Internal configuration macros
  24.  */
  25.  
  26. #define PR_LINKER_ARCH    "bsdi"
  27. #define _PR_SI_SYSNAME "BSDI"
  28. #define _PR_SI_ARCHITECTURE "x86"
  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. #define    HAVE_DLL
  36. #define USE_DLFCN
  37. #define HAVE_BSD_FLOCK
  38. #define NEED_TIME_R
  39.  
  40. #if defined(BSDI_2)
  41. #define PROT_NONE 0x0
  42. #endif
  43.  
  44. #define USE_SETJMP
  45.  
  46. #include <setjmp.h>
  47.  
  48. #if defined(BSDI_2)
  49. #define _MD_GET_SP(_t)    (_t)->md.context[2] 
  50. #else
  51. #define _MD_GET_SP(_t)    (_t)->md.context[0].jb_esp
  52. #endif
  53.  
  54. #define PR_NUM_GCREGS    _JBLEN
  55. #define PR_CONTEXT_TYPE    jmp_buf
  56.  
  57. #define CONTEXT(_th) ((_th)->md.context)
  58.  
  59. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)      \
  60. {                                  \
  61.     *status = PR_TRUE; \
  62.     if (setjmp(CONTEXT(_thread))) {                  \
  63.     _main();                      \
  64.     }                                  \
  65.     _MD_GET_SP(_thread) = (int) (_sp - 64); \
  66. }
  67.  
  68. #define _MD_SWITCH_CONTEXT(_thread)  \
  69.     if (!setjmp(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.     errno = (_thread)->md.errcode;         \
  80.     _MD_SET_CURRENT_THREAD(_thread); \
  81.     longjmp(CONTEXT(_thread), 1);    \
  82. }
  83.  
  84. /* Machine-dependent (MD) data structures */
  85.  
  86. struct _MDThread {
  87.     PR_CONTEXT_TYPE context;
  88.     int id;
  89.     int errcode;
  90. };
  91.  
  92. struct _MDThreadStack {
  93.     PRInt8 notused;
  94. };
  95.  
  96. struct _MDLock {
  97.     PRInt8 notused;
  98. };
  99.  
  100. struct _MDSemaphore {
  101.     PRInt8 notused;
  102. };
  103.  
  104. struct _MDCVar {
  105.     PRInt8 notused;
  106. };
  107.  
  108. struct _MDSegment {
  109.     PRInt8 notused;
  110. };
  111.  
  112. struct _MDCPU {
  113.     struct _MDCPU_Unix md_unix;
  114. };
  115.  
  116. #define _MD_INIT_LOCKS()
  117. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  118. #define _MD_FREE_LOCK(lock)
  119. #define _MD_LOCK(lock)
  120. #define _MD_UNLOCK(lock)
  121. #define _MD_INIT_IO()
  122. #define _MD_IOQ_LOCK()
  123. #define _MD_IOQ_UNLOCK()
  124.  
  125. #define _MD_EARLY_INIT          _MD_EarlyInit
  126. #define _MD_FINAL_INIT            _PR_UnixInit
  127. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  128. #define _MD_INIT_THREAD         _MD_InitializeThread
  129. #define _MD_EXIT_THREAD(thread)
  130. #define _MD_CLEAN_THREAD(_thread)
  131.  
  132. #include <sys/syscall.h>
  133. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  134.  
  135. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  136. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  137.  
  138. #endif /* nspr_bsdi_defs_h___ */
  139.