[Xquartz-changes] xserver: Branch 'master' - 2 commits
Jeremy Huddleston
jeremyhu at freedesktop.org
Fri Nov 26 09:44:47 PST 2010
dix/getevents.c | 8 ++++----
include/inputstr.h | 2 +-
test/input.c | 16 ++++++++++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
New commits:
commit 23e3d1f23318ce69623f91908f888a09f8b74ac2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Fri Nov 26 10:00:49 2010 +1000
dix: remove now unnecessary !! before BitIsOn()
The macro has been changed to do this already, no need for double
not-not-ing.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Keith Packard <keithp at keithp.com>
diff --git a/dix/getevents.c b/dix/getevents.c
index 0d59290..f09d31c 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -115,9 +115,9 @@ button_is_down(DeviceIntPtr pDev, int button, int type)
int ret = 0;
if (type & BUTTON_PROCESSED)
- ret |= !!BitIsOn(pDev->button->down, button);
+ ret |= BitIsOn(pDev->button->down, button);
if (type & BUTTON_POSTED)
- ret |= !!BitIsOn(pDev->button->postdown, button);
+ ret |= BitIsOn(pDev->button->postdown, button);
return ret;
}
@@ -146,9 +146,9 @@ key_is_down(DeviceIntPtr pDev, int key_code, int type)
int ret = 0;
if (type & KEY_PROCESSED)
- ret |= !!BitIsOn(pDev->key->down, key_code);
+ ret |= BitIsOn(pDev->key->down, key_code);
if (type & KEY_POSTED)
- ret |= !!BitIsOn(pDev->key->postdown, key_code);
+ ret |= BitIsOn(pDev->key->postdown, key_code);
return ret;
}
commit 42dc91e32a02b6b21ff5c45f465f3349e5822615
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Wed Nov 24 14:20:30 2010 +1000
include: let BitIsOn() return a boolean value.
Simply returning the mask bit breaks checks like
BitIsOn(mask, 0) != BitIsOn(mask, 1);
as used in 048e93593e3f7a99a7d2a219e1ce2bdc9d407807.
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 at who-t.net>
Reviewed-by: Pat Kane <pekane52 at gmail.com>
Reviewed-by: Julien Cristau <jcristau at debian.org>
Reviewed-by: Keith Packard <keithp at keithp.com>
diff --git a/include/inputstr.h b/include/inputstr.h
index d4c253e..44de9c4 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -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);
diff --git a/test/input.c b/test/input.c
index 4ccfaff..1fe228c 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1050,7 +1050,22 @@ static void dix_valuator_mode(void)
g_assert(valuator_get_mode(&dev, i) == Relative);
}
+static void include_bit_test_macros(void)
+{
+ uint8_t mask[9] = { 0 };
+ int i;
+ for (i = 0; i < sizeof(mask)/sizeof(mask[0]); i++)
+ {
+ g_assert(BitIsOn(mask, i) == 0);
+ SetBit(mask, i);
+ g_assert(BitIsOn(mask, i) == 1);
+ g_assert(!!(mask[i/8] & (1 << (i % 8))));
+ g_assert(CountBits(mask, sizeof(mask)) == 1);
+ ClearBit(mask, i);
+ g_assert(BitIsOn(mask, i) == 0);
+ }
+}
int main(int argc, char** argv)
{
@@ -1066,6 +1081,7 @@ int main(int argc, char** argv)
g_test_add_func("/dix/input/grab_matching", dix_grab_matching);
g_test_add_func("/dix/input/valuator_mode", dix_valuator_mode);
g_test_add_func("/include/byte_padding_macros", include_byte_padding_macros);
+ g_test_add_func("/include/bit_test_macros", include_bit_test_macros);
g_test_add_func("/Xi/xiproperty/register-unregister", xi_unregister_handlers);
More information about the Xquartz-changes
mailing list