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