hash_log2.c (1573) | hash_log2.c (14272) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 1990, 1993 | 2 * Copyright (c) 1990, 1993, 1994 |
3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Margo Seltzer. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 19 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) | 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Margo Seltzer. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 19 unchanged lines hidden (view full) --- 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 37#if defined(LIBC_SCCS) && !defined(lint) |
38static char sccsid[] = "@(#)hash_log2.c 8.1 (Berkeley) 6/4/93"; | 38static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; |
39#endif /* LIBC_SCCS and not lint */ 40 41#include <sys/types.h> 42 | 39#endif /* LIBC_SCCS and not lint */ 40 41#include <sys/types.h> 42 |
43u_int | 43#include <db.h> 44 45u_int32_t |
44__log2(num) | 46__log2(num) |
45 u_int num; | 47 u_int32_t num; |
46{ | 48{ |
47 register u_int i, limit; | 49 register u_int32_t i, limit; |
48 49 limit = 1; 50 for (i = 0; limit < num; limit = limit << 1, i++); 51 return (i); 52} | 50 51 limit = 1; 52 for (i = 0; limit < num; limit = limit << 1, i++); 53 return (i); 54} |