Remove extra .Cm
[dragonfly.git] / share / man / man9 / hash.9
1 .\"
2 .\" Copyright (c) 2003, 2004 The DragonFly Project.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to The DragonFly Project
5 .\" by Hiten Pandya <hmp@backplane.com>.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in
15 .\"    the documentation and/or other materials provided with the
16 .\"    distribution.
17 .\" 3. Neither the name of The DragonFly Project nor the names of its
18 .\"    contributors may be used to endorse or promote products derived
19 .\"    from this software without specific, prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\" $DragonFly: src/share/man/man9/hash.9,v 1.3 2004/07/16 05:04:36 hmp Exp $
35 .\"
36 .Dd May 14, 2004
37 .Os
38 .Dt HASH 9
39 .Sh NAME
40 .Nm hash ,
41 .Nm hashinit ,
42 .Nm phashinit
43 .Nd generic hash table functions for the kernel
44 .Sh SYNOPSIS
45 .In sys/param.h
46 .In sys/systm.h
47 .In sys/malloc.h
48 .Ft void *
49 .Fn hashinit "int elements" "struct malloc_type *type" "u_long *hashmask"
50 .Ft void *
51 .Fn phashinit "int elements" "struct malloc_type *type" "u_long *nentries"
52 .Sh DESCRIPTION
53 The kernel hash functions are used for creating a generic hash table.
54 .Pp
55 The
56 .Fn hashinit
57 function returns a pointer to a hash table which is sized a
58 .Dq "power of two"
59 greater or equal to the number of
60 .Fa elements
61 requested.
62 The masking value is stored in
63 .Fa hashmask .
64 .Pp
65 The
66 .Fn phashinit
67 function returns a pointer to a prime number sized hash table.
68 The number of
69 .Fa elements
70 requested is used to dictate an upper-bound for the size of the
71 hash table.
72 The final size of the hash table is stored by the function in
73 .Fa nentries .
74 .Pp
75 The
76 .Fa type
77 argument to both of the above functions is used for keeping track
78 of memory allocated for the hash table.
79 See the
80 .Xr malloc 9
81 manual page for more information on memory statistics.
82 .Sh CODE REFERENCES
83 The VFS namecache code is one of many examples for using the
84 .Fn hashinit
85 function; it is located within the file
86 .Pa sys/kern/vfs_cache.c .
87 .Pp
88 The hostcache code uses the
89 .Fn phashinit
90 function for creating a prime number sized hash table; it is located
91 within the file
92 .Pa sys/net/hostcache.c .
93 .Pp
94 All pathnames in this section are relative to the
95 .Dx
96 source tree.
97 .Sh SEE ALSO
98 .Xr tcp 4 ,
99 .Xr udp 4 ,
100 .Xr malloc 9 ,
101 .Xr namei 9
102 .Sh AUTHORS
103 This manual page was written by
104 .An Hiten Pandya Aq hmp@backplane.com .