diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2019-07-19 21:53:24 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2019-08-06 10:09:08 +0200 |
commit | c5e2ea18296014ffedb44f25c1614543a0bb64ea (patch) | |
tree | 4c848d0c8bfded3289d155c20106052cefe3ae61 /zendian.h | |
parent | 4bc6ffa41a7a23e04a2da409ca512a73cf268382 (diff) |
Rename gzendian to zendian since it is included in more than just the gzip library code.
Diffstat (limited to 'zendian.h')
-rw-r--r-- | zendian.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/zendian.h b/zendian.h new file mode 100644 index 0000000..5087034 --- /dev/null +++ b/zendian.h @@ -0,0 +1,60 @@ +/* zendian.h -- define BYTE_ORDER for endian tests + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +#ifndef ENDIAN_H_ +#define ENDIAN_H_ + +/* First check whether the compiler knows the target __BYTE_ORDER__. */ +#if defined(__BYTE_ORDER__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# if !defined(LITTLE_ENDIAN) +# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +# endif +# if !defined(BYTE_ORDER) +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# if !defined(BIG_ENDIAN) +# define BIG_ENDIAN __ORDER_BIG_ENDIAN__ +# endif +# if !defined(BYTE_ORDER) +# define BYTE_ORDER BIG_ENDIAN +# endif +# endif +#elif defined(__MINGW32__) +# include <sys/param.h> +#elif defined(WIN32) || defined(_WIN32) +# define LITTLE_ENDIAN 1234 +# define BIG_ENDIAN 4321 +# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) +# define BYTE_ORDER LITTLE_ENDIAN +# else +# error Unknown endianness! +# endif +#elif defined(__linux__) +# include <endian.h> +#elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__) +# include <machine/endian.h> +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) +# include <sys/endian.h> +#elif defined(__sun) || defined(sun) +# include <sys/byteorder.h> +# if !defined(LITTLE_ENDIAN) +# define LITTLE_ENDIAN 4321 +# endif +# if !defined(BIG_ENDIAN) +# define BIG_ENDIAN 1234 +# endif +# if !defined(BYTE_ORDER) +# if defined(_BIG_ENDIAN) +# define BYTE_ORDER BIG_ENDIAN +# else +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# endif +#else +# include <endian.h> +#endif + +#endif |