Back to index

lightning-sunbird  0.9+nobinonly
_aix.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_aix_defs_h___
00039 #define nspr_aix_defs_h___
00040 
00041 #include <sys/types.h>
00042 #if defined(_PR_PTHREADS) || defined(PTHREADS_USER)
00043 #include <pthread.h>
00044 #endif
00045 
00046 /*
00047  * To pick up fd_set and the poll events.
00048  */
00049 #include <sys/select.h>
00050 #include <sys/poll.h>
00051 
00052 /*
00053  * Internal configuration macros
00054  */
00055 
00056 #define PR_LINKER_ARCH          "aix"
00057 #define _PR_SI_SYSNAME                 "AIX"
00058 #define _PR_SI_ARCHITECTURE     "rs6000"
00059 #define PR_DLL_SUFFIX                  ".so"
00060 
00061 #define _PR_VMBASE                  0x30000000
00062 #define _PR_STACK_VMBASE        0x50000000
00063 #define _MD_DEFAULT_STACK_SIZE     (2*65536L)
00064 #define _MD_MINIMUM_STACK_SIZE     (2*65536L)
00065 #define _MD_MMAP_FLAGS                 MAP_PRIVATE
00066 
00067 #define NEED_TIME_R
00068 #undef  HAVE_STACK_GROWING_UP
00069 #undef HAVE_WEAK_IO_SYMBOLS
00070 #undef HAVE_WEAK_MALLOC_SYMBOLS
00071 #define       HAVE_DLL
00072 #define       USE_DLFCN
00073 #define _PR_HAVE_SOCKADDR_LEN
00074 #define _PR_POLL_AVAILABLE
00075 #define _PR_USE_POLL
00076 #define _PR_STAT_HAS_ONLY_ST_ATIME
00077 #ifdef _PR_INET6
00078 #define _PR_HAVE_INET_NTOP
00079 #define _PR_HAVE_GETHOSTBYNAME2
00080 #define _PR_HAVE_GETADDRINFO
00081 #endif
00082 #define _PR_HAVE_SYSV_SEMAPHORES
00083 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
00084 #define _PR_ACCEPT_INHERIT_NONBLOCK
00085 
00086 /* Timer operations */
00087 #if defined(AIX_TIMERS)
00088 extern PRIntervalTime _MD_AixGetInterval(void);
00089 #define _MD_GET_INTERVAL _MD_AixGetInterval
00090 
00091 extern PRIntervalTime _MD_AixIntervalPerSec(void);
00092 #define _MD_INTERVAL_PER_SEC _MD_AixIntervalPerSec
00093 
00094 #else  /* defined(AIX_TIMERS) */
00095 #define _MD_GET_INTERVAL        _PR_UNIX_GetInterval
00096 #define _MD_INTERVAL_PER_SEC    _PR_UNIX_TicksPerSecond
00097 #endif  /* defined(AIX_TIMERS) */
00098 
00099 #ifdef AIX_HAVE_ATOMIC_OP_H
00100 /* The atomic operations */
00101 #include <sys/atomic_op.h>
00102 #define _PR_HAVE_ATOMIC_OPS
00103 #ifndef IS_64
00104 #define _PR_HAVE_ATOMIC_CAS
00105 #endif
00106 #define _MD_INIT_ATOMIC()
00107 #define _MD_ATOMIC_INCREMENT(val)   ((PRInt32)fetch_and_add((atomic_p)val, 1) + 1)
00108 #define _MD_ATOMIC_ADD(ptr, val)   ((PRInt32)fetch_and_add((atomic_p)ptr, val) + val)
00109 #define _MD_ATOMIC_DECREMENT(val)   ((PRInt32)fetch_and_add((atomic_p)val, -1) - 1)
00110 #define _MD_ATOMIC_SET(val, newval) _AIX_AtomicSet(val, newval)
00111 #endif /* AIX_HAVE_ATOMIC_OP_H */
00112 
00113 #define USE_SETJMP
00114 
00115 #include <setjmp.h>
00116 
00117 #define _MD_GET_SP(_t)                           (_t)->md.jb[3]
00118 #define _MD_SET_THR_SP(_t, _sp)           ((_t)->md.jb[3] = (int) (_sp - 2 * 64))
00119 #define PR_NUM_GCREGS                            _JBLEN
00120 
00121 #define CONTEXT(_th)                             ((_th)->md.jb)
00122 #define SAVE_CONTEXT(_th)                 _setjmp(CONTEXT(_th))
00123 #define GOTO_CONTEXT(_th)                 _longjmp(CONTEXT(_th), 1)
00124 
00125 #ifdef PTHREADS_USER
00126 #include "_nspr_pthread.h"
00127 #else
00128 
00129 /*
00130 ** Initialize the thread context preparing it to execute _main.
00131 */
00132 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)         \
00133     PR_BEGIN_MACRO                              \
00134         *status = PR_TRUE;              \
00135        if (setjmp(CONTEXT(_thread))) {    \
00136            (*_main)();                    \
00137        }                           \
00138        _MD_GET_SP(_thread) = (int) (_sp - 2 * 64);             \
00139     PR_END_MACRO
00140 
00141 #define _MD_SWITCH_CONTEXT(_thread)  \
00142     if (!setjmp(CONTEXT(_thread))) { \
00143        (_thread)->md.errcode = errno;  \
00144        _PR_Schedule();                  \
00145     }
00146 
00147 /*
00148 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00149 */
00150 #define _MD_RESTORE_CONTEXT(_thread) \
00151 {                                \
00152     errno = (_thread)->md.errcode; \
00153     _MD_SET_CURRENT_THREAD(_thread); \
00154     longjmp(CONTEXT(_thread), 1); \
00155 }
00156 
00157 /* Machine-dependent (MD) data structures */
00158 
00159 struct _MDThread {
00160     jmp_buf jb;
00161     int id;
00162     int errcode;
00163 };
00164 
00165 struct _MDThreadStack {
00166     PRInt8 notused;
00167 };
00168 
00169 struct _MDLock {
00170     PRInt8 notused;
00171 };
00172 
00173 struct _MDSemaphore {
00174     PRInt8 notused;
00175 };
00176 
00177 struct _MDCVar {
00178     PRInt8 notused;
00179 };
00180 
00181 struct _MDSegment {
00182     PRInt8 notused;
00183 };
00184 
00185 /*
00186  * md-specific cpu structure field
00187  */
00188 #define _PR_MD_MAX_OSFD FD_SETSIZE
00189 
00190 struct _MDCPU_Unix {
00191     PRCList ioQ;
00192     PRUint32 ioq_timeout;
00193     PRInt32 ioq_max_osfd;
00194     PRInt32 ioq_osfd_cnt;
00195 #ifndef _PR_USE_POLL
00196     fd_set fd_read_set, fd_write_set, fd_exception_set;
00197     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00198                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00199 #else
00200        struct pollfd *ioq_pollfds;
00201        int ioq_pollfds_size;
00202 #endif /* _PR_USE_POLL */
00203 };
00204 
00205 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00206 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00207 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00208 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00209 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00210 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00211 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00212 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00213 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00214 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00215 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00216 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00217 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00218 
00219 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00220 
00221 struct _MDCPU {
00222     struct _MDCPU_Unix md_unix;
00223 };
00224 
00225 #if !defined(_PR_PTHREADS)
00226 #define _MD_INIT_LOCKS()
00227 #endif
00228 
00229 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00230 #define _MD_FREE_LOCK(lock)
00231 #define _MD_LOCK(lock)
00232 #define _MD_UNLOCK(lock)
00233 #define _MD_INIT_IO()
00234 #define _MD_IOQ_LOCK()
00235 #define _MD_IOQ_UNLOCK()
00236 
00237 #define _MD_EARLY_INIT             _MD_EarlyInit
00238 #define _MD_FINAL_INIT                    _PR_UnixInit
00239 #define _MD_INIT_RUNNING_CPU(cpu)  _MD_unix_init_running_cpu(cpu)
00240 #define _MD_INIT_THREAD                   _MD_InitializeThread
00241 #define _MD_EXIT_THREAD(thread)
00242 #define       _MD_SUSPEND_THREAD(thread)
00243 #define       _MD_RESUME_THREAD(thread)
00244 #define _MD_CLEAN_THREAD(_thread)
00245 #endif /* PTHREADS_USER */
00246 
00247 #ifdef AIX_RENAME_SELECT
00248 #define _MD_SELECT   select
00249 #define _MD_POLL     poll
00250 #endif
00251 
00252 extern void _MD_aix_map_sendfile_error(int err);
00253 
00254 #endif /* nspr_aix_defs_h___ */