Back to index

lightning-sunbird  0.9+nobinonly
_nec.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_nec_defs_h___
00039 #define nspr_nec_defs_h___
00040  
00041 /*
00042  * Internal configuration macros
00043  */
00044 
00045 #define PR_LINKER_ARCH  "nec"
00046 #define _PR_SI_SYSNAME "NEC"
00047 #define _PR_SI_ARCHITECTURE "mips"
00048 #define PR_DLL_SUFFIX              ".so"
00049  
00050 #define _PR_STACK_VMBASE        0x50000000
00051 #define _MD_DEFAULT_STACK_SIZE  65536L
00052 #define _MD_MMAP_FLAGS          MAP_PRIVATE
00053 
00054 #undef  HAVE_STACK_GROWING_UP
00055 #define HAVE_DLL
00056 #define USE_DLFCN
00057 #define NEED_TIME_R
00058 #define NEED_STRFTIME_LOCK
00059 #define _PR_POLL_AVAILABLE
00060 #define _PR_USE_POLL
00061 #define _PR_NO_LARGE_FILES
00062 #define _PR_STAT_HAS_ST_ATIM_UNION
00063  
00064 #include <ucontext.h>
00065 #include <sys/regset.h>
00066  
00067 #define PR_NUM_GCREGS   NGREG
00068 #define PR_CONTEXT_TYPE ucontext_t
00069  
00070 #define CONTEXT(_thread) (&(_thread)->md.context)
00071  
00072 #define _MD_GET_SP(_t)    (_t)->md.context.uc_mcontext.gregs[CXT_SP]
00073  
00074 /*
00075 ** Initialize the thread context preparing it to execute "e(o,a)"
00076 */
00077 #define _MD_INIT_CONTEXT(thread, _sp, _main, status)               \
00078 {                                                                   \
00079     *status = PR_TRUE; \
00080     getcontext(CONTEXT(thread));                                    \
00081     CONTEXT(thread)->uc_stack.ss_sp = (char*) (thread)->stack->stackBottom; \
00082     CONTEXT(thread)->uc_stack.ss_size = (thread)->stack->stackSize; \
00083     _MD_GET_SP(thread) = (greg_t) _sp - 64;             \
00084     makecontext(CONTEXT(thread), _main, 0);              \
00085 }
00086  
00087 #define _MD_SWITCH_CONTEXT(_thread)      \
00088     if (!getcontext(CONTEXT(_thread))) { \
00089         (_thread)->md.errcode = errno;      \
00090         _PR_Schedule();                  \
00091     }
00092  
00093 /*
00094 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00095 */
00096 #define _MD_RESTORE_CONTEXT(_thread)   \
00097 {                                      \
00098     ucontext_t *uc = CONTEXT(_thread); \
00099     uc->uc_mcontext.gregs[CXT_V0] = 1; \
00100     uc->uc_mcontext.gregs[CXT_A3] = 0; \
00101     errno = (_thread)->md.errcode;     \
00102     _MD_SET_CURRENT_THREAD(_thread);   \
00103     setcontext(uc);                    \
00104 }
00105 
00106 /* Machine-dependent (MD) data structures */
00107 
00108 struct _MDThread {
00109     PR_CONTEXT_TYPE context;
00110     int id;
00111     int errcode;
00112 };
00113 
00114 struct _MDThreadStack {
00115     PRInt8 notused;
00116 };
00117 
00118 struct _MDLock {
00119     PRInt8 notused;
00120 };
00121 
00122 struct _MDSemaphore {
00123     PRInt8 notused;
00124 };
00125 
00126 struct _MDCVar {
00127     PRInt8 notused;
00128 };
00129 
00130 struct _MDSegment {
00131     PRInt8 notused;
00132 };
00133 
00134 /*
00135  * md-specific cpu structure field
00136  */
00137 #define _PR_MD_MAX_OSFD FD_SETSIZE
00138 
00139 struct _MDCPU_Unix {
00140     PRCList ioQ;
00141     PRUint32 ioq_timeout;
00142     PRInt32 ioq_max_osfd;
00143     PRInt32 ioq_osfd_cnt;
00144 #ifndef _PR_USE_POLL
00145     fd_set fd_read_set, fd_write_set, fd_exception_set;
00146     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00147                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00148 #else
00149        struct pollfd *ioq_pollfds;
00150        int ioq_pollfds_size;
00151 #endif /* _PR_USE_POLL */
00152 };
00153 
00154 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00155 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00156 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00157 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00158 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00159 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00160 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00161 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00162 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00163 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00164 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00165 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00166 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00167 
00168 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00169 
00170 struct _MDCPU {
00171        struct _MDCPU_Unix md_unix;
00172 };
00173 
00174 #define _MD_INIT_LOCKS()
00175 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00176 #define _MD_FREE_LOCK(lock)
00177 #define _MD_LOCK(lock)
00178 #define _MD_UNLOCK(lock)
00179 #define _MD_INIT_IO()
00180 #define _MD_IOQ_LOCK()
00181 #define _MD_IOQ_UNLOCK()
00182 
00183 #define _MD_EARLY_INIT          _MD_EarlyInit
00184 #define _MD_FINAL_INIT                    _PR_UnixInit
00185 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
00186 #define _MD_INIT_THREAD         _MD_InitializeThread
00187 #define _MD_EXIT_THREAD(thread)
00188 #define _MD_CLEAN_THREAD(_thread)
00189 
00190 #define _MD_SELECT _select
00191 #define _MD_POLL _poll
00192 
00193 #define _MD_GET_INTERVAL                  _PR_UNIX_GetInterval
00194 #define _MD_INTERVAL_PER_SEC              _PR_UNIX_TicksPerSecond
00195  
00196 #endif /* nspr_nec_defs_h___ */