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.4 (Berkeley) 09/26/91"; 13 #endif /* LIBC_SCCS and not lint */ 14 15 #include <sys/types.h> 16 17 u_int 18 __log2(num) 19 u_int num; 20 { 21 register u_int i, limit; 22 23 limit = 1; 24 for (i = 0; limit < num; limit = limit << 1, i++); 25 return (i); 26 } 27