xref: /original-bsd/lib/libc/db/hash/hash_log2.c (revision 95a66346)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Margo Seltzer.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #if defined(LIBC_SCCS) && !defined(lint)
12 static char sccsid[] = "@(#)hash_log2.c	5.1 (Berkeley) 02/12/91";
13 #endif /* LIBC_SCCS and not lint */
14 
15 __log2( num )
16 int	num;
17 {
18     register int	i;
19     register int	limit = 1;
20 
21     for ( i = 0; limit < num; limit = limit << 1, i++ );
22     return (i);
23 }
24