Back to index

lightning-sunbird  0.9+nobinonly
_linux.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_linux_defs_h___
00039 #define nspr_linux_defs_h___
00040 
00041 #include "prthread.h"
00042 
00043 /*
00044  * Internal configuration macros
00045  */
00046 
00047 #define PR_LINKER_ARCH      "linux"
00048 #define _PR_SI_SYSNAME  "LINUX"
00049 #ifdef __powerpc64__
00050 #define _PR_SI_ARCHITECTURE "ppc64"
00051 #elif defined(__powerpc__)
00052 #define _PR_SI_ARCHITECTURE "ppc"
00053 #elif defined(__alpha)
00054 #define _PR_SI_ARCHITECTURE "alpha"
00055 #elif defined(__ia64__)
00056 #define _PR_SI_ARCHITECTURE "ia64"
00057 #elif defined(__x86_64__)
00058 #define _PR_SI_ARCHITECTURE "x86-64"
00059 #elif defined(__mc68000__)
00060 #define _PR_SI_ARCHITECTURE "m68k"
00061 #elif defined(__sparc__)
00062 #define _PR_SI_ARCHITECTURE "sparc"
00063 #elif defined(__i386__)
00064 #define _PR_SI_ARCHITECTURE "x86"
00065 #elif defined(__mips__)
00066 #define _PR_SI_ARCHITECTURE "mips"
00067 #elif defined(__arm__)
00068 #define _PR_SI_ARCHITECTURE "arm"
00069 #elif defined(__hppa__)
00070 #define _PR_SI_ARCHITECTURE "hppa"
00071 #elif defined(__s390x__)
00072 #define _PR_SI_ARCHITECTURE "s390x"
00073 #elif defined(__s390__)
00074 #define _PR_SI_ARCHITECTURE "s390"
00075 #else
00076 #error "Unknown CPU architecture"
00077 #endif
00078 #define PR_DLL_SUFFIX              ".so"
00079 
00080 #define _PR_VMBASE              0x30000000
00081 #define _PR_STACK_VMBASE    0x50000000
00082 #define _MD_DEFAULT_STACK_SIZE     65536L
00083 #define _MD_MMAP_FLAGS          MAP_PRIVATE
00084 
00085 #undef HAVE_STACK_GROWING_UP
00086 
00087 /*
00088  * Elf linux supports dl* functions
00089  */
00090 #define HAVE_DLL
00091 #define USE_DLFCN
00092 
00093 #if defined(__i386__)
00094 #define _PR_HAVE_ATOMIC_OPS
00095 #define _MD_INIT_ATOMIC()
00096 extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val);
00097 #define _MD_ATOMIC_INCREMENT          _PR_x86_AtomicIncrement
00098 extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val);
00099 #define _MD_ATOMIC_DECREMENT          _PR_x86_AtomicDecrement
00100 extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
00101 #define _MD_ATOMIC_ADD                _PR_x86_AtomicAdd
00102 extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
00103 #define _MD_ATOMIC_SET                _PR_x86_AtomicSet
00104 #endif
00105 
00106 #if defined(__ia64__)
00107 #define _PR_HAVE_ATOMIC_OPS
00108 #define _MD_INIT_ATOMIC()
00109 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
00110 #define _MD_ATOMIC_INCREMENT          _PR_ia64_AtomicIncrement
00111 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
00112 #define _MD_ATOMIC_DECREMENT          _PR_ia64_AtomicDecrement
00113 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
00114 #define _MD_ATOMIC_ADD                _PR_ia64_AtomicAdd
00115 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
00116 #define _MD_ATOMIC_SET                _PR_ia64_AtomicSet
00117 #endif
00118 
00119 #if defined(__x86_64__)
00120 #define _PR_HAVE_ATOMIC_OPS
00121 #define _MD_INIT_ATOMIC()
00122 extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val);
00123 #define _MD_ATOMIC_INCREMENT          _PR_x86_64_AtomicIncrement
00124 extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val);
00125 #define _MD_ATOMIC_DECREMENT          _PR_x86_64_AtomicDecrement
00126 extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
00127 #define _MD_ATOMIC_ADD                _PR_x86_64_AtomicAdd
00128 extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
00129 #define _MD_ATOMIC_SET                _PR_x86_64_AtomicSet
00130 #endif
00131 
00132 #if defined(__alpha)
00133 #define _PR_HAVE_ATOMIC_OPS
00134 #define _MD_INIT_ATOMIC()
00135 #define _MD_ATOMIC_ADD(ptr, i) ({               \
00136     PRInt32 __atomic_tmp, __atomic_ret;   \
00137     __asm__ __volatile__(                       \
00138     "1: ldl_l   %[ret], %[val]          \n"     \
00139     "   addl    %[ret], %[inc], %[tmp]  \n"     \
00140     "   addl    %[ret], %[inc], %[ret]  \n"     \
00141     "   stl_c   %[tmp], %[val]          \n"     \
00142     "   beq     %[tmp], 2f              \n"     \
00143     ".subsection 2                      \n"     \
00144     "2: br      1b                      \n"     \
00145     ".previous"                                 \
00146     : [ret] "=&r" (__atomic_ret),               \
00147       [tmp] "=&r" (__atomic_tmp),               \
00148       [val] "=m" (*ptr)                         \
00149     : [inc] "Ir" (i), "m" (*ptr));              \
00150     __atomic_ret;                               \
00151 })
00152 #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)
00153 #define _MD_ATOMIC_DECREMENT(ptr) ({            \
00154     PRInt32 __atomic_tmp, __atomic_ret;   \
00155     __asm__ __volatile__(                       \
00156     "1: ldl_l   %[ret], %[val]          \n"     \
00157     "   subl    %[ret], 1, %[tmp]       \n"     \
00158     "   subl    %[ret], 1, %[ret]       \n"     \
00159     "   stl_c   %[tmp], %[val]          \n"     \
00160     "   beq     %[tmp], 2f              \n"     \
00161     ".subsection 2                      \n"     \
00162     "2: br      1b                      \n"     \
00163     ".previous"                                 \
00164     : [ret] "=&r" (__atomic_ret),               \
00165       [tmp] "=&r" (__atomic_tmp),               \
00166       [val] "=m" (*ptr)                         \
00167     : "m" (*ptr));                              \
00168     __atomic_ret;                               \
00169 })
00170 #define _MD_ATOMIC_SET(ptr, n) ({               \
00171     PRInt32 __atomic_tmp, __atomic_ret;   \
00172     __asm__ __volatile__(                       \
00173     "1: ldl_l   %[ret], %[val]          \n"     \
00174     "   mov     %[newval], %[tmp]       \n"     \
00175     "   stl_c   %[tmp], %[val]          \n"     \
00176     "   beq     %[tmp], 2f              \n"     \
00177     ".subsection 2                      \n"     \
00178     "2: br      1b                      \n"     \
00179     ".previous"                                 \
00180     : [ret] "=&r" (__atomic_ret),               \
00181       [tmp] "=&r"(__atomic_tmp),                \
00182       [val] "=m" (*ptr)                         \
00183     : [newval] "Ir" (n), "m" (*ptr));           \
00184     __atomic_ret;                               \
00185 })
00186 #endif
00187 
00188 #define USE_SETJMP
00189 #if defined(__GLIBC__) && __GLIBC__ >= 2
00190 #define _PR_POLL_AVAILABLE
00191 #endif
00192 #undef _PR_USE_POLL
00193 #define _PR_STAT_HAS_ONLY_ST_ATIME
00194 #if defined(__alpha) || defined(__ia64__)
00195 #define _PR_HAVE_LARGE_OFF_T
00196 #elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
00197 #define _PR_HAVE_OFF64_T
00198 #else
00199 #define _PR_NO_LARGE_FILES
00200 #endif
00201 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
00202 #define _PR_INET6
00203 #define _PR_HAVE_INET_NTOP
00204 #define _PR_HAVE_GETHOSTBYNAME2
00205 #define _PR_HAVE_GETADDRINFO
00206 #define _PR_INET6_PROBE
00207 #endif
00208 #define _PR_HAVE_SYSV_SEMAPHORES
00209 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
00210 #if (__GLIBC__ >= 2) && defined(_PR_PTHREADS)
00211 #define _PR_HAVE_GETHOST_R
00212 #define _PR_HAVE_GETHOST_R_INT
00213 #endif
00214 
00215 #ifdef _PR_PTHREADS
00216 
00217 extern void _MD_CleanupBeforeExit(void);
00218 #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit
00219 
00220 #else  /* ! _PR_PTHREADS */
00221 
00222 #include <setjmp.h>
00223 
00224 #define PR_CONTEXT_TYPE     sigjmp_buf
00225 
00226 #define CONTEXT(_th) ((_th)->md.context)
00227 
00228 #ifdef __powerpc__
00229 /*
00230  * PowerPC based MkLinux
00231  *
00232  * On the PowerPC, the new style jmp_buf isn't used until glibc
00233  * 2.1.
00234  */
00235 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
00236 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1]
00237 #else
00238 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0]
00239 #endif /* glibc 2.1 or later */
00240 #define _MD_SET_FP(_t, val)
00241 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00242 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00243 /* aix = 64, macos = 70 */
00244 #define PR_NUM_GCREGS  64
00245 
00246 #elif defined(__alpha)
00247 /* Alpha based Linux */
00248 
00249 #if defined(__GLIBC__) && __GLIBC__ >= 2
00250 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
00251 #define _MD_SET_FP(_t, val)
00252 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00253 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00254 #define _MD_SP_TYPE long int
00255 #else
00256 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
00257 #define _MD_SET_FP(_t, val)
00258 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00259 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00260 #define _MD_SP_TYPE __ptr_t
00261 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00262 
00263 /* XXX not sure if this is correct, or maybe it should be 17? */
00264 #define PR_NUM_GCREGS 9
00265 
00266 #elif defined(__ia64__)
00267 
00268 #define _MD_GET_SP(_t)      ((long *)((_t)->md.context[0].__jmpbuf)[0])
00269 #define _MD_SET_FP(_t, val)
00270 #define _MD_GET_SP_PTR(_t)  &(_MD_GET_SP(_t))
00271 #define _MD_GET_FP_PTR(_t)  ((void *) 0)
00272 #define _MD_SP_TYPE         long int
00273 
00274 #define PR_NUM_GCREGS       _JBLEN
00275 
00276 #elif defined(__mc68000__)
00277 /* m68k based Linux */
00278 
00279 /*
00280  * On the m68k, glibc still uses the old style sigjmp_buf, even
00281  * in glibc 2.0.7.
00282  */
00283 #if defined(__GLIBC__) && __GLIBC__ >= 2
00284 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
00285 #define _MD_SET_FP(_t, val)
00286 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00287 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00288 #define _MD_SP_TYPE int
00289 #else
00290 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
00291 #define _MD_SET_FP(_t, val)
00292 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00293 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00294 #define _MD_SP_TYPE __ptr_t
00295 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00296 
00297 /* XXX not sure if this is correct, or maybe it should be 17? */
00298 #define PR_NUM_GCREGS 9
00299 
00300 #elif defined(__sparc__)
00301 /* Sparc */
00302 #if defined(__GLIBC__) && __GLIBC__ >= 2
00303 /*
00304  * You need glibc2-2.0.7-25 or later. The libraries that came with
00305  * Red Hat 5.1 are not new enough, but they are in 5.2.
00306  */
00307 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
00308 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_FP] = val)
00309 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00310 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_FP])
00311 #define _MD_SP_TYPE int
00312 #else
00313 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__fp
00314 #define _MD_SET_FP(_t, val)
00315 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00316 #define _MD_GET_FP_PTR(_t) ((void *) 0)
00317 #define _MD_SP_TYPE __ptr_t
00318 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00319 
00320 #elif defined(__i386__)
00321 /* Intel based Linux */
00322 #if defined(__GLIBC__) && __GLIBC__ >= 2
00323 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
00324 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_BP] = val)
00325 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00326 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_BP])
00327 #define _MD_SP_TYPE int
00328 #else
00329 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
00330 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__bp = val)
00331 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00332 #define _MD_GET_FP_PTR(_t) &((_t)->md.context[0].__jmpbuf[0].__bp)
00333 #define _MD_SP_TYPE __ptr_t
00334 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00335 #define PR_NUM_GCREGS   6
00336 
00337 #elif defined(__mips__)
00338 /* Linux/MIPS */
00339 #if defined(__GLIBC__) && __GLIBC__ >= 2
00340 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
00341 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__fp = (val))
00342 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00343 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__fp)
00344 #define _MD_SP_TYPE __ptr_t
00345 #else
00346 #error "Linux/MIPS pre-glibc2 not supported yet"
00347 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00348 
00349 #elif defined(__arm__)
00350 /* ARM/Linux */
00351 #if defined(__GLIBC__) && __GLIBC__ >= 2
00352 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[20]
00353 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[19] = (val))
00354 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
00355 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[19])
00356 #define _MD_SP_TYPE __ptr_t
00357 #else
00358 #error "ARM/Linux pre-glibc2 not supported yet"
00359 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
00360 
00361 #else
00362 
00363 #error "Unknown CPU architecture"
00364 
00365 #endif /*__powerpc__*/
00366 
00367 /*
00368 ** Initialize a thread context to run "_main()" when started
00369 */
00370 #ifdef __powerpc__
00371 
00372 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
00373 {  \
00374     *status = PR_TRUE;  \
00375     if (sigsetjmp(CONTEXT(_thread), 1)) {  \
00376         _main();  \
00377     }  \
00378     _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 128); \
00379        _thread->md.sp = _MD_GET_SP_PTR(_thread); \
00380        _thread->md.fp = _MD_GET_FP_PTR(_thread); \
00381     _MD_SET_FP(_thread, 0); \
00382 }
00383 
00384 #elif defined(__mips__)
00385 
00386 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
00387 {  \
00388     *status = PR_TRUE;  \
00389     (void) sigsetjmp(CONTEXT(_thread), 1);  \
00390     _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t) _main;  \
00391     _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \
00392     _thread->md.sp = _MD_GET_SP_PTR(_thread); \
00393     _thread->md.fp = _MD_GET_FP_PTR(_thread); \
00394     _MD_SET_FP(_thread, 0); \
00395 }
00396 
00397 #else
00398 
00399 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)  \
00400 {  \
00401     *status = PR_TRUE;  \
00402     if (sigsetjmp(CONTEXT(_thread), 1)) {  \
00403         _main();  \
00404     }  \
00405     _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \
00406        _thread->md.sp = _MD_GET_SP_PTR(_thread); \
00407        _thread->md.fp = _MD_GET_FP_PTR(_thread); \
00408     _MD_SET_FP(_thread, 0); \
00409 }
00410 
00411 #endif /*__powerpc__*/
00412 
00413 #define _MD_SWITCH_CONTEXT(_thread)  \
00414     if (!sigsetjmp(CONTEXT(_thread), 1)) {  \
00415        (_thread)->md.errcode = errno;  \
00416        _PR_Schedule();  \
00417     }
00418 
00419 /*
00420 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
00421 */
00422 #define _MD_RESTORE_CONTEXT(_thread) \
00423 {   \
00424     errno = (_thread)->md.errcode;  \
00425     _MD_SET_CURRENT_THREAD(_thread);  \
00426     siglongjmp(CONTEXT(_thread), 1);  \
00427 }
00428 
00429 /* Machine-dependent (MD) data structures */
00430 
00431 struct _MDThread {
00432     PR_CONTEXT_TYPE context;
00433        void *sp;
00434        void *fp;
00435     int id;
00436     int errcode;
00437 };
00438 
00439 struct _MDThreadStack {
00440     PRInt8 notused;
00441 };
00442 
00443 struct _MDLock {
00444     PRInt8 notused;
00445 };
00446 
00447 struct _MDSemaphore {
00448     PRInt8 notused;
00449 };
00450 
00451 struct _MDCVar {
00452     PRInt8 notused;
00453 };
00454 
00455 struct _MDSegment {
00456     PRInt8 notused;
00457 };
00458 
00459 /*
00460  * md-specific cpu structure field
00461  */
00462 #include <sys/time.h>  /* for FD_SETSIZE */
00463 #define _PR_MD_MAX_OSFD FD_SETSIZE
00464 
00465 struct _MDCPU_Unix {
00466     PRCList ioQ;
00467     PRUint32 ioq_timeout;
00468     PRInt32 ioq_max_osfd;
00469     PRInt32 ioq_osfd_cnt;
00470 #ifndef _PR_USE_POLL
00471     fd_set fd_read_set, fd_write_set, fd_exception_set;
00472     PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
00473                             fd_exception_cnt[_PR_MD_MAX_OSFD];
00474 #else
00475        struct pollfd *ioq_pollfds;
00476        int ioq_pollfds_size;
00477 #endif /* _PR_USE_POLL */
00478 };
00479 
00480 #define _PR_IOQ(_cpu)                     ((_cpu)->md.md_unix.ioQ)
00481 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
00482 #define _PR_FD_READ_SET(_cpu)             ((_cpu)->md.md_unix.fd_read_set)
00483 #define _PR_FD_READ_CNT(_cpu)             ((_cpu)->md.md_unix.fd_read_cnt)
00484 #define _PR_FD_WRITE_SET(_cpu)            ((_cpu)->md.md_unix.fd_write_set)
00485 #define _PR_FD_WRITE_CNT(_cpu)            ((_cpu)->md.md_unix.fd_write_cnt)
00486 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
00487 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
00488 #define _PR_IOQ_TIMEOUT(_cpu)             ((_cpu)->md.md_unix.ioq_timeout)
00489 #define _PR_IOQ_MAX_OSFD(_cpu)            ((_cpu)->md.md_unix.ioq_max_osfd)
00490 #define _PR_IOQ_OSFD_CNT(_cpu)            ((_cpu)->md.md_unix.ioq_osfd_cnt)
00491 #define _PR_IOQ_POLLFDS(_cpu)             ((_cpu)->md.md_unix.ioq_pollfds)
00492 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
00493 
00494 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu)    32
00495 
00496 struct _MDCPU {
00497        struct _MDCPU_Unix md_unix;
00498 };
00499 
00500 #define _MD_INIT_LOCKS()
00501 #define _MD_NEW_LOCK(lock) PR_SUCCESS
00502 #define _MD_FREE_LOCK(lock)
00503 #define _MD_LOCK(lock)
00504 #define _MD_UNLOCK(lock)
00505 #define _MD_INIT_IO()
00506 #define _MD_IOQ_LOCK()
00507 #define _MD_IOQ_UNLOCK()
00508 
00509 extern PRStatus _MD_InitializeThread(PRThread *thread);
00510 
00511 #define _MD_INIT_RUNNING_CPU(cpu)       _MD_unix_init_running_cpu(cpu)
00512 #define _MD_INIT_THREAD                 _MD_InitializeThread
00513 #define _MD_EXIT_THREAD(thread)
00514 #define _MD_SUSPEND_THREAD(thread)      _MD_suspend_thread
00515 #define _MD_RESUME_THREAD(thread)       _MD_resume_thread
00516 #define _MD_CLEAN_THREAD(_thread)
00517 
00518 extern PRStatus _MD_CREATE_THREAD(
00519     PRThread *thread,
00520     void (*start) (void *),
00521     PRThreadPriority priority,
00522     PRThreadScope scope,
00523     PRThreadState state,
00524     PRUint32 stackSize);
00525 extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);
00526 extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);
00527 extern PRStatus _MD_WAKEUP_WAITER(PRThread *);
00528 extern void _MD_YIELD(void);
00529 
00530 #endif /* ! _PR_PTHREADS */
00531 
00532 extern void _MD_EarlyInit(void);
00533 extern PRIntervalTime _PR_UNIX_GetInterval(void);
00534 extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
00535 
00536 #define _MD_EARLY_INIT                  _MD_EarlyInit
00537 #define _MD_FINAL_INIT                                  _PR_UnixInit
00538 #define _MD_GET_INTERVAL                _PR_UNIX_GetInterval
00539 #define _MD_INTERVAL_PER_SEC            _PR_UNIX_TicksPerSecond
00540 
00541 /*
00542  * We wrapped the select() call.  _MD_SELECT refers to the built-in,
00543  * unwrapped version.
00544  */
00545 #define _MD_SELECT __select
00546 
00547 #ifdef _PR_POLL_AVAILABLE
00548 #include <sys/poll.h>
00549 extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds,
00550        int timeout);
00551 #define _MD_POLL __syscall_poll
00552 #endif
00553 
00554 /* For writev() */
00555 #include <sys/uio.h>
00556 
00557 extern void _MD_linux_map_sendfile_error(int err);
00558 
00559 #endif /* nspr_linux_defs_h___ */