1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/md/_hpux.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,288 @@ 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_xhppa_defs_h___ 1.10 +#define nspr_xhppa_defs_h___ 1.11 + 1.12 +/* 1.13 + * Internal configuration macros 1.14 + */ 1.15 + 1.16 +#define PR_LINKER_ARCH "hpux" 1.17 +#define _PR_SI_SYSNAME "HPUX" 1.18 +#ifdef __ia64 1.19 +#define _PR_SI_ARCHITECTURE "ia64" 1.20 +#define PR_DLL_SUFFIX ".so" 1.21 +#else 1.22 +/* 1.23 + * _PR_SI_ARCHITECTURE must be "hppa1.1" for backward compatibility. 1.24 + * It was changed to "hppa" in NSPR 4.6.2, but was changed back in 1.25 + * NSPR 4.6.4. 1.26 + */ 1.27 +#define _PR_SI_ARCHITECTURE "hppa1.1" 1.28 +#define PR_DLL_SUFFIX ".sl" 1.29 +#endif 1.30 + 1.31 +#define _PR_VMBASE 0x30000000 1.32 +#define _PR_STACK_VMBASE 0x50000000 1.33 +/* 1.34 + * _USE_BIG_FDS increases the size of fd_set from 256 bytes to 1.35 + * about 7500 bytes. PR_Poll allocates three fd_sets on the 1.36 + * stack, so it is safer to also increase the default thread 1.37 + * stack size. 1.38 + */ 1.39 +#define _MD_DEFAULT_STACK_SIZE (2*65536L) 1.40 +#define _MD_MINIMUM_STACK_SIZE (2*65536L) 1.41 +#define _MD_MMAP_FLAGS MAP_PRIVATE 1.42 + 1.43 +#define NEED_TIME_R 1.44 + 1.45 +#define HAVE_STACK_GROWING_UP 1.46 +#undef HAVE_WEAK_IO_SYMBOLS 1.47 +#undef HAVE_WEAK_MALLOC_SYMBOLS 1.48 +#define HAVE_DLL 1.49 +#ifdef IS_64 1.50 +#define USE_DLFCN 1.51 +#else 1.52 +#define USE_HPSHL 1.53 +#endif 1.54 +#ifndef HAVE_STRERROR 1.55 +#define HAVE_STRERROR 1.56 +#endif 1.57 +#define _PR_POLL_AVAILABLE 1.58 +#define _PR_USE_POLL 1.59 +#define _PR_STAT_HAS_ONLY_ST_ATIME 1.60 +#define _PR_HAVE_POSIX_SEMAPHORES 1.61 +#define PR_HAVE_POSIX_NAMED_SHARED_MEMORY 1.62 +#define _PR_ACCEPT_INHERIT_NONBLOCK 1.63 + 1.64 +#if defined(__ia64) 1.65 +#define _PR_HAVE_ATOMIC_OPS 1.66 +#define _MD_INIT_ATOMIC() 1.67 +extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val); 1.68 +#define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement 1.69 +extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val); 1.70 +#define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement 1.71 +extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val); 1.72 +#define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd 1.73 +extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval); 1.74 +#define _MD_ATOMIC_SET _PR_ia64_AtomicSet 1.75 +#endif 1.76 + 1.77 +#define _PR_HAVE_GETIPNODEBYNAME 1.78 +#define _PR_HAVE_GETIPNODEBYADDR 1.79 +#define _PR_HAVE_GETADDRINFO 1.80 +#ifdef _PR_INET6 1.81 +#define _PR_HAVE_INET_NTOP 1.82 +#else 1.83 +#define _PR_INET6_PROBE 1.84 + 1.85 +/* for HP-UX 11.11 without IPv6 */ 1.86 +#ifndef AF_INET6 1.87 +#define AF_INET6 22 1.88 +#define AI_CANONNAME 2 1.89 +#define AI_NUMERICHOST 4 1.90 +#define AI_NUMERICSERV 8 1.91 +#define AI_V4MAPPED 0x00000010 1.92 +#define AI_ADDRCONFIG 0x00000040 1.93 +#define AI_ALL 0x00000020 1.94 +#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG) 1.95 +#define NI_NUMERICHOST 2 1.96 +struct addrinfo { 1.97 + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 1.98 + int ai_family; /* PF_xxx */ 1.99 + int ai_socktype; /* SOCK_xxx */ 1.100 + int ai_protocol; /* IPPROTO_xxx for IPv4 and IPv6 */ 1.101 + socklen_t ai_addrlen; /* length of ai_addr */ 1.102 + char *ai_canonname; /* canonical name for host */ 1.103 + struct sockaddr *ai_addr; /* binary address */ 1.104 + struct addrinfo *ai_next; /* next structure in linked list */ 1.105 +}; 1.106 +#endif /* for HP-UX 11.11 without IPv6 */ 1.107 + 1.108 +#define _PR_HAVE_MD_SOCKADDR_IN6 1.109 +/* isomorphic to struct in6_addr on HP-UX B.11.23 */ 1.110 +struct _md_in6_addr { 1.111 + union { 1.112 + PRUint8 _S6_u8[16]; 1.113 + PRUint16 _S6_u16[8]; 1.114 + PRUint32 _S6_u32[4]; 1.115 + PRUint32 __S6_align; 1.116 + } _s6_un; 1.117 +}; 1.118 +/* isomorphic to struct sockaddr_in6 on HP-UX B.11.23 */ 1.119 +struct _md_sockaddr_in6 { 1.120 + PRUint16 sin6_family; 1.121 + PRUint16 sin6_port; 1.122 + PRUint32 sin6_flowinfo; 1.123 + struct _md_in6_addr sin6_addr; 1.124 + PRUint32 sin6_scope_id; 1.125 +}; 1.126 +#endif 1.127 + 1.128 +#if !defined(_PR_PTHREADS) 1.129 + 1.130 +#include <syscall.h> 1.131 +#include <setjmp.h> 1.132 + 1.133 +#define USE_SETJMP 1.134 + 1.135 +#define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1)) 1.136 +#define PR_NUM_GCREGS _JBLEN 1.137 +/* Caveat: This makes jmp_buf full of doubles. */ 1.138 +#define CONTEXT(_th) ((_th)->md.jb) 1.139 + 1.140 + /* Stack needs two frames (64 bytes) at the bottom */ \ 1.141 +#define _MD_SET_THR_SP(_t, _sp) ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2)) 1.142 +#define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th)) 1.143 +#define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1) 1.144 + 1.145 +#if !defined(PTHREADS_USER) 1.146 + 1.147 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 1.148 +{ \ 1.149 + *(status) = PR_TRUE; \ 1.150 + if (_setjmp(CONTEXT(_thread))) (*_main)(); \ 1.151 + /* Stack needs two frames (64 bytes) at the bottom */ \ 1.152 + (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \ 1.153 +} 1.154 + 1.155 +#define _MD_SWITCH_CONTEXT(_thread) \ 1.156 + if (!_setjmp(CONTEXT(_thread))) { \ 1.157 + (_thread)->md.errcode = errno; \ 1.158 + _PR_Schedule(); \ 1.159 + } 1.160 + 1.161 +/* 1.162 +** Restore a thread context, saved by _MD_SWITCH_CONTEXT 1.163 +*/ 1.164 +#define _MD_RESTORE_CONTEXT(_thread) \ 1.165 +{ \ 1.166 + errno = (_thread)->md.errcode; \ 1.167 + _MD_SET_CURRENT_THREAD(_thread); \ 1.168 + _longjmp(CONTEXT(_thread), 1); \ 1.169 +} 1.170 + 1.171 +/* Machine-dependent (MD) data structures. HP-UX has no native threads. */ 1.172 + 1.173 +struct _MDThread { 1.174 + jmp_buf jb; 1.175 + int id; 1.176 + int errcode; 1.177 +}; 1.178 + 1.179 +struct _MDThreadStack { 1.180 + PRInt8 notused; 1.181 +}; 1.182 + 1.183 +struct _MDLock { 1.184 + PRInt8 notused; 1.185 +}; 1.186 + 1.187 +struct _MDSemaphore { 1.188 + PRInt8 notused; 1.189 +}; 1.190 + 1.191 +struct _MDCVar { 1.192 + PRInt8 notused; 1.193 +}; 1.194 + 1.195 +struct _MDSegment { 1.196 + PRInt8 notused; 1.197 +}; 1.198 + 1.199 +/* 1.200 + * md-specific cpu structure field 1.201 + */ 1.202 +#define _PR_MD_MAX_OSFD FD_SETSIZE 1.203 + 1.204 +struct _MDCPU_Unix { 1.205 + PRCList ioQ; 1.206 + PRUint32 ioq_timeout; 1.207 + PRInt32 ioq_max_osfd; 1.208 + PRInt32 ioq_osfd_cnt; 1.209 +#ifndef _PR_USE_POLL 1.210 + fd_set fd_read_set, fd_write_set, fd_exception_set; 1.211 + PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 1.212 + fd_exception_cnt[_PR_MD_MAX_OSFD]; 1.213 +#else 1.214 + struct pollfd *ioq_pollfds; 1.215 + int ioq_pollfds_size; 1.216 +#endif /* _PR_USE_POLL */ 1.217 +}; 1.218 + 1.219 +#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 1.220 +#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 1.221 +#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 1.222 +#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 1.223 +#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 1.224 +#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 1.225 +#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 1.226 +#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 1.227 +#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 1.228 +#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 1.229 +#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 1.230 +#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 1.231 +#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 1.232 + 1.233 +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 1.234 + 1.235 +struct _MDCPU { 1.236 + struct _MDCPU_Unix md_unix; 1.237 +}; 1.238 + 1.239 +#define _MD_INIT_LOCKS() 1.240 +#define _MD_NEW_LOCK(lock) PR_SUCCESS 1.241 +#define _MD_FREE_LOCK(lock) 1.242 +#define _MD_LOCK(lock) 1.243 +#define _MD_UNLOCK(lock) 1.244 +#define _MD_INIT_IO() 1.245 +#define _MD_IOQ_LOCK() 1.246 +#define _MD_IOQ_UNLOCK() 1.247 + 1.248 +#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 1.249 +#define _MD_INIT_THREAD _MD_InitializeThread 1.250 +#define _MD_EXIT_THREAD(thread) 1.251 +#define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread 1.252 +#define _MD_RESUME_THREAD(thread) _MD_resume_thread 1.253 +#define _MD_CLEAN_THREAD(_thread) 1.254 + 1.255 +#else /* PTHREADS_USER */ 1.256 + 1.257 +#include "_nspr_pthread.h" 1.258 + 1.259 +#endif /* PTHREADS_USER */ 1.260 + 1.261 +#endif /* !defined(_PR_PTHREADS) */ 1.262 + 1.263 +#if !defined(PTHREADS_USER) 1.264 +#define _MD_EARLY_INIT _MD_EarlyInit 1.265 +#define _MD_FINAL_INIT _PR_UnixInit 1.266 +#endif 1.267 + 1.268 +#if defined(HPUX_LW_TIMER) 1.269 +extern void _PR_HPUX_LW_IntervalInit(void); 1.270 +extern PRIntervalTime _PR_HPUX_LW_GetInterval(void); 1.271 +#define _MD_INTERVAL_INIT _PR_HPUX_LW_IntervalInit 1.272 +#define _MD_GET_INTERVAL _PR_HPUX_LW_GetInterval 1.273 +#define _MD_INTERVAL_PER_SEC() 1000 1.274 +#else 1.275 +#define _MD_INTERVAL_USE_GTOD 1.276 +#endif 1.277 + 1.278 +/* 1.279 + * We wrapped the select() call. _MD_SELECT refers to the built-in, 1.280 + * unwrapped version. 1.281 + */ 1.282 +#define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv) 1.283 + 1.284 +#include <poll.h> 1.285 +#define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout) 1.286 + 1.287 +#ifdef HPUX11 1.288 +extern void _MD_hpux_map_sendfile_error(int err); 1.289 +#endif /* HPUX11 */ 1.290 + 1.291 +#endif /* nspr_xhppa_defs_h___ */