mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Common: provide minimal byteswap.h and endian.h
This commit is contained in:
parent
8a27680fbb
commit
471de28967
24
libraries/AP_Common/missing/byteswap.h
Normal file
24
libraries/AP_Common/missing/byteswap.h
Normal file
@ -0,0 +1,24 @@
|
||||
#if defined(HAVE_BYTESWAP_H) && HAVE_BYTESWAP_H
|
||||
#include_next <byteswap.h>
|
||||
#else
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* minimal version defining only the macros we need in our codebase */
|
||||
|
||||
static inline uint16_t __bswap_16(uint16_t u)
|
||||
{
|
||||
return (uint16_t) __builtin_bswap16(u);
|
||||
}
|
||||
|
||||
static inline uint32_t __bswap_32(uint32_t u)
|
||||
{
|
||||
return (uint32_t) __builtin_bswap32(u);
|
||||
}
|
||||
|
||||
static inline uint64_t __bswap_64(uint64_t u)
|
||||
{
|
||||
return (uint64_t) __builtin_bswap64(u);
|
||||
}
|
||||
|
||||
#endif
|
16
libraries/AP_Common/missing/endian.h
Normal file
16
libraries/AP_Common/missing/endian.h
Normal file
@ -0,0 +1,16 @@
|
||||
#if defined(HAVE_ENDIAN_H) && HAVE_ENDIAN_H
|
||||
#include_next <endian.h>
|
||||
#else
|
||||
|
||||
/* minimal version defining only the macros we need in our codebase */
|
||||
|
||||
#define __LITTLE_ENDIAN 1234
|
||||
#define __BIG_ENDIAN 4321
|
||||
|
||||
#ifdef __ARMEB__
|
||||
#define __BYTE_ORDER __BIG_ENDIAN
|
||||
#else
|
||||
#define __BYTE_ORDER __LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user