VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/4.2/include/extensions/xtrapbits.h@ 6202

Last change on this file since 6202 was 6202, checked in by vboxsync, 17 years ago

re-export x11

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $XFree86: xc/include/extensions/xtrapbits.h,v 1.1 2001/11/02 23:29:26 dawes Exp $ */
2/*
3 * This include file is designed to be a portable way for systems to define
4 * bit field manipulation of arrays of bits.
5 */
6#ifndef __XTRAPBITS__
7#define __XTRAPBITS__ "@(#)xtrapbits.h 1.6 - 90/09/18 "
8
9/*****************************************************************************
10Copyright 1987, 1988, 1989, 1990, 1994 by Digital Equipment Corporation,
11Maynard, MA
12
13Permission to use, copy, modify, and distribute this software and its
14documentation for any purpose and without fee is hereby granted,
15provided that the above copyright notice appear in all copies and that
16both that copyright notice and this permission notice appear in
17supporting documentation, and that the name of Digital not be
18used in advertising or publicity pertaining to distribution of the
19software without specific, written prior permission.
20
21DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
22ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
23DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27SOFTWARE.
28
29*****************************************************************************/
30/*
31 *
32 * CONTRIBUTORS:
33 *
34 * Dick Annicchiarico
35 * Robert Chesler
36 * Dan Coutu
37 * Gene Durso
38 * Marc Evans
39 * Alan Jamison
40 * Mark Henry
41 * Ken Miller
42 *
43 */
44typedef unsigned char *UByteP; /* Pointer to an unsigned byte array */
45#define BitsInByte 8L /* The number of bits in a byte */
46
47#define BitInByte(bit) /* Returns the bit mask of a byte */ \
48 (1L << (((bit) % BitsInByte)))
49
50#define BitInWord(bit) /* Returns the bit mask of a word */ \
51 (1L << (((bit) % (BitsInByte * 2L))))
52
53#define BitInLong(bit) /* Returns the bit mask of a long */ \
54 (1L << (((bit) % (BitsInByte * 4L))))
55
56#define ByteInArray(array,bit) /* Returns the byte offset to get to a bit */ \
57 (((UByteP)(array))[(bit) / BitsInByte])
58
59#define BitIsTrue(array,bit) /* Test to see if a specific bit is True */ \
60 (ByteInArray(array,bit) & BitInByte(bit))
61
62#define BitIsFalse(array,bit) /* Test to see if a specific bit is False */ \
63 (!(BitIsTrue(array,bit)))
64
65#define BitTrue(array,bit) /* Set a specific bit to be True */ \
66 (ByteInArray(array,bit) |= BitInByte(bit))
67
68#define BitFalse(array,bit) /* Set a specific bit to be False */ \
69 (ByteInArray(array,bit) &= ~BitInByte(bit))
70
71#define BitToggle(array,bit) /* Toggle a specific bit */ \
72 (ByteInArray(array,bit) ^= BitInByte(bit))
73
74#define BitCopy(dest,src,bit) /* Copy a specific bit */ \
75 BitIsTrue((src),(bit)) ? BitTrue((dest),(bit)) : BitFalse((dest),(bit))
76
77#define BitValue(array,bit) /* Return True or False depending on bit */ \
78 (BitIsTrue((array),(bit)) ? True : False)
79
80#define BitSet(array,bit,value) /* Set bit to given value in array */ \
81 (value) ? BitTrue((array),(bit)) : BitFalse((array),(bit))
82
83#endif /* __XTRAPBITS__ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette