1*64377c51SSascha Wildner.\" 2*64377c51SSascha Wildner.\" Copyright (c) 2003, 2004 The DragonFly Project. All rights reserved. 3*64377c51SSascha Wildner.\" 4*64377c51SSascha Wildner.\" This code is derived from software contributed to The DragonFly Project 5*64377c51SSascha Wildner.\" by Hiten Pandya <hmp@backplane.com>. 6*64377c51SSascha Wildner.\" 7*64377c51SSascha Wildner.\" Redistribution and use in source and binary forms, with or without 8*64377c51SSascha Wildner.\" modification, are permitted provided that the following conditions 9*64377c51SSascha Wildner.\" are met: 10*64377c51SSascha Wildner.\" 11*64377c51SSascha Wildner.\" 1. Redistributions of source code must retain the above copyright 12*64377c51SSascha Wildner.\" notice, this list of conditions and the following disclaimer. 13*64377c51SSascha Wildner.\" 2. Redistributions in binary form must reproduce the above copyright 14*64377c51SSascha Wildner.\" notice, this list of conditions and the following disclaimer in 15*64377c51SSascha Wildner.\" the documentation and/or other materials provided with the 16*64377c51SSascha Wildner.\" distribution. 17*64377c51SSascha Wildner.\" 3. Neither the name of The DragonFly Project nor the names of its 18*64377c51SSascha Wildner.\" contributors may be used to endorse or promote products derived 19*64377c51SSascha Wildner.\" from this software without specific, prior written permission. 20*64377c51SSascha Wildner.\" 21*64377c51SSascha Wildner.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*64377c51SSascha Wildner.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*64377c51SSascha Wildner.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*64377c51SSascha Wildner.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*64377c51SSascha Wildner.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*64377c51SSascha Wildner.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*64377c51SSascha Wildner.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28*64377c51SSascha Wildner.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29*64377c51SSascha Wildner.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30*64377c51SSascha Wildner.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31*64377c51SSascha Wildner.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*64377c51SSascha Wildner.\" SUCH DAMAGE. 33*64377c51SSascha Wildner.\" 34*64377c51SSascha Wildner.Dd December 20, 2009 35*64377c51SSascha Wildner.Dt HASHINIT 9 36*64377c51SSascha Wildner.Os 37*64377c51SSascha Wildner.Sh NAME 38*64377c51SSascha Wildner.Nm hashinit , 39*64377c51SSascha Wildner.Nm hashinit_ext , 40*64377c51SSascha Wildner.Nm phashinit , 41*64377c51SSascha Wildner.Nm phashinit_ext 42*64377c51SSascha Wildner.Nd generic hash table functions for the kernel 43*64377c51SSascha Wildner.Sh SYNOPSIS 44*64377c51SSascha Wildner.In sys/param.h 45*64377c51SSascha Wildner.In sys/systm.h 46*64377c51SSascha Wildner.In sys/malloc.h 47*64377c51SSascha Wildner.Ft void * 48*64377c51SSascha Wildner.Fn hashinit "int count" "struct malloc_type *type" "u_long *hashmask" 49*64377c51SSascha Wildner.Ft void * 50*64377c51SSascha Wildner.Fn hashinit_ext "int count" "size_t size" "struct malloc_type *type" "u_long *hashmask" 51*64377c51SSascha Wildner.Ft void * 52*64377c51SSascha Wildner.Fn phashinit "int count" "struct malloc_type *type" "u_long *nentries" 53*64377c51SSascha Wildner.Ft void * 54*64377c51SSascha Wildner.Fn phashinit_ext "int count" "size_t size" "struct malloc_type *type" "u_long *nentries" 55*64377c51SSascha Wildner.Sh DESCRIPTION 56*64377c51SSascha WildnerThe kernel hash functions are used for creating a generic hash table. 57*64377c51SSascha Wildner.Pp 58*64377c51SSascha WildnerThe 59*64377c51SSascha Wildner.Fn hashinit 60*64377c51SSascha Wildnerfunction returns a pointer to a hash table which is sized a 61*64377c51SSascha Wildner.Dq "power of two" 62*64377c51SSascha Wildnergreater or equal to the element 63*64377c51SSascha Wildner.Fa count 64*64377c51SSascha Wildnerrequested. 65*64377c51SSascha WildnerThe masking value is stored in 66*64377c51SSascha Wildner.Fa hashmask . 67*64377c51SSascha Wildner.Pp 68*64377c51SSascha WildnerThe 69*64377c51SSascha Wildner.Fn phashinit 70*64377c51SSascha Wildnerfunction returns a pointer to a prime number sized hash table. 71*64377c51SSascha WildnerThe element 72*64377c51SSascha Wildner.Fa count 73*64377c51SSascha Wildnerrequested is used to dictate an upper-bound for the size of the 74*64377c51SSascha Wildnerhash table. 75*64377c51SSascha WildnerThe final size of the hash table is stored by the function in 76*64377c51SSascha Wildner.Fa nentries . 77*64377c51SSascha Wildner.Pp 78*64377c51SSascha WildnerThe 79*64377c51SSascha Wildner.Fa type 80*64377c51SSascha Wildnerargument to both of the above functions is used for keeping track 81*64377c51SSascha Wildnerof memory allocated for the hash table. 82*64377c51SSascha WildnerSee the 83*64377c51SSascha Wildner.Xr kmalloc 9 84*64377c51SSascha Wildnermanual page for more information on memory statistics. 85*64377c51SSascha Wildner.Pp 86*64377c51SSascha WildnerThe 87*64377c51SSascha Wildner.Fn hashinit_ext 88*64377c51SSascha Wildnerand 89*64377c51SSascha Wildner.Fn phashinit_ext 90*64377c51SSascha Wildnerfunctions are extended versions of 91*64377c51SSascha Wildner.Fn hashinit 92*64377c51SSascha Wildnerand 93*64377c51SSascha Wildner.Fn phashinit 94*64377c51SSascha Wildnerwhich take the 95*64377c51SSascha Wildner.Fa size 96*64377c51SSascha Wildnerof the structure as an additional argument and will zero the array instead 97*64377c51SSascha Wildnerof assuming that it is an array of 98*64377c51SSascha Wildner.Dv LIST_HEAD Ns s . 99*64377c51SSascha Wildner.Sh SEE ALSO 100*64377c51SSascha Wildner.Xr tcp 4 , 101*64377c51SSascha Wildner.Xr udp 4 , 102*64377c51SSascha Wildner.Xr kmalloc 9 , 103*64377c51SSascha Wildner.Xr nlookup 9 104*64377c51SSascha Wildner.Sh AUTHORS 105*64377c51SSascha WildnerThis manual page was written by 106*64377c51SSascha Wildner.An Hiten Pandya Aq hmp@backplane.com . 107