endian.h
#pragma once
#if defined(__FreeBSD__)
#include <sys/endian.h>
#if BYTE_ORDER == LITTLE_ENDIAN
#define OSMO_IS_LITTLE_ENDIAN 1
#define OSMO_IS_BIG_ENDIAN 0
#elif BYTE_ORDER == BIG_ENDIAN
#define OSMO_IS_LITTLE_ENDIAN 0
#define OSMO_IS_BIG_ENDIAN 1
#else
#error "Unknown endian"
#endif
#else
#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define OSMO_IS_LITTLE_ENDIAN 1
#define OSMO_IS_BIG_ENDIAN 0
#elif __BYTE_ORDER == __BIG_ENDIAN
#define OSMO_IS_LITTLE_ENDIAN 0
#define OSMO_IS_BIG_ENDIAN 1
#else
#error "Unknown endian"
#endif
#endif