|
|
1.1 root 1: /*
2: * $Source: /u1/X/hacks/bitrot/RCS/twiddle.h,v $
3: * $Author: tony $
4: * $Locker: $
5: * $Header: twiddle.h,v 10.1 86/02/01 15:43:23 tony Rel $
6: */
7:
8: #include <sys/types.h>
9:
10: /* WARNING! ASSUMES 8-BIT CHARACTERS! */
11:
12: /* Each of these operates on the xth bit from map */
13: /* Map must be a pointer, not necessarily a u_char pointer */
14: #define fetch(map, x) (1 & (((u_char *) map)[x >> 3] >> (x & 7)))
15: #define set(map, x) ((((u_char *) map)[x>>3] |= 1 << (x & 7)))
16: #define reset(map, x) ((((u_char *) map)[x>>3] &= ~(1 << (x & 7))))
17: #define flip(map,x) ((((u_char *) map)[x>>3] ^= 1 << (x & 7)))
18: #define place(map, x, bit) ((bit ? set(map,x),0 : reset(map,x), 0))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.