Wed, 31 Dec 2014 06:55:50 +0100
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_xhppa_defs_h___
7 #define nspr_xhppa_defs_h___
9 /*
10 * Internal configuration macros
11 */
13 #define PR_LINKER_ARCH "hpux"
14 #define _PR_SI_SYSNAME "HPUX"
15 #ifdef __ia64
16 #define _PR_SI_ARCHITECTURE "ia64"
17 #define PR_DLL_SUFFIX ".so"
18 #else
19 /*
20 * _PR_SI_ARCHITECTURE must be "hppa1.1" for backward compatibility.
21 * It was changed to "hppa" in NSPR 4.6.2, but was changed back in
22 * NSPR 4.6.4.
23 */
24 #define _PR_SI_ARCHITECTURE "hppa1.1"
25 #define PR_DLL_SUFFIX ".sl"
26 #endif
28 #define _PR_VMBASE 0x30000000
29 #define _PR_STACK_VMBASE 0x50000000
30 /*
31 * _USE_BIG_FDS increases the size of fd_set from 256 bytes to
32 * about 7500 bytes. PR_Poll allocates three fd_sets on the
33 * stack, so it is safer to also increase the default thread
34 * stack size.
35 */
36 #define _MD_DEFAULT_STACK_SIZE (2*65536L)
37 #define _MD_MINIMUM_STACK_SIZE (2*65536L)
38 #define _MD_MMAP_FLAGS MAP_PRIVATE
40 #define NEED_TIME_R
42 #define HAVE_STACK_GROWING_UP
43 #undef HAVE_WEAK_IO_SYMBOLS
44 #undef HAVE_WEAK_MALLOC_SYMBOLS
45 #define HAVE_DLL
46 #ifdef IS_64
47 #define USE_DLFCN
48 #else
49 #define USE_HPSHL
50 #endif
51 #ifndef HAVE_STRERROR
52 #define HAVE_STRERROR
53 #endif
54 #define _PR_POLL_AVAILABLE
55 #define _PR_USE_POLL
56 #define _PR_STAT_HAS_ONLY_ST_ATIME
57 #define _PR_HAVE_POSIX_SEMAPHORES
58 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
59 #define _PR_ACCEPT_INHERIT_NONBLOCK
61 #if defined(__ia64)
62 #define _PR_HAVE_ATOMIC_OPS
63 #define _MD_INIT_ATOMIC()
64 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
65 #define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement
66 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
67 #define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement
68 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
69 #define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd
70 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
71 #define _MD_ATOMIC_SET _PR_ia64_AtomicSet
72 #endif
74 #define _PR_HAVE_GETIPNODEBYNAME
75 #define _PR_HAVE_GETIPNODEBYADDR
76 #define _PR_HAVE_GETADDRINFO
77 #ifdef _PR_INET6
78 #define _PR_HAVE_INET_NTOP
79 #else
80 #define _PR_INET6_PROBE
82 /* for HP-UX 11.11 without IPv6 */
83 #ifndef AF_INET6
84 #define AF_INET6 22
85 #define AI_CANONNAME 2
86 #define AI_NUMERICHOST 4
87 #define AI_NUMERICSERV 8
88 #define AI_V4MAPPED 0x00000010
89 #define AI_ADDRCONFIG 0x00000040
90 #define AI_ALL 0x00000020
91 #define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
92 #define NI_NUMERICHOST 2
93 struct addrinfo {
94 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
95 int ai_family; /* PF_xxx */
96 int ai_socktype; /* SOCK_xxx */
97 int ai_protocol; /* IPPROTO_xxx for IPv4 and IPv6 */
98 socklen_t ai_addrlen; /* length of ai_addr */
99 char *ai_canonname; /* canonical name for host */
100 struct sockaddr *ai_addr; /* binary address */
101 struct addrinfo *ai_next; /* next structure in linked list */
102 };
103 #endif /* for HP-UX 11.11 without IPv6 */
105 #define _PR_HAVE_MD_SOCKADDR_IN6
106 /* isomorphic to struct in6_addr on HP-UX B.11.23 */
107 struct _md_in6_addr {
108 union {
109 PRUint8 _S6_u8[16];
110 PRUint16 _S6_u16[8];
111 PRUint32 _S6_u32[4];
112 PRUint32 __S6_align;
113 } _s6_un;
114 };
115 /* isomorphic to struct sockaddr_in6 on HP-UX B.11.23 */
116 struct _md_sockaddr_in6 {
117 PRUint16 sin6_family;
118 PRUint16 sin6_port;
119 PRUint32 sin6_flowinfo;
120 struct _md_in6_addr sin6_addr;
121 PRUint32 sin6_scope_id;
122 };
123 #endif
125 #if !defined(_PR_PTHREADS)
127 #include <syscall.h>
128 #include <setjmp.h>
130 #define USE_SETJMP
132 #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
133 #define PR_NUM_GCREGS _JBLEN
134 /* Caveat: This makes jmp_buf full of doubles. */
135 #define CONTEXT(_th) ((_th)->md.jb)
137 /* Stack needs two frames (64 bytes) at the bottom */ \
138 #define _MD_SET_THR_SP(_t, _sp) ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
139 #define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th))
140 #define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1)
142 #if !defined(PTHREADS_USER)
144 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
145 { \
146 *(status) = PR_TRUE; \
147 if (_setjmp(CONTEXT(_thread))) (*_main)(); \
148 /* Stack needs two frames (64 bytes) at the bottom */ \
149 (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
150 }
152 #define _MD_SWITCH_CONTEXT(_thread) \
153 if (!_setjmp(CONTEXT(_thread))) { \
154 (_thread)->md.errcode = errno; \
155 _PR_Schedule(); \
156 }
158 /*
159 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
160 */
161 #define _MD_RESTORE_CONTEXT(_thread) \
162 { \
163 errno = (_thread)->md.errcode; \
164 _MD_SET_CURRENT_THREAD(_thread); \
165 _longjmp(CONTEXT(_thread), 1); \
166 }
168 /* Machine-dependent (MD) data structures. HP-UX has no native threads. */
170 struct _MDThread {
171 jmp_buf jb;
172 int id;
173 int errcode;
174 };
176 struct _MDThreadStack {
177 PRInt8 notused;
178 };
180 struct _MDLock {
181 PRInt8 notused;
182 };
184 struct _MDSemaphore {
185 PRInt8 notused;
186 };
188 struct _MDCVar {
189 PRInt8 notused;
190 };
192 struct _MDSegment {
193 PRInt8 notused;
194 };
196 /*
197 * md-specific cpu structure field
198 */
199 #define _PR_MD_MAX_OSFD FD_SETSIZE
201 struct _MDCPU_Unix {
202 PRCList ioQ;
203 PRUint32 ioq_timeout;
204 PRInt32 ioq_max_osfd;
205 PRInt32 ioq_osfd_cnt;
206 #ifndef _PR_USE_POLL
207 fd_set fd_read_set, fd_write_set, fd_exception_set;
208 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
209 fd_exception_cnt[_PR_MD_MAX_OSFD];
210 #else
211 struct pollfd *ioq_pollfds;
212 int ioq_pollfds_size;
213 #endif /* _PR_USE_POLL */
214 };
216 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
217 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
218 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
219 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
220 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
221 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
222 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
223 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
224 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
225 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
226 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
227 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
228 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
230 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
232 struct _MDCPU {
233 struct _MDCPU_Unix md_unix;
234 };
236 #define _MD_INIT_LOCKS()
237 #define _MD_NEW_LOCK(lock) PR_SUCCESS
238 #define _MD_FREE_LOCK(lock)
239 #define _MD_LOCK(lock)
240 #define _MD_UNLOCK(lock)
241 #define _MD_INIT_IO()
242 #define _MD_IOQ_LOCK()
243 #define _MD_IOQ_UNLOCK()
245 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
246 #define _MD_INIT_THREAD _MD_InitializeThread
247 #define _MD_EXIT_THREAD(thread)
248 #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
249 #define _MD_RESUME_THREAD(thread) _MD_resume_thread
250 #define _MD_CLEAN_THREAD(_thread)
252 #else /* PTHREADS_USER */
254 #include "_nspr_pthread.h"
256 #endif /* PTHREADS_USER */
258 #endif /* !defined(_PR_PTHREADS) */
260 #if !defined(PTHREADS_USER)
261 #define _MD_EARLY_INIT _MD_EarlyInit
262 #define _MD_FINAL_INIT _PR_UnixInit
263 #endif
265 #if defined(HPUX_LW_TIMER)
266 extern void _PR_HPUX_LW_IntervalInit(void);
267 extern PRIntervalTime _PR_HPUX_LW_GetInterval(void);
268 #define _MD_INTERVAL_INIT _PR_HPUX_LW_IntervalInit
269 #define _MD_GET_INTERVAL _PR_HPUX_LW_GetInterval
270 #define _MD_INTERVAL_PER_SEC() 1000
271 #else
272 #define _MD_INTERVAL_USE_GTOD
273 #endif
275 /*
276 * We wrapped the select() call. _MD_SELECT refers to the built-in,
277 * unwrapped version.
278 */
279 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
281 #include <poll.h>
282 #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
284 #ifdef HPUX11
285 extern void _MD_hpux_map_sendfile_error(int err);
286 #endif /* HPUX11 */
288 #endif /* nspr_xhppa_defs_h___ */