Skip to content

Commit 9058210

Browse files
thedixk0ekk0ek
authored andcommitted
Fix problem with building on BSD-based systems (some do not have <endian.h>)
1 parent e91241a commit 9058210

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/generic/endian.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,18 @@
7474
#define le64toh(x) OSSwapLittleToHostInt64(x)
7575

7676
#else
77-
#include <endian.h>
77+
78+
#if defined(linux) || defined(__OpenBSD__)
79+
# ifdef HAVE_ENDIAN_H
80+
# include <endian.h> /* attempt to define endianness */
81+
# else
82+
# include <machine/endian.h> /* on older OpenBSD */
83+
# endif
84+
#endif
85+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
86+
#include <sys/endian.h> /* attempt to define endianness */
87+
#endif
88+
7889
#endif
7990

8091
#endif // ENDIAN_H

0 commit comments

Comments
 (0)