man.bsd.lv manual page server

Manual Page Search Parameters

SETBIT(9) Kernel Developer's Manual SETBIT(9)

setbitmacros related to bitmaps

#include <sys/param.h>

void
setbit(array, x);

void
clrbit(array, x);

int
isset(array, x);

int
isclr(array, x);

The setbit family of macros operate with bitmaps, also known as bit arrays.

In a nutshell, () sets the bit x in array, () clears it, () tests whether x is set, and () returns 1 if x is not set.

The following example declares a buffer of 10 chars, treating it as an array of 80 bits:

char buf[10];

...

setbit(buf, 12);	/* set the fifth bit in the second byte */

bitmap(3), bitstring(3)

The number of valid bits in a given array is assumed to be multiple of CHAR_BIT, the number of bits for smallest object that is not a bit-field.

December 4, 2012 NetBSD-9.2