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