Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


wacom-util.h
01: /*
02:  * Copyright 2011 by Jason Gerecke, Wacom. <jason.gerecke@wacom.com>
03:  *
04:  * This program is free software; you can redistribute it and/or
05:  * modify it under the terms of the GNU General Public License
06:  * as published by the Free Software Foundation; either version 2
07:  * of the License, or (at your option) any later version.
08:  *
09:  * This program is distributed in the hope that it will be useful,
10:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12:  * GNU General Public License for more details.
13:  *
14:  * You should have received a copy of the GNU General Public License
15:  * along with this program; if not, write to the Free Software
16:  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17:  */
18: 
19: #ifndef WACOM_UTIL_H_
20: #define WACOM_UTIL_H_
21: 
22: /**
23:  * Get the number of elements in an array
24:  */
25: #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
26: 
27: /* to access kernel defined bits */
28: #define BIT(x)          (1UL<<((x) & (BITS_PER_LONG - 1)))
29: #define BITS_PER_LONG   (sizeof(long) * 8)
30: #define NBITS(x)        ((((x)-1)/BITS_PER_LONG)+1)
31: #define ISBITSET(x,y)   ((x)[LONG(y)] & BIT(y))
32: #define SETBIT(x,y)     ((x)[LONG(y)] |= BIT(y))
33: #define CLEARBIT(x,y)   ((x)[LONG(y)] &= ~BIT(y))
34: #define OFF(x)          ((x)%BITS_PER_LONG)
35: #define LONG(x)         ((x)/BITS_PER_LONG)
36: 
37: /**
38:  * Test if the mask is set in the given bitfield.
39:  * @return TRUE if set or FALSE otherwise.
40:  */
41: #define MaskIsSet(bitfield, mask) !!(((bitfield) & (mask)) == (mask))
42: /**
43:  * Set the given mask for the given bitfield.
44:  */
45: #define MaskSet(bitfield, mask) ((bitfield) |= (mask))
46: /**
47:  * Clear the given mask from the given bitfield
48:  */
49: #define MaskClear(bitfield, mask) ((bitfield) &= ~(mask))
50: 
51: #endif /* WACOM_UTIL_H_ */
52: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/