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