1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/md/_bsdi.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,181 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nspr_bsdi_defs_h___ 1.10 +#define nspr_bsdi_defs_h___ 1.11 + 1.12 +/* 1.13 + * Internal configuration macros 1.14 + */ 1.15 + 1.16 +#include <sys/param.h> /* for _BSDI_VERSION */ 1.17 + 1.18 +#define PR_LINKER_ARCH "bsdi" 1.19 +#define _PR_SI_SYSNAME "BSDI" 1.20 +#if defined(__i386__) 1.21 +#define _PR_SI_ARCHITECTURE "x86" 1.22 +#elif defined(__sparc__) 1.23 +#define _PR_SI_ARCHITECTURE "sparc" 1.24 +#else 1.25 +#error "Unknown CPU architecture" 1.26 +#endif 1.27 +#define PR_DLL_SUFFIX ".so" 1.28 + 1.29 +#define _PR_STACK_VMBASE 0x50000000 1.30 +#define _MD_DEFAULT_STACK_SIZE 65536L 1.31 +#define _MD_MMAP_FLAGS MAP_PRIVATE 1.32 + 1.33 +#define HAVE_BSD_FLOCK 1.34 +#define NEED_TIME_R 1.35 +#define _PR_HAVE_SOCKADDR_LEN 1.36 +#define _PR_NO_LARGE_FILES 1.37 + 1.38 +#define USE_SETJMP 1.39 + 1.40 +/* BSD/OS 4.3 and newer all have IPv6 support */ 1.41 +#if _BSDI_VERSION >= 200105 1.42 +#define _PR_INET6 1.43 +#define _PR_HAVE_INET_NTOP 1.44 +#define _PR_HAVE_GETIPNODEBYNAME 1.45 +#define _PR_HAVE_GETIPNODEBYADDR 1.46 +#define _PR_HAVE_GETADDRINFO 1.47 +#define _PR_INET6_PROBE 1.48 +#endif 1.49 + 1.50 +#ifndef _PR_PTHREADS 1.51 + 1.52 +#include <setjmp.h> 1.53 + 1.54 +#if defined(_PR_BSDI_JMPBUF_IS_ARRAY) 1.55 +#define _MD_GET_SP(_t) (_t)->md.context[2] 1.56 +#elif defined(_PR_BSDI_JMPBUF_IS_STRUCT) 1.57 +#define _MD_GET_SP(_t) (_t)->md.context[0].jb_esp 1.58 +#else 1.59 +#error "Unknown BSDI jmp_buf type" 1.60 +#endif 1.61 + 1.62 +#define PR_NUM_GCREGS _JBLEN 1.63 +#define PR_CONTEXT_TYPE jmp_buf 1.64 + 1.65 +#define CONTEXT(_th) ((_th)->md.context) 1.66 + 1.67 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 1.68 +{ \ 1.69 + *status = PR_TRUE; \ 1.70 + if (setjmp(CONTEXT(_thread))) { \ 1.71 + _main(); \ 1.72 + } \ 1.73 + _MD_GET_SP(_thread) = (int) (_sp - 64); \ 1.74 +} 1.75 + 1.76 +#define _MD_SWITCH_CONTEXT(_thread) \ 1.77 + if (!setjmp(CONTEXT(_thread))) { \ 1.78 + (_thread)->md.errcode = errno; \ 1.79 + _PR_Schedule(); \ 1.80 + } 1.81 + 1.82 +/* 1.83 +** Restore a thread context, saved by _MD_SWITCH_CONTEXT 1.84 +*/ 1.85 +#define _MD_RESTORE_CONTEXT(_thread) \ 1.86 +{ \ 1.87 + errno = (_thread)->md.errcode; \ 1.88 + _MD_SET_CURRENT_THREAD(_thread); \ 1.89 + longjmp(CONTEXT(_thread), 1); \ 1.90 +} 1.91 + 1.92 +/* Machine-dependent (MD) data structures */ 1.93 + 1.94 +struct _MDThread { 1.95 + PR_CONTEXT_TYPE context; 1.96 + int id; 1.97 + int errcode; 1.98 +}; 1.99 + 1.100 +struct _MDThreadStack { 1.101 + PRInt8 notused; 1.102 +}; 1.103 + 1.104 +struct _MDLock { 1.105 + PRInt8 notused; 1.106 +}; 1.107 + 1.108 +struct _MDSemaphore { 1.109 + PRInt8 notused; 1.110 +}; 1.111 + 1.112 +struct _MDCVar { 1.113 + PRInt8 notused; 1.114 +}; 1.115 + 1.116 +struct _MDSegment { 1.117 + PRInt8 notused; 1.118 +}; 1.119 + 1.120 +/* 1.121 + * md-specific cpu structure field 1.122 + */ 1.123 +#define _PR_MD_MAX_OSFD FD_SETSIZE 1.124 + 1.125 +struct _MDCPU_Unix { 1.126 + PRCList ioQ; 1.127 + PRUint32 ioq_timeout; 1.128 + PRInt32 ioq_max_osfd; 1.129 + PRInt32 ioq_osfd_cnt; 1.130 +#ifndef _PR_USE_POLL 1.131 + fd_set fd_read_set, fd_write_set, fd_exception_set; 1.132 + PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 1.133 + fd_exception_cnt[_PR_MD_MAX_OSFD]; 1.134 +#else 1.135 + struct pollfd *ioq_pollfds; 1.136 + int ioq_pollfds_size; 1.137 +#endif /* _PR_USE_POLL */ 1.138 +}; 1.139 + 1.140 +#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 1.141 +#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 1.142 +#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 1.143 +#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 1.144 +#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 1.145 +#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 1.146 +#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 1.147 +#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 1.148 +#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 1.149 +#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 1.150 +#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 1.151 +#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 1.152 +#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 1.153 + 1.154 +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 1.155 + 1.156 +struct _MDCPU { 1.157 + struct _MDCPU_Unix md_unix; 1.158 +}; 1.159 + 1.160 +#define _MD_INIT_LOCKS() 1.161 +#define _MD_NEW_LOCK(lock) PR_SUCCESS 1.162 +#define _MD_FREE_LOCK(lock) 1.163 +#define _MD_LOCK(lock) 1.164 +#define _MD_UNLOCK(lock) 1.165 +#define _MD_INIT_IO() 1.166 +#define _MD_IOQ_LOCK() 1.167 +#define _MD_IOQ_UNLOCK() 1.168 + 1.169 +#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 1.170 +#define _MD_INIT_THREAD _MD_InitializeThread 1.171 +#define _MD_EXIT_THREAD(thread) 1.172 +#define _MD_CLEAN_THREAD(_thread) 1.173 + 1.174 +#endif /* ! _PR_PTHREADS */ 1.175 + 1.176 +#define _MD_EARLY_INIT _MD_EarlyInit 1.177 +#define _MD_FINAL_INIT _PR_UnixInit 1.178 + 1.179 +#include <sys/syscall.h> 1.180 +#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv) 1.181 + 1.182 +#define _MD_INTERVAL_USE_GTOD 1.183 + 1.184 +#endif /* nspr_bsdi_defs_h___ */