wg: use libc's endianness macro if no compiler macro

This lets us be compiled with ancient gcc.

Reported-by: Jeff Brandt <jeff@jeffcolo.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-10-09 15:21:27 +02:00
parent 846d2514c5
commit c1ca487f63
1 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,16 @@
#include <stdint.h>
#include <string.h>
#ifndef __BYTE_ORDER__
#include <sys/param.h>
#if !defined(BYTE_ORDER) || !defined(BIG_ENDIAN) || !defined(LITTLE_ENDIAN)
#error "Unable to determine endianness."
#endif
#define __BYTE_ORDER__ BYTE_ORDER
#define __ORDER_BIG_ENDIAN__ BIG_ENDIAN
#define __ORDER_LITTLE_ENDIAN__ LITTLE_ENDIAN
#endif
#ifdef __linux__
#include <linux/types.h>
typedef __u64 u64;