xref: /titanic_52/usr/src/cmd/fm/fmd/common/fmd_thread.h (revision 587644a8567e6a9533f88401daa59cbd78c4632f)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_FMD_THREAD_H
26 #define	_FMD_THREAD_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <fmd_list.h>
33 #include <fmd_trace.h>
34 
35 struct fmd_module;			/* see <fmd_module.h> */
36 
37 typedef void fmd_thread_f(void *);	/* signature of thread startup func */
38 
39 typedef struct fmd_thread {
40 	fmd_list_t thr_list;		/* linked-list next/prev pointers */
41 	struct fmd_module *thr_mod;	/* module associated with this thread */
42 	pthread_t thr_tid;		/* thread identifier */
43 	fmd_thread_f *thr_func;		/* thread startup function */
44 	void *thr_arg;			/* argument for startup function */
45 	fmd_tracebuf_t *thr_trdata;	/* thread trace buffer */
46 	fmd_tracebuf_f *thr_trfunc;	/* thread trace function */
47 	uint_t thr_errdepth;		/* fmd_verror() nesting depth */
48 	int thr_isdoor;			/* a private door server thread */
49 } fmd_thread_t;
50 
51 extern fmd_thread_t *fmd_thread_xcreate(struct fmd_module *, pthread_t);
52 extern fmd_thread_t *fmd_thread_create(struct fmd_module *,
53     fmd_thread_f *, void *);
54 extern fmd_thread_t *fmd_doorthread_create(struct fmd_module *,
55     fmd_thread_f *, void *);
56 
57 #define	FMD_THREAD_NOJOIN	0	/* do not attempt to join with thread */
58 #define	FMD_THREAD_JOIN		1	/* wait for and join with thread */
59 
60 extern void fmd_thread_destroy(fmd_thread_t *, int);
61 
62 #ifdef	__cplusplus
63 }
64 #endif
65 
66 #endif	/* _FMD_THREAD_H */
67