Blame src/plugins/kdb/db2/libdb2/hash/hash_log2.c

Packit fd8b60
/*-
Packit fd8b60
 * Copyright (c) 1990, 1993, 1994
Packit fd8b60
 *	The Regents of the University of California.  All rights reserved.
Packit fd8b60
 *
Packit fd8b60
 * This code is derived from software contributed to Berkeley by
Packit fd8b60
 * Margo Seltzer.
Packit fd8b60
 *
Packit fd8b60
 * Redistribution and use in source and binary forms, with or without
Packit fd8b60
 * modification, are permitted provided that the following conditions
Packit fd8b60
 * are met:
Packit fd8b60
 * 1. Redistributions of source code must retain the above copyright
Packit fd8b60
 *    notice, this list of conditions and the following disclaimer.
Packit fd8b60
 * 2. Redistributions in binary form must reproduce the above copyright
Packit fd8b60
 *    notice, this list of conditions and the following disclaimer in the
Packit fd8b60
 *    documentation and/or other materials provided with the distribution.
Packit fd8b60
 * 3. All advertising materials mentioning features or use of this software
Packit fd8b60
 *    must display the following acknowledgement:
Packit fd8b60
 *	This product includes software developed by the University of
Packit fd8b60
 *	California, Berkeley and its contributors.
Packit fd8b60
 * 4. Neither the name of the University nor the names of its contributors
Packit fd8b60
 *    may be used to endorse or promote products derived from this software
Packit fd8b60
 *    without specific prior written permission.
Packit fd8b60
 *
Packit fd8b60
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Packit fd8b60
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit fd8b60
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit fd8b60
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
Packit fd8b60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit fd8b60
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit fd8b60
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit fd8b60
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit fd8b60
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit fd8b60
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit fd8b60
 * SUCH DAMAGE.
Packit fd8b60
 */
Packit fd8b60
Packit fd8b60
#if defined(LIBC_SCCS) && !defined(lint)
Packit fd8b60
static char sccsid[] = "@(#)hash_log2.c	8.4 (Berkeley) 11/7/95";
Packit fd8b60
#endif /* LIBC_SCCS and not lint */
Packit fd8b60
Packit fd8b60
#include "db-int.h"
Packit fd8b60
#include "hash.h"
Packit fd8b60
#include "page.h"
Packit fd8b60
#include "extern.h"
Packit fd8b60
Packit fd8b60
u_int32_t
Packit fd8b60
__kdb2_log2(num)
Packit fd8b60
	u_int32_t num;
Packit fd8b60
{
Packit fd8b60
	u_int32_t i, limit;
Packit fd8b60
Packit fd8b60
	limit = 1;
Packit fd8b60
	for (i = 0; limit < num; limit = limit << 1, i++);
Packit fd8b60
	return (i);
Packit fd8b60
}