]>
git.saurik.com Git - apple/libc.git/blob - threads.subproj/cthread_internals.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Mach Operating System
24 * Copyright (c) 1989 Carnegie-Mellon University
25 * All rights reserved. The CMU software License Agreement specifies
26 * the terms and conditions for use and redistribution.
31 * 08-Mar-90 Avadis Tevanian, Jr. (avie) at NeXT
32 * Added errno field to cproc structure.
37 * cthread_internals.h - by Eric Cooper
39 * Private definitions for the C Threads implementation.
41 * The cproc structure is used for different implementations
42 * of the basic schedulable units that execute cthreads.
44 * MTHREAD MACH threads; single address space,
45 * kernel-mode preemptive scheduling
48 #include <mach/mach.h>
49 #include <mach/mach_error.h>
52 * Low-level thread implementation.
53 * This structure must agree with struct ur_cthread in cthreads.h
55 typedef struct cproc
{
56 struct cproc
*next
; /* for lock, condition, and ready queues */
57 struct cproc
*incarnation
; /* for cthread_self() */
59 mach_port_t reply_port
; /* for mig_get_reply_port() */
61 mach_port_t wait_port
;
64 struct cproc
*link
; /* so all cprocs can be found
68 unsigned int stack_base
;
69 unsigned int stack_size
;
74 #define NO_CPROC ((cproc_t) 0)
75 #define cproc_self() ((cproc_t) ur_cthread_self())
76 extern void cthread_set_self(cproc_t p
);
79 * Possible cproc states.
81 #define CPROC_RUNNING 0
82 #define CPROC_SPINNING 1
83 #define CPROC_BLOCKED 2
86 * The cproc flag bits.
88 #define CPROC_INITIAL_STACK 0x1
89 #define CPROC_NOCACHE_THREAD /* Don't try to cache this cthread on exit */
95 extern char *malloc();
96 #endif /* __STRICT_BSD__ */
101 extern void mach_error();
106 #ifdef __STRICT_BSD__
110 #endif /* __STRICT_BSD__ */
113 * Macro for MACH kernel calls.
116 #define MACH_CALL(expr, ret) { \
117 if (((ret) = (expr)) != KERN_SUCCESS) { \
118 mach_error(#expr, (ret)); \
127 #ifdef CTHREADS_DEBUG
130 #define TRACE(x) if (cthread_debug) x ; else
131 extern int cthread_debug
;
138 #else /* CTHREADS_DEBUG */
140 #define private static