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