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