It is not POSIX. It is placed in different places in GNU and BSD systems.
Moreover not every system has leXXdec-style functions.
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/endian.h>
#include <zstd.h>
perror("can not fread(stdin)");
goto Exit;
}
- srcWantSize = (size_t)be64dec(src);
+ srcWantSize = ((uint64_t)(src[0]) << 56) | ((uint64_t)(src[1]) << 48) |
+ ((uint64_t)(src[2]) << 40) | ((uint64_t)(src[3]) << 32) |
+ ((uint64_t)(src[4]) << 24) | ((uint64_t)(src[5]) << 16) |
+ ((uint64_t)(src[6]) << 8) | (uint64_t)(src[7]);
if (srcWantSize > srcSize) {
free(src);
srcSize = srcWantSize;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/endian.h>
#include <zstd.h>
#include <sysexits.h>
#endif // __FreeBSD__
+static uint32_t
+le32dec(const char buf[4])
+{
+ return (uint32_t)(buf[3]) << 24 | (uint32_t)(buf[2]) << 16 |
+ (uint32_t)(buf[1]) << 8 | (uint32_t)(buf[0]);
+}
+
int
main(int argc, char **argv)
{