Go to the documentation of this file.
19 #include <libkern/OSByteOrder.h>
20 #define bswap_16(x) OSSwapInt16(x)
21 #define bswap_32(x) OSSwapInt32(x)
22 #define bswap_64(x) OSSwapInt64(x)
61 if ((
size_t)data & 0x3)
64 fprintf(stderr,
"ERROR: pointer to 32-bit integer is not 32-bit aligned (pointer is 0x%llx)\n",(
long long)data);
70 ( (udata[i]>>24)&0xff ) |
71 ( (udata[i]>>8)&0xff00 ) |
72 ( (udata[i]<<8)&0xff0000 ) |
73 ( (udata[i]<<24)&0xff000000 );
92 if ((
size_t)data & 0x1)
95 fprintf(stderr,
"ERROR: pointer to 16-bit integer is not 16-bit aligned (pointer is 0x%llx)\n",(
long long)data);
101 ( (udata[i]>>8)&0xff ) |
102 ( (udata[i]<<8)&0xff00 );
122 if ((
size_t)data & 0x5)
125 fprintf(stderr,
"ERROR: pointer to 64-bit integer is not 64-bit aligned (pointer is 0x%llx)\n",(
long long)data);
130 udata[i]=bswap_64(udata[i]);
179 size_t count = *nnum;
183 fprintf(stderr,
"ERROR NOT ALIGNED SLOW CODE USED (nb and count %9d %9lu )\n",nb, count);
185 for (j = 0; j < nn; j++)
187 for (i = 0; i < nb; i++)
188 swap[i] = data[j * nb + i];
189 for (i = 0; i < nb; i++)
190 data[j * nb + i] = swap[nb - i - 1];
void byteswap_(char *data, int *nbyte, int *nnum)
Byteswap.
void fast_byteswap_errors(int flag)
Set a flag to turn warnings off for non-aligned pointers.
static int send_errors
If non-zero, warn about non-aligned pointers.
Header file for byteswap functions.
static int simple_swap_16(void *data, size_t len)
Simple single-value loops.
int fast_byteswap(void *data, int bytes, size_t count)
Fast byteswap.
static int simple_swap_32(void *data, size_t len)
Simple single-value loops.
static int macro_swap_64(void *data, size_t len)
Use the GNU macros, which are specialized byteswap ASM instructions.