Home | History | Annotate | Download | only in truss
      1  0  stevel /*
      2  0  stevel  * CDDL HEADER START
      3  0  stevel  *
      4  0  stevel  * The contents of this file are subject to the terms of the
      5  0  stevel  * Common Development and Distribution License, Version 1.0 only
      6  0  stevel  * (the "License").  You may not use this file except in compliance
      7  0  stevel  * with the License.
      8  0  stevel  *
      9  0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  0  stevel  * or http://www.opensolaris.org/os/licensing.
     11  0  stevel  * See the License for the specific language governing permissions
     12  0  stevel  * and limitations under the License.
     13  0  stevel  *
     14  0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     15  0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     17  0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     18  0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  0  stevel  *
     20  0  stevel  * CDDL HEADER END
     21  0  stevel  */
     22  0  stevel /*
     23  0  stevel  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
     24  0  stevel  * Use is subject to license terms.
     25  0  stevel  */
     26  0  stevel 
     27  0  stevel #ifndef	_HTBL_H
     28  0  stevel #define	_HTBL_H
     29  0  stevel 
     30  0  stevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31  0  stevel 
     32  0  stevel #ifdef	__cplusplus
     33  0  stevel extern "C" {
     34  0  stevel #endif
     35  0  stevel 
     36  0  stevel #include <stdlib.h>
     37  0  stevel 
     38  0  stevel typedef struct hentry {
     39  0  stevel 	struct hentry *next;		/* next entry in hash chain */
     40  0  stevel 	struct hentry *prev;		/* previous entry in hash chain */
     41  0  stevel 	char *lib;			/* library name */
     42  0  stevel 	char *key;			/* hash key (function name) */
     43  0  stevel 	unsigned long count;		/* number of occurances of fn */
     44  0  stevel } hentry_t;
     45  0  stevel 
     46  0  stevel typedef struct hashb {
     47  0  stevel 	hentry_t *first;		/* first entry in bucket */
     48  0  stevel 	mutex_t block;			/* bucket lock */
     49  0  stevel } hashb_t;
     50  0  stevel 
     51  0  stevel typedef struct htbl {
     52  0  stevel 	unsigned int size;		/* size of tbl in buckets */
     53  0  stevel 	hashb_t *tbl;			/* ptr to buckets */
     54  0  stevel } htbl_t;
     55  0  stevel 
     56  0  stevel typedef struct hiter {
     57  0  stevel 	int bucket;			/* bucket in current iteration */
     58  0  stevel 	hentry_t *next;			/* next entry in iteration */
     59  0  stevel 	htbl_t *table;			/* ptr to table */
     60  0  stevel } hiter_t;
     61  0  stevel 
     62  0  stevel /*
     63  0  stevel  * HD_hashntry specifies that the entry written to disk contains information
     64  0  stevel  * about function calls and is stored in the hash table.  When read back from
     65  0  stevel  * disk this is merged into the parent's hash table
     66  0  stevel  *
     67  0  stevel  * HD_cts_syscts specifies that the entry written to disk is a struct counts
     68  0  stevel  * struct syscount pair.  This contains information about system calls,
     69  0  stevel  * signals, and faults.  When read back from disk, the information is added
     70  0  stevel  * to the struct count / struct syscount information kept by the parent.
     71  0  stevel  */
     72  0  stevel 
     73  0  stevel typedef enum hdtype { HD_hashntry, HD_cts_syscts } hdtype_t;
     74  0  stevel 
     75  0  stevel typedef struct hdntry {
     76  0  stevel 	hdtype_t type;		/* type of entry we've written to disk */
     77  0  stevel 	size_t sz_lib;		/* size of library string on disk */
     78  0  stevel 	size_t sz_key;		/* size of key string on disk */
     79  0  stevel 	unsigned long count;	/* count of occurrances of key */
     80  0  stevel } hdntry_t;
     81  0  stevel 
     82  0  stevel 
     83  0  stevel extern htbl_t *init_hash(unsigned int);
     84  0  stevel extern void destroy_hash(htbl_t *);
     85  0  stevel extern hiter_t *iterate_hash(htbl_t *);
     86  0  stevel extern hentry_t *iter_next(hiter_t *);
     87  0  stevel extern void iter_free(hiter_t *);
     88  0  stevel extern void add_fcall(htbl_t *, char *, char *, unsigned long);
     89  0  stevel extern size_t elements_in_table(htbl_t *);
     90  0  stevel 
     91  0  stevel #ifdef	__cplusplus
     92  0  stevel }
     93  0  stevel #endif
     94  0  stevel 
     95  0  stevel #endif	/* _HTBL_H */
     96