8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libfakekernel / common / sys / thread.h
blob6213be28073665d879c8679a53929f5682de34e4
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
29 #ifndef _SYS_THREAD_H
30 #define _SYS_THREAD_H
32 #include <sys/types.h>
33 #include <sys/t_lock.h>
34 #include <sys/klwp.h>
35 #include <sys/signal.h> /* expected by including code */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
42 * The thread object, its states, and the methods by which it
43 * is accessed.
47 * Values that t_state may assume. Note that t_state cannot have more
48 * than one of these flags set at a time.
50 #define TS_FREE 0x00 /* Thread at loose ends */
51 #define TS_SLEEP 0x01 /* Awaiting an event */
52 #define TS_RUN 0x02 /* Runnable, but not yet on a processor */
53 #define TS_ONPROC 0x04 /* Thread is being run on a processor */
54 #define TS_ZOMB 0x08 /* Thread has died but hasn't been reaped */
55 #define TS_STOPPED 0x10 /* Stopped, initial state */
56 #define TS_WAIT 0x20 /* Waiting to become runnable */
58 /* ctxop_t */
60 /* afd_t needed by sys/file.h via sys/t_lock.h */
61 typedef struct _afd_not_used afd_t;
63 struct turnstile;
64 struct panic_trap_info;
65 struct upimutex;
66 struct kproject;
67 struct on_trap_data;
68 struct waitq;
69 struct _kcpc_ctx;
70 struct _kcpc_set;
72 /* Definition for kernel thread identifier type */
73 typedef uint64_t kt_did_t;
75 struct _kthread;
76 typedef struct _kthread *kthread_id_t;
78 typedef struct _kthread kthread_t;
80 extern kthread_t *_curthread(void); /* returns thread pointer */
81 #define curthread (_curthread()) /* current thread pointer */
83 #define _KTHREAD_INVALID ((void *)(uintptr_t)-1)
86 struct proc;
87 extern struct proc *_curproc(void);
88 #define curproc (_curproc()) /* current proc pointer */
90 struct zone;
91 extern struct zone *_curzone(void);
92 #define curzone (_curzone()) /* current zone pointer */
94 extern kthread_t *thread_create(
95 caddr_t stk,
96 size_t stksize,
97 void (*proc)(),
98 void *arg,
99 size_t len,
100 struct proc *pp,
101 int state,
102 pri_t pri);
103 extern void thread_exit(void) __NORETURN;
104 extern void thread_join(kt_did_t);
106 extern kthread_t *zthread_create(caddr_t, size_t, void (*)(), void *, size_t,
107 pri_t);
108 extern void zthread_exit(void) __NORETURN;
110 #ifdef __cplusplus
112 #endif
114 #endif /* _SYS_THREAD_H */