1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 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/
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.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
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
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
35 #ifndef nspr_xhppa_defs_h___
36 #define nspr_xhppa_defs_h___
39 * Internal configuration macros
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"
47 #define _PR_VMBASE 0x30000000
48 #define _PR_STACK_VMBASE 0x50000000
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
55 #define _MD_DEFAULT_STACK_SIZE (2*65536L)
56 #define _MD_MINIMUM_STACK_SIZE (2*65536L)
57 #define _MD_MMAP_FLAGS MAP_PRIVATE
61 #define HAVE_STACK_GROWING_UP
62 #undef HAVE_WEAK_IO_SYMBOLS
63 #undef HAVE_WEAK_MALLOC_SYMBOLS
73 #define _PR_POLL_AVAILABLE
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
80 #undef _PR_HAVE_ATOMIC_OPS
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
90 #if !defined(_PR_PTHREADS)
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)
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)
107 #if !defined(PTHREADS_USER)
109 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
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); \
117 #define _MD_SWITCH_CONTEXT(_thread) \
118 if (!_setjmp(CONTEXT(_thread))) { \
119 (_thread)->md.errcode = errno; \
124 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
126 #define _MD_RESTORE_CONTEXT(_thread) \
128 errno = (_thread)->md.errcode; \
129 _MD_SET_CURRENT_THREAD(_thread); \
130 _longjmp(CONTEXT(_thread), 1); \
133 /* Machine-dependent (MD) data structures. HP-UX has no native threads. */
141 struct _MDThreadStack
{
149 struct _MDSemaphore
{
162 * md-specific cpu structure field
164 #define _PR_MD_MAX_OSFD FD_SETSIZE
168 PRUint32 ioq_timeout
;
169 PRInt32 ioq_max_osfd
;
170 PRInt32 ioq_osfd_cnt
;
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
];
176 struct pollfd
*ioq_pollfds
;
177 int ioq_pollfds_size
;
178 #endif /* _PR_USE_POLL */
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)
195 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
198 struct _MDCPU_Unix md_unix
;
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()
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)
217 #else /* PTHREADS_USER */
219 #include "_nspr_pthread.h"
221 #endif /* PTHREADS_USER */
223 #endif /* !defined(_PR_PTHREADS) */
225 #if !defined(PTHREADS_USER)
226 #define _MD_EARLY_INIT _MD_EarlyInit
227 #define _MD_FINAL_INIT _PR_UnixInit
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
237 #define _MD_GET_INTERVAL _PR_UNIX_GetInterval
238 #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
242 * We wrapped the select() call. _MD_SELECT refers to the built-in,
245 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
248 #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
251 extern void _MD_hpux_map_sendfile_error(int err
);
254 #endif /* nspr_xhppa_defs_h___ */