Commit 384ff647 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

portable_endian.h: A more uniform fix for the various BSD flavours



See pull requests #59 and #83.

It looks like various BSD derivates have adopted the more common naming
conventions for the endian conversion macros, which means that we would
attempt to redefine them without need (potentially even to 'historic'
names that no longer exist).

Try to avoid this by properly checking for existing functions first.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 4c411103
...@@ -41,22 +41,29 @@ ...@@ -41,22 +41,29 @@
# define __LITTLE_ENDIAN LITTLE_ENDIAN # define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __PDP_ENDIAN PDP_ENDIAN # define __PDP_ENDIAN PDP_ENDIAN
#elif defined(__OpenBSD__) || defined(__FreeBSD__) #elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/endian.h>
#elif defined(__NetBSD__) || defined(__DragonFly__)
# include <sys/endian.h> # include <sys/endian.h>
/* For functions still missing, try to substitute 'historic' OpenBSD names */
#ifndef be16toh
# define be16toh(x) betoh16(x) # define be16toh(x) betoh16(x)
#endif
#ifndef le16toh
# define le16toh(x) letoh16(x) # define le16toh(x) letoh16(x)
#endif
#ifndef be32toh
# define be32toh(x) betoh32(x) # define be32toh(x) betoh32(x)
#endif
#ifndef le32toh
# define le32toh(x) letoh32(x) # define le32toh(x) letoh32(x)
#endif
#ifndef be64toh
# define be64toh(x) betoh64(x) # define be64toh(x) betoh64(x)
#endif
#ifndef le64toh
# define le64toh(x) letoh64(x) # define le64toh(x) letoh64(x)
#endif
#elif defined(__WINDOWS__) #elif defined(__WINDOWS__)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment