xref: /titanic_50/usr/src/cmd/prstat/prtable.h (revision 61491074b8a9b27fe22ce320f874f909877c6d91)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Portions Copyright 2009 Chad Mynhier
26  */
27 
28 #ifndef	_PRTABLE_H
29 #define	_PRTABLE_H
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <limits.h>
36 #include <zone.h>
37 #include "prstat.h"
38 
39 #define	PLWP_TBL_SZ	4096	/* hash table of plwp_t structures */
40 #define	LWP_ACTIVE	1
41 
42 typedef struct {
43 	size_t		t_size;
44 	size_t		t_nent;
45 	long		*t_list;
46 } table_t;
47 
48 typedef struct {
49 	size_t		n_size;
50 	size_t		n_nent;
51 	uid_t		*n_list;
52 } uidtbl_t;
53 
54 typedef struct {
55 	zoneid_t	z_id;
56 	char		z_name[ZONENAME_MAX];
57 } zonename_t;
58 
59 typedef struct {
60 	size_t		z_size;
61 	size_t		z_nent;
62 	zonename_t	*z_list;
63 } zonetbl_t;
64 
65 typedef struct plwp {		/* linked list of pointers to lwps */
66 	pid_t		l_pid;
67 	id_t		l_lwpid;
68 	int		l_active;
69 	lwp_info_t	*l_lwp;
70 	struct plwp	*l_next;
71 } plwp_t;
72 
73 extern void pwd_getname(uid_t, char *, int, int);
74 extern void add_uid(uidtbl_t *, char *);
75 extern int has_uid(uidtbl_t *, uid_t);
76 extern void add_element(table_t *, long);
77 extern int has_element(table_t *, long);
78 extern void add_zone(zonetbl_t *, char *);
79 extern int has_zone(zonetbl_t *, zoneid_t);
80 extern void convert_zone(zonetbl_t *);
81 extern int foreach_element(table_t *, void *, void (*)(long, void *));
82 extern void lwpid_init();
83 extern void lwpid_add(lwp_info_t *, pid_t, id_t);
84 extern lwp_info_t *lwpid_get(pid_t, id_t);
85 extern int lwpid_pidcheck(pid_t);
86 extern void lwpid_del(pid_t, id_t);
87 extern void lwpid_set_active(pid_t, id_t);
88 extern int lwpid_is_active(pid_t, id_t);
89 
90 #ifdef	__cplusplus
91 }
92 #endif
93 
94 #endif	/* _PRTABLE_H */
95