1 2 3#ifdef HAVE_XORG_CONFIG_H 4#include <xorg-config.h> 5#endif 6 7#include <X11/Xarch.h> 8 9#ifndef FIXEDBASE 10#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base + (b)) 11#else 12#define CHECKRETURN(b) if(width <= ((b) * 32)) return(base) 13#endif 14 15#if X_BYTE_ORDER == X_BIG_ENDIAN 16# define SHIFT_L(value, shift) ((value) >> (shift)) 17# define SHIFT_R(value, shift) ((value) << (shift)) 18#else 19# define SHIFT_L(value, shift) ((value) << (shift)) 20# define SHIFT_R(value, shift) ((value) >> (shift)) 21#endif 22 23#ifndef MSBFIRST 24# ifdef FIXEDBASE 25# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = data; 26# else 27# define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = data; 28# endif 29#else 30# ifdef FIXEDBASE 31# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = SWAP_BITS_IN_BYTES(data); 32# else 33# define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = SWAP_BITS_IN_BYTES(data) 34# endif 35#endif 36 37#ifdef FIXEDBASE 38# ifdef MSBFIRST 39# define WRITE_BITS(b) *base = SWAP_BITS_IN_BYTES(b) 40# define WRITE_BITS1(b) { \ 41 *base = byte_reversed_expand3[(b) & 0xFF] | \ 42 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; } 43# define WRITE_BITS2(b) { \ 44 *base = byte_reversed_expand3[(b) & 0xFF] | \ 45 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ 46 *base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 47 byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; } 48# define WRITE_BITS3(b) { \ 49 *base = byte_reversed_expand3[(b) & 0xFF] | \ 50 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ 51 *base = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 52 byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ 53 *base = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ 54 byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; } 55# else 56# define WRITE_BITS(b) *base = (b) 57# define WRITE_BITS1(b) { \ 58 *base = byte_expand3[(b) & 0xFF] | \ 59 byte_expand3[((b) & 0xFF00) >> 8] << 24; } 60# define WRITE_BITS2(b) { \ 61 *base = byte_expand3[(b) & 0xFF] | \ 62 byte_expand3[((b) & 0xFF00) >> 8] << 24; \ 63 *base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 64 byte_expand3[((b) & 0xFF0000) >> 16] << 16; } 65# define WRITE_BITS3(b) { \ 66 *base = byte_expand3[(b) & 0xFF] | \ 67 byte_expand3[((b) & 0xFF00) >> 8] << 24; \ 68 *base = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 69 byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ 70 *base = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ 71 byte_expand3[((b) & 0xFF000000) >> 24] << 8; } 72# endif 73#else 74# ifdef MSBFIRST 75# define WRITE_BITS(b) *(base++) = SWAP_BITS_IN_BYTES(b) 76# define WRITE_BITS1(b) { \ 77 *(base++) = byte_reversed_expand3[(b) & 0xFF] | \ 78 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; } 79# define WRITE_BITS2(b) { \ 80 *(base) = byte_reversed_expand3[(b) & 0xFF] | \ 81 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ 82 *(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 83 byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ 84 base += 2; } 85# define WRITE_BITS3(b) { \ 86 *(base) = byte_reversed_expand3[(b) & 0xFF] | \ 87 byte_reversed_expand3[((b) & 0xFF00) >> 8] << 24; \ 88 *(base + 1) = byte_reversed_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 89 byte_reversed_expand3[((b) & 0xFF0000) >> 16] << 16; \ 90 *(base + 2) = byte_reversed_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ 91 byte_reversed_expand3[((b) & 0xFF000000) >> 24] << 8; \ 92 base += 3; } 93# else 94# define WRITE_BITS(b) *(base++) = (b) 95# define WRITE_BITS1(b) { \ 96 *(base++) = byte_expand3[(b) & 0xFF] | \ 97 byte_expand3[((b) & 0xFF00) >> 8] << 24; } 98# define WRITE_BITS2(b) { \ 99 *(base) = byte_expand3[(b) & 0xFF] | \ 100 byte_expand3[((b) & 0xFF00) >> 8] << 24; \ 101 *(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 102 byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ 103 base += 2; } 104# define WRITE_BITS3(b) { \ 105 *(base) = byte_expand3[(b) & 0xFF] | \ 106 byte_expand3[((b) & 0xFF00) >> 8] << 24; \ 107 *(base + 1) = byte_expand3[((b) & 0xFF00) >> 8] >> 8 | \ 108 byte_expand3[((b) & 0xFF0000) >> 16] << 16; \ 109 *(base + 2) = byte_expand3[((b) & 0xFF0000) >> 16] >> 16 | \ 110 byte_expand3[((b) & 0xFF000000) >> 24] << 8; \ 111 base += 3; } 112# endif 113#endif 114 115#ifdef FIXEDBASE 116# ifdef MSBFIRST 117# define EXPNAME(x) x##MSBFirstFixedBase 118# else 119# define EXPNAME(x) x##LSBFirstFixedBase 120# endif 121#else 122# ifdef MSBFIRST 123# define EXPNAME(x) x##MSBFirst 124# else 125# define EXPNAME(x) x##LSBFirst 126# endif 127#endif 128