eive-obsw/gomspace/libutil/include/gs/util/endian.h

54 lines
889 B
C
Raw Normal View History

2020-11-19 18:24:03 +01:00
#ifndef GS_UTIL_ENDIAN_H
#define GS_UTIL_ENDIAN_H
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
/**
@file
Detecting endian type.
*/
// generated by waf configure, defines either UTIL_BIG_ENDIAN or UTIL_LITTLE_ENDIAN
#include <conf_util.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !UTIL_BIG_ENDIAN && !UTIL_LITTLE_ENDIAN
#error No endian defined
#endif
#if UTIL_BIG_ENDIAN && UTIL_LITTLE_ENDIAN
#error Both big and little endian defined
#endif
#include <gs/util/byteorder.h>
/**
Returns \a true if platform is big endian.
*/
static inline bool gs_endian_big(void)
{
#if (UTIL_BIG_ENDIAN)
return true;
#else
return false;
#endif
}
/**
Returns \a true if platform is little endian.
*/
static inline bool gs_endian_little(void)
{
#if (UTIL_LITTLE_ENDIAN)
return true;
#else
return false;
#endif
}
#ifdef __cplusplus
}
#endif
#endif