summaryrefslogtreecommitdiff
path: root/src/libstddjb/bitarray_testandpoke.c
blob: 5075f1d418ff1b8397f9d49a8af87c6b1a09c32e (plain)
1
2
3
4
5
6
7
8
9
10
11
/* ISC license. */

#include <skalibs/bitarray.h>

int bitarray_testandpoke (register unsigned char *s, register unsigned int n, register int h)
{
  register unsigned char mask = 1 << (n & 7) ;
  register unsigned char c = s[n>>3] ;
  s[n>>3] = h ? c | mask : c & ~mask ;
  return (c & mask) ? 1 : 0 ;
}