/*
 *	$Source: /mit/watchmaker/include/RCS/twiddle.h,v $
 *	$Author: builder $
 *	$Locker:  $
 *	$Header: twiddle.h,v 1.1 85/08/12 11:03:53 builder 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))
