Back to index

lightning-sunbird  0.9+nobinonly
_openvms.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 /*
00039 ** This is the OpenVMS machine dependant configuration file. It is based
00040 ** on the OSF/1 machine dependant file.
00041 */
00042 
00043 #ifndef nspr_openvms_defs_h___
00044 #define nspr_openvms_defs_h___
00045 
00046 /*
00047  * Internal configuration macros
00048  */
00049 
00050 #define PR_LINKER_ARCH      "OpenVMS"
00051 #define _PR_SI_SYSNAME      "OpenVMS"
00052 #ifdef __alpha
00053 #define _PR_SI_ARCHITECTURE "alpha"
00054 #else
00055 #define _PR_SI_ARCHITECTURE "vax"
00056 #endif
00057 #define PR_DLL_SUFFIX              ".so"
00058 
00059 #define _PR_VMBASE          0x30000000
00060 #define _PR_STACK_VMBASE    0x50000000
00061 #define _MD_DEFAULT_STACK_SIZE     131072L
00062 #define _MD_MINIMUM_STACK_SIZE     131072L
00063 
00064 /*
00065 ** This is not defined on OpenVMS. I believe its only used in GC code, and
00066 ** isn't that only used in Java? Anyway, for now, let's keep the compiler
00067 ** happy.
00068 */
00069 #define SA_RESTART 0
00070 
00071 /*
00072 ** OpenVMS doesn't have these in socket.h.
00073 ** Does in later versions!
00074 */
00075 #if 0
00076 struct ip_mreq {
00077     struct in_addr  imr_multiaddr;      /* IP multicast address of group */
00078     struct in_addr  imr_interface;      /* local IP address of interface */
00079 };
00080 #endif
00081 
00082 /*
00083  * OSF1 needs the MAP_FIXED flag to ensure that mmap returns a pointer
00084  * with the upper 32 bits zero.  This is because Java sticks a pointer
00085  * into an int.
00086  */
00087 #define _MD_MMAP_FLAGS          MAP_PRIVATE|MAP_FIXED
00088 
00089 #undef  HAVE_STACK_GROWING_UP
00090 #undef        HAVE_WEAK_IO_SYMBOLS
00091 #undef        HAVE_WEAK_MALLOC_SYMBOLS
00092 #undef  HAVE_BSD_FLOCK
00093 
00094 #define NEED_TIME_R
00095 
00096 #define HAVE_DLL
00097 #define USE_DLFCN
00098 
00099 #define _PR_POLL_AVAILABLE
00100 #define _PR_USE_POLL
00101 #define _PR_STAT_HAS_ONLY_ST_ATIME
00102 #define _PR_NO_LARGE_FILES
00103 #define _PR_STRICT_ADDR_LEN
00104 #define _PR_NEED_SECRET_AF
00105 
00106 /* IPv6 support */
00107 #ifdef _SOCKADDR_LEN
00108 #define _PR_HAVE_SOCKADDR_LEN
00109 #endif
00110 #define _PR_HAVE_GETIPNODEBYNAME
00111 #define _PR_HAVE_GETIPNODEBYADDR
00112 #define _PR_HAVE_GETADDRINFO
00113 #define _PR_INET6_PROBE
00114 #ifdef _PR_INET6
00115 #define _PR_HAVE_INET_NTOP
00116 #else
00117 #define AF_INET6 26
00118 #ifndef AI_CANONNAME
00119 #define AI_CANONNAME 0x00000002
00120 struct addrinfo {
00121     int ai_flags;
00122     int ai_family;
00123     int ai_socktype;
00124     int ai_protocol;
00125     size_t ai_addrlen;
00126     char *ai_canonname;
00127     struct sockaddr *ai_addr;
00128     struct addrinfo *ai_next;
00129 };
00130 #endif
00131 #define AI_V4MAPPED 0x00000010
00132 #define AI_ALL      0x00000008
00133 #define AI_ADDRCONFIG 0x00000020
00134 #endif
00135 
00136 #define _PR_HAVE_MD_SOCKADDR_IN6
00137 /* if we have a quadword field defined in the structure, then its length */
00138 /* will be a multiple of 8, and connect() won't accept 32 (it wants 28) */
00139 struct _md_in6_addr {
00140     union {
00141         PRUint8  _S6_u8[16];
00142         PRUint16 _S6_u16[8];
00143         PRUint32 _S6_u32[4];
00144     } _S6_un;
00145 };
00146 struct _md_sockaddr_in6 {
00147     PRUint16 sin6_family;
00148     PRUint16 sin6_port;
00149     PRUint32 sin6_flowinfo;
00150     struct _md_in6_addr sin6_addr;
00151     PRUint32 sin6_scope_id;
00152 };
00153 
00154 #undef  USE_SETJMP
00155 
00156 #include <setjmp.h>
00157 
00158 /*
00159  * A jmp_buf is actually a struct sigcontext.  The sc_sp field of
00160  * struct sigcontext is the stack pointer.
00161  */
00162 #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp)
00163 #define PR_NUM_GCREGS _JBLEN
00164 #define CONTEXT(_th) ((_th)->md.context)
00165 
00166 /*
00167 ** I am ifdef'ing these out because that's the way they are in FT.
00168 */
00169 #ifndef __VMS
00170 
00171 /*
00172 ** Initialize a thread context to run "_main()" when started
00173 */
00174 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \
00175 {                                                                \
00176         *status = PR_TRUE;              \
00177     if (setjmp(CONTEXT(_thread))) {                            \
00178        (*_main)();                                      \
00179     }                                                   \
00180     _MD_GET_SP(_thread) = (long) ((_sp) - 64);                 \
00181     _MD_GET_SP(_thread) &= ~15;                                \
00182 }
00183 
00184 #define _MD_SWITCH_CONTEXT(_thread)  \
00185     if (!setjmp(CONTEXT(_thread))) { \
00186        (_thread)->md.errcode = errno;  \
00187        _PR_Schedule();                  \
00188     }
00189 
00190 /*
00191 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00192 */
00193 #define _MD_RESTORE_CONTEXT(_thread) \
00194 {                                \
00195     errno = (_thread)->md.errcode;     \
00196     _MD_SET_CURRENT_THREAD(_thread);      \
00197     longjmp(CONTEXT(_thread), 1);    \
00198 }
00199 
00200 #endif /* __VMS */
00201 
00202 /* Machine-dependent (MD) data structures */
00203 
00204 struct _MDThread {
00205     jmp_buf context;
00206     int id;
00207     int errcode;
00208 };
00209 
00210 struct _MDThreadStack {
00211     PRInt8 notused;
00212 };
00213 
00214 struct _MDLock {
00215     PRInt8 notused;
00216 };
00217 
00218 struct _MDSemaphore {
00219     PRInt8 notused;
00220 };
00221 
00222 struct _MDCVar {
00223     PRInt8 notused;
00224 };
00225 
00226 struct _MDSegment {
00227     PRInt8 notused;
00228 };
00229 
00230 /*
00231  * md-specific cpu structure field
00232  */
00233 #define _PR_MD_MAX_OSFD FD_SETSIZE
00234 
00235 struct _MDCPU_Unix {
00236     PRCList ioQ;
00237     PRUint32 ioq_timeout;
00238     PRInt32 ioq_max_osfd;
00239     PRInt32 ioq_osfd_cnt;
00240 #ifndef _PR_USE_POLL
00241     fd_set fd_read_set, fd_write_set, fd_exception_set;
00242     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00243                               fd_exception_cnt[_PR_MD_MAX_OSFD];
00244 #else
00245       struct pollfd *ioq_pollfds;
00246       int ioq_pollfds_size;
00247 #endif        /* _PR_USE_POLL */
00248 };
00249 
00250 #define _PR_IOQ(_cpu)                 ((_cpu)->md.md_unix.ioQ)
00251 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00252 #define _PR_FD_READ_SET(_cpu)         ((_cpu)->md.md_unix.fd_read_set)
00253 #define _PR_FD_READ_CNT(_cpu)         ((_cpu)->md.md_unix.fd_read_cnt)
00254 #define _PR_FD_WRITE_SET(_cpu)                ((_cpu)->md.md_unix.fd_write_set)
00255 #define _PR_FD_WRITE_CNT(_cpu)                ((_cpu)->md.md_unix.fd_write_cnt)
00256 #define _PR_FD_EXCEPTION_SET(_cpu)    ((_cpu)->md.md_unix.fd_exception_set)
00257 #define _PR_FD_EXCEPTION_CNT(_cpu)    ((_cpu)->md.md_unix.fd_exception_cnt)
00258 #define _PR_IOQ_TIMEOUT(_cpu)         ((_cpu)->md.md_unix.ioq_timeout)
00259 #define _PR_IOQ_MAX_OSFD(_cpu)                ((_cpu)->md.md_unix.ioq_max_osfd)
00260 #define _PR_IOQ_OSFD_CNT(_cpu)                ((_cpu)->md.md_unix.ioq_osfd_cnt)
00261 #define _PR_IOQ_POLLFDS(_cpu)         ((_cpu)->md.md_unix.ioq_pollfds)
00262 #define _PR_IOQ_POLLFDS_SIZE(_cpu)    ((_cpu)->md.md_unix.ioq_pollfds_size)
00263 
00264 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)        32
00265 
00266 struct _MDCPU {
00267        struct _MDCPU_Unix md_unix;
00268 };
00269 
00270 #ifndef _PR_PTHREADS
00271 #define _MD_INIT_LOCKS()
00272 #endif
00273 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00274 #define _MD_FREE_LOCK(lock)
00275 #define _MD_LOCK(lock)
00276 #define _MD_UNLOCK(lock)
00277 #define _MD_INIT_IO()
00278 #define _MD_IOQ_LOCK()
00279 #define _MD_IOQ_UNLOCK()
00280 
00281 /*
00282  * The following are copied from _sunos.h, _aix.h.  This means
00283  * some of them should probably be moved into _unixos.h.  But
00284  * _irix.h seems to be quite different in regard to these macros.
00285  */
00286 #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
00287 extern PRIntervalTime _PR_UNIX_GetInterval(void);
00288 #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
00289 extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
00290 
00291 #define _MD_EARLY_INIT             _MD_EarlyInit
00292 void _MD_EarlyInit(void);
00293 #define _MD_FINAL_INIT             _PR_UnixInit
00294 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
00295 #define _MD_INIT_THREAD         _MD_InitializeThread
00296 #ifdef _VMS_NOT_YET
00297 NSPR_API(void) _PR_InitThreads(
00298   PRThreadType type, PRThreadPriority priority, PRUintn maxPTDs);
00299 #endif
00300 #define _MD_EXIT_THREAD(thread)
00301 #define       _MD_SUSPEND_THREAD(thread)
00302 #define       _MD_RESUME_THREAD(thread)
00303 #define _MD_CLEAN_THREAD(_thread)
00304 
00305 /* The following defines unwrapped versions of select() and poll(). */
00306 extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
00307 #define _MD_SELECT              __select
00308 
00309 #ifndef __VMS
00310 #define _MD_POLL __poll
00311 extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout);
00312 #endif
00313 
00314 #ifdef __VMS
00315 NSPR_API(void) _PR_InitCPUs(void);
00316 NSPR_API(void) _PR_MD_START_INTERRUPTS(void);
00317 #endif
00318 
00319 /*
00320  * Atomic operations
00321  */
00322 #include <machine/builtins.h>
00323 #define _PR_HAVE_ATOMIC_OPS
00324 #define _MD_INIT_ATOMIC()
00325 #define _MD_ATOMIC_ADD(ptr,val) (__ATOMIC_ADD_LONG(ptr,val) + val)
00326 #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1)
00327 #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1)
00328 #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval)
00329 
00330 extern int thread_suspend(PRThread *thr_id);
00331 extern int thread_resume(PRThread *thr_id);
00332 
00333 #endif /* nspr_openvms_defs_h___ */