Back to index

lightning-sunbird  0.9+nobinonly
_hpux.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nspr_xhppa_defs_h___
00039 #define nspr_xhppa_defs_h___
00040 
00041 /*
00042  * Internal configuration macros
00043  */
00044 
00045 #define PR_LINKER_ARCH    "hpux"
00046 #define _PR_SI_SYSNAME   "HPUX"
00047 #ifdef __ia64
00048 #define _PR_SI_ARCHITECTURE "ia64"
00049 #define PR_DLL_SUFFIX        ".so"
00050 #else
00051 /*
00052  * _PR_SI_ARCHITECTURE must be "hppa1.1" for backward compatibility.
00053  * It was changed to "hppa" in NSPR 4.6.2, but was changed back in
00054  * NSPR 4.6.4.
00055  */
00056 #define _PR_SI_ARCHITECTURE "hppa1.1"
00057 #define PR_DLL_SUFFIX        ".sl"
00058 #endif
00059 
00060 #define _PR_VMBASE        0x30000000 
00061 #define _PR_STACK_VMBASE    0x50000000
00062 /*
00063  * _USE_BIG_FDS increases the size of fd_set from 256 bytes to
00064  * about 7500 bytes.  PR_Poll allocates three fd_sets on the
00065  * stack, so it is safer to also increase the default thread
00066  * stack size.
00067  */
00068 #define _MD_DEFAULT_STACK_SIZE    (2*65536L)
00069 #define _MD_MINIMUM_STACK_SIZE    (2*65536L)
00070 #define _MD_MMAP_FLAGS          MAP_PRIVATE
00071 
00072 #define NEED_TIME_R
00073 
00074 #define HAVE_STACK_GROWING_UP
00075 #undef HAVE_WEAK_IO_SYMBOLS
00076 #undef HAVE_WEAK_MALLOC_SYMBOLS
00077 #define       HAVE_DLL
00078 #ifdef IS_64
00079 #define USE_DLFCN
00080 #else
00081 #define USE_HPSHL
00082 #endif
00083 #ifndef HAVE_STRERROR
00084 #define HAVE_STRERROR
00085 #endif
00086 #define _PR_POLL_AVAILABLE
00087 #define _PR_USE_POLL
00088 #define _PR_STAT_HAS_ONLY_ST_ATIME
00089 #define _PR_HAVE_POSIX_SEMAPHORES
00090 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
00091 #define _PR_ACCEPT_INHERIT_NONBLOCK
00092 
00093 #if defined(__ia64)
00094 #define _PR_HAVE_ATOMIC_OPS
00095 #define _MD_INIT_ATOMIC()
00096 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
00097 #define _MD_ATOMIC_INCREMENT          _PR_ia64_AtomicIncrement
00098 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
00099 #define _MD_ATOMIC_DECREMENT          _PR_ia64_AtomicDecrement
00100 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
00101 #define _MD_ATOMIC_ADD                _PR_ia64_AtomicAdd
00102 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
00103 #define _MD_ATOMIC_SET                _PR_ia64_AtomicSet
00104 #endif
00105 
00106 #define _PR_HAVE_GETIPNODEBYNAME
00107 #define _PR_HAVE_GETIPNODEBYADDR
00108 #define _PR_HAVE_GETADDRINFO
00109 #ifdef _PR_INET6
00110 #define _PR_HAVE_INET_NTOP
00111 #else
00112 #define _PR_INET6_PROBE
00113 #define _PR_HAVE_MD_SOCKADDR_IN6
00114 /* isomorphic to struct in6_addr on HP-UX B.11.23 */
00115 struct _md_in6_addr {
00116     union {
00117         PRUint8   _S6_u8[16];
00118         PRUint16  _S6_u16[8];
00119         PRUint32  _S6_u32[4];
00120         PRUint32  __S6_align;
00121     } _s6_un;
00122 };
00123 /* isomorphic to struct sockaddr_in6 on HP-UX B.11.23 */
00124 struct _md_sockaddr_in6 {
00125     PRUint16 sin6_family;
00126     PRUint16 sin6_port;
00127     PRUint32 sin6_flowinfo;
00128     struct _md_in6_addr sin6_addr;
00129     PRUint32 sin6_scope_id;
00130 };
00131 #endif
00132 
00133 #if !defined(_PR_PTHREADS)
00134 
00135 #include <syscall.h>
00136 #include <setjmp.h>
00137 
00138 #define USE_SETJMP
00139 
00140 #define _MD_GET_SP(_t) (*((int *)((_t)->md.jb) + 1))
00141 #define PR_NUM_GCREGS _JBLEN
00142 /* Caveat: This makes jmp_buf full of doubles. */
00143 #define CONTEXT(_th) ((_th)->md.jb)
00144 
00145     /* Stack needs two frames (64 bytes) at the bottom */ \
00146 #define _MD_SET_THR_SP(_t, _sp)     ((_MD_GET_SP(_t)) = (int) (_sp + 64 *2))
00147 #define SAVE_CONTEXT(_th)           _setjmp(CONTEXT(_th))
00148 #define GOTO_CONTEXT(_th)           _longjmp(CONTEXT(_th), 1)
00149 
00150 #if !defined(PTHREADS_USER)
00151 
00152 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
00153 { \
00154     *(status) = PR_TRUE; \
00155     if (_setjmp(CONTEXT(_thread))) (*_main)(); \
00156     /* Stack needs two frames (64 bytes) at the bottom */ \
00157     (_MD_GET_SP(_thread)) = (int) ((_sp) + 64*2); \
00158 }
00159 
00160 #define _MD_SWITCH_CONTEXT(_thread) \
00161     if (!_setjmp(CONTEXT(_thread))) { \
00162     (_thread)->md.errcode = errno; \
00163     _PR_Schedule(); \
00164     }
00165 
00166 /*
00167 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00168 */
00169 #define _MD_RESTORE_CONTEXT(_thread) \
00170 { \
00171     errno = (_thread)->md.errcode; \
00172     _MD_SET_CURRENT_THREAD(_thread); \
00173     _longjmp(CONTEXT(_thread), 1); \
00174 }
00175 
00176 /* Machine-dependent (MD) data structures.  HP-UX has no native threads. */
00177 
00178 struct _MDThread {
00179     jmp_buf jb;
00180     int id;
00181     int errcode;
00182 };
00183 
00184 struct _MDThreadStack {
00185     PRInt8 notused;
00186 };
00187 
00188 struct _MDLock {
00189     PRInt8 notused;
00190 };
00191 
00192 struct _MDSemaphore {
00193     PRInt8 notused;
00194 };
00195 
00196 struct _MDCVar {
00197     PRInt8 notused;
00198 };
00199 
00200 struct _MDSegment {
00201     PRInt8 notused;
00202 };
00203 
00204 /*
00205  * md-specific cpu structure field
00206  */
00207 #define _PR_MD_MAX_OSFD FD_SETSIZE
00208 
00209 struct _MDCPU_Unix {
00210     PRCList ioQ;
00211     PRUint32 ioq_timeout;
00212     PRInt32 ioq_max_osfd;
00213     PRInt32 ioq_osfd_cnt;
00214 #ifndef _PR_USE_POLL
00215     fd_set fd_read_set, fd_write_set, fd_exception_set;
00216     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00217                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00218 #else
00219        struct pollfd *ioq_pollfds;
00220        int ioq_pollfds_size;
00221 #endif /* _PR_USE_POLL */
00222 };
00223 
00224 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00225 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00226 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00227 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00228 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00229 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00230 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00231 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00232 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00233 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00234 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00235 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00236 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00237 
00238 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00239 
00240 struct _MDCPU {
00241     struct _MDCPU_Unix md_unix;
00242 };
00243 
00244 #define _MD_INIT_LOCKS()
00245 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00246 #define _MD_FREE_LOCK(lock)
00247 #define _MD_LOCK(lock)
00248 #define _MD_UNLOCK(lock)
00249 #define _MD_INIT_IO()
00250 #define _MD_IOQ_LOCK()
00251 #define _MD_IOQ_UNLOCK()
00252 
00253 #define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
00254 #define _MD_INIT_THREAD                 _MD_InitializeThread
00255 #define _MD_EXIT_THREAD(thread)
00256 #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
00257 #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
00258 #define _MD_CLEAN_THREAD(_thread)
00259 
00260 #else /* PTHREADS_USER      */
00261 
00262 #include "_nspr_pthread.h"
00263 
00264 #endif /* PTHREADS_USER     */
00265 
00266 #endif  /* !defined(_PR_PTHREADS) */
00267 
00268 #if !defined(PTHREADS_USER)
00269 #define _MD_EARLY_INIT                    _MD_EarlyInit
00270 #define _MD_FINAL_INIT                                  _PR_UnixInit
00271 #endif 
00272 
00273 #if defined(HPUX_LW_TIMER)
00274 extern void _PR_HPUX_LW_IntervalInit(void);
00275 extern PRIntervalTime _PR_HPUX_LW_GetInterval(void);
00276 #define _MD_INTERVAL_INIT                 _PR_HPUX_LW_IntervalInit
00277 #define _MD_GET_INTERVAL                  _PR_HPUX_LW_GetInterval
00278 #define _MD_INTERVAL_PER_SEC()            1000
00279 #else
00280 #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
00281 #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
00282 #endif
00283 
00284 /*
00285  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
00286  * unwrapped version.
00287  */
00288 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
00289 
00290 #include <poll.h>
00291 #define _MD_POLL(fds,nfds,timeout) syscall(SYS_poll,fds,nfds,timeout)
00292 
00293 #ifdef HPUX11
00294 extern void _MD_hpux_map_sendfile_error(int err);
00295 #endif /* HPUX11 */
00296 
00297 #endif /* nspr_xhppa_defs_h___ */