home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-v.zip / nspr30-v / include / md / _openbsd.h < prev    next >
C/C++ Source or Header  |  1998-09-25  |  5KB  |  172 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_openbsd_defs_h___
  20. #define nspr_openbsd_defs_h___
  21.  
  22. #include <sys/syscall.h>
  23.  
  24. #define PR_LINKER_ARCH "openbsd"
  25. #define _PR_SI_SYSNAME  "OpenBSD"
  26. #if defined(__i386__)
  27. #define _PR_SI_ARCHITECTURE "x86"
  28. #elif defined(__alpha__)
  29. #define _PR_SI_ARCHITECTURE "alpha"
  30. #elif defined(__m68k__)
  31. #define _PR_SI_ARCHITECTURE "m68k"
  32. #elif defined(__powerpc__)
  33. #define _PR_SI_ARCHITECTURE "powerpc"
  34. #elif defined(__sparc__)
  35. #define _PR_SI_ARCHITECTURE "sparc"
  36. #elif defined(__arm32__)
  37. #define _PR_SI_ARCHITECTURE "arm32"
  38. #endif
  39.  
  40. #define PR_DLL_SUFFIX          ".so.1.0"
  41.  
  42. #define _PR_VMBASE              0x30000000
  43. #define _PR_STACK_VMBASE       0x50000000
  44. #define _MD_DEFAULT_STACK_SIZE 65536L
  45. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  46.  
  47. #undef  HAVE_STACK_GROWING_UP
  48. #define HAVE_DLL
  49. #define USE_DLFCN
  50. #define _PR_HAVE_SOCKADDR_LEN
  51.  
  52. #define USE_SETJMP
  53.  
  54. #ifndef _PR_PTHREADS
  55. #include <setjmp.h>
  56.  
  57. #define PR_CONTEXT_TYPE        sigjmp_buf
  58.  
  59. #define CONTEXT(_th) ((_th)->md.context)
  60.  
  61. #if defined(__i386__) || defined(__sparc__) || defined(__m68k__) || defined(__powerpc__)
  62. #define JB_SP_INDEX 2
  63. #elif defined(__alpha__)
  64. #define JB_SP_INDEX 34
  65. #elif defined(__arm32__)
  66. /*
  67.  * On the arm32, the jmpbuf regs underwent a namechange after NetBSD 1.3
  68.  */
  69. #ifdef JMPBUF_REG_R13
  70. #define JB_SP_INDEX JMPBUF_REG_R13
  71. #else
  72. #define JB_SP_INDEX _JB_REG_R13
  73. #endif
  74. #else
  75. #error "Need to define SP index in jmp_buf here"
  76. #endif
  77. #define _MD_GET_SP(_th)    (_th)->md.context[JB_SP_INDEX]
  78.  
  79. #define PR_NUM_GCREGS  _JBLEN
  80.  
  81. /*
  82. ** Initialize a thread context to run "_main()" when started
  83. */
  84. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
  85. {  \
  86.     *status = PR_TRUE;  \
  87.     if (sigsetjmp(CONTEXT(_thread), 1)) {  \
  88.         _main();  \
  89.     }  \
  90.     _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 64); \
  91. }
  92.  
  93. #define _MD_SWITCH_CONTEXT(_thread)  \
  94.     if (!sigsetjmp(CONTEXT(_thread), 1)) {  \
  95.         (_thread)->md.errcode = errno;  \
  96.         _PR_Schedule();  \
  97.     }
  98.  
  99. /*
  100. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  101. */
  102. #define _MD_RESTORE_CONTEXT(_thread) \
  103. {   \
  104.     errno = (_thread)->md.errcode;  \
  105.     _MD_SET_CURRENT_THREAD(_thread);  \
  106.     siglongjmp(CONTEXT(_thread), 1);  \
  107. }
  108.  
  109. /* Machine-dependent (MD) data structures */
  110.  
  111. struct _MDThread {
  112.     PR_CONTEXT_TYPE context;
  113.     int id;
  114.     int errcode;
  115. };
  116.  
  117. struct _MDThreadStack {
  118.     PRInt8 notused;
  119. };
  120.  
  121. struct _MDLock {
  122.     PRInt8 notused;
  123. };
  124.  
  125. struct _MDSemaphore {
  126.     PRInt8 notused;
  127. };
  128.  
  129. struct _MDCVar {
  130.     PRInt8 notused;
  131. };
  132.  
  133. struct _MDSegment {
  134.     PRInt8 notused;
  135. };
  136.  
  137. struct _MDCPU {
  138.     struct _MDCPU_Unix md_unix;
  139. };
  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.  
  150. #define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
  151. #define _MD_INIT_THREAD                 _MD_InitializeThread
  152. #define _MD_EXIT_THREAD(thread)
  153. #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
  154. #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
  155. #define _MD_CLEAN_THREAD(_thread)
  156.  
  157. #endif /* ! _PR_PTHREADS */
  158.  
  159. #define _MD_EARLY_INIT                  _MD_EarlyInit
  160. #define _MD_FINAL_INIT                 _PR_UnixInit
  161. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  162. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  163.  
  164. /*
  165.  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  166.  * unwrapped version.
  167.  */
  168. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  169. #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
  170.  
  171. #endif /* nspr_openbsd_defs_h___ */
  172.