Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2007 Pekka Riikonen
+ Copyright (C) 2007 - 2008 Pekka Riikonen
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
*/
-/****h* silcutil/SILC Bit Operations Interface
+/****h* silcutil/Bit Operations Interface
*
* DESCRIPTION
*
* find bits in an arbitrarily large bitmap. The interface does not support
* setting the bits atomically.
*
+ * EXAMPLE
+ *
* Example with a pre-allocated bitmap:
*
* // Declare bitmap of size of 500 bits
#define SILC_BIT_SIZE (SILC_SIZEOF_LONG * 8)
-/****d* silcutil/SilcBitOpAPI/SILC_BITMAP_DECLARE
+/****d* silcutil/SILC_BITMAP_DECLARE
*
* NAME
*
#define SILC_BITMAP_DECLARE(name, bits) \
unsigned long name[SILC_BITMAP_SIZE(bits)]
-/****d* silcutil/SilcBitOpAPI/SILC_BITMAP_SIZE
+/****d* silcutil/SILC_BITMAP_SIZE
*
* NAME
*
***/
#define SILC_BITMAP_SIZE(bits) (((bits) + SILC_BIT_SIZE) / SILC_BIT_SIZE)
-/****f* silcutil/SilcBitOpAPI/silc_bit_set
+/****f* silcutil/silc_bit_set
*
* SYNOPSIS
*
* DESCRIPTION
*
* Set bit number `bit' in the `bitmap' of size of `bitmap_size'. Returns
- * FALSE on error.
+ * FALSE on error and sets silc_errno.
*
***/
SilcBool silc_bit_set(volatile unsigned long *bitmap, SilcUInt32 bitmap_size,
SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_clear
+/****f* silcutil/silc_bit_clear
*
* SYNOPSIS
*
* DESCRIPTION
*
* Clear bit number `bit' in the `bitmap' of size of `bitmap_size'.
- * Returns FALSE on error.
+ * Returns FALSE on error and sets silc_errno.
*
***/
SilcBool silc_bit_clear(volatile unsigned long *bitmap, SilcUInt32 bitmap_size,
SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_toggle
+/****f* silcutil/silc_bit_toggle
*
* SYNOPSIS
*
* DESCRIPTION
*
* Toggle bit number `bit' in the `bitmap' of size of `bitmap_size'.
- * Returns FALSE on error.
+ * Returns FALSE on error and sets silc_errno.
*
***/
SilcBool silc_bit_toggle(volatile unsigned long *bitmap,
SilcUInt32 bitmap_size, SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_test_and_set
+/****f* silcutil/silc_bit_test_and_set
*
* SYNOPSIS
*
* DESCRIPTION
*
* Set bit number `bit' in the `bitmap' of size of `bitmap_size' and
- * return the value before setting. Returns -1 on error.
+ * return the value before setting. Returns -1 on error and sets
+ * silc_errno.
*
***/
int silc_bit_test_and_set(volatile unsigned long *bitmap,
SilcUInt32 bitmap_size, SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_test_and_clear
+/****f* silcutil/silc_bit_test_and_clear
*
* SYNOPSIS
*
* DESCRIPTION
*
* Clear bit number `bit' in the `bitmap' of size of `bitmap_size' and
- * return the value before setting. Returns -1 on error.
+ * return the value before setting. Returns -1 on error and sets
+ * silc_errno.
*
***/
int silc_bit_test_and_clear(volatile unsigned long *bitmap,
SilcUInt32 bitmap_size, SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_test_and_toggle
+/****f* silcutil/silc_bit_test_and_toggle
*
* SYNOPSIS
*
* DESCRIPTION
*
* Toggle bit number `bit' in the `bitmap' of size of `bitmap_size' and
- * return the value before setting. Returns -1 on error.
+ * return the value before setting. Returns -1 on error and sets
+ * silc_errno.
*
***/
int silc_bit_test_and_toggle(volatile unsigned long *bitmap,
SilcUInt32 bitmap_size, SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_get
+/****f* silcutil/silc_bit_get
*
* SYNOPSIS
*
*
* DESCRIPTION
*
- * Returns the value of the bit number `bit' or -1 on error.
+ * Returns the value of the bit number `bit' or -1 on error and sets
+ * silc_errno.
*
***/
int silc_bit_get(volatile unsigned long *bitmap, SilcUInt32 bitmap_size,
SilcUInt32 bit);
-/****f* silcutil/SilcBitOpAPI/silc_bit_ffs
+/****f* silcutil/silc_bit_ffs
*
* SYNOPSIS
*
* DESCRIPTION
*
* Returns the bit number of the first set bit in the `bitmap' of size
- * of `bitmap_size'. Returns -1 on error or when there were no set bits.
+ * of `bitmap_size'. Returns -1 on error or when there were no set bits
+ * and sets silc_errno.
*
***/
int silc_bit_ffs(volatile unsigned long *bitmap, SilcUInt32 bitmap_size);
-/****f* silcutil/SilcBitOpAPI/silc_bit_ffz
+/****f* silcutil/silc_bit_ffz
*
* SYNOPSIS
*
* DESCRIPTION
*
* Returns the bit number of the first zero bit in the `bitmap' of size
- * of `bitmap_size'. Returns -1 on error or when there were no zero bits.
+ * of `bitmap_size'. Returns -1 on error or when there were no zero bits
+ * and sets silc_errno.
*
***/
int silc_bit_ffz(volatile unsigned long *bitmap, SilcUInt32 bitmap_size);
-/****f* silcutil/SilcBitOpAPI/silc_bit_fns
+/****f* silcutil/silc_bit_fns
*
* SYNOPSIS
*
*
* Returns the bit number of the next set bit in the `bitmap' of size
* of `bitmap_size' starting at bit `offset'. Returns -1 on error or
- * when there were no more set bits.
+ * when there were no more set bits and sets silc_errno.
*
***/
int silc_bit_fns(volatile unsigned long *bitmap, SilcUInt32 bitmap_size,
SilcUInt32 offset);
-/****f* silcutil/SilcBitOpAPI/silc_bit_fnz
+/****f* silcutil/silc_bit_fnz
*
* SYNOPSIS
*
*
* Returns the bit number of the next zero bit in the `bitmap' of size
* of `bitmap_size' starting at bit `offset'. Returns -1 on error or
- * when there were no more zero bits.
+ * when there were no more zero bits and sets silc_errno.
*
***/
int silc_bit_fnz(volatile unsigned long *bitmap, SilcUInt32 bitmap_size,
SilcUInt32 offset);
-/****f* silcutil/SilcBitOpAPI/silc_bit_clear_bitmap
+/****f* silcutil/silc_bit_clear_bitmap
*
* SYNOPSIS
*