Import Curve 448 support
[openssl.git] / crypto / ec / curve448 / include / portable_endian.h
1 /* Subset of Mathias Panzenböck's portable endian code, public domain */
2
3 #ifndef __PORTABLE_ENDIAN_H__
4 #define __PORTABLE_ENDIAN_H__
5
6 #if defined(__linux__) || defined(__CYGWIN__)
7 #       include <endian.h>
8 #elif defined(__OpenBSD__)
9 #       include <sys/endian.h>
10 #elif defined(__APPLE__)
11 #       include <libkern/OSByteOrder.h>
12 #       define htole64(x) OSSwapHostToLittleInt64(x)
13 #       define le64toh(x) OSSwapLittleToHostInt64(x)
14 #elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
15 #       include <sys/endian.h>
16 #       ifndef le64toh
17 #               define le64toh(x) letoh64(x)
18 #       endif
19 #elif defined(__sun) && defined(__SVR4)
20 #       include <sys/byteorder.h>
21 #       define htole64(x) LE_64(x)
22 #       define le64toh(x) LE_64(x)
23 #elif defined(_WIN16) || defined(_WIN32) || defined(_WIN64) || defined(__WINDOWS__)
24 #       include <winsock2.h>
25 #       include <sys/param.h>
26 #       if BYTE_ORDER == LITTLE_ENDIAN
27 #               define htole64(x) (x)
28 #               define le64toh(x) (x)
29 #       elif BYTE_ORDER == BIG_ENDIAN
30 #               define htole64(x) __builtin_bswap64(x)
31 #               define le64toh(x) __builtin_bswap64(x)
32 #       else
33 #               error byte order not supported
34 #       endif
35 #else
36 #       error platform not supported
37 #endif
38
39 #endif // __PORTABLE_ENDIAN_H__