]>
git.saurik.com Git - apple/libc.git/blob - threads/cthread_internals.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
34 * 08-Mar-90 Avadis Tevanian, Jr. (avie) at NeXT
35 * Added errno field to cproc structure.
40 * cthread_internals.h - by Eric Cooper
42 * Private definitions for the C Threads implementation.
44 * The cproc structure is used for different implementations
45 * of the basic schedulable units that execute cthreads.
47 * MTHREAD MACH threads; single address space,
48 * kernel-mode preemptive scheduling
51 #include <mach/mach.h>
52 #include <mach/mach_error.h>
55 * Low-level thread implementation.
56 * This structure must agree with struct ur_cthread in cthreads.h
58 typedef struct cproc
{
59 struct cproc
*next
; /* for lock, condition, and ready queues */
60 struct cproc
*incarnation
; /* for cthread_self() */
62 mach_port_t reply_port
; /* for mig_get_reply_port() */
64 mach_port_t wait_port
;
67 struct cproc
*link
; /* so all cprocs can be found
71 unsigned int stack_base
;
72 unsigned int stack_size
;
77 #define NO_CPROC ((cproc_t) 0)
78 #define cproc_self() ((cproc_t) ur_cthread_self())
79 extern void cthread_set_self(cproc_t p
);
82 * Possible cproc states.
84 #define CPROC_RUNNING 0
85 #define CPROC_SPINNING 1
86 #define CPROC_BLOCKED 2
89 * The cproc flag bits.
91 #define CPROC_INITIAL_STACK 0x1
92 #define CPROC_NOCACHE_THREAD /* Don't try to cache this cthread on exit */
98 extern char *malloc();
99 #endif /* __STRICT_BSD__ */
104 extern void mach_error();
109 #ifdef __STRICT_BSD__
113 #endif /* __STRICT_BSD__ */
116 * Macro for MACH kernel calls.
119 #define MACH_CALL(expr, ret) { \
120 if (((ret) = (expr)) != KERN_SUCCESS) { \
121 mach_error(#expr, (ret)); \
130 #ifdef CTHREADS_DEBUG
133 #define TRACE(x) if (cthread_debug) x ; else
134 extern int cthread_debug
;
141 #else /* CTHREADS_DEBUG */
143 #define private static