home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_11
/
allison
/
bit.h
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-01
|
516b
|
24 lines
LISTING 3 - Declarations for Bit Access Functions
/* bit.h: Bitwise functions for unsigned ints */
#ifndef BIT_H
#define BIT_H
#include <stdio.h>
#include <limits.h>
#define mask1(i) (1u << i)
#define mask0(i) ~(1u << i)
#define set(n,i) (n | mask1(i))
#define reset(n,i) (n & mask0(i))
#define toggle(n,i) (n ^ mask1(i))
#define test(n,i) !!(n & mask1(i))
#define nbits(x) (sizeof(##x##) * CHAR_BIT)
unsigned fputb(unsigned, FILE *);
unsigned fgetb(FILE *);
unsigned count(unsigned);
#endif