00001 /*- 00002 * See the file LICENSE for redistribution information. 00003 * 00004 * Copyright (c) 1996, 1997, 1998, 1999, 2000 00005 * Sleepycat Software. All rights reserved. 00006 */ 00007 /* 00008 * Copyright (c) 1995, 1996 00009 * The Regents of the University of California. All rights reserved. 00010 * 00011 * This code is derived from software contributed to Berkeley by 00012 * Margo Seltzer. 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions 00016 * are met: 00017 * 1. Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the distribution. 00022 * 3. Neither the name of the University nor the names of its contributors 00023 * may be used to endorse or promote products derived from this software 00024 * without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00027 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00030 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00031 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00032 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00033 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00034 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00035 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00036 * SUCH DAMAGE. 00037 */ 00038 00039 #include "config.h" 00040 00041 #ifndef lint 00042 static const char revid[] = "$Id: db__log2_8c-source.html,v 1.1 2008/06/08 10:17:51 sebdiaz Exp $"; 00043 #endif /* not lint */ 00044 00045 #ifndef NO_SYSTEM_INCLUDES 00046 #include <sys/types.h> 00047 #endif 00048 00049 #include "db_int.h" 00050 #include "common_ext.h" 00051 00052 /* 00053 * PUBLIC: u_int32_t CDB___db_log2 __P((u_int32_t)); 00054 */ 00055 u_int32_t 00056 CDB___db_log2(num) 00057 u_int32_t num; 00058 { 00059 u_int32_t i, limit; 00060 00061 limit = 1; 00062 for (i = 0; limit < num; limit = limit << 1) 00063 ++i; 00064 return (i); 00065 }