146370Sbostic /*- 2*61202Sbostic * Copyright (c) 1990, 1993 3*61202Sbostic * The Regents of the University of California. All rights reserved. 446370Sbostic * 546370Sbostic * This code is derived from software contributed to Berkeley by 646370Sbostic * Margo Seltzer. 746370Sbostic * 846370Sbostic * %sccs.include.redist.c% 946370Sbostic */ 1046370Sbostic 1146370Sbostic #if defined(LIBC_SCCS) && !defined(lint) 12*61202Sbostic static char sccsid[] = "@(#)hash_log2.c 8.1 (Berkeley) 06/04/93"; 1346370Sbostic #endif /* LIBC_SCCS and not lint */ 1446370Sbostic 1550997Sbostic #include <sys/types.h> 1650997Sbostic 1751059Sbostic u_int __log2(num)1850997Sbostic__log2(num) 1951059Sbostic u_int num; 2046370Sbostic { 2151059Sbostic register u_int i, limit; 2246370Sbostic 2350997Sbostic limit = 1; 2450997Sbostic for (i = 0; limit < num; limit = limit << 1, i++); 2550997Sbostic return (i); 2646370Sbostic } 27