xref: /titanic_52/usr/src/tools/ctf/cvt/ctfmerge.h (revision 74e20cfe817b82802b16fac8690dadcda76f54f5)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2002-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _CTFMERGE_H
28 #define	_CTFMERGE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Merging structures used in ctfmerge.  See ctfmerge.c for locking semantics.
34  */
35 
36 #include <pthread.h>
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 #include "ctftools.h"
43 #include "barrier.h"
44 #include "fifo.h"
45 
46 typedef struct wip {
47 	pthread_mutex_t wip_lock;
48 	pthread_cond_t wip_cv;
49 	tdata_t *wip_td;
50 	int wip_nmerged;
51 	int wip_batchid;
52 } wip_t;
53 
54 typedef struct workqueue {
55 	int wq_next_batchid;
56 
57 	int wq_maxbatchsz;
58 
59 	wip_t *wq_wip;
60 	int wq_nwipslots;
61 	int wq_nthreads;
62 	int wq_ithrottle;
63 
64 	pthread_mutex_t wq_queue_lock;
65 	fifo_t *wq_queue;
66 	pthread_cond_t wq_work_avail;
67 	pthread_cond_t wq_work_removed;
68 	int wq_ninqueue;
69 	int wq_nextpownum;
70 
71 	pthread_mutex_t wq_donequeue_lock;
72 	fifo_t *wq_donequeue;
73 	int wq_lastdonebatch;
74 	pthread_cond_t wq_done_cv;
75 
76 	pthread_cond_t wq_alldone_cv; /* protected by queue_lock */
77 	int wq_alldone;
78 
79 	int wq_nomorefiles;
80 
81 	barrier_t wq_bar1;
82 	barrier_t wq_bar2;
83 } workqueue_t;
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* _CTFMERGE_H */
90