bitmap.h

Go to the documentation of this file.
00001 // Copyright (C) 2006-2007 Benedikt Böhm <hollow@gentoo.org>
00002 //
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
00016 
00017 /*!
00018  * @defgroup bitmap Bitmap conversion
00019  *
00020  * The i2v and v2i family of functions convert between a bitmap and a bit index.
00021  *
00022  * A bitmap is simply an integer with certain bits being 1 (enabled) and 0
00023  * (disabled).
00024  *
00025  * These functions only return usable results if exactly one bit is enabled.
00026  *
00027  * - Bit index to bitmap<br>
00028  *   The resulting bitmask is a simple arithmetic left shift of 1 index times.
00029  * - Bitmap to bit index<br>
00030  *   The resulting bit index is asimple arithmetic right shift until the map is
00031  *   empty.
00032  *
00033  * These functions are mainly used by the flist family of functions.
00034  *
00035  * @{
00036  */
00037 
00038 #ifndef _LUCID_BITMAP_H
00039 #define _LUCID_BITMAP_H
00040 
00041 #include <stdint.h>
00042 
00043 /*!
00044  * @brief convert bit index to 32 bit value
00045  *
00046  * @param[in] index bit index (0-31)
00047  *
00048  * @return 32 bit value
00049  */
00050 uint32_t i2v32(int index);
00051 
00052 /*!
00053  * @brief convert bit index to 64 bit value
00054  *
00055  * @param[in] index bit index (0-63)
00056  *
00057  * @return 64 bit value
00058  */
00059 uint64_t i2v64(int index);
00060 
00061 /*!
00062  * @brief convert 32 bit value to bit index
00063  *
00064  * @param[in] val 32 bit value
00065  *
00066  * @return bit index (0-31)
00067  */
00068 int v2i32(uint32_t val);
00069 
00070 /*!
00071  * @brief convert 64 bit value to bit index
00072  *
00073  * @param[in] val 64 bit value
00074  *
00075  * @return bit index (0-63)
00076  */
00077 int v2i64(uint64_t val);
00078 
00079 #endif
00080 
00081 /*! @} bitmap */

Generated on Tue Jun 19 20:38:25 2007 for lucid by  doxygen 1.5.2