/* bitops - operation with bits, used by malloc
   Copyright 1993, 1994 Tristan Gingold
		  Written December 1993 by Tristan Gingold

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License 
along with this program; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   The author may be reached (Email) at the address marc@david.saclay.cea.fr,
   or (US/French mail) as Tristan Gingold 
   			  8 rue Parmentier
   			  F91120 PALAISEAU
   			  FRANCE
*/

/* If you want speed, you can define log_size with machine instructions.
   Consequently, the fonction is inline and faster.
   log_size return the offset of the higher bit set to one. If this offsert
   is above 19, the function must return 19.
   e.g: log_size(32) is 5
        log_size(48) is 5
   There is a C equivalent function in free.c
 */  
 
#ifdef __GNUC__
#ifdef i386
#if HASH_SIZE != 20
#error "Please, update log_size for i386, since you have changed HASH_SIZE"
#endif
extern __inline__ int
log_size(size_t size)
{
	register int __res __asm__("ax");

	__asm__("bsrl %1,%0\n\t"
		"cmpl $20,%0\n\t"	/* $20 is $HASH_SIZE */
 		"jb 1f\n\t"
		"movl $19,%0\n"		/* $19 is $(HASH_SIZE - 1) */
		"1:"
		:"=a" (__res) : "r" (size));
	return __res;
}
#define HAS_INLINE_LOG_SIZE
#endif
#endif

#ifndef HAS_INLINE_LOG_SIZE
int log_size(size_t size);
#endif
