home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _bsdi.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_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. #define _PR_HAVE_SOCKADDR_LEN
  40. #define _PR_STAT_HAS_ST_ATIMESPEC
  41. #define _PR_NO_LARGE_FILES
  42.  
  43. #if defined(BSDI_2)
  44. #define PROT_NONE 0x0
  45. #endif
  46.  
  47. #define USE_SETJMP
  48.  
  49. #include <setjmp.h>
  50.  
  51. #if defined(BSDI_2)
  52. #define _MD_GET_SP(_t)    (_t)->md.context[2] 
  53. #else
  54. #define _MD_GET_SP(_t)    (_t)->md.context[0].jb_esp
  55. #endif
  56.  
  57. #define PR_NUM_GCREGS    _JBLEN
  58. #define PR_CONTEXT_TYPE    jmp_buf
  59.  
  60. #define CONTEXT(_th) ((_th)->md.context)
  61.  
  62. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)      \
  63. {                                  \
  64.     *status = PR_TRUE; \
  65.     if (setjmp(CONTEXT(_thread))) {                  \
  66.     _main();                      \
  67.     }                                  \
  68.     _MD_GET_SP(_thread) = (int) (_sp - 64); \
  69. }
  70.  
  71. #define _MD_SWITCH_CONTEXT(_thread)  \
  72.     if (!setjmp(CONTEXT(_thread))) { \
  73.     (_thread)->md.errcode = errno;  \
  74.     _PR_Schedule();             \
  75.     }
  76.  
  77. /*
  78. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  79. */
  80. #define _MD_RESTORE_CONTEXT(_thread) \
  81. {                     \
  82.     errno = (_thread)->md.errcode;         \
  83.     _MD_SET_CURRENT_THREAD(_thread); \
  84.     longjmp(CONTEXT(_thread), 1);    \
  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. #include <sys/syscall.h>
  172. #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
  173.  
  174. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  175. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  176.  
  177. #endif /* nspr_bsdi_defs_h___ */
  178.