Add 64-bit ntoh/hton functions for Linux

BSD macros aren't tested, but should work. These should already
be defined on Windows.
This commit is contained in:
Michael Cook (mackal) 2015-06-05 19:07:01 -04:00
parent fafbecb055
commit a9b98ed057

View File

@ -83,4 +83,20 @@ typedef const char Const_char; //for perl XS
#define DLLFUNC extern "C"
#endif
// htonll and ntohll already defined on windows
#ifndef WIN32
# if defined(__linux__)
# include <endian.h>
# elif defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/endian.h>
# elif defined (__OpenBSD__)
# include <sys/types.h>
# define be16toh(x) betoh16(x)
# define be32toh(x) betoh32(x)
# define be64toh(x) betoh64(x)
# endif
# define htonll(x) htobe64(x)
# define ntohll(x) be64toh(x)
#endif
#endif