xref: /netbsd-src/usr.bin/nbperf/nbperf.h (revision 7c219dd6db4315f574c078369f92489252c284c0)
1*7c219dd6Sjoerg /*	$NetBSD: nbperf.h,v 1.5 2021/01/07 16:03:08 joerg Exp $	*/
203c8ba1cSjoerg /*-
303c8ba1cSjoerg  * Copyright (c) 2009 The NetBSD Foundation, Inc.
403c8ba1cSjoerg  * All rights reserved.
503c8ba1cSjoerg  *
603c8ba1cSjoerg  * This code is derived from software contributed to The NetBSD Foundation
703c8ba1cSjoerg  * by Joerg Sonnenberger.
803c8ba1cSjoerg  *
903c8ba1cSjoerg  * Redistribution and use in source and binary forms, with or without
1003c8ba1cSjoerg  * modification, are permitted provided that the following conditions
1103c8ba1cSjoerg  * are met:
1203c8ba1cSjoerg  *
1303c8ba1cSjoerg  * 1. Redistributions of source code must retain the above copyright
1403c8ba1cSjoerg  *    notice, this list of conditions and the following disclaimer.
1503c8ba1cSjoerg  * 2. Redistributions in binary form must reproduce the above copyright
1603c8ba1cSjoerg  *    notice, this list of conditions and the following disclaimer in
1703c8ba1cSjoerg  *    the documentation and/or other materials provided with the
1803c8ba1cSjoerg  *    distribution.
1903c8ba1cSjoerg  *
2003c8ba1cSjoerg  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2103c8ba1cSjoerg  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2203c8ba1cSjoerg  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2303c8ba1cSjoerg  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
2403c8ba1cSjoerg  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2503c8ba1cSjoerg  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
2603c8ba1cSjoerg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2703c8ba1cSjoerg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2803c8ba1cSjoerg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2903c8ba1cSjoerg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3003c8ba1cSjoerg  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3103c8ba1cSjoerg  * SUCH DAMAGE.
3203c8ba1cSjoerg  */
3303c8ba1cSjoerg 
34976b948dSjoerg #define	NBPERF_MAX_HASH_SIZE	3
35976b948dSjoerg 
3603c8ba1cSjoerg struct nbperf {
3703c8ba1cSjoerg 	FILE *output;
3803c8ba1cSjoerg 	FILE *map_output;
3903c8ba1cSjoerg 	const char *hash_name;
4003c8ba1cSjoerg 	int static_hash;
41*7c219dd6Sjoerg 	int allow_hash_fudging;
4203c8ba1cSjoerg 	size_t n;
4303c8ba1cSjoerg 	const void * __restrict * keys;
4403c8ba1cSjoerg 	const size_t *keylens;
45*7c219dd6Sjoerg 	int check_duplicates, has_duplicates;
4603c8ba1cSjoerg 
4703c8ba1cSjoerg 	double c;
4803c8ba1cSjoerg 
4903c8ba1cSjoerg 	size_t hash_size;
5003c8ba1cSjoerg 	void (*seed_hash)(struct nbperf *);
5103c8ba1cSjoerg 	void (*print_hash)(struct nbperf *, const char *, const char *, const char *,
5203c8ba1cSjoerg 	    const char *);
5303c8ba1cSjoerg 	void (*compute_hash)(struct nbperf *, const void *, size_t,
5403c8ba1cSjoerg 	    uint32_t *);
5503c8ba1cSjoerg 	uint32_t seed[1];
5603c8ba1cSjoerg };
5703c8ba1cSjoerg 
5803c8ba1cSjoerg int	chm_compute(struct nbperf *);
5903c8ba1cSjoerg int	chm3_compute(struct nbperf *);
60a81d4ca3Sjoerg int	bpz_compute(struct nbperf *);
61