/****************************************************************************/
/*	Copyright (c) 2009, Bendor Research Pty. Ltd. All rights reserved.		*/
/*	This software is released under the GNU General Public License, version	*/
/*	3, with the exemptions that 1) the header files installed by this 	 	*/
/*	package can be included in closed-source code and 2) the libraries		*/
/*	built by this package can be statically linked into a closed-source 	*/
/*	binary. See the file LICENSE for the details.							*/
/*	This software is provided "AS IS", without any warranty or guarantee.	*/
/*	By using this software you acknowledge that neither Bendor Research nor	*/
/*	any of its personnel or affiliates can be held liable for any damages,	*/
/*	including, but not limited to, loss of business, loss of money, loss of */
/*	life, loss of reputation, arising out of this software being faulty or	*/
/*	not performing as advertised, even if Bendor Research was aware of such	*/
/*	faults in the software. You use this software at your own risk, any and */
/*	all liabilities that arise out of your using this software are strictly	*/
/*	yours.																	*/
/****************************************************************************/

#error "Do not include this file! Use <misc/bits.h> instead"

/****************************************************************************/
/*  This file is for documentation only, describing assembly routines.		*/
/****************************************************************************/

/** @addtogroup misc_bits */
/** @{ */

/**
*	Number of one bits of a word.
*
*	The function counts the number of '1' bits in a 32-bit word and
*	returns the count.
*
*	@param	x	The word in question
*	@return		The number of 1 bits in the word
*/

unsigned	bitcnt( unsigned x );

/**
*	Number of leading zero bits of a word.
*
*	The function counts the number of consecutive 0 bits from the MSB of
*	a 32-bit word. If the MSB is set, then the returned value is 0, if
*	the word is 0, then the returned value is 32.
*
*	@param	x	The word in question
*	@return		The number of leading 0 bits
*/

unsigned	ldzcnt( unsigned x );

/**
*	Number of trailing zero bits of a word.
*
*	The function counts the number of consecutive 0 bits from the LSB of
*	a 32-bit word. If the LSB is set, then the returned value is 0, if
*	the word is 0, then the returned value is 32.
*
*	@param	x	The word in question
*	@return		The number of trailing 0 bits
*/

unsigned	trzcnt( unsigned x );

/**
*	Reverse bits in a word.
*
*	The function takes a 32-bit word, then swaps its LSB with its MSB,
*	bit 1 with bit 30 and in general bit<sub>N</sub> with bit<sub>31-N</sub>
*	for all N-s from 0 to 15.
*
*	@param	x	The word to reverse
*	@return		The reversed word
*/

unsigned	bitrev( unsigned x );

/**
*	Change the endianness of a word.
*
*	The function changes a 32 bit word in little-endian byte order to a
*	32-bit word in big-endian byte order and <i>vice versa</i>.
*	That is, if the function argument was <tt>0x12345678</tt> then
*	the returned word will be <tt>0x78563412</tt>.
*
*	@param	x	A word in some endiannes
*	@return		The word in the other endianness
*/

unsigned	endian( unsigned x );

/** @} */

