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

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