home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-e.zip / nspr30-e / include / md / _ncr.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  6KB  |  213 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_unixware_defs_h___
  20. #define nspr_unixware_defs_h___
  21.  
  22. /*
  23.  * Internal configuration macros
  24.  */
  25.  
  26. #define PR_LINKER_ARCH    "ncr"
  27. #define _PR_SI_SYSNAME        "NCR"
  28. #define _PR_SI_ARCHITECTURE    "x86"
  29. #define PR_DLL_SUFFIX        ".so"
  30.  
  31. #define _PR_VMBASE         0x30000000
  32. #define _PR_STACK_VMBASE    0x50000000
  33. #define _MD_DEFAULT_STACK_SIZE    65536L
  34. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  35.  
  36. #define    HAVE_DLL
  37. #define    USE_DLFCN
  38. #define _PR_RECV_BROKEN /* recv doesn't work on Unix Domain Sockets */
  39.  
  40. #if !defined (HAVE_STRERROR)
  41. #define HAVE_STRERROR
  42. #endif
  43.  
  44. #ifndef    HAVE_WEAK_IO_SYMBOLS
  45. #define    HAVE_WEAK_IO_SYMBOLS
  46. #endif
  47.  
  48. #define _PR_POLL_AVAILABLE
  49. #define _PR_USE_POLL
  50. #define _PR_NO_LARGE_FILES
  51. #define _PR_STAT_HAS_ST_ATIM_UNION
  52.  
  53. #undef  HAVE_STACK_GROWING_UP
  54. #define HAVE_NETCONFIG
  55. #define NEED_STRFTIME_LOCK
  56. #define NEED_TIME_R
  57. #define NEED_LOCALTIME_R
  58. #define NEED_GMTIME_R  
  59. #define NEED_ASCTIME_R
  60. #define NEED_STRTOK_R
  61. #define NEED_CTIME_R
  62. #define _PR_NEED_STRCASECMP
  63.  
  64. #define USE_SETJMP
  65.  
  66. #include <setjmp.h>
  67.  
  68. #define _SETJMP setjmp
  69. #define _LONGJMP longjmp
  70. #define _PR_CONTEXT_TYPE         jmp_buf
  71. #define _MD_GET_SP(_t)           (_t)->md.context[4]
  72. #define _PR_NUM_GCREGS    _JBLEN
  73.  
  74. #define CONTEXT(_th) ((_th)->md.context)
  75.  
  76. /*
  77. ** Initialize the thread context preparing it to execute _main.
  78. */
  79. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
  80. {                                  \
  81.     *status = PR_TRUE; \
  82.     if(_SETJMP(CONTEXT(_thread))) (*_main)(); \
  83.     _MD_GET_SP(_thread) = (int) ((_sp) - 128); \
  84. }
  85.  
  86. #define _MD_SWITCH_CONTEXT(_thread)  \
  87.     if (!_SETJMP(CONTEXT(_thread))) { \
  88.     (_thread)->md.errcode = errno;  \
  89.     _PR_Schedule();             \
  90.     }
  91.  
  92. /*
  93. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  94. */
  95. #define _MD_RESTORE_CONTEXT(_thread) \
  96. {                     \
  97.     errno = (_thread)->md.errcode;         \
  98.     _MD_SET_CURRENT_THREAD(_thread); \
  99.     _LONGJMP(CONTEXT(_thread), 1);    \
  100. }
  101.  
  102. /* Machine-dependent (MD) data structures.
  103.  * Don't use SVR4 native threads (yet). 
  104.  */
  105.  
  106. struct _MDThread {
  107.     _PR_CONTEXT_TYPE context;
  108.     int id;
  109.     int errcode;
  110. };
  111.  
  112. struct _MDThreadStack {
  113.     PRInt8 notused;
  114. };
  115.  
  116. struct _MDLock {
  117.     PRInt8 notused;
  118. };
  119.  
  120. struct _MDSemaphore {
  121.     PRInt8 notused;
  122. };
  123.  
  124. struct _MDCVar {
  125.     PRInt8 notused;
  126. };
  127.  
  128. struct _MDSegment {
  129.     PRInt8 notused;
  130. };
  131.  
  132. /*
  133.  * md-specific cpu structure field
  134.  */
  135. #define _PR_MD_MAX_OSFD FD_SETSIZE
  136.  
  137. struct _MDCPU_Unix {
  138.     PRCList ioQ;
  139.     PRUint32 ioq_timeout;
  140.     PRInt32 ioq_max_osfd;
  141.     PRInt32 ioq_osfd_cnt;
  142. #ifndef _PR_USE_POLL
  143.     fd_set fd_read_set, fd_write_set, fd_exception_set;
  144.     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
  145.                 fd_exception_cnt[_PR_MD_MAX_OSFD];
  146. #else
  147.     struct pollfd *ioq_pollfds;
  148.     int ioq_pollfds_size;
  149. #endif    /* _PR_USE_POLL */
  150. };
  151.  
  152. #define _PR_IOQ(_cpu)            ((_cpu)->md.md_unix.ioQ)
  153. #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
  154. #define _PR_FD_READ_SET(_cpu)        ((_cpu)->md.md_unix.fd_read_set)
  155. #define _PR_FD_READ_CNT(_cpu)        ((_cpu)->md.md_unix.fd_read_cnt)
  156. #define _PR_FD_WRITE_SET(_cpu)        ((_cpu)->md.md_unix.fd_write_set)
  157. #define _PR_FD_WRITE_CNT(_cpu)        ((_cpu)->md.md_unix.fd_write_cnt)
  158. #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.md_unix.fd_exception_set)
  159. #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.md_unix.fd_exception_cnt)
  160. #define _PR_IOQ_TIMEOUT(_cpu)        ((_cpu)->md.md_unix.ioq_timeout)
  161. #define _PR_IOQ_MAX_OSFD(_cpu)        ((_cpu)->md.md_unix.ioq_max_osfd)
  162. #define _PR_IOQ_OSFD_CNT(_cpu)        ((_cpu)->md.md_unix.ioq_osfd_cnt)
  163. #define _PR_IOQ_POLLFDS(_cpu)        ((_cpu)->md.md_unix.ioq_pollfds)
  164. #define _PR_IOQ_POLLFDS_SIZE(_cpu)    ((_cpu)->md.md_unix.ioq_pollfds_size)
  165.  
  166. #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
  167.  
  168. struct _MDCPU {
  169.     struct _MDCPU_Unix md_unix;
  170. };
  171.  
  172. #define _MD_INIT_LOCKS()
  173. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  174. #define _MD_FREE_LOCK(lock)
  175. #define _MD_LOCK(lock)
  176. #define _MD_UNLOCK(lock)
  177. #define _MD_INIT_IO()
  178. #define _MD_IOQ_LOCK()
  179. #define _MD_IOQ_UNLOCK()
  180.  
  181. /*
  182.  * The following are copied from _sunos.h, _aix.h.  This means
  183.  * some of them should probably be moved into _unixos.h.  But
  184.  * _irix.h seems to be quite different in regard to these macros.
  185.  */
  186. #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
  187. #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
  188.  
  189. #define _MD_EARLY_INIT        _MD_EarlyInit
  190. #define _MD_FINAL_INIT        _PR_UnixInit
  191. #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
  192. #define _MD_INIT_THREAD         _MD_InitializeThread
  193. #define _MD_EXIT_THREAD(thread)
  194. #define    _MD_SUSPEND_THREAD(thread)
  195. #define    _MD_RESUME_THREAD(thread)
  196. #define _MD_CLEAN_THREAD(_thread)
  197.  
  198. /*
  199.  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
  200.  * unwrapped version.
  201.  */
  202. #include <sys/time.h>
  203. #include <sys/types.h>
  204. #include <sys/select.h>
  205. extern int _select(int nfds, fd_set *readfds, fd_set *writefds,
  206.     fd_set *execptfds, struct timeval *timeout);
  207. #define _MD_SELECT _select
  208.  
  209. #define _MD_POLL _poll
  210. extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
  211.  
  212. #endif /* nspr_ncr_defs_h */
  213.