convert litte vs big endian
| 56 | |
| 57 | /// convert litte vs big endian |
| 58 | inline uint64_t swap(uint64_t x) |
| 59 | { |
| 60 | #if defined(__GNUC__) || defined(__clang__) |
| 61 | return __builtin_bswap64(x); |
| 62 | #endif |
| 63 | #ifdef _MSC_VER |
| 64 | return _byteswap_uint64(x); |
| 65 | #endif |
| 66 | |
| 67 | return (x >> 56) | |
| 68 | ((x >> 40) & 0x000000000000FF00ULL) | |
| 69 | ((x >> 24) & 0x0000000000FF0000ULL) | |
| 70 | ((x >> 8) & 0x00000000FF000000ULL) | |
| 71 | ((x << 8) & 0x000000FF00000000ULL) | |
| 72 | ((x << 24) & 0x0000FF0000000000ULL) | |
| 73 | ((x << 40) & 0x00FF000000000000ULL) | |
| 74 | (x << 56); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /// return x % 5 for 0 <= x <= 9 |
no outgoing calls
no test coverage detected