Back to index

lightning-sunbird  0.9+nobinonly
_bsdi.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_bsdi_defs_h___
00039 #define nspr_bsdi_defs_h___
00040 
00041 /*
00042  * Internal configuration macros
00043  */
00044 
00045 #include <sys/param.h>      /* for _BSDI_VERSION */
00046 
00047 #define PR_LINKER_ARCH      "bsdi"
00048 #define _PR_SI_SYSNAME "BSDI"
00049 #if defined(__i386__)
00050 #define _PR_SI_ARCHITECTURE "x86"
00051 #elif defined(__sparc__)
00052 #define _PR_SI_ARCHITECTURE "sparc"
00053 #else
00054 #error "Unknown CPU architecture"
00055 #endif
00056 #define PR_DLL_SUFFIX              ".so"
00057 
00058 #define _PR_STACK_VMBASE    0x50000000
00059 #define _MD_DEFAULT_STACK_SIZE     65536L
00060 #define _MD_MMAP_FLAGS          MAP_PRIVATE
00061 
00062 #define HAVE_BSD_FLOCK
00063 #define NEED_TIME_R
00064 #define _PR_HAVE_SOCKADDR_LEN
00065 #define _PR_NO_LARGE_FILES
00066 
00067 #define USE_SETJMP
00068 
00069 /* BSD/OS 4.3 and newer all have IPv6 support */
00070 #if _BSDI_VERSION >= 200105
00071 #define _PR_INET6
00072 #define _PR_HAVE_INET_NTOP
00073 #define _PR_HAVE_GETIPNODEBYNAME
00074 #define _PR_HAVE_GETIPNODEBYADDR
00075 #define _PR_HAVE_GETADDRINFO
00076 #define _PR_INET6_PROBE
00077 #endif
00078 
00079 #ifndef _PR_PTHREADS
00080 
00081 #include <setjmp.h>
00082 
00083 #if defined(_PR_BSDI_JMPBUF_IS_ARRAY)
00084 #define _MD_GET_SP(_t)    (_t)->md.context[2] 
00085 #elif defined(_PR_BSDI_JMPBUF_IS_STRUCT)
00086 #define _MD_GET_SP(_t)    (_t)->md.context[0].jb_esp
00087 #else
00088 #error "Unknown BSDI jmp_buf type"
00089 #endif
00090 
00091 #define PR_NUM_GCREGS       _JBLEN
00092 #define PR_CONTEXT_TYPE     jmp_buf
00093 
00094 #define CONTEXT(_th) ((_th)->md.context)
00095 
00096 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)     \
00097 {                                                         \
00098     *status = PR_TRUE; \
00099     if (setjmp(CONTEXT(_thread))) {                              \
00100        _main();                                    \
00101     }                                                     \
00102     _MD_GET_SP(_thread) = (int) (_sp - 64); \
00103 }
00104 
00105 #define _MD_SWITCH_CONTEXT(_thread)  \
00106     if (!setjmp(CONTEXT(_thread))) { \
00107        (_thread)->md.errcode = errno;  \
00108        _PR_Schedule();                  \
00109     }
00110 
00111 /*
00112 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00113 */
00114 #define _MD_RESTORE_CONTEXT(_thread) \
00115 {                                \
00116     errno = (_thread)->md.errcode;      \
00117     _MD_SET_CURRENT_THREAD(_thread); \
00118     longjmp(CONTEXT(_thread), 1);    \
00119 }
00120 
00121 /* Machine-dependent (MD) data structures */
00122 
00123 struct _MDThread {
00124     PR_CONTEXT_TYPE context;
00125     int id;
00126     int errcode;
00127 };
00128 
00129 struct _MDThreadStack {
00130     PRInt8 notused;
00131 };
00132 
00133 struct _MDLock {
00134     PRInt8 notused;
00135 };
00136 
00137 struct _MDSemaphore {
00138     PRInt8 notused;
00139 };
00140 
00141 struct _MDCVar {
00142     PRInt8 notused;
00143 };
00144 
00145 struct _MDSegment {
00146     PRInt8 notused;
00147 };
00148 
00149 /*
00150  * md-specific cpu structure field
00151  */
00152 #define _PR_MD_MAX_OSFD FD_SETSIZE
00153 
00154 struct _MDCPU_Unix {
00155     PRCList ioQ;
00156     PRUint32 ioq_timeout;
00157     PRInt32 ioq_max_osfd;
00158     PRInt32 ioq_osfd_cnt;
00159 #ifndef _PR_USE_POLL
00160     fd_set fd_read_set, fd_write_set, fd_exception_set;
00161     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00162                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00163 #else
00164        struct pollfd *ioq_pollfds;
00165        int ioq_pollfds_size;
00166 #endif /* _PR_USE_POLL */
00167 };
00168 
00169 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00170 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00171 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00172 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00173 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00174 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00175 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00176 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00177 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00178 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00179 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00180 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00181 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00182 
00183 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00184 
00185 struct _MDCPU {
00186        struct _MDCPU_Unix md_unix;
00187 };
00188 
00189 #define _MD_INIT_LOCKS()
00190 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00191 #define _MD_FREE_LOCK(lock)
00192 #define _MD_LOCK(lock)
00193 #define _MD_UNLOCK(lock)
00194 #define _MD_INIT_IO()
00195 #define _MD_IOQ_LOCK()
00196 #define _MD_IOQ_UNLOCK()
00197 
00198 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
00199 #define _MD_INIT_THREAD         _MD_InitializeThread
00200 #define _MD_EXIT_THREAD(thread)
00201 #define _MD_CLEAN_THREAD(_thread)
00202 
00203 #endif /* ! _PR_PTHREADS */
00204 
00205 #define _MD_EARLY_INIT          _MD_EarlyInit
00206 #define _MD_FINAL_INIT                    _PR_UnixInit
00207 
00208 #include <sys/syscall.h>
00209 #define _MD_SELECT(nfds,r,w,e,tv) syscall(SYS_select,nfds,r,w,e,tv)
00210 
00211 #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
00212 #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
00213 
00214 #endif /* nspr_bsdi_defs_h___ */