Deleted Added
full compact
hash.9 (156710) hash.9 (162877)
1.\" Copyright (c) 2001 Tobias Weingartner
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $OpenBSD: hash.9,v 1.5 2003/04/17 05:08:39 jmc Exp $
1.\" Copyright (c) 2001 Tobias Weingartner
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 10 unchanged lines hidden (view full) ---

19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $OpenBSD: hash.9,v 1.5 2003/04/17 05:08:39 jmc Exp $
27.\" $FreeBSD: head/share/man/man9/hash.9 156710 2006-03-14 17:19:09Z andre $
27.\" $FreeBSD: head/share/man/man9/hash.9 162877 2006-09-30 17:09:59Z ru $
28.\"
29.Dd December 8, 2001
30.Dt HASH 9
31.Os
32.Sh NAME
28.\"
29.Dd December 8, 2001
30.Dt HASH 9
31.Os
32.Sh NAME
33.Nm hash
34.\" XXX - Should all these be .Nm as well?
35.\" .Nm hash32 ,
36.\" .Nm hash32_buf ,
37.\" .Nm hash32_str ,
38.\" .Nm hash32_strn ,
39.\" .Nm hash32_stre ,
40.\" .Nm hash32_strne
33.Nm hash ,
34.Nm hash32 ,
35.Nm hash32_buf ,
36.Nm hash32_str ,
37.Nm hash32_strn ,
38.Nm hash32_stre ,
39.Nm hash32_strne
41.Nd general kernel hashing functions
42.Sh SYNOPSIS
40.Nd general kernel hashing functions
41.Sh SYNOPSIS
43.Fd #include <sys/hash.h>
42.In sys/hash.h
44.Ft uint32_t
45.Fn hash32_buf "void *buf" "size_t len" "uint32_t hash"
46.Ft uint32_t
47.Fn hash32_str "void *buf" "uint32_t hash"
48.Ft uint32_t
49.Fn hash32_strn "void *buf" "size_t len" "uint32_t hash"
50.Ft uint32_t
51.Fn hash32_stre "void *buf" "int end" "char **ep" "uint32_t hash"
52.Ft uint32_t
53.Fn hash32_strne "void *buf" "size_t len" "int end" "char **ep" "uint32_t hash"
54.Sh DESCRIPTION
55The
56.Fn hash32
57functions are used to give a consistent and general interface to
58a decent hashing algorithm within the kernel.
43.Ft uint32_t
44.Fn hash32_buf "void *buf" "size_t len" "uint32_t hash"
45.Ft uint32_t
46.Fn hash32_str "void *buf" "uint32_t hash"
47.Ft uint32_t
48.Fn hash32_strn "void *buf" "size_t len" "uint32_t hash"
49.Ft uint32_t
50.Fn hash32_stre "void *buf" "int end" "char **ep" "uint32_t hash"
51.Ft uint32_t
52.Fn hash32_strne "void *buf" "size_t len" "int end" "char **ep" "uint32_t hash"
53.Sh DESCRIPTION
54The
55.Fn hash32
56functions are used to give a consistent and general interface to
57a decent hashing algorithm within the kernel.
59These functions can be used to hash ASCII
58These functions can be used to hash
59.Tn ASCII
60.Dv NUL
61terminated strings, as well as blocks of memory.
62.Pp
63The
64.Fn hash32_buf
65function is used as a general buffer hashing function.
66The argument
67.Fa buf

--- 46 unchanged lines hidden (view full) ---

114.Sh EXAMPLES
115.Bd -literal -offset indent
116LIST_HEAD(head, cache) *hashtbl = NULL;
117u_long mask = 0;
118
119void
120sample_init(void)
121{
60.Dv NUL
61terminated strings, as well as blocks of memory.
62.Pp
63The
64.Fn hash32_buf
65function is used as a general buffer hashing function.
66The argument
67.Fa buf

--- 46 unchanged lines hidden (view full) ---

114.Sh EXAMPLES
115.Bd -literal -offset indent
116LIST_HEAD(head, cache) *hashtbl = NULL;
117u_long mask = 0;
118
119void
120sample_init(void)
121{
122
122 hashtbl = hashinit(numwanted, type, flags, &mask);
123}
124
125void
126sample_use(char *str, int len)
127{
128 uint32_t hash;
129

--- 31 unchanged lines hidden ---
123 hashtbl = hashinit(numwanted, type, flags, &mask);
124}
125
126void
127sample_use(char *str, int len)
128{
129 uint32_t hash;
130

--- 31 unchanged lines hidden ---