fix: ha_seed_jitter loop-until-full partial read; byteorder.h musl portability
This commit is contained in:
parent
2c375cf476
commit
8a9fce1be4
2 changed files with 31 additions and 2 deletions
|
|
@ -1,7 +1,24 @@
|
|||
#pragma once
|
||||
/* Portable be64toh() for non-glibc or pre-2.25 targets. */
|
||||
/* Portable be64toh() — big-endian to host byte order conversion. */
|
||||
#if defined(__linux__)
|
||||
# ifndef _DEFAULT_SOURCE
|
||||
# define _DEFAULT_SOURCE 1
|
||||
# endif
|
||||
# ifndef _BSD_SOURCE
|
||||
# define _BSD_SOURCE 1
|
||||
# endif
|
||||
# include <endian.h>
|
||||
# ifndef be64toh
|
||||
/* musl and some older glibc: fall back to builtin */
|
||||
# include <stdint.h>
|
||||
static inline uint64_t be64toh(uint64_t x) {
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
return __builtin_bswap64(x);
|
||||
# else
|
||||
return x;
|
||||
# endif
|
||||
}
|
||||
# endif /* be64toh */
|
||||
#elif defined(__APPLE__)
|
||||
# include <machine/endian.h>
|
||||
# include <libkern/OSByteOrder.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue