fsfw/osal/Endiness.h

49 lines
821 B
C
Raw Normal View History

#ifndef FRAMEWORK_OSAL_ENDINESS_H_
#define FRAMEWORK_OSAL_ENDINESS_H_
2018-07-13 15:56:37 +02:00
/*
* BSD-style endian declaration
*/
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif
2018-07-13 15:56:37 +02:00
// This is a GCC C extension
2018-07-13 18:28:26 +02:00
#ifndef BYTE_ORDER_SYSTEM
#ifdef __BYTE_ORDER__
2018-07-13 15:56:37 +02:00
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
2018-07-13 18:28:26 +02:00
#define BYTE_ORDER_SYSTEM LITTLE_ENDIAN
2018-07-13 15:56:37 +02:00
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
2018-07-13 18:28:26 +02:00
#define BYTE_ORDER_SYSTEM BIG_ENDIAN
2018-07-13 15:56:37 +02:00
#else
#error "Can't decide which end is which!"
#endif
2020-12-20 15:32:03 +01:00
#else
#ifdef WIN32
2021-01-29 00:12:40 +01:00
#include <winsock2.h>
#include <windows.h>
2020-12-20 15:32:03 +01:00
#if REG_DWORD == REG_DWORD_LITTLE_ENDIAN
#define BYTE_ORDER_SYSTEM LITTLE_ENDIAN
#else
#define BYTE_ORDER_SYSTEM BIG_ENDIAN
#endif
2018-07-13 18:28:26 +02:00
#else
#error __BYTE_ORDER__ not defined
#endif
2020-12-20 15:32:03 +01:00
#endif
2018-07-13 15:56:37 +02:00
#endif
#endif /* FRAMEWORK_OSAL_ENDINESS_H_ */