xref: /titanic_50/usr/src/cmd/fm/fmd/common/fmd_buf.h (revision 14d56903b5e712ea59206c206e57d3731107fcf1)
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 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FMD_BUF_H
29 #define	_FMD_BUF_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/types.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 typedef struct fmd_buf {
40 	char *buf_name;			/* name of this buffer */
41 	struct fmd_buf *buf_next;	/* next buffer in hash chain */
42 	void *buf_data;			/* buffer data storage */
43 	size_t buf_size;		/* buffer size */
44 	uint_t buf_flags;		/* buffer flags (see below) */
45 } fmd_buf_t;
46 
47 #define	FMD_BUF_DIRTY	0x1		/* buffer is dirty (needs checkpoint) */
48 
49 typedef void fmd_buf_f(fmd_buf_t *, void *);
50 
51 typedef struct fmd_buf_hash {
52 	fmd_buf_t **bh_hash;		/* hash bucket array for buffers */
53 	uint_t bh_hashlen;		/* length of hash bucket array */
54 	uint_t bh_count;		/* number of buffers in hash */
55 } fmd_buf_hash_t;
56 
57 extern void fmd_buf_hash_create(fmd_buf_hash_t *);
58 extern size_t fmd_buf_hash_destroy(fmd_buf_hash_t *);
59 extern void fmd_buf_hash_apply(fmd_buf_hash_t *, fmd_buf_f *, void *);
60 extern void fmd_buf_hash_commit(fmd_buf_hash_t *);
61 extern uint_t fmd_buf_hash_count(fmd_buf_hash_t *);
62 
63 extern fmd_buf_t *fmd_buf_insert(fmd_buf_hash_t *, const char *, size_t);
64 extern fmd_buf_t *fmd_buf_lookup(fmd_buf_hash_t *, const char *);
65 extern void fmd_buf_delete(fmd_buf_hash_t *, const char *);
66 
67 #ifdef	__cplusplus
68 }
69 #endif
70 
71 #endif	/* _FMD_BUF_H */
72