Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FreeBSD support #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

#if defined(__linux__) || defined(__CYGWIN__)

# include <endian.h>
# undef PORTABLE_ENDIAN_H__
# include_next <endian.h>
# define PORTABLE_ENDIAN_H__

#elif defined(__APPLE__)

Expand All @@ -48,11 +50,11 @@
# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __PDP_ENDIAN PDP_ENDIAN

#elif defined(__OpenBSD__)
#elif defined(__OpenBSD__) || defined(__FreeBSD__)

# include <sys/endian.h>

#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
#elif defined(__NetBSD__) || defined(__DragonFly__)

# include <sys/endian.h>

Expand All @@ -72,19 +74,19 @@

# if BYTE_ORDER == LITTLE_ENDIAN

# define htobe16(x) htons(x)
# define htobe16(x) __builtin_bswap16(x)
# define htole16(x) (x)
# define be16toh(x) ntohs(x)
# define be16toh(x) __builtin_bswap16(x)
# define le16toh(x) (x)

# define htobe32(x) htonl(x)
# define htobe32(x) __builtin_bswap32(x)
# define htole32(x) (x)
# define be32toh(x) ntohl(x)
# define be32toh(x) __builtin_bswap32(x)
# define le32toh(x) (x)

# define htobe64(x) htonll(x)
# define htobe64(x) __builtin_bswap64(x)
# define htole64(x) (x)
# define be64toh(x) ntohll(x)
# define be64toh(x) __builtin_bswap64(x)
# define le64toh(x) (x)

# elif BYTE_ORDER == BIG_ENDIAN
Expand Down