nsprpub/pr/include/md/_bsdi.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nspr_bsdi_defs_h___
     7 #define nspr_bsdi_defs_h___
     9 /*
    10  * Internal configuration macros
    11  */
    13 #include <sys/param.h>	/* for _BSDI_VERSION */
    15 #define PR_LINKER_ARCH	"bsdi"
    16 #define _PR_SI_SYSNAME "BSDI"
    17 #if defined(__i386__)
    18 #define _PR_SI_ARCHITECTURE "x86"
    19 #elif defined(__sparc__)
    20 #define _PR_SI_ARCHITECTURE "sparc"
    21 #else
    22 #error "Unknown CPU architecture"
    23 #endif
    24 #define PR_DLL_SUFFIX		".so"
    26 #define _PR_STACK_VMBASE	0x50000000
    27 #define _MD_DEFAULT_STACK_SIZE	65536L
    28 #define _MD_MMAP_FLAGS          MAP_PRIVATE
    30 #define HAVE_BSD_FLOCK
    31 #define NEED_TIME_R
    32 #define _PR_HAVE_SOCKADDR_LEN
    33 #define _PR_NO_LARGE_FILES
    35 #define USE_SETJMP
    37 /* BSD/OS 4.3 and newer all have IPv6 support */
    38 #if _BSDI_VERSION >= 200105
    39 #define _PR_INET6
    40 #define _PR_HAVE_INET_NTOP
    41 #define _PR_HAVE_GETIPNODEBYNAME
    42 #define _PR_HAVE_GETIPNODEBYADDR
    43 #define _PR_HAVE_GETADDRINFO
    44 #define _PR_INET6_PROBE
    45 #endif
    47 #ifndef _PR_PTHREADS
    49 #include <setjmp.h>
    51 #if defined(_PR_BSDI_JMPBUF_IS_ARRAY)
    52 #define _MD_GET_SP(_t)    (_t)->md.context[2] 
    53 #elif defined(_PR_BSDI_JMPBUF_IS_STRUCT)
    54 #define _MD_GET_SP(_t)    (_t)->md.context[0].jb_esp
    55 #else
    56 #error "Unknown BSDI jmp_buf type"
    57 #endif
    59 #define PR_NUM_GCREGS	_JBLEN
    60 #define PR_CONTEXT_TYPE	jmp_buf
    62 #define CONTEXT(_th) ((_th)->md.context)
    64 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)	  \
    65 {								  \
    66     *status = PR_TRUE; \
    67     if (setjmp(CONTEXT(_thread))) {				  \
    68 	_main();					  \
    69     }								  \
    70     _MD_GET_SP(_thread) = (int) (_sp - 64); \
    71 }
    73 #define _MD_SWITCH_CONTEXT(_thread)  \
    74     if (!setjmp(CONTEXT(_thread))) { \
    75 	(_thread)->md.errcode = errno;  \
    76 	_PR_Schedule();		     \
    77     }
    79 /*
    80 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
    81 */
    82 #define _MD_RESTORE_CONTEXT(_thread) \
    83 {				     \
    84     errno = (_thread)->md.errcode;	     \
    85     _MD_SET_CURRENT_THREAD(_thread); \
    86     longjmp(CONTEXT(_thread), 1);    \
    87 }
    89 /* Machine-dependent (MD) data structures */
    91 struct _MDThread {
    92     PR_CONTEXT_TYPE context;
    93     int id;
    94     int errcode;
    95 };
    97 struct _MDThreadStack {
    98     PRInt8 notused;
    99 };
   101 struct _MDLock {
   102     PRInt8 notused;
   103 };
   105 struct _MDSemaphore {
   106     PRInt8 notused;
   107 };
   109 struct _MDCVar {
   110     PRInt8 notused;
   111 };
   113 struct _MDSegment {
   114     PRInt8 notused;
   115 };
   117 /*
   118  * md-specific cpu structure field
   119  */
   120 #define _PR_MD_MAX_OSFD FD_SETSIZE
   122 struct _MDCPU_Unix {
   123     PRCList ioQ;
   124     PRUint32 ioq_timeout;
   125     PRInt32 ioq_max_osfd;
   126     PRInt32 ioq_osfd_cnt;
   127 #ifndef _PR_USE_POLL
   128     fd_set fd_read_set, fd_write_set, fd_exception_set;
   129     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
   130 				fd_exception_cnt[_PR_MD_MAX_OSFD];
   131 #else
   132 	struct pollfd *ioq_pollfds;
   133 	int ioq_pollfds_size;
   134 #endif	/* _PR_USE_POLL */
   135 };
   137 #define _PR_IOQ(_cpu)			((_cpu)->md.md_unix.ioQ)
   138 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
   139 #define _PR_FD_READ_SET(_cpu)		((_cpu)->md.md_unix.fd_read_set)
   140 #define _PR_FD_READ_CNT(_cpu)		((_cpu)->md.md_unix.fd_read_cnt)
   141 #define _PR_FD_WRITE_SET(_cpu)		((_cpu)->md.md_unix.fd_write_set)
   142 #define _PR_FD_WRITE_CNT(_cpu)		((_cpu)->md.md_unix.fd_write_cnt)
   143 #define _PR_FD_EXCEPTION_SET(_cpu)	((_cpu)->md.md_unix.fd_exception_set)
   144 #define _PR_FD_EXCEPTION_CNT(_cpu)	((_cpu)->md.md_unix.fd_exception_cnt)
   145 #define _PR_IOQ_TIMEOUT(_cpu)		((_cpu)->md.md_unix.ioq_timeout)
   146 #define _PR_IOQ_MAX_OSFD(_cpu)		((_cpu)->md.md_unix.ioq_max_osfd)
   147 #define _PR_IOQ_OSFD_CNT(_cpu)		((_cpu)->md.md_unix.ioq_osfd_cnt)
   148 #define _PR_IOQ_POLLFDS(_cpu)		((_cpu)->md.md_unix.ioq_pollfds)
   149 #define _PR_IOQ_POLLFDS_SIZE(_cpu)	((_cpu)->md.md_unix.ioq_pollfds_size)
   151 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)	32
   153 struct _MDCPU {
   154 	struct _MDCPU_Unix md_unix;
   155 };
   157 #define _MD_INIT_LOCKS()
   158 #define _MD_NEW_LOCK(lock) PR_SUCCESS
   159 #define _MD_FREE_LOCK(lock)
   160 #define _MD_LOCK(lock)
   161 #define _MD_UNLOCK(lock)
   162 #define _MD_INIT_IO()
   163 #define _MD_IOQ_LOCK()
   164 #define _MD_IOQ_UNLOCK()
   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)
   171 #endif /* ! _PR_PTHREADS */
   173 #define _MD_EARLY_INIT          _MD_EarlyInit
   174 #define _MD_FINAL_INIT			_PR_UnixInit
   176 #include <sys/syscall.h>
   177 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
   179 #define _MD_INTERVAL_USE_GTOD
   181 #endif /* nspr_bsdi_defs_h___ */

mercurial