aboutsummaryrefslogtreecommitdiffstats
path: root/common/endiantest.h
blob: 893653bdad89c8ec05962cb1897915ab6c3ccfff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef AL_ENDIANTEST_H
#define AL_ENDIANTEST_H

#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
#define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
#else
constexpr inline bool EndianTest() noexcept
{
    constexpr int test_val{1};
    return static_cast<const char&>(test_val);
}
#define IS_LITTLE_ENDIAN (EndianTest())
#endif

#endif /* AL_ENDIANTEST_H */