xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_buf.h (revision 2a8bcb4e)
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 #include <sys/types.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 typedef struct fmd_buf {
38 	char *buf_name;			/* name of this buffer */
39 	struct fmd_buf *buf_next;	/* next buffer in hash chain */
40 	void *buf_data;			/* buffer data storage */
41 	size_t buf_size;		/* buffer size */
42 	uint_t buf_flags;		/* buffer flags (see below) */
43 } fmd_buf_t;
44 
45 #define	FMD_BUF_DIRTY	0x1		/* buffer is dirty (needs checkpoint) */
46 
47 typedef void fmd_buf_f(fmd_buf_t *, void *);
48 
49 typedef struct fmd_buf_hash {
50 	fmd_buf_t **bh_hash;		/* hash bucket array for buffers */
51 	uint_t bh_hashlen;		/* length of hash bucket array */
52 	uint_t bh_count;		/* number of buffers in hash */
53 } fmd_buf_hash_t;
54 
55 extern void fmd_buf_hash_create(fmd_buf_hash_t *);
56 extern size_t fmd_buf_hash_destroy(fmd_buf_hash_t *);
57 extern void fmd_buf_hash_apply(fmd_buf_hash_t *, fmd_buf_f *, void *);
58 extern void fmd_buf_hash_commit(fmd_buf_hash_t *);
59 extern uint_t fmd_buf_hash_count(fmd_buf_hash_t *);
60 
61 extern fmd_buf_t *fmd_buf_insert(fmd_buf_hash_t *, const char *, size_t);
62 extern fmd_buf_t *fmd_buf_lookup(fmd_buf_hash_t *, const char *);
63 extern void fmd_buf_delete(fmd_buf_hash_t *, const char *);
64 
65 #ifdef	__cplusplus
66 }
67 #endif
68 
69 #endif	/* _FMD_BUF_H */
70