Skip to content

Commit

Permalink
tests: Cope with lack of __FLOAT_WORD_ORDER__ with Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecrowe committed Jul 14, 2020
1 parent 893617f commit ecd8139
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/dbus_type_double_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ namespace test {
uint64_t u;
memcpy(&u, &value, sizeof(u));

// __FLOAT_WORD_ORDER__ is the same as __BYTE_ORDER__ on almost
// everything in the world. We only swap or not so we couldn't
// cope if it is not. Let's use __FLOAT_WORD_ORDER__ here so at
// least this test will fail in that case.
// __FLOAT_WORD_ORDER__ is the same as __BYTE_ORDER__ on
// almost everything in the world. We only swap or not so we
// couldn't cope if it is not. Let's use __FLOAT_WORD_ORDER__
// if it's available so at least this test will fail in that
// case.
#if defined(__FLOAT_WORD_ORDER__)
if (byteOrder != __FLOAT_WORD_ORDER__)
u = __bswap_64(u);

#else
if (byteOrder != __BYTE_ORDER)
u = __bswap_64(u);
#endif
MessageIStream stream((uint8_t*)&u, sizeof(u), byteOrder != __BYTE_ORDER);
dbusType.unmarshall(stream);

Expand Down

0 comments on commit ecd8139

Please sign in to comment.