1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is the Netscape Portable Runtime (NSPR).
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998-2000
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | #ifndef nspr_xhppa_defs_h___
|
---|
39 | #define nspr_xhppa_defs_h___
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * Internal configuration macros
|
---|
43 | */
|
---|
44 |
|
---|
45 | #define PR_LINKER_ARCH "hpux"
|
---|
46 | #define _PR_SI_SYSNAME "HPUX"
|
---|
47 | #define _PR_SI_ARCHITECTURE "hppa1.1"
|
---|
48 | #define PR_DLL_SUFFIX ".sl"
|
---|
49 |
|
---|
50 | #define _PR_VMBASE 0x30000000
|
---|
51 | #define _PR_STACK_VMBASE 0x50000000
|
---|
52 | /*
|
---|
53 | * _USE_BIG_FDS increases the size of fd_set from 256 bytes to
|
---|
54 | * about 7500 bytes. PR_Poll allocates three fd_sets on the
|
---|
55 | * stack, so it is safer to also increase the default thread
|
---|
56 | * stack size.
|
---|
57 | */
|
---|
58 | #define _MD_DEFAULT_STACK_SIZE (2*65536L)
|
---|
59 | #define _MD_MINIMUM_STACK_SIZE (2*65536L)
|
---|
60 | #define _MD_MMAP_FLAGS MAP_PRIVATE
|
---|
61 |
|
---|
62 | #define NEED_TIME_R
|
---|
63 |
|
---|
64 | #define HAVE_STACK_GROWING_UP
|
---|
65 | #undef HAVE_WEAK_IO_SYMBOLS
|
---|
66 | #undef HAVE_WEAK_MALLOC_SYMBOLS
|
---|
67 | #define HAVE_DLL
|
---|
68 | #ifdef IS_64
|
---|
69 | #define USE_DLFCN
|
---|
70 | #else
|
---|
71 | #define USE_HPSHL
|
---|
72 | #endif
|
---|
73 | #ifndef HAVE_STRERROR
|
---|
74 | #define HAVE_STRERROR
|
---|
75 | #endif
|
---|
76 | #define _PR_POLL_AVAILABLE
|
---|
77 | #define _PR_USE_POLL
|
---|
78 | #define _PR_STAT_HAS_ONLY_ST_ATIME
|
---|
79 | #define _PR_HAVE_POSIX_SEMAPHORES
|
---|
80 | #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
|
---|
81 | #define _PR_ACCEPT_INHERIT_NONBLOCK
|
---|
82 |
|
---|
83 | #undef _PR_HAVE_ATOMIC_OPS
|
---|
84 |
|
---|
85 | #ifdef _PR_INET6
|
---|
86 | #define _PR_HAVE_INET_NTOP
|
---|
87 | #define _PR_HAVE_GETIPNODEBYNAME
|
---|
88 | #define _PR_HAVE_GETIPNODEBYADDR
|
---|
89 | #define _PR_HAVE_GETADDRINFO
|
---|
90 | #define _PR_INET6_PROBE
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | #if !defined(_PR_PTHREADS)
|
---|
94 |
|
---|
95 | #include <syscall.h>
|
---|
96 | #include <setjmp.h>
|
---|
97 |
|
---|
98 | #define USE_SETJMP
|
---|
99 |
|
---|
100 | #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
|
---|
101 | #define PR_NUM_GCREGS _JBLEN
|
---|
102 | /* Caveat: This makes jmp_buf full of doubles. */
|
---|
103 | #define CONTEXT(_th) ((_th)->md.jb)
|
---|
104 |
|
---|
105 | /* Stack needs two frames (64 bytes) at the bottom */ \
|
---|
106 | #define _MD_SET_THR_SP(_t, _sp) ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
|
---|
107 | #define SAVE_CONTEXT(_th) _setjmp(CONTEXT(_th))
|
---|
108 | #define GOTO_CONTEXT(_th) _longjmp(CONTEXT(_th), 1)
|
---|
109 |
|
---|
110 | #if !defined(PTHREADS_USER)
|
---|
111 |
|
---|
112 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
|
---|
113 | { \
|
---|
114 | *(status) = PR_TRUE; \
|
---|
115 | if (_setjmp(CONTEXT(_thread))) (*_main)(); \
|
---|
116 | /* Stack needs two frames (64 bytes) at the bottom */ \
|
---|
117 | (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
|
---|
118 | }
|
---|
119 |
|
---|
120 | #define _MD_SWITCH_CONTEXT(_thread) \
|
---|
121 | if (!_setjmp(CONTEXT(_thread))) { \
|
---|
122 | (_thread)->md.errcode = errno; \
|
---|
123 | _PR_Schedule(); \
|
---|
124 | }
|
---|
125 |
|
---|
126 | /*
|
---|
127 | ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
|
---|
128 | */
|
---|
129 | #define _MD_RESTORE_CONTEXT(_thread) \
|
---|
130 | { \
|
---|
131 | errno = (_thread)->md.errcode; \
|
---|
132 | _MD_SET_CURRENT_THREAD(_thread); \
|
---|
133 | _longjmp(CONTEXT(_thread), 1); \
|
---|
134 | }
|
---|
135 |
|
---|
136 | /* Machine-dependent (MD) data structures. HP-UX has no native threads. */
|
---|
137 |
|
---|
138 | struct _MDThread {
|
---|
139 | jmp_buf jb;
|
---|
140 | int id;
|
---|
141 | int errcode;
|
---|
142 | };
|
---|
143 |
|
---|
144 | struct _MDThreadStack {
|
---|
145 | PRInt8 notused;
|
---|
146 | };
|
---|
147 |
|
---|
148 | struct _MDLock {
|
---|
149 | PRInt8 notused;
|
---|
150 | };
|
---|
151 |
|
---|
152 | struct _MDSemaphore {
|
---|
153 | PRInt8 notused;
|
---|
154 | };
|
---|
155 |
|
---|
156 | struct _MDCVar {
|
---|
157 | PRInt8 notused;
|
---|
158 | };
|
---|
159 |
|
---|
160 | struct _MDSegment {
|
---|
161 | PRInt8 notused;
|
---|
162 | };
|
---|
163 |
|
---|
164 | /*
|
---|
165 | * md-specific cpu structure field
|
---|
166 | */
|
---|
167 | #define _PR_MD_MAX_OSFD FD_SETSIZE
|
---|
168 |
|
---|
169 | struct _MDCPU_Unix {
|
---|
170 | PRCList ioQ;
|
---|
171 | PRUint32 ioq_timeout;
|
---|
172 | PRInt32 ioq_max_osfd;
|
---|
173 | PRInt32 ioq_osfd_cnt;
|
---|
174 | #ifndef _PR_USE_POLL
|
---|
175 | fd_set fd_read_set, fd_write_set, fd_exception_set;
|
---|
176 | PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
|
---|
177 | fd_exception_cnt[_PR_MD_MAX_OSFD];
|
---|
178 | #else
|
---|
179 | struct pollfd *ioq_pollfds;
|
---|
180 | int ioq_pollfds_size;
|
---|
181 | #endif /* _PR_USE_POLL */
|
---|
182 | };
|
---|
183 |
|
---|
184 | #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
|
---|
185 | #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
|
---|
186 | #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
|
---|
187 | #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
|
---|
188 | #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
|
---|
189 | #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
|
---|
190 | #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
|
---|
191 | #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
|
---|
192 | #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
|
---|
193 | #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
|
---|
194 | #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
|
---|
195 | #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
|
---|
196 | #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
|
---|
197 |
|
---|
198 | #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
|
---|
199 |
|
---|
200 | struct _MDCPU {
|
---|
201 | struct _MDCPU_Unix md_unix;
|
---|
202 | };
|
---|
203 |
|
---|
204 | #define _MD_INIT_LOCKS()
|
---|
205 | #define _MD_NEW_LOCK(lock) PR_SUCCESS
|
---|
206 | #define _MD_FREE_LOCK(lock)
|
---|
207 | #define _MD_LOCK(lock)
|
---|
208 | #define _MD_UNLOCK(lock)
|
---|
209 | #define _MD_INIT_IO()
|
---|
210 | #define _MD_IOQ_LOCK()
|
---|
211 | #define _MD_IOQ_UNLOCK()
|
---|
212 |
|
---|
213 | #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
|
---|
214 | #define _MD_INIT_THREAD _MD_InitializeThread
|
---|
215 | #define _MD_EXIT_THREAD(thread)
|
---|
216 | #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
|
---|
217 | #define _MD_RESUME_THREAD(thread) _MD_resume_thread
|
---|
218 | #define _MD_CLEAN_THREAD(_thread)
|
---|
219 |
|
---|
220 | #else /* PTHREADS_USER */
|
---|
221 |
|
---|
222 | #include "_nspr_pthread.h"
|
---|
223 |
|
---|
224 | #endif /* PTHREADS_USER */
|
---|
225 |
|
---|
226 | #endif /* !defined(_PR_PTHREADS) */
|
---|
227 |
|
---|
228 | #if !defined(PTHREADS_USER)
|
---|
229 | #define _MD_EARLY_INIT _MD_EarlyInit
|
---|
230 | #define _MD_FINAL_INIT _PR_UnixInit
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | #if defined(HPUX_LW_TIMER)
|
---|
234 | extern void _PR_HPUX_LW_IntervalInit(void);
|
---|
235 | extern PRIntervalTime _PR_HPUX_LW_GetInterval(void);
|
---|
236 | #define _MD_INTERVAL_INIT _PR_HPUX_LW_IntervalInit
|
---|
237 | #define _MD_GET_INTERVAL _PR_HPUX_LW_GetInterval
|
---|
238 | #define _MD_INTERVAL_PER_SEC() 1000
|
---|
239 | #else
|
---|
240 | #define _MD_GET_INTERVAL _PR_UNIX_GetInterval
|
---|
241 | #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
|
---|
242 | #endif
|
---|
243 |
|
---|
244 | /*
|
---|
245 | * We wrapped the select() call. _MD_SELECT refers to the built-in,
|
---|
246 | * unwrapped version.
|
---|
247 | */
|
---|
248 | #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
|
---|
249 |
|
---|
250 | #include <poll.h>
|
---|
251 | #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
|
---|
252 |
|
---|
253 | #ifdef HPUX11
|
---|
254 | extern void _MD_hpux_map_sendfile_error(int err);
|
---|
255 | #endif /* HPUX11 */
|
---|
256 |
|
---|
257 | #endif /* nspr_xhppa_defs_h___ */
|
---|