[PATCH] rename NBITS to NLONGS to reflect its actual meaning

Matt Helsley matt.helsley at gmail.com
Sun Jan 11 18:04:40 PST 2009


NBITS really convers the number of bits passed as its argument
into a number of longs. This is somewhat atypical of many 
function-like-macro names. Rename it to NLONGS.

Signed-off-by: Matt Helsley <matt.helsley at gmail.com>
---
 src/evdev.c |   16 ++++++++--------
 src/evdev.h |   14 ++++++++------
 2 files changed, 16 insertions(+), 14 deletions(-)

Index: xf86-input-evdev/src/evdev.c
===================================================================
--- xf86-input-evdev.orig/src/evdev.c
+++ xf86-input-evdev/src/evdev.c
@@ -1221,15 +1221,15 @@ EvdevCacheCompare(InputInfoPtr pInfo, BO
 {
     EvdevPtr pEvdev = pInfo->private;
     int i;
 
     char name[1024]                  = {0};
-    long bitmask[NBITS(EV_MAX)]      = {0};
-    long key_bitmask[NBITS(KEY_MAX)] = {0};
-    long rel_bitmask[NBITS(REL_MAX)] = {0};
-    long abs_bitmask[NBITS(ABS_MAX)] = {0};
-    long led_bitmask[NBITS(LED_MAX)] = {0};
+    long bitmask[NLONGS(EV_MAX)]      = {0};
+    long key_bitmask[NLONGS(KEY_MAX)] = {0};
+    long rel_bitmask[NLONGS(REL_MAX)] = {0};
+    long abs_bitmask[NLONGS(ABS_MAX)] = {0};
+    long led_bitmask[NLONGS(LED_MAX)] = {0};
     struct input_absinfo absinfo[ABS_MAX];
 
     if (ioctl(pInfo->fd,
               EVIOCGNAME(sizeof(name) - 1), name) < 0) {
         xf86Msg(X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
@@ -1321,13 +1321,13 @@ error:
 }
 
 static int
 EvdevProbe(InputInfoPtr pInfo)
 {
-    long key_bitmask[NBITS(KEY_MAX)] = {0};
-    long rel_bitmask[NBITS(REL_MAX)] = {0};
-    long abs_bitmask[NBITS(ABS_MAX)] = {0};
+    long key_bitmask[NLONGS(KEY_MAX)] = {0};
+    long rel_bitmask[NLONGS(REL_MAX)] = {0};
+    long abs_bitmask[NLONGS(ABS_MAX)] = {0};
     int i, has_axes, has_keys, num_buttons, has_scroll;
     int kernel24 = 0;
     EvdevPtr pEvdev = pInfo->private;
 
     if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
Index: xf86-input-evdev/src/evdev.h
===================================================================
--- xf86-input-evdev.orig/src/evdev.h
+++ xf86-input-evdev/src/evdev.h
@@ -45,11 +45,13 @@
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
 #define HAVE_PROPERTIES 1
 #endif
 
 #define LONG_BITS (sizeof(long) * 8)
-#define NBITS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
+
+/* Number of longs needed to hold the given number of bits */
+#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
 
 /* axis specific data for wheel emulation */
 typedef struct {
     int up_button;
     int down_button;
@@ -119,15 +121,15 @@ typedef struct {
     int reopen_left;     /* number of attempts left to re-open the device */
     OsTimerPtr reopen_timer;
 
     /* Cached info from device. */
     char name[1024];
-    long bitmask[NBITS(EV_MAX)];
-    long key_bitmask[NBITS(KEY_MAX)];
-    long rel_bitmask[NBITS(REL_MAX)];
-    long abs_bitmask[NBITS(ABS_MAX)];
-    long led_bitmask[NBITS(LED_MAX)];
+    long bitmask[NLONGS(EV_MAX)];
+    long key_bitmask[NLONGS(KEY_MAX)];
+    long rel_bitmask[NLONGS(REL_MAX)];
+    long abs_bitmask[NLONGS(ABS_MAX)];
+    long led_bitmask[NLONGS(LED_MAX)];
     struct input_absinfo absinfo[ABS_MAX];
 
     /* minor/major number */
     dev_t min_maj;
 } EvdevRec, *EvdevPtr;





More information about the xorg mailing list