Make linux.h compile cleanly when the non-standard htobe16() and htobe64()
[shallot/rransom.git] / src / linux.h
blob2d8ed7f201c98b5c74f2742a0ab578467cfc48c6
1 #ifndef LINUX_H
2 #define LINUX_H
4 #include "config.h"
6 #if defined(LINUX_PORT) || defined(OSX) || defined(GENERIC)
8 #include <stdint.h>
10 #if defined(OSX) || defined(GENERIC)
11 #include <arpa/inet.h>
12 #else
13 #include <endian.h>
14 #include <netinet/in.h>
15 #endif
17 #ifndef htobe64
18 #if BYTE_ORDER == BIG_ENDIAN
19 #warning Compiling for a BIG_ENDIAN system.
20 #define htobe64(x) (x)
21 #define htobe16(x) (x)
23 #elif BYTE_ORDER == LITTLE_ENDIAN
24 #warning Compiling for a LITTLE_ENDIAN system.
25 #define htobe64(x) (((uint64_t)htonl(x) << 32) | htonl(x >> 32))
26 #define htobe16(x) htons(x)
28 #else
29 #error Sell your PDP.
30 #endif
31 #endif
33 #ifdef LINUX_PORT
34 uint8_t parse_cpuinfo(char *buf, uint16_t avail, uint16_t *used);
35 #endif
37 #endif // defined(LINUX_PORT) || defined(OSX) || defined(GENERIC)
39 #endif