mirror of
https://github.com/X11Libre/xserver.git
synced 2026-09-25 21:02:21 +00:00
include: let BitIsOn() return a boolean value.
Simply returning the mask bit breaks checks like
BitIsOn(mask, 0) != BitIsOn(mask, 1);
as used in 048e93593e.
The naming of this macro suggests that it should return boolean values
anyway. This patch also adds a few simple tests for these macros to make
sure they don't accidentally break in the future.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pat Kane <pekane52@gmail.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
4e0f8f666e
commit
42dc91e32a
2 changed files with 17 additions and 1 deletions
|
|
@ -57,7 +57,7 @@ SOFTWARE.
|
|||
#include "geext.h"
|
||||
#include "privates.h"
|
||||
|
||||
#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
|
||||
#define BitIsOn(ptr, bit) (!!(((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
|
||||
#define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
|
||||
#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
|
||||
extern _X_EXPORT int CountBits(const uint8_t *mask, int len);
|
||||
|
|
|
|||
Loading…
Reference in a new issue