forked from bblanchon/ArduinoJson
Travis: restore build on GCC 4.4
This commit is contained in:
@ -2,6 +2,12 @@ sudo: false
|
|||||||
language: cpp
|
language: cpp
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
|
- compiler: gcc
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
|
packages: ['g++-4.4']
|
||||||
|
env: SCRIPT=cmake GCC=4.4
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
@ -139,7 +139,7 @@
|
|||||||
#ifndef ARDUINOJSON_LITTLE_ENDIAN
|
#ifndef ARDUINOJSON_LITTLE_ENDIAN
|
||||||
#if defined(_MSC_VER) || \
|
#if defined(_MSC_VER) || \
|
||||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
|
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
|
||||||
(defined(__LITTLE_ENDIAN__))
|
defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64)
|
||||||
#define ARDUINOJSON_LITTLE_ENDIAN 1
|
#define ARDUINOJSON_LITTLE_ENDIAN 1
|
||||||
#else
|
#else
|
||||||
#define ARDUINOJSON_LITTLE_ENDIAN 0
|
#define ARDUINOJSON_LITTLE_ENDIAN 0
|
||||||
|
@ -9,30 +9,33 @@
|
|||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
|
|
||||||
inline void fixEndianess(uint8_t* p, integral_constant<size_t, 8>) {
|
#if ARDUINOJSON_LITTLE_ENDIAN
|
||||||
|
inline void fixEndianess(uint8_t *p, integral_constant<size_t, 8>) {
|
||||||
swap(p[0], p[7]);
|
swap(p[0], p[7]);
|
||||||
swap(p[1], p[6]);
|
swap(p[1], p[6]);
|
||||||
swap(p[2], p[5]);
|
swap(p[2], p[5]);
|
||||||
swap(p[3], p[4]);
|
swap(p[3], p[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void fixEndianess(uint8_t* p, integral_constant<size_t, 4>) {
|
inline void fixEndianess(uint8_t *p, integral_constant<size_t, 4>) {
|
||||||
swap(p[0], p[3]);
|
swap(p[0], p[3]);
|
||||||
swap(p[1], p[2]);
|
swap(p[1], p[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void fixEndianess(uint8_t* p, integral_constant<size_t, 2>) {
|
inline void fixEndianess(uint8_t *p, integral_constant<size_t, 2>) {
|
||||||
swap(p[0], p[1]);
|
swap(p[0], p[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void fixEndianess(uint8_t*, integral_constant<size_t, 1>) {}
|
inline void fixEndianess(uint8_t *, integral_constant<size_t, 1>) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void fixEndianess(T& value) {
|
inline void fixEndianess(T &value) {
|
||||||
#if ARDUINOJSON_LITTLE_ENDIAN
|
fixEndianess(reinterpret_cast<uint8_t *>(&value),
|
||||||
fixEndianess(reinterpret_cast<uint8_t*>(&value),
|
|
||||||
integral_constant<size_t, sizeof(T)>());
|
integral_constant<size_t, sizeof(T)>());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
inline void fixEndianess(T &) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
} // namespace ARDUINOJSON_NAMESPACE
|
||||||
|
Reference in New Issue
Block a user