/*
 *	$Source: /var/lib/cvsd/repos/CSRG/43BSDTahoe/new/X/hacks/bitrot/twiddle.h,v $
 *	$Author: root $
 *	$Locker:  $
 *	$Header: /var/lib/cvsd/repos/CSRG/43BSDTahoe/new/X/hacks/bitrot/twiddle.h,v 1.1.1.1 2018/04/24 16:12:58 root Exp $
 */

#include <sys/types.h>

/* WARNING!  ASSUMES 8-BIT CHARACTERS! */

/* Each of these operates on the xth bit from map */
/* Map must be a pointer, not necessarily a u_char pointer */
#define fetch(map, x) (1 & (((u_char *) map)[x >> 3] >> (x & 7)))
#define set(map, x) ((((u_char *) map)[x>>3] |= 1 << (x & 7)))
#define reset(map, x) ((((u_char *) map)[x>>3] &= ~(1 << (x & 7))))
#define flip(map,x) ((((u_char *) map)[x>>3] ^=  1 << (x & 7)))
#define place(map, x, bit) ((bit ? set(map,x),0 : reset(map,x), 0))
