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)
57 if ((
size_t)data & 0x3)
60 fprintf(stderr,
"ERROR: pointer to 32-bit integer is not 32-bit aligned (pointer is 0x%llx)\n",(
long long)data);
66 ( (udata[i]>>24)&0xff ) |
67 ( (udata[i]>>8)&0xff00 ) |
68 ( (udata[i]<<8)&0xff0000 ) |
69 ( (udata[i]<<24)&0xff000000 );
86 if ((
size_t)data & 0x1)
89 fprintf(stderr,
"ERROR: pointer to 16-bit integer is not 16-bit aligned (pointer is 0x%llx)\n",(
long long)data);
95 ( (udata[i]>>8)&0xff ) |
96 ( (udata[i]<<8)&0xff00 );
114 if ((
size_t)data & 0x5)
117 fprintf(stderr,
"ERROR: pointer to 64-bit integer is not 64-bit aligned (pointer is 0x%llx)\n",(
long long)data);
122 udata[i]=bswap_64(udata[i]);
167 size_t count = *nnum;
171 fprintf(stderr,
"ERROR NOT ALIGNED SLOW CODE USED (nb and count %9d %9lu )\n",nb, count);
173 for (j = 0; j < nn; j++)
175 for (i = 0; i < nb; i++)
176 swap[i] = data[j * nb + i];
177 for (i = 0; i < nb; i++)
178 data[j * nb + i] = swap[nb - i - 1];
static int macro_swap_64(void *data, size_t len)
Use the GNU macros, which are specialized byteswap ASM instructions.
static int simple_swap_16(void *data, size_t len)
Simple single-value loops.
void fast_byteswap_errors(int flag)
Set a flag to turn warnings off for non-aligned pointers.
static int simple_swap_32(void *data, size_t len)
Simple single-value loops.
int fast_byteswap(void *data, int bytes, size_t count)
Fast byteswap.
static int send_errors
If non-zero, warn about non-aligned pointers.
void byteswap_(char *data, int *nbyte, int *nnum)
Byteswap.
Include file to define variables for Fortran to C interface(s) revision history.
Header file for byteswap functions.