File:  [CSRG BSD Unix] / 43BSD / contrib / X / hacks / bitrot / twiddle.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

/*
 *	$Source: /var/lib/cvsd/repos/CSRG/43BSD/contrib/X/hacks/bitrot/twiddle.h,v $
 *	$Author: root $
 *	$Locker:  $
 *	$Header: /var/lib/cvsd/repos/CSRG/43BSD/contrib/X/hacks/bitrot/twiddle.h,v 1.1.1.1 2018/04/24 16:12:54 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))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.