57 #error This code requires 8-bit bytes 384 typedef __arch_dependant__
sph_u32;
390 typedef __arch_dependant__
sph_s32;
402 typedef __arch_dependant__ sph_u64;
408 typedef __arch_dependant__ sph_s64;
438 #define SPH_ROTL32(x, n) 450 #define SPH_ROTR32(x, n) 495 #define SPH_ROTL64(x, n) 508 #define SPH_ROTR64(x, n) 525 #define SPH_LITTLE_ENDIAN 533 #define SPH_BIG_ENDIAN 542 #define SPH_LITTLE_FAST 566 #define SPH_UNALIGNED 587 static inline sph_u64 sph_bswap64(sph_u64 x);
596 static inline unsigned sph_dec16le(
const void *src);
605 static inline void sph_enc16le(
void *dst,
unsigned val);
614 static inline unsigned sph_dec16be(
const void *src);
623 static inline void sph_enc16be(
void *dst,
unsigned val);
717 static inline sph_u64 sph_dec64le(
const void *src);
730 static inline sph_u64 sph_dec64le_aligned(
const void *src);
740 static inline void sph_enc64le(
void *dst, sph_u64 val);
754 static inline void sph_enc64le_aligned(
void *dst, sph_u64 val);
764 static inline sph_u64 sph_dec64be(
const void *src);
777 static inline sph_u64 sph_dec64be_aligned(
const void *src);
787 static inline void sph_enc64be(
void *dst, sph_u64 val);
801 static inline void sph_enc64be_aligned(
void *dst, sph_u64 val);
807 #ifndef DOXYGEN_IGNORE 819 #if defined __STDC__ && __STDC_VERSION__ >= 199901L 838 typedef uint64_t sph_u64;
839 typedef int64_t sph_s64;
841 typedef uint_fast64_t sph_u64;
842 typedef int_fast64_t sph_s64;
846 #define SPH_C32(x) ((sph_u32)(x)) 848 #define SPH_C64(x) ((sph_u64)(x)) 861 #if ((UINT_MAX >> 11) >> 11) >= 0x3FF 866 #define SPH_C32(x) ((sph_u32)(x ## U)) 873 #define SPH_C32(x) ((sph_u32)(x ## UL)) 887 #if ((ULONG_MAX >> 31) >> 31) >= 3 889 typedef unsigned long sph_u64;
890 typedef long sph_s64;
892 #define SPH_C64(x) ((sph_u64)(x ## UL)) 896 #elif ((ULLONG_MAX >> 31) >> 31) >= 3 || defined __GNUC__ 898 typedef unsigned long long sph_u64;
899 typedef long long sph_s64;
901 #define SPH_C64(x) ((sph_u64)(x ## ULL)) 922 #if SPH_64 && (((ULONG_MAX >> 31) >> 31) >= 3 || defined _M_X64) 923 #define SPH_64_TRUE 1 932 #define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF)) 933 #define SPH_ROTL32(x, n) SPH_T32(((x) << (n)) | ((x) >> (32 - (n)))) 934 #define SPH_ROTR32(x, n) SPH_ROTL32(x, (32 - (n))) 938 #define SPH_T64(x) ((x) & SPH_C64(0xFFFFFFFFFFFFFFFF)) 939 #define SPH_ROTL64(x, n) SPH_T64(((x) << (n)) | ((x) >> (64 - (n)))) 940 #define SPH_ROTR64(x, n) SPH_ROTL64(x, (64 - (n))) 944 #ifndef DOXYGEN_IGNORE 949 #if (defined __STDC__ && __STDC_VERSION__ >= 199901L) || defined __GNUC__ 950 #define SPH_INLINE inline 951 #elif defined _MSC_VER 952 #define SPH_INLINE __inline 1000 #if defined __i386__ || defined _M_IX86 1002 #define SPH_DETECT_UNALIGNED 1 1003 #define SPH_DETECT_LITTLE_ENDIAN 1 1004 #define SPH_DETECT_UPTR sph_u32 1006 #define SPH_DETECT_I386_GCC 1 1009 #define SPH_DETECT_I386_MSVC 1 1015 #elif defined __x86_64 || defined _M_X64 1017 #define SPH_DETECT_UNALIGNED 1 1018 #define SPH_DETECT_LITTLE_ENDIAN 1 1019 #define SPH_DETECT_UPTR sph_u64 1021 #define SPH_DETECT_AMD64_GCC 1 1024 #define SPH_DETECT_AMD64_MSVC 1 1030 #elif ((defined __sparc__ || defined __sparc) && defined __arch64__) \ 1031 || defined __sparcv9 1033 #define SPH_DETECT_BIG_ENDIAN 1 1034 #define SPH_DETECT_UPTR sph_u64 1036 #define SPH_DETECT_SPARCV9_GCC_64 1 1037 #define SPH_DETECT_LITTLE_FAST 1 1043 #elif (defined __sparc__ || defined __sparc) \ 1044 && !(defined __sparcv9 || defined __arch64__) 1046 #define SPH_DETECT_BIG_ENDIAN 1 1047 #define SPH_DETECT_UPTR sph_u32 1048 #if defined __GNUC__ && defined __sparc_v9__ 1049 #define SPH_DETECT_SPARCV9_GCC_32 1 1050 #define SPH_DETECT_LITTLE_FAST 1 1056 #elif defined __arm__ && __ARMEL__ 1058 #define SPH_DETECT_LITTLE_ENDIAN 1 1063 #elif MIPSEL || _MIPSEL || __MIPSEL || __MIPSEL__ 1065 #define SPH_DETECT_LITTLE_ENDIAN 1 1070 #elif MIPSEB || _MIPSEB || __MIPSEB || __MIPSEB__ 1072 #define SPH_DETECT_BIG_ENDIAN 1 1077 #elif defined __powerpc__ || defined __POWERPC__ || defined __ppc__ \ 1078 || defined _ARCH_PPC 1086 #if defined __GNUC__ 1088 #define SPH_DETECT_PPC64_GCC 1 1090 #define SPH_DETECT_PPC32_GCC 1 1094 #if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN 1095 #define SPH_DETECT_BIG_ENDIAN 1 1096 #elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN 1097 #define SPH_DETECT_LITTLE_ENDIAN 1 1103 #elif defined __ia64 || defined __ia64__ \ 1104 || defined __itanium__ || defined _M_IA64 1106 #if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN 1107 #define SPH_DETECT_BIG_ENDIAN 1 1109 #define SPH_DETECT_LITTLE_ENDIAN 1 1111 #if defined __LP64__ || defined _LP64 1112 #define SPH_DETECT_UPTR sph_u64 1114 #define SPH_DETECT_UPTR sph_u32 1119 #if defined SPH_DETECT_SPARCV9_GCC_32 || defined SPH_DETECT_SPARCV9_GCC_64 1120 #define SPH_DETECT_SPARCV9_GCC 1 1123 #if defined SPH_DETECT_UNALIGNED && !defined SPH_UNALIGNED 1124 #define SPH_UNALIGNED SPH_DETECT_UNALIGNED 1126 #if defined SPH_DETECT_UPTR && !defined SPH_UPTR 1127 #define SPH_UPTR SPH_DETECT_UPTR 1129 #if defined SPH_DETECT_LITTLE_ENDIAN && !defined SPH_LITTLE_ENDIAN 1130 #define SPH_LITTLE_ENDIAN SPH_DETECT_LITTLE_ENDIAN 1132 #if defined SPH_DETECT_BIG_ENDIAN && !defined SPH_BIG_ENDIAN 1133 #define SPH_BIG_ENDIAN SPH_DETECT_BIG_ENDIAN 1135 #if defined SPH_DETECT_LITTLE_FAST && !defined SPH_LITTLE_FAST 1136 #define SPH_LITTLE_FAST SPH_DETECT_LITTLE_FAST 1138 #if defined SPH_DETECT_BIG_FAST && !defined SPH_BIG_FAST 1139 #define SPH_BIG_FAST SPH_DETECT_BIG_FAST 1141 #if defined SPH_DETECT_SPARCV9_GCC_32 && !defined SPH_SPARCV9_GCC_32 1142 #define SPH_SPARCV9_GCC_32 SPH_DETECT_SPARCV9_GCC_32 1144 #if defined SPH_DETECT_SPARCV9_GCC_64 && !defined SPH_SPARCV9_GCC_64 1145 #define SPH_SPARCV9_GCC_64 SPH_DETECT_SPARCV9_GCC_64 1147 #if defined SPH_DETECT_SPARCV9_GCC && !defined SPH_SPARCV9_GCC 1148 #define SPH_SPARCV9_GCC SPH_DETECT_SPARCV9_GCC 1150 #if defined SPH_DETECT_I386_GCC && !defined SPH_I386_GCC 1151 #define SPH_I386_GCC SPH_DETECT_I386_GCC 1153 #if defined SPH_DETECT_I386_MSVC && !defined SPH_I386_MSVC 1154 #define SPH_I386_MSVC SPH_DETECT_I386_MSVC 1156 #if defined SPH_DETECT_AMD64_GCC && !defined SPH_AMD64_GCC 1157 #define SPH_AMD64_GCC SPH_DETECT_AMD64_GCC 1159 #if defined SPH_DETECT_AMD64_MSVC && !defined SPH_AMD64_MSVC 1160 #define SPH_AMD64_MSVC SPH_DETECT_AMD64_MSVC 1162 #if defined SPH_DETECT_PPC32_GCC && !defined SPH_PPC32_GCC 1163 #define SPH_PPC32_GCC SPH_DETECT_PPC32_GCC 1165 #if defined SPH_DETECT_PPC64_GCC && !defined SPH_PPC64_GCC 1166 #define SPH_PPC64_GCC SPH_DETECT_PPC64_GCC 1169 #if SPH_LITTLE_ENDIAN && !defined SPH_LITTLE_FAST 1170 #define SPH_LITTLE_FAST 1 1172 #if SPH_BIG_ENDIAN && !defined SPH_BIG_FAST 1173 #define SPH_BIG_FAST 1 1176 #if defined SPH_UPTR && !(SPH_LITTLE_ENDIAN || SPH_BIG_ENDIAN) 1177 #error SPH_UPTR defined, but endianness is not known. 1180 #if SPH_I386_GCC && !SPH_NO_ASM 1190 __asm__ __volatile__ (
"bswapl %0" :
"=r" (x) :
"0" (x));
1197 sph_bswap64(sph_u64 x)
1205 #elif SPH_AMD64_GCC && !SPH_NO_ASM 1215 __asm__ __volatile__ (
"bswapl %0" :
"=r" (x) :
"0" (x));
1222 sph_bswap64(sph_u64 x)
1224 __asm__ __volatile__ (
"bswapq %0" :
"=r" (x) :
"0" (x));
1268 x =
SPH_T32((x << 16) | (x >> 16));
1269 x = ((x &
SPH_C32(0xFF00FF00)) >> 8)
1270 | ((x &
SPH_C32(0x00FF00FF)) << 8);
1283 sph_bswap64(sph_u64 x)
1285 x = SPH_T64((x << 32) | (x >> 32));
1286 x = ((x & SPH_C64(0xFFFF0000FFFF0000)) >> 16)
1287 | ((x & SPH_C64(0x0000FFFF0000FFFF)) << 16);
1288 x = ((x & SPH_C64(0xFF00FF00FF00FF00)) >> 8)
1289 | ((x & SPH_C64(0x00FF00FF00FF00FF)) << 8);
1297 #if SPH_SPARCV9_GCC && !SPH_NO_ASM 1315 #define SPH_SPARCV9_SET_ASI \ 1316 sph_u32 sph_sparcv9_asi; \ 1317 __asm__ __volatile__ ( \ 1318 "rd %%asi,%0\n\twr %%g0,0x88,%%asi" : "=r" (sph_sparcv9_asi)); 1320 #define SPH_SPARCV9_RESET_ASI \ 1321 __asm__ __volatile__ ("wr %%g0,%0,%%asi" : : "r" (sph_sparcv9_asi)); 1323 #define SPH_SPARCV9_DEC32LE(base, idx) ({ \ 1324 sph_u32 sph_sparcv9_tmp; \ 1325 __asm__ __volatile__ ("lda [%1+" #idx "*4]%%asi,%0" \ 1326 : "=r" (sph_sparcv9_tmp) : "r" (base)); \ 1335 ((
unsigned char *)dst)[0] = (val >> 8);
1336 ((
unsigned char *)dst)[1] = val;
1342 return ((
unsigned)(((
const unsigned char *)src)[0]) << 8)
1343 | (unsigned)(((
const unsigned char *)src)[1]);
1349 ((
unsigned char *)dst)[0] = val;
1350 ((
unsigned char *)dst)[1] = val >> 8;
1356 return (
unsigned)(((
const unsigned char *)src)[0])
1357 | ((
unsigned)(((
const unsigned char *)src)[1]) << 8);
1369 #if defined SPH_UPTR 1371 #if SPH_LITTLE_ENDIAN 1376 if (((SPH_UPTR)dst & 3) == 0) {
1377 #if SPH_LITTLE_ENDIAN 1382 ((
unsigned char *)dst)[0] = (val >> 24);
1383 ((
unsigned char *)dst)[1] = (val >> 16);
1384 ((
unsigned char *)dst)[2] = (val >> 8);
1385 ((
unsigned char *)dst)[3] = val;
1389 ((
unsigned char *)dst)[0] = (val >> 24);
1390 ((
unsigned char *)dst)[1] = (val >> 16);
1391 ((
unsigned char *)dst)[2] = (val >> 8);
1392 ((
unsigned char *)dst)[3] = val;
1406 #if SPH_LITTLE_ENDIAN 1408 #elif SPH_BIG_ENDIAN 1411 ((
unsigned char *)dst)[0] = (val >> 24);
1412 ((
unsigned char *)dst)[1] = (val >> 16);
1413 ((
unsigned char *)dst)[2] = (val >> 8);
1414 ((
unsigned char *)dst)[3] = val;
1427 #if defined SPH_UPTR 1429 #if SPH_LITTLE_ENDIAN 1435 if (((SPH_UPTR)src & 3) == 0) {
1436 #if SPH_LITTLE_ENDIAN 1442 return ((
sph_u32)(((
const unsigned char *)src)[0]) << 24)
1443 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 16)
1444 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 8)
1445 | (
sph_u32)(((
const unsigned char *)src)[3]);
1449 return ((
sph_u32)(((
const unsigned char *)src)[0]) << 24)
1450 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 16)
1451 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 8)
1452 | (
sph_u32)(((
const unsigned char *)src)[3]);
1466 #if SPH_LITTLE_ENDIAN 1468 #elif SPH_BIG_ENDIAN 1471 return ((
sph_u32)(((
const unsigned char *)src)[0]) << 24)
1472 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 16)
1473 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 8)
1474 | (
sph_u32)(((
const unsigned char *)src)[3]);
1487 #if defined SPH_UPTR 1494 if (((SPH_UPTR)dst & 3) == 0) {
1500 ((
unsigned char *)dst)[0] = val;
1501 ((
unsigned char *)dst)[1] = (val >> 8);
1502 ((
unsigned char *)dst)[2] = (val >> 16);
1503 ((
unsigned char *)dst)[3] = (val >> 24);
1507 ((
unsigned char *)dst)[0] = val;
1508 ((
unsigned char *)dst)[1] = (val >> 8);
1509 ((
unsigned char *)dst)[2] = (val >> 16);
1510 ((
unsigned char *)dst)[3] = (val >> 24);
1524 #if SPH_LITTLE_ENDIAN 1526 #elif SPH_BIG_ENDIAN 1529 ((
unsigned char *)dst)[0] = val;
1530 ((
unsigned char *)dst)[1] = (val >> 8);
1531 ((
unsigned char *)dst)[2] = (val >> 16);
1532 ((
unsigned char *)dst)[3] = (val >> 24);
1545 #if defined SPH_UPTR 1553 if (((SPH_UPTR)src & 3) == 0) {
1555 #if SPH_SPARCV9_GCC && !SPH_NO_ASM 1564 __asm__ __volatile__ (
1565 "lda [%1]0x88,%0" :
"=r" (tmp) :
"r" (src));
1593 return (
sph_u32)(((
const unsigned char *)src)[0])
1594 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 8)
1595 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 16)
1596 | ((
sph_u32)(((
const unsigned char *)src)[3]) << 24);
1600 return (
sph_u32)(((
const unsigned char *)src)[0])
1601 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 8)
1602 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 16)
1603 | ((
sph_u32)(((
const unsigned char *)src)[3]) << 24);
1617 #if SPH_LITTLE_ENDIAN 1619 #elif SPH_BIG_ENDIAN 1620 #if SPH_SPARCV9_GCC && !SPH_NO_ASM 1623 __asm__ __volatile__ (
"lda [%1]0x88,%0" :
"=r" (tmp) :
"r" (src));
1638 return (
sph_u32)(((
const unsigned char *)src)[0])
1639 | ((
sph_u32)(((
const unsigned char *)src)[1]) << 8)
1640 | ((
sph_u32)(((
const unsigned char *)src)[2]) << 16)
1641 | ((
sph_u32)(((
const unsigned char *)src)[3]) << 24);
1654 sph_enc64be(
void *dst, sph_u64 val)
1656 #if defined SPH_UPTR 1658 #if SPH_LITTLE_ENDIAN 1659 val = sph_bswap64(val);
1661 *(sph_u64 *)dst = val;
1663 if (((SPH_UPTR)dst & 7) == 0) {
1664 #if SPH_LITTLE_ENDIAN 1665 val = sph_bswap64(val);
1667 *(sph_u64 *)dst = val;
1669 ((
unsigned char *)dst)[0] = (val >> 56);
1670 ((
unsigned char *)dst)[1] = (val >> 48);
1671 ((
unsigned char *)dst)[2] = (val >> 40);
1672 ((
unsigned char *)dst)[3] = (val >> 32);
1673 ((
unsigned char *)dst)[4] = (val >> 24);
1674 ((
unsigned char *)dst)[5] = (val >> 16);
1675 ((
unsigned char *)dst)[6] = (val >> 8);
1676 ((
unsigned char *)dst)[7] = val;
1680 ((
unsigned char *)dst)[0] = (val >> 56);
1681 ((
unsigned char *)dst)[1] = (val >> 48);
1682 ((
unsigned char *)dst)[2] = (val >> 40);
1683 ((
unsigned char *)dst)[3] = (val >> 32);
1684 ((
unsigned char *)dst)[4] = (val >> 24);
1685 ((
unsigned char *)dst)[5] = (val >> 16);
1686 ((
unsigned char *)dst)[6] = (val >> 8);
1687 ((
unsigned char *)dst)[7] = val;
1699 sph_enc64be_aligned(
void *dst, sph_u64 val)
1701 #if SPH_LITTLE_ENDIAN 1702 *(sph_u64 *)dst = sph_bswap64(val);
1703 #elif SPH_BIG_ENDIAN 1704 *(sph_u64 *)dst = val;
1706 ((
unsigned char *)dst)[0] = (val >> 56);
1707 ((
unsigned char *)dst)[1] = (val >> 48);
1708 ((
unsigned char *)dst)[2] = (val >> 40);
1709 ((
unsigned char *)dst)[3] = (val >> 32);
1710 ((
unsigned char *)dst)[4] = (val >> 24);
1711 ((
unsigned char *)dst)[5] = (val >> 16);
1712 ((
unsigned char *)dst)[6] = (val >> 8);
1713 ((
unsigned char *)dst)[7] = val;
1724 sph_dec64be(
const void *src)
1726 #if defined SPH_UPTR 1728 #if SPH_LITTLE_ENDIAN 1729 return sph_bswap64(*(
const sph_u64 *)src);
1731 return *(
const sph_u64 *)src;
1734 if (((SPH_UPTR)src & 7) == 0) {
1735 #if SPH_LITTLE_ENDIAN 1736 return sph_bswap64(*(
const sph_u64 *)src);
1738 return *(
const sph_u64 *)src;
1741 return ((sph_u64)(((
const unsigned char *)src)[0]) << 56)
1742 | ((sph_u64)(((
const unsigned char *)src)[1]) << 48)
1743 | ((sph_u64)(((
const unsigned char *)src)[2]) << 40)
1744 | ((sph_u64)(((
const unsigned char *)src)[3]) << 32)
1745 | ((sph_u64)(((
const unsigned char *)src)[4]) << 24)
1746 | ((sph_u64)(((
const unsigned char *)src)[5]) << 16)
1747 | ((sph_u64)(((
const unsigned char *)src)[6]) << 8)
1748 | (sph_u64)(((
const unsigned char *)src)[7]);
1752 return ((sph_u64)(((
const unsigned char *)src)[0]) << 56)
1753 | ((sph_u64)(((
const unsigned char *)src)[1]) << 48)
1754 | ((sph_u64)(((
const unsigned char *)src)[2]) << 40)
1755 | ((sph_u64)(((
const unsigned char *)src)[3]) << 32)
1756 | ((sph_u64)(((
const unsigned char *)src)[4]) << 24)
1757 | ((sph_u64)(((
const unsigned char *)src)[5]) << 16)
1758 | ((sph_u64)(((
const unsigned char *)src)[6]) << 8)
1759 | (sph_u64)(((
const unsigned char *)src)[7]);
1771 sph_dec64be_aligned(
const void *src)
1773 #if SPH_LITTLE_ENDIAN 1774 return sph_bswap64(*(
const sph_u64 *)src);
1775 #elif SPH_BIG_ENDIAN 1776 return *(
const sph_u64 *)src;
1778 return ((sph_u64)(((
const unsigned char *)src)[0]) << 56)
1779 | ((sph_u64)(((
const unsigned char *)src)[1]) << 48)
1780 | ((sph_u64)(((
const unsigned char *)src)[2]) << 40)
1781 | ((sph_u64)(((
const unsigned char *)src)[3]) << 32)
1782 | ((sph_u64)(((
const unsigned char *)src)[4]) << 24)
1783 | ((sph_u64)(((
const unsigned char *)src)[5]) << 16)
1784 | ((sph_u64)(((
const unsigned char *)src)[6]) << 8)
1785 | (sph_u64)(((
const unsigned char *)src)[7]);
1796 sph_enc64le(
void *dst, sph_u64 val)
1798 #if defined SPH_UPTR 1801 val = sph_bswap64(val);
1803 *(sph_u64 *)dst = val;
1805 if (((SPH_UPTR)dst & 7) == 0) {
1807 val = sph_bswap64(val);
1809 *(sph_u64 *)dst = val;
1811 ((
unsigned char *)dst)[0] = val;
1812 ((
unsigned char *)dst)[1] = (val >> 8);
1813 ((
unsigned char *)dst)[2] = (val >> 16);
1814 ((
unsigned char *)dst)[3] = (val >> 24);
1815 ((
unsigned char *)dst)[4] = (val >> 32);
1816 ((
unsigned char *)dst)[5] = (val >> 40);
1817 ((
unsigned char *)dst)[6] = (val >> 48);
1818 ((
unsigned char *)dst)[7] = (val >> 56);
1822 ((
unsigned char *)dst)[0] = val;
1823 ((
unsigned char *)dst)[1] = (val >> 8);
1824 ((
unsigned char *)dst)[2] = (val >> 16);
1825 ((
unsigned char *)dst)[3] = (val >> 24);
1826 ((
unsigned char *)dst)[4] = (val >> 32);
1827 ((
unsigned char *)dst)[5] = (val >> 40);
1828 ((
unsigned char *)dst)[6] = (val >> 48);
1829 ((
unsigned char *)dst)[7] = (val >> 56);
1841 sph_enc64le_aligned(
void *dst, sph_u64 val)
1843 #if SPH_LITTLE_ENDIAN 1844 *(sph_u64 *)dst = val;
1845 #elif SPH_BIG_ENDIAN 1846 *(sph_u64 *)dst = sph_bswap64(val);
1848 ((
unsigned char *)dst)[0] = val;
1849 ((
unsigned char *)dst)[1] = (val >> 8);
1850 ((
unsigned char *)dst)[2] = (val >> 16);
1851 ((
unsigned char *)dst)[3] = (val >> 24);
1852 ((
unsigned char *)dst)[4] = (val >> 32);
1853 ((
unsigned char *)dst)[5] = (val >> 40);
1854 ((
unsigned char *)dst)[6] = (val >> 48);
1855 ((
unsigned char *)dst)[7] = (val >> 56);
1866 sph_dec64le(
const void *src)
1868 #if defined SPH_UPTR 1871 return sph_bswap64(*(
const sph_u64 *)src);
1873 return *(
const sph_u64 *)src;
1876 if (((SPH_UPTR)src & 7) == 0) {
1878 #if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM 1881 __asm__ __volatile__ (
1882 "ldxa [%1]0x88,%0" :
"=r" (tmp) :
"r" (src));
1899 return sph_bswap64(*(
const sph_u64 *)src);
1902 return *(
const sph_u64 *)src;
1905 return (sph_u64)(((
const unsigned char *)src)[0])
1906 | ((sph_u64)(((
const unsigned char *)src)[1]) << 8)
1907 | ((sph_u64)(((
const unsigned char *)src)[2]) << 16)
1908 | ((sph_u64)(((
const unsigned char *)src)[3]) << 24)
1909 | ((sph_u64)(((
const unsigned char *)src)[4]) << 32)
1910 | ((sph_u64)(((
const unsigned char *)src)[5]) << 40)
1911 | ((sph_u64)(((
const unsigned char *)src)[6]) << 48)
1912 | ((sph_u64)(((
const unsigned char *)src)[7]) << 56);
1916 return (sph_u64)(((
const unsigned char *)src)[0])
1917 | ((sph_u64)(((
const unsigned char *)src)[1]) << 8)
1918 | ((sph_u64)(((
const unsigned char *)src)[2]) << 16)
1919 | ((sph_u64)(((
const unsigned char *)src)[3]) << 24)
1920 | ((sph_u64)(((
const unsigned char *)src)[4]) << 32)
1921 | ((sph_u64)(((
const unsigned char *)src)[5]) << 40)
1922 | ((sph_u64)(((
const unsigned char *)src)[6]) << 48)
1923 | ((sph_u64)(((
const unsigned char *)src)[7]) << 56);
1935 sph_dec64le_aligned(
const void *src)
1937 #if SPH_LITTLE_ENDIAN 1938 return *(
const sph_u64 *)src;
1939 #elif SPH_BIG_ENDIAN 1940 #if SPH_SPARCV9_GCC_64 && !SPH_NO_ASM 1943 __asm__ __volatile__ (
"ldxa [%1]0x88,%0" :
"=r" (tmp) :
"r" (src));
1958 return sph_bswap64(*(
const sph_u64 *)src);
1961 return (sph_u64)(((
const unsigned char *)src)[0])
1962 | ((sph_u64)(((
const unsigned char *)src)[1]) << 8)
1963 | ((sph_u64)(((
const unsigned char *)src)[2]) << 16)
1964 | ((sph_u64)(((
const unsigned char *)src)[3]) << 24)
1965 | ((sph_u64)(((
const unsigned char *)src)[4]) << 32)
1966 | ((sph_u64)(((
const unsigned char *)src)[5]) << 40)
1967 | ((sph_u64)(((
const unsigned char *)src)[6]) << 48)
1968 | ((sph_u64)(((
const unsigned char *)src)[7]) << 56);
static SPH_INLINE unsigned sph_dec16le(const void *src)
static SPH_INLINE void sph_enc16le(void *dst, unsigned val)
static SPH_INLINE void sph_enc32le_aligned(void *dst, sph_u32 val)
Encode a 32-bit value into the provided buffer (little endian convention).
static SPH_INLINE void sph_enc16be(void *dst, unsigned val)
static SPH_INLINE sph_u32 sph_dec32le_aligned(const void *src)
Decode a 32-bit value from the provided buffer (little endian convention).
static SPH_INLINE sph_u32 sph_dec32be_aligned(const void *src)
Decode a 32-bit value from the provided buffer (big endian convention).
static SPH_INLINE sph_u32 sph_dec32be(const void *src)
Decode a 32-bit value from the provided buffer (big endian convention).
static SPH_INLINE unsigned sph_dec16be(const void *src)
static SPH_INLINE void sph_enc32le(void *dst, sph_u32 val)
Encode a 32-bit value into the provided buffer (little endian convention).
static SPH_INLINE sph_u32 sph_dec32le(const void *src)
Decode a 32-bit value from the provided buffer (little endian convention).
static SPH_INLINE void sph_enc32be_aligned(void *dst, sph_u32 val)
Encode a 32-bit value into the provided buffer (big endian convention).
static SPH_INLINE void sph_enc32be(void *dst, sph_u32 val)
Encode a 32-bit value into the provided buffer (big endian convention).
static SPH_INLINE sph_u32 sph_bswap32(sph_u32 x)