Back to index

lightning-sunbird  0.9+nobinonly
_osf1.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_osf1_defs_h___
00039 #define nspr_osf1_defs_h___
00040 
00041 /*
00042  * Internal configuration macros
00043  */
00044 
00045 #define PR_LINKER_ARCH      "osf"
00046 #define _PR_SI_SYSNAME      "OSF"
00047 #define _PR_SI_ARCHITECTURE "alpha"
00048 #define PR_DLL_SUFFIX              ".so"
00049 
00050 #define _PR_VMBASE              0x30000000
00051 #define _PR_STACK_VMBASE        0x50000000
00052 #define _MD_DEFAULT_STACK_SIZE  131072L
00053 #define _MD_MMAP_FLAGS          MAP_PRIVATE
00054 
00055 #undef  HAVE_STACK_GROWING_UP
00056 #undef        HAVE_WEAK_IO_SYMBOLS
00057 #undef        HAVE_WEAK_MALLOC_SYMBOLS
00058 #define HAVE_DLL
00059 #define HAVE_BSD_FLOCK
00060 
00061 #define NEED_TIME_R
00062 #define USE_DLFCN
00063 
00064 #define _PR_POLL_AVAILABLE
00065 #define _PR_USE_POLL
00066 #define _PR_STAT_HAS_ONLY_ST_ATIME
00067 #define _PR_HAVE_LARGE_OFF_T
00068 #define _PR_HAVE_GETIPNODEBYNAME
00069 #define _PR_HAVE_GETIPNODEBYADDR
00070 #define _PR_HAVE_GETADDRINFO
00071 #define _PR_INET6_PROBE
00072 #ifdef _PR_INET6
00073 #define _PR_HAVE_INET_NTOP
00074 #else
00075 #define AF_INET6 26
00076 #ifndef AI_CANONNAME
00077 #define AI_CANONNAME 0x00000002
00078 struct addrinfo {
00079     int              ai_flags;
00080     int              ai_family;
00081     int              ai_socktype;
00082     int              ai_protocol;
00083     size_t           ai_addrlen;
00084     char            *ai_canonname;
00085     struct sockaddr *ai_addr;
00086     struct addrinfo *ai_next;
00087 };
00088 #endif
00089 #define AI_V4MAPPED 0x00000010
00090 #define AI_ALL      0x00000008
00091 #define AI_ADDRCONFIG 0x00000020
00092 #endif
00093 #define _PR_HAVE_POSIX_SEMAPHORES
00094 #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY
00095 
00096 #define USE_SETJMP
00097 
00098 #include <setjmp.h>
00099 
00100 /*
00101  * A jmp_buf is actually a struct sigcontext.  The sc_sp field of
00102  * struct sigcontext is the stack pointer.
00103  */
00104 #define _MD_GET_SP(_t) (((struct sigcontext *) (_t)->md.context)->sc_sp)
00105 #define PR_NUM_GCREGS _JBLEN
00106 #define CONTEXT(_th) ((_th)->md.context)
00107 
00108 /*
00109 ** Initialize a thread context to run "_main()" when started
00110 */
00111 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \
00112 {                                                                \
00113         *status = PR_TRUE;              \
00114     if (setjmp(CONTEXT(_thread))) {                            \
00115        (*_main)();                                      \
00116     }                                                   \
00117     _MD_GET_SP(_thread) = (long) ((_sp) - 64);                 \
00118     _MD_GET_SP(_thread) &= ~15;                                \
00119 }
00120 
00121 #define _MD_SWITCH_CONTEXT(_thread)  \
00122     if (!setjmp(CONTEXT(_thread))) { \
00123        (_thread)->md.errcode = errno;  \
00124        _PR_Schedule();                  \
00125     }
00126 
00127 /*
00128 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00129 */
00130 #define _MD_RESTORE_CONTEXT(_thread) \
00131 {                                \
00132     errno = (_thread)->md.errcode;     \
00133     _MD_SET_CURRENT_THREAD(_thread);      \
00134     longjmp(CONTEXT(_thread), 1);    \
00135 }
00136 
00137 /* Machine-dependent (MD) data structures */
00138 
00139 struct _MDThread {
00140     jmp_buf context;
00141     int id;
00142     int errcode;
00143 };
00144 
00145 struct _MDThreadStack {
00146     PRInt8 notused;
00147 };
00148 
00149 struct _MDLock {
00150     PRInt8 notused;
00151 };
00152 
00153 struct _MDSemaphore {
00154     PRInt8 notused;
00155 };
00156 
00157 struct _MDCVar {
00158     PRInt8 notused;
00159 };
00160 
00161 struct _MDSegment {
00162     PRInt8 notused;
00163 };
00164 
00165 /*
00166  * md-specific cpu structure field
00167  */
00168 #define _PR_MD_MAX_OSFD FD_SETSIZE
00169 
00170 struct _MDCPU_Unix {
00171     PRCList ioQ;
00172     PRUint32 ioq_timeout;
00173     PRInt32 ioq_max_osfd;
00174     PRInt32 ioq_osfd_cnt;
00175 #ifndef _PR_USE_POLL
00176     fd_set fd_read_set, fd_write_set, fd_exception_set;
00177     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00178                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00179 #else
00180        struct pollfd *ioq_pollfds;
00181        int ioq_pollfds_size;
00182 #endif /* _PR_USE_POLL */
00183 };
00184 
00185 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00186 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00187 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00188 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00189 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00190 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00191 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00192 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00193 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00194 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00195 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00196 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00197 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00198 
00199 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00200 
00201 struct _MDCPU {
00202        struct _MDCPU_Unix md_unix;
00203 };
00204 
00205 #ifndef _PR_PTHREADS
00206 #define _MD_INIT_LOCKS()
00207 #endif
00208 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00209 #define _MD_FREE_LOCK(lock)
00210 #define _MD_LOCK(lock)
00211 #define _MD_UNLOCK(lock)
00212 #define _MD_INIT_IO()
00213 #define _MD_IOQ_LOCK()
00214 #define _MD_IOQ_UNLOCK()
00215 
00216 /*
00217  * The following are copied from _sunos.h, _aix.h.  This means
00218  * some of them should probably be moved into _unixos.h.  But
00219  * _irix.h seems to be quite different in regard to these macros.
00220  */
00221 #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
00222 #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
00223 
00224 #define _MD_EARLY_INIT             _MD_EarlyInit
00225 #define _MD_FINAL_INIT             _PR_UnixInit
00226 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
00227 #define _MD_INIT_THREAD         _MD_InitializeThread
00228 #define _MD_EXIT_THREAD(thread)
00229 #define       _MD_SUSPEND_THREAD(thread)
00230 #define       _MD_RESUME_THREAD(thread)
00231 #define _MD_CLEAN_THREAD(_thread)
00232 
00233 /* The following defines unwrapped versions of select() and poll(). */
00234 #include <sys/time.h>
00235 extern int __select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
00236 #define _MD_SELECT              __select
00237 
00238 #include <sys/poll.h>
00239 #define _MD_POLL __poll
00240 extern int __poll(struct pollfd filedes[], unsigned int nfds, int timeout);
00241 
00242 /*
00243  * Atomic operations
00244  */
00245 #ifdef OSF1_HAVE_MACHINE_BUILTINS_H
00246 #include <machine/builtins.h>
00247 #define _PR_HAVE_ATOMIC_OPS
00248 #define _MD_INIT_ATOMIC()
00249 #define _MD_ATOMIC_INCREMENT(val) (__ATOMIC_INCREMENT_LONG(val) + 1)
00250 #define _MD_ATOMIC_ADD(ptr, val)  (__ATOMIC_ADD_LONG(ptr, val) + val)
00251 #define _MD_ATOMIC_DECREMENT(val) (__ATOMIC_DECREMENT_LONG(val) - 1)
00252 #define _MD_ATOMIC_SET(val, newval) __ATOMIC_EXCH_LONG(val, newval)
00253 #endif /* OSF1_HAVE_MACHINE_BUILTINS_H */
00254 
00255 #endif /* nspr_osf1_defs_h___ */