MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / swap

Function swap

src/sha3.cpp:58–75  ·  view source on GitHub ↗

convert litte vs big endian

Source from the content-addressed store, hash-verified

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

Callers 4

swapMethod · 0.85
swapMethod · 0.85
take_savesMethod · 0.85
AnyClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected