Bug 449533. Set the mFixedPitch flag within SetFixedPitch. r+sr=vlad
[wine-gecko.git] / nsprpub / pr / include / md / _linux.h
blob583997165af95a43e58371dbbdcb4eeb089ab99a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is the Netscape Portable Runtime (NSPR).
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * This file is used by not only Linux but also other glibc systems
40 * such as GNU/Hurd and GNU/k*BSD.
43 #ifndef nspr_linux_defs_h___
44 #define nspr_linux_defs_h___
46 #include "prthread.h"
49 * Internal configuration macros
52 #define PR_LINKER_ARCH "linux"
53 #define _PR_SI_SYSNAME "LINUX"
54 #ifdef __powerpc64__
55 #define _PR_SI_ARCHITECTURE "ppc64"
56 #elif defined(__powerpc__)
57 #define _PR_SI_ARCHITECTURE "ppc"
58 #elif defined(__alpha)
59 #define _PR_SI_ARCHITECTURE "alpha"
60 #elif defined(__ia64__)
61 #define _PR_SI_ARCHITECTURE "ia64"
62 #elif defined(__x86_64__)
63 #define _PR_SI_ARCHITECTURE "x86-64"
64 #elif defined(__mc68000__)
65 #define _PR_SI_ARCHITECTURE "m68k"
66 #elif defined(__sparc__)
67 #define _PR_SI_ARCHITECTURE "sparc"
68 #elif defined(__i386__)
69 #define _PR_SI_ARCHITECTURE "x86"
70 #elif defined(__mips__)
71 #define _PR_SI_ARCHITECTURE "mips"
72 #elif defined(__arm__)
73 #define _PR_SI_ARCHITECTURE "arm"
74 #elif defined(__hppa__)
75 #define _PR_SI_ARCHITECTURE "hppa"
76 #elif defined(__s390x__)
77 #define _PR_SI_ARCHITECTURE "s390x"
78 #elif defined(__s390__)
79 #define _PR_SI_ARCHITECTURE "s390"
80 #else
81 #error "Unknown CPU architecture"
82 #endif
83 #define PR_DLL_SUFFIX ".so"
85 #define _PR_VMBASE 0x30000000
86 #define _PR_STACK_VMBASE 0x50000000
87 #define _MD_DEFAULT_STACK_SIZE 65536L
88 #define _MD_MMAP_FLAGS MAP_PRIVATE
90 #undef HAVE_STACK_GROWING_UP
93 * Elf linux supports dl* functions
95 #define HAVE_DLL
96 #define USE_DLFCN
98 #ifdef __FreeBSD_kernel__
99 #define _PR_HAVE_SOCKADDR_LEN
100 #endif
102 #if defined(__i386__)
103 #define _PR_HAVE_ATOMIC_OPS
104 #define _MD_INIT_ATOMIC()
105 extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val);
106 #define _MD_ATOMIC_INCREMENT _PR_x86_AtomicIncrement
107 extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val);
108 #define _MD_ATOMIC_DECREMENT _PR_x86_AtomicDecrement
109 extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
110 #define _MD_ATOMIC_ADD _PR_x86_AtomicAdd
111 extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
112 #define _MD_ATOMIC_SET _PR_x86_AtomicSet
113 #endif
115 #if defined(__ia64__)
116 #define _PR_HAVE_ATOMIC_OPS
117 #define _MD_INIT_ATOMIC()
118 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val);
119 #define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement
120 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val);
121 #define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement
122 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
123 #define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd
124 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval);
125 #define _MD_ATOMIC_SET _PR_ia64_AtomicSet
126 #endif
128 #if defined(__x86_64__)
129 #define _PR_HAVE_ATOMIC_OPS
130 #define _MD_INIT_ATOMIC()
131 extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val);
132 #define _MD_ATOMIC_INCREMENT _PR_x86_64_AtomicIncrement
133 extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val);
134 #define _MD_ATOMIC_DECREMENT _PR_x86_64_AtomicDecrement
135 extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
136 #define _MD_ATOMIC_ADD _PR_x86_64_AtomicAdd
137 extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
138 #define _MD_ATOMIC_SET _PR_x86_64_AtomicSet
139 #endif
141 #if defined(__powerpc__) && !defined(__powerpc64__)
142 #define _PR_HAVE_ATOMIC_OPS
143 #define _MD_INIT_ATOMIC()
144 extern PRInt32 _PR_ppc_AtomicIncrement(PRInt32 *val);
145 #define _MD_ATOMIC_INCREMENT _PR_ppc_AtomicIncrement
146 extern PRInt32 _PR_ppc_AtomicDecrement(PRInt32 *val);
147 #define _MD_ATOMIC_DECREMENT _PR_ppc_AtomicDecrement
148 extern PRInt32 _PR_ppc_AtomicAdd(PRInt32 *ptr, PRInt32 val);
149 #define _MD_ATOMIC_ADD _PR_ppc_AtomicAdd
150 extern PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);
151 #define _MD_ATOMIC_SET _PR_ppc_AtomicSet
152 #endif
154 #if defined(__alpha)
155 #define _PR_HAVE_ATOMIC_OPS
156 #define _MD_INIT_ATOMIC()
157 #define _MD_ATOMIC_ADD(ptr, i) ({ \
158 PRInt32 __atomic_tmp, __atomic_ret; \
159 __asm__ __volatile__( \
160 "1: ldl_l %[ret], %[val] \n" \
161 " addl %[ret], %[inc], %[tmp] \n" \
162 " addl %[ret], %[inc], %[ret] \n" \
163 " stl_c %[tmp], %[val] \n" \
164 " beq %[tmp], 2f \n" \
165 ".subsection 2 \n" \
166 "2: br 1b \n" \
167 ".previous" \
168 : [ret] "=&r" (__atomic_ret), \
169 [tmp] "=&r" (__atomic_tmp), \
170 [val] "=m" (*ptr) \
171 : [inc] "Ir" (i), "m" (*ptr)); \
172 __atomic_ret; \
174 #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)
175 #define _MD_ATOMIC_DECREMENT(ptr) ({ \
176 PRInt32 __atomic_tmp, __atomic_ret; \
177 __asm__ __volatile__( \
178 "1: ldl_l %[ret], %[val] \n" \
179 " subl %[ret], 1, %[tmp] \n" \
180 " subl %[ret], 1, %[ret] \n" \
181 " stl_c %[tmp], %[val] \n" \
182 " beq %[tmp], 2f \n" \
183 ".subsection 2 \n" \
184 "2: br 1b \n" \
185 ".previous" \
186 : [ret] "=&r" (__atomic_ret), \
187 [tmp] "=&r" (__atomic_tmp), \
188 [val] "=m" (*ptr) \
189 : "m" (*ptr)); \
190 __atomic_ret; \
192 #define _MD_ATOMIC_SET(ptr, n) ({ \
193 PRInt32 __atomic_tmp, __atomic_ret; \
194 __asm__ __volatile__( \
195 "1: ldl_l %[ret], %[val] \n" \
196 " mov %[newval], %[tmp] \n" \
197 " stl_c %[tmp], %[val] \n" \
198 " beq %[tmp], 2f \n" \
199 ".subsection 2 \n" \
200 "2: br 1b \n" \
201 ".previous" \
202 : [ret] "=&r" (__atomic_ret), \
203 [tmp] "=&r"(__atomic_tmp), \
204 [val] "=m" (*ptr) \
205 : [newval] "Ir" (n), "m" (*ptr)); \
206 __atomic_ret; \
208 #endif
210 #if defined(__arm__) && defined(_PR_ARM_KUSER)
211 #define _PR_HAVE_ATOMIC_OPS
212 #define _MD_INIT_ATOMIC()
215 * The kernel provides this helper function at a fixed address with a fixed
216 * ABI signature, directly callable from user space.
218 * Definition:
219 * Atomically store newval in *ptr if *ptr is equal to oldval.
220 * Return zero if *ptr was changed or non-zero if no exchange happened.
222 typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
223 #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
225 #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)
226 #define _MD_ATOMIC_DECREMENT(ptr) _MD_ATOMIC_ADD(ptr, -1)
228 static inline PRInt32 _MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 n)
230 PRInt32 ov, nv;
231 volatile PRInt32 *vp = ptr;
233 do {
234 ov = *vp;
235 nv = ov + n;
236 } while (__kernel_cmpxchg(ov, nv, vp));
238 return nv;
241 static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *ptr, PRInt32 nv)
243 PRInt32 ov;
244 volatile PRInt32 *vp = ptr;
246 do {
247 ov = *vp;
248 } while (__kernel_cmpxchg(ov, nv, vp));
250 return ov;
252 #endif
254 #define USE_SETJMP
255 #if defined(__GLIBC__) && __GLIBC__ >= 2
256 #define _PR_POLL_AVAILABLE
257 #endif
258 #undef _PR_USE_POLL
259 #define _PR_STAT_HAS_ONLY_ST_ATIME
260 #if defined(__alpha) || defined(__ia64__)
261 #define _PR_HAVE_LARGE_OFF_T
262 #elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
263 #define _PR_HAVE_OFF64_T
264 #else
265 #define _PR_NO_LARGE_FILES
266 #endif
267 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
268 #define _PR_INET6
269 #define _PR_HAVE_INET_NTOP
270 #define _PR_HAVE_GETHOSTBYNAME2
271 #define _PR_HAVE_GETADDRINFO
272 #define _PR_INET6_PROBE
273 #endif
274 #define _PR_HAVE_SYSV_SEMAPHORES
275 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
276 #if (__GLIBC__ >= 2) && defined(_PR_PTHREADS)
277 #define _PR_HAVE_GETHOST_R
278 #define _PR_HAVE_GETHOST_R_INT
279 #endif
281 #ifdef _PR_PTHREADS
283 extern void _MD_CleanupBeforeExit(void);
284 #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit
286 #else /* ! _PR_PTHREADS */
288 #include <setjmp.h>
290 #define PR_CONTEXT_TYPE sigjmp_buf
292 #define CONTEXT(_th) ((_th)->md.context)
294 #ifdef __powerpc__
296 * PowerPC based MkLinux
298 * On the PowerPC, the new style jmp_buf isn't used until glibc
299 * 2.1.
301 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
302 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1]
303 #else
304 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0]
305 #endif /* glibc 2.1 or later */
306 #define _MD_SET_FP(_t, val)
307 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
308 #define _MD_GET_FP_PTR(_t) ((void *) 0)
309 /* aix = 64, macos = 70 */
310 #define PR_NUM_GCREGS 64
312 #elif defined(__alpha)
313 /* Alpha based Linux */
315 #if defined(__GLIBC__) && __GLIBC__ >= 2
316 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
317 #define _MD_SET_FP(_t, val)
318 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
319 #define _MD_GET_FP_PTR(_t) ((void *) 0)
320 #define _MD_SP_TYPE long int
321 #else
322 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
323 #define _MD_SET_FP(_t, val)
324 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
325 #define _MD_GET_FP_PTR(_t) ((void *) 0)
326 #define _MD_SP_TYPE __ptr_t
327 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
329 /* XXX not sure if this is correct, or maybe it should be 17? */
330 #define PR_NUM_GCREGS 9
332 #elif defined(__ia64__)
334 #define _MD_GET_SP(_t) ((long *)((_t)->md.context[0].__jmpbuf)[0])
335 #define _MD_SET_FP(_t, val)
336 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
337 #define _MD_GET_FP_PTR(_t) ((void *) 0)
338 #define _MD_SP_TYPE long int
340 #define PR_NUM_GCREGS _JBLEN
342 #elif defined(__mc68000__)
343 /* m68k based Linux */
346 * On the m68k, glibc still uses the old style sigjmp_buf, even
347 * in glibc 2.0.7.
349 #if defined(__GLIBC__) && __GLIBC__ >= 2
350 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
351 #define _MD_SET_FP(_t, val)
352 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
353 #define _MD_GET_FP_PTR(_t) ((void *) 0)
354 #define _MD_SP_TYPE int
355 #else
356 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
357 #define _MD_SET_FP(_t, val)
358 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
359 #define _MD_GET_FP_PTR(_t) ((void *) 0)
360 #define _MD_SP_TYPE __ptr_t
361 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
363 /* XXX not sure if this is correct, or maybe it should be 17? */
364 #define PR_NUM_GCREGS 9
366 #elif defined(__sparc__)
367 /* Sparc */
368 #if defined(__GLIBC__) && __GLIBC__ >= 2
370 * You need glibc2-2.0.7-25 or later. The libraries that came with
371 * Red Hat 5.1 are not new enough, but they are in 5.2.
373 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
374 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_FP] = val)
375 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
376 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_FP])
377 #define _MD_SP_TYPE int
378 #else
379 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__fp
380 #define _MD_SET_FP(_t, val)
381 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
382 #define _MD_GET_FP_PTR(_t) ((void *) 0)
383 #define _MD_SP_TYPE __ptr_t
384 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
386 #elif defined(__i386__)
387 /* Intel based Linux */
388 #if defined(__GLIBC__) && __GLIBC__ >= 2
389 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP]
390 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_BP] = val)
391 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
392 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_BP])
393 #define _MD_SP_TYPE int
394 #else
395 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
396 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__bp = val)
397 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
398 #define _MD_GET_FP_PTR(_t) &((_t)->md.context[0].__jmpbuf[0].__bp)
399 #define _MD_SP_TYPE __ptr_t
400 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
401 #define PR_NUM_GCREGS 6
403 #elif defined(__mips__)
404 /* Linux/MIPS */
405 #if defined(__GLIBC__) && __GLIBC__ >= 2
406 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp
407 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__fp = (val))
408 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
409 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__fp)
410 #define _MD_SP_TYPE __ptr_t
411 #else
412 #error "Linux/MIPS pre-glibc2 not supported yet"
413 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
415 #elif defined(__arm__)
416 /* ARM/Linux */
417 #if defined(__GLIBC__) && __GLIBC__ >= 2
418 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[20]
419 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[19] = (val))
420 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t))
421 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[19])
422 #define _MD_SP_TYPE __ptr_t
423 #else
424 #error "ARM/Linux pre-glibc2 not supported yet"
425 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
427 #else
429 #error "Unknown CPU architecture"
431 #endif /*__powerpc__*/
434 ** Initialize a thread context to run "_main()" when started
436 #ifdef __powerpc__
438 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
440 *status = PR_TRUE; \
441 if (sigsetjmp(CONTEXT(_thread), 1)) { \
442 _main(); \
444 _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 128); \
445 _thread->md.sp = _MD_GET_SP_PTR(_thread); \
446 _thread->md.fp = _MD_GET_FP_PTR(_thread); \
447 _MD_SET_FP(_thread, 0); \
450 #elif defined(__mips__)
452 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
454 *status = PR_TRUE; \
455 (void) sigsetjmp(CONTEXT(_thread), 1); \
456 _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \
457 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \
458 _thread->md.sp = _MD_GET_SP_PTR(_thread); \
459 _thread->md.fp = _MD_GET_FP_PTR(_thread); \
460 _MD_SET_FP(_thread, 0); \
463 #else
465 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \
467 *status = PR_TRUE; \
468 if (sigsetjmp(CONTEXT(_thread), 1)) { \
469 _main(); \
471 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \
472 _thread->md.sp = _MD_GET_SP_PTR(_thread); \
473 _thread->md.fp = _MD_GET_FP_PTR(_thread); \
474 _MD_SET_FP(_thread, 0); \
477 #endif /*__powerpc__*/
479 #define _MD_SWITCH_CONTEXT(_thread) \
480 if (!sigsetjmp(CONTEXT(_thread), 1)) { \
481 (_thread)->md.errcode = errno; \
482 _PR_Schedule(); \
486 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
488 #define _MD_RESTORE_CONTEXT(_thread) \
490 errno = (_thread)->md.errcode; \
491 _MD_SET_CURRENT_THREAD(_thread); \
492 siglongjmp(CONTEXT(_thread), 1); \
495 /* Machine-dependent (MD) data structures */
497 struct _MDThread {
498 PR_CONTEXT_TYPE context;
499 void *sp;
500 void *fp;
501 int id;
502 int errcode;
505 struct _MDThreadStack {
506 PRInt8 notused;
509 struct _MDLock {
510 PRInt8 notused;
513 struct _MDSemaphore {
514 PRInt8 notused;
517 struct _MDCVar {
518 PRInt8 notused;
521 struct _MDSegment {
522 PRInt8 notused;
526 * md-specific cpu structure field
528 #include <sys/time.h> /* for FD_SETSIZE */
529 #define _PR_MD_MAX_OSFD FD_SETSIZE
531 struct _MDCPU_Unix {
532 PRCList ioQ;
533 PRUint32 ioq_timeout;
534 PRInt32 ioq_max_osfd;
535 PRInt32 ioq_osfd_cnt;
536 #ifndef _PR_USE_POLL
537 fd_set fd_read_set, fd_write_set, fd_exception_set;
538 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD],
539 fd_exception_cnt[_PR_MD_MAX_OSFD];
540 #else
541 struct pollfd *ioq_pollfds;
542 int ioq_pollfds_size;
543 #endif /* _PR_USE_POLL */
546 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ)
547 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu))
548 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set)
549 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt)
550 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set)
551 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt)
552 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set)
553 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt)
554 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout)
555 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd)
556 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt)
557 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds)
558 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size)
560 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32
562 struct _MDCPU {
563 struct _MDCPU_Unix md_unix;
566 #define _MD_INIT_LOCKS()
567 #define _MD_NEW_LOCK(lock) PR_SUCCESS
568 #define _MD_FREE_LOCK(lock)
569 #define _MD_LOCK(lock)
570 #define _MD_UNLOCK(lock)
571 #define _MD_INIT_IO()
572 #define _MD_IOQ_LOCK()
573 #define _MD_IOQ_UNLOCK()
575 extern PRStatus _MD_InitializeThread(PRThread *thread);
577 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu)
578 #define _MD_INIT_THREAD _MD_InitializeThread
579 #define _MD_EXIT_THREAD(thread)
580 #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread
581 #define _MD_RESUME_THREAD(thread) _MD_resume_thread
582 #define _MD_CLEAN_THREAD(_thread)
584 extern PRStatus _MD_CREATE_THREAD(
585 PRThread *thread,
586 void (*start) (void *),
587 PRThreadPriority priority,
588 PRThreadScope scope,
589 PRThreadState state,
590 PRUint32 stackSize);
591 extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri);
592 extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout);
593 extern PRStatus _MD_WAKEUP_WAITER(PRThread *);
594 extern void _MD_YIELD(void);
596 #endif /* ! _PR_PTHREADS */
598 extern void _MD_EarlyInit(void);
599 extern PRIntervalTime _PR_UNIX_GetInterval(void);
600 extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
602 #define _MD_EARLY_INIT _MD_EarlyInit
603 #define _MD_FINAL_INIT _PR_UnixInit
604 #define _MD_GET_INTERVAL _PR_UNIX_GetInterval
605 #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond
608 * We wrapped the select() call. _MD_SELECT refers to the built-in,
609 * unwrapped version.
611 #define _MD_SELECT __select
613 #ifdef _PR_POLL_AVAILABLE
614 #include <sys/poll.h>
615 extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds,
616 int timeout);
617 #define _MD_POLL __syscall_poll
618 #endif
620 /* For writev() */
621 #include <sys/uio.h>
623 extern void _MD_linux_map_sendfile_error(int err);
625 #endif /* nspr_linux_defs_h___ */