/usr/include/kmer/util/endianess.H is in libkmer-dev 0~20150903+r2013-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 | #ifndef ENDIANESS_H
#define ENDIANESS_H
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
// We need to test how to swap off_t and size_t
// See also test/endianess.c
// If we wanted to convert to network order for everything, rather
// than convert only when needed, this would be useful.
//
#if 0
bool
checkEndianessSwapNeeded(void) {
union u64 {
uint64 u;
unsigned char c[8];
};
union u32 {
uint32 u;
unsigned char c[4];
};
union u16 {
uint16 u;
unsigned char c[2];
};
u64 u64t.u = uint64NUMBER(0x0123456789abcdef);
return(u64t.c[0] != 0x0f)
}
#endif
inline
uint64
uint64Swap(uint64 x) {
x = ((x >> 8) & uint64NUMBER(0x00ff00ff00ff00ff)) | ((x << 8) & uint64NUMBER(0xff00ff00ff00ff00));
x = ((x >> 16) & uint64NUMBER(0x0000ffff0000ffff)) | ((x << 16) & uint64NUMBER(0xffff0000ffff0000));
x = ((x >> 32) & uint64NUMBER(0x00000000ffffffff)) | ((x << 32) & uint64NUMBER(0xffffffff00000000));
return(x);
}
inline
uint32
uint32Swap(uint32 x) {
x = ((x >> 8) & uint32NUMBER(0x00ff00ff)) | ((x << 8) & uint32NUMBER(0xff00ff00));
x = ((x >> 16) & uint32NUMBER(0x0000ffff)) | ((x << 16) & uint32NUMBER(0xffff0000));
return(x);
}
inline
uint16
uint16Swap(uint16 x) {
x = ((x >> 8) & 0x00ff) | ((x << 8) & 0xff00);
return(x);
}
#endif // ENDIANESS_H
|