[PATCH:xf86-video-xgi 01/19] Avoid redefinitions of u8, uint8_t, and GETBITS.

Matthieu Herrb matthieu at herrb.eu
Mon Aug 10 23:38:14 PDT 2015


On Thu, Aug 06, 2015 at 02:56:59PM +0200, Thomas Klausner wrote:

Hi,

I think it would be better to clean up this kind of drivers by
completely getting rid of custom integer types. use uint8_t & co
everywhere directly.

CARD8 in driver is particularly wrong. the CARD*  types are only part
of the X *protocol definition*. They are not meant to be used as an
hardware interface.

Iirc more maintained driver have already been cleaned up wrt those
integer types definitions.

> Signed-off-by: Thomas Klausner <wiz at NetBSD.org>
> ---
>  src/vb_i2c.h | 6 +++++-
>  src/xgi.h    | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/vb_i2c.h b/src/vb_i2c.h
> index 1e9de25..69f02cd 100755
> --- a/src/vb_i2c.h
> +++ b/src/vb_i2c.h
> @@ -7,7 +7,9 @@
>  #endif 
>  #ifndef u32
>  #define u32 unsigned long
> -#define u8 unsigned long
> +#endif
> +#ifndef u8
> +#define u8 uint8_t
>  #endif
>  
>  /* Jong at 08052009 */
> @@ -82,7 +84,9 @@
>  // set bits as 1 between bit(a) and bit(b)
>  #define MASK(n)         ( BITS(LARGE(n)-SMALL(n)+1) << SMALL(n) )
>  // get bits [a:b]'s binary value
> +#ifndef GETBITS
>  #define GETBITS(b,n)    ( ((b) & MASK(n)) >> SMALL(n) ) /* Jong at 08032009 */
> +#endif
>  // set binary value from [a:0] to [c:d]
>  #define SETBITS(b, n)   ( ( (b) << ((1?n) > (0?n) ? (0?n) : (1?n)) ) & MASK(n) )
>  // move bits value from [a:b] to [c:d]
> diff --git a/src/xgi.h b/src/xgi.h
> index 0bc8d30..a5702c4 100755
> --- a/src/xgi.h
> +++ b/src/xgi.h
> @@ -1022,7 +1022,9 @@ extern void XGI_SetRegANDOR(XGIIOADDRESS Port, USHORT Index, USHORT DataAND,
>  extern void XGI_SetRegAND(XGIIOADDRESS Port, USHORT Index, USHORT DataAND);
>  extern void XGI_SetRegOR(XGIIOADDRESS Port, USHORT Index, USHORT DataOR);
>  
> +#ifndef uint8_t
>  #define uint8_t	CARD8
> +#endif
>  extern void XGI_WriteDAC(XGIIOADDRESS dac_data, unsigned shift,
>      unsigned ordering, uint8_t red, uint8_t green, uint8_t blue);
>  
> -- 
> 2.5.0
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel

-- 
Matthieu Herrb


More information about the xorg-devel mailing list