1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/md/_aix.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,225 @@ 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_aix_defs_h___ 1.10 +#define nspr_aix_defs_h___ 1.11 + 1.12 +#include <sys/types.h> 1.13 +#if defined(_PR_PTHREADS) || defined(PTHREADS_USER) 1.14 +#include <pthread.h> 1.15 +#endif 1.16 + 1.17 +/* 1.18 + * To pick up fd_set and the poll events. 1.19 + */ 1.20 +#include <sys/select.h> 1.21 +#include <sys/poll.h> 1.22 + 1.23 +/* 1.24 + * Internal configuration macros 1.25 + */ 1.26 + 1.27 +#define PR_LINKER_ARCH "aix" 1.28 +#define _PR_SI_SYSNAME "AIX" 1.29 +#define _PR_SI_ARCHITECTURE "rs6000" 1.30 +#define PR_DLL_SUFFIX ".so" 1.31 + 1.32 +#define _PR_VMBASE 0x30000000 1.33 +#define _PR_STACK_VMBASE 0x50000000 1.34 +#define _MD_DEFAULT_STACK_SIZE (2*65536L) 1.35 +#define _MD_MINIMUM_STACK_SIZE (2*65536L) 1.36 +#define _MD_MMAP_FLAGS MAP_PRIVATE 1.37 + 1.38 +#define NEED_TIME_R 1.39 +#undef HAVE_STACK_GROWING_UP 1.40 +#undef HAVE_WEAK_IO_SYMBOLS 1.41 +#undef HAVE_WEAK_MALLOC_SYMBOLS 1.42 +#define HAVE_DLL 1.43 +#define USE_DLFCN 1.44 +#define _PR_HAVE_SOCKADDR_LEN 1.45 +#define _PR_POLL_AVAILABLE 1.46 +#define _PR_USE_POLL 1.47 +#define _PR_STAT_HAS_ONLY_ST_ATIME 1.48 +#ifdef _PR_INET6 1.49 +#define _PR_HAVE_INET_NTOP 1.50 +#define _PR_HAVE_GETHOSTBYNAME2 1.51 +#ifdef _AIX51 /* AIX 4.3.3 does not have AI_NUMERICHOST. */ 1.52 +#define _PR_HAVE_GETADDRINFO 1.53 +#endif 1.54 +#endif 1.55 +#define _PR_HAVE_SYSV_SEMAPHORES 1.56 +#define PR_HAVE_SYSV_NAMED_SHARED_MEMORY 1.57 +#define _PR_ACCEPT_INHERIT_NONBLOCK 1.58 + 1.59 +/* Timer operations */ 1.60 +#if defined(AIX_TIMERS) 1.61 +#define _MD_INTERVAL_INIT() 1.62 + 1.63 +extern PRIntervalTime _MD_AixGetInterval(void); 1.64 +#define _MD_GET_INTERVAL _MD_AixGetInterval 1.65 + 1.66 +extern PRIntervalTime _MD_AixIntervalPerSec(void); 1.67 +#define _MD_INTERVAL_PER_SEC _MD_AixIntervalPerSec 1.68 + 1.69 +#else /* defined(AIX_TIMERS) */ 1.70 +#define _MD_INTERVAL_USE_GTOD 1.71 +#endif /* defined(AIX_TIMERS) */ 1.72 + 1.73 +#ifdef AIX_HAVE_ATOMIC_OP_H 1.74 +/* The atomic operations */ 1.75 +#include <sys/atomic_op.h> 1.76 +#define _PR_HAVE_ATOMIC_OPS 1.77 +#ifndef IS_64 1.78 +#define _PR_HAVE_ATOMIC_CAS 1.79 +#endif 1.80 +#define _MD_INIT_ATOMIC() 1.81 +#define _MD_ATOMIC_INCREMENT(val) ((PRInt32)fetch_and_add((atomic_p)val, 1) + 1) 1.82 +#define _MD_ATOMIC_ADD(ptr, val) ((PRInt32)fetch_and_add((atomic_p)ptr, val) + val) 1.83 +#define _MD_ATOMIC_DECREMENT(val) ((PRInt32)fetch_and_add((atomic_p)val, -1) - 1) 1.84 +#define _MD_ATOMIC_SET(val, newval) _AIX_AtomicSet(val, newval) 1.85 +#endif /* AIX_HAVE_ATOMIC_OP_H */ 1.86 + 1.87 +#define USE_SETJMP 1.88 + 1.89 +#include <setjmp.h> 1.90 + 1.91 +#define _MD_GET_SP(_t) (_t)->md.jb[3] 1.92 +#define _MD_SET_THR_SP(_t, _sp) ((_t)->md.jb[3] = (int) (_sp - 2 * 64)) 1.93 +#define PR_NUM_GCREGS _JBLEN 1.94 + 1.95 +#define CONTEXT(_th) ((_th)->md.jb) 1.96 +#define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th)) 1.97 +#define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1) 1.98 + 1.99 +#ifdef PTHREADS_USER 1.100 +#include "_nspr_pthread.h" 1.101 +#else 1.102 + 1.103 +/* 1.104 +** Initialize the thread context preparing it to execute _main. 1.105 +*/ 1.106 +#define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ 1.107 + PR_BEGIN_MACRO \ 1.108 + *status = PR_TRUE; \ 1.109 + if (setjmp(CONTEXT(_thread))) { \ 1.110 + (*_main)(); \ 1.111 + } \ 1.112 + _MD_GET_SP(_thread) = (int) (_sp - 2 * 64); \ 1.113 + PR_END_MACRO 1.114 + 1.115 +#define _MD_SWITCH_CONTEXT(_thread) \ 1.116 + if (!setjmp(CONTEXT(_thread))) { \ 1.117 + (_thread)->md.errcode = errno; \ 1.118 + _PR_Schedule(); \ 1.119 + } 1.120 + 1.121 +/* 1.122 +** Restore a thread context, saved by _MD_SWITCH_CONTEXT 1.123 +*/ 1.124 +#define _MD_RESTORE_CONTEXT(_thread) \ 1.125 +{ \ 1.126 + errno = (_thread)->md.errcode; \ 1.127 + _MD_SET_CURRENT_THREAD(_thread); \ 1.128 + longjmp(CONTEXT(_thread), 1); \ 1.129 +} 1.130 + 1.131 +/* Machine-dependent (MD) data structures */ 1.132 + 1.133 +struct _MDThread { 1.134 + jmp_buf jb; 1.135 + int id; 1.136 + int errcode; 1.137 +}; 1.138 + 1.139 +struct _MDThreadStack { 1.140 + PRInt8 notused; 1.141 +}; 1.142 + 1.143 +struct _MDLock { 1.144 + PRInt8 notused; 1.145 +}; 1.146 + 1.147 +struct _MDSemaphore { 1.148 + PRInt8 notused; 1.149 +}; 1.150 + 1.151 +struct _MDCVar { 1.152 + PRInt8 notused; 1.153 +}; 1.154 + 1.155 +struct _MDSegment { 1.156 + PRInt8 notused; 1.157 +}; 1.158 + 1.159 +/* 1.160 + * md-specific cpu structure field 1.161 + */ 1.162 +#define _PR_MD_MAX_OSFD FD_SETSIZE 1.163 + 1.164 +struct _MDCPU_Unix { 1.165 + PRCList ioQ; 1.166 + PRUint32 ioq_timeout; 1.167 + PRInt32 ioq_max_osfd; 1.168 + PRInt32 ioq_osfd_cnt; 1.169 +#ifndef _PR_USE_POLL 1.170 + fd_set fd_read_set, fd_write_set, fd_exception_set; 1.171 + PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], 1.172 + fd_exception_cnt[_PR_MD_MAX_OSFD]; 1.173 +#else 1.174 + struct pollfd *ioq_pollfds; 1.175 + int ioq_pollfds_size; 1.176 +#endif /* _PR_USE_POLL */ 1.177 +}; 1.178 + 1.179 +#define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) 1.180 +#define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) 1.181 +#define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) 1.182 +#define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) 1.183 +#define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) 1.184 +#define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) 1.185 +#define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) 1.186 +#define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) 1.187 +#define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) 1.188 +#define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) 1.189 +#define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) 1.190 +#define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) 1.191 +#define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) 1.192 + 1.193 +#define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 1.194 + 1.195 +struct _MDCPU { 1.196 + struct _MDCPU_Unix md_unix; 1.197 +}; 1.198 + 1.199 +#if !defined(_PR_PTHREADS) 1.200 +#define _MD_INIT_LOCKS() 1.201 +#endif 1.202 + 1.203 +#define _MD_NEW_LOCK(lock) PR_SUCCESS 1.204 +#define _MD_FREE_LOCK(lock) 1.205 +#define _MD_LOCK(lock) 1.206 +#define _MD_UNLOCK(lock) 1.207 +#define _MD_INIT_IO() 1.208 +#define _MD_IOQ_LOCK() 1.209 +#define _MD_IOQ_UNLOCK() 1.210 + 1.211 +#define _MD_EARLY_INIT _MD_EarlyInit 1.212 +#define _MD_FINAL_INIT _PR_UnixInit 1.213 +#define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) 1.214 +#define _MD_INIT_THREAD _MD_InitializeThread 1.215 +#define _MD_EXIT_THREAD(thread) 1.216 +#define _MD_SUSPEND_THREAD(thread) 1.217 +#define _MD_RESUME_THREAD(thread) 1.218 +#define _MD_CLEAN_THREAD(_thread) 1.219 +#endif /* PTHREADS_USER */ 1.220 + 1.221 +#ifdef AIX_RENAME_SELECT 1.222 +#define _MD_SELECT select 1.223 +#define _MD_POLL poll 1.224 +#endif 1.225 + 1.226 +extern void _MD_aix_map_sendfile_error(int err); 1.227 + 1.228 +#endif /* nspr_aix_defs_h___ */