Compare commits

...

2 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult bd2171ec9d dix: make CountBits() inline
The function is small enough for easily being inlined.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:45 +02:00
Enrico Weigelt, metux IT consult f8eae88dc7 dix: unexport and document CountBits()
Not used by any drivers/modules, so no need to keep it exported.
Also adding a bit of documentation.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-05-15 19:06:45 +02:00
3 changed files with 18 additions and 15 deletions

View File

@ -51,7 +51,8 @@ SOFTWARE.
#ifndef _XSERVER_INPUT_PRIV_H
#define _XSERVER_INPUT_PRIV_H
#include "input.h"
#include "include/input.h"
#include "include/inputstr.h"
typedef struct _InputOption InputOption;
typedef struct _XI2Mask XI2Mask;
@ -364,4 +365,20 @@ int InputThreadRegisterDev(int fd,
int InputThreadUnregisterDev(int fd);
/*
* @brief count the bits set in the given bitmask
*
* @param mask pointer to bitmask
* @param len size of bitmask in bits (may span multiple bytes)
* @return number of bits set in the given bitmask
*/
static inline int CountBits(const uint8_t * mask, int len)
{
int ret = 0;
for (int i = 0; i < len; i++)
if (BitIsOn(mask, i))
ret++;
return ret;
}
#endif /* _XSERVER_INPUT_PRIV_H */

View File

@ -690,19 +690,6 @@ valuator_mask_fetch_unaccelerated(const ValuatorMask *mask,
return FALSE;
}
int
CountBits(const uint8_t * mask, int len)
{
int i;
int ret = 0;
for (i = 0; i < len; i++)
if (BitIsOn(mask, i))
ret++;
return ret;
}
/**
* Verifies sanity of the event. If the event is not an internal event,
* memdumps the first 32 bytes of event to the log, a backtrace, then kill

View File

@ -63,7 +63,6 @@ extern _X_EXPORT void AssignTypeAndName(DeviceIntPtr dev,
#define BitIsOn(ptr, bit) (!!(((const 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);
#define SameClient(obj,client) \
(CLIENT_BITS((obj)->resource) == (client)->clientAsMask)