/usr/include/BALL/SYSTEM/binaryFileAdaptor.iC is in libball1.4-dev 1.4.3~beta1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #include <BALL/CONFIG/config.h>
namespace BALL
{
#define BALL_SWAP_BYTES_16(x)\
x = ((x >> 8) & 0x00FFu) | ((x << 8) & 0xFF00u)
#define BALL_SWAP_BYTES_32(x)\
x = ((x >> 8) & 0x00FF00FFu) | ((x << 8) & 0xFF00FF00u);\
x = ((x >> 16) & 0x0000FFFFu) | ((x << 16) & 0xFFFF0000u)
#define BALL_SWAP_BYTES_64(x)\
x = ((x >> 8) & 0x00FF00FF00FF00FFull) | ((x << 8) & 0xFF00FF00FF00FF00ull);\
x = ((x >> 16) & 0x0000FFFF0000FFFFull) | ((x << 16) & 0xFFFF0000FFFF0000ull);\
x = ((x >> 32) & 0x00000000FFFFFFFFull) | ((x << 32) & 0xFFFFFFFF00000000ull)
template <>
BALL_INLINE void swapBytes(unsigned short& t)
{
#if BALL_USHORT_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_USHORT_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_USHORT_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown unsigned short size, refusing to compile."
#endif
}
template <>
BALL_INLINE void swapBytes(short& t)
{
#if BALL_SHORT_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_SHORT_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_SHORT_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown short size, refusing to compile."
#endif
}
template <>
BALL_INLINE void swapBytes(unsigned int& t)
{
#if BALL_UINT_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_UINT_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_UINT_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown unsigned int size, refusing to compile."
#endif
}
template <>
BALL_INLINE void swapBytes(int& t)
{
#if BALL_INT_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_INT_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_INT_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown int size, refusing to compile."
#endif
}
template <>
BALL_INLINE void swapBytes(long& t)
{
#if BALL_LONG_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_LONG_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_LONG_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown long size, refusing to compile."
#endif
}
template <>
BALL_INLINE void swapBytes(unsigned long& t)
{
#if BALL_ULONG_SIZE == 2
BALL_SWAP_BYTES_16(t);
#elif BALL_ULONG_SIZE == 4
BALL_SWAP_BYTES_32(t);
#elif BALL_ULONG_SIZE == 8
BALL_SWAP_BYTES_64(t);
#else
#error "Unknown unsigned long size, refusing to compile."
#endif
}
namespace __private
{
//We need these unions to provide a safe cast (without violating strict aliasing)
//from float/double to a bitfield
union UFloat
{
UFloat(float f_) : f(f_) { }
#if BALL_FLOAT_SIZE == 2
BALL_UINT16 u;
#elif BALL_FLOAT_SIZE == 4
BALL_UINT32 u;
#elif BALL_FLOAT_SIZE == 8
BALL_UINT64 u;
#else
#error "Unknown double size, refusing to compile."
#endif
float f;
};
union UDouble
{
UDouble(double f_) : f(f_) { }
#if BALL_DOUBLE_SIZE == 2
BALL_UINT16 u;
#elif BALL_DOUBLE_SIZE == 4
BALL_UINT32 u;
#elif BALL_DOUBLE_SIZE == 8
BALL_UINT64 u;
#else
#error "Unknown double size, refusing to compile."
#endif
double f;
};
}
template <>
BALL_INLINE void swapBytes(float& f)
{
__private::UFloat u(f);
#if BALL_FLOAT_SIZE == 2
BALL_SWAP_BYTES_16(u.u);
#elif BALL_FLOAT_SIZE == 4
BALL_SWAP_BYTES_32(u.u);
#elif BALL_FLOAT_SIZE == 8
BALL_SWAP_BYTES_64(u.u);
#else
#error "Unknown float size, refusing to compile."
#endif
f = u.f;
}
template <>
BALL_INLINE void swapBytes(double& f)
{
__private::UDouble u(f);
#if BALL_DOUBLE_SIZE == 2
BALL_SWAP_BYTES_16(u.u);
#elif BALL_DOUBLE_SIZE == 4
BALL_SWAP_BYTES_32(u.u);
#elif BALL_DOUBLE_SIZE == 8
BALL_SWAP_BYTES_64(u.u);
#else
#error "Unknown double size, refusing to compile."
#endif
f = u.f;
}
}
|