Commit e21b854d authored by Kenton Varda's avatar Kenton Varda

__buistin_bswap16() is apparently missing on Cygwin32.

parent c633a6f8
...@@ -98,7 +98,9 @@ template <typename T> ...@@ -98,7 +98,9 @@ template <typename T>
class SwappingWireValue<T, 2> { class SwappingWireValue<T, 2> {
public: public:
KJ_ALWAYS_INLINE(T get() const) { KJ_ALWAYS_INLINE(T get() const) {
uint16_t swapped = __builtin_bswap16(value); // Not all platforms have __builtin_bswap16() for some reason. In particular, it is missing
// on gcc-4.7.3-cygwin32 (but present on gcc-4.8.1-cygwin64).
uint16_t swapped = (value << 8) | (value >> 8);
T result; T result;
memcpy(&result, &swapped, sizeof(T)); memcpy(&result, &swapped, sizeof(T));
return result; return result;
...@@ -106,7 +108,9 @@ public: ...@@ -106,7 +108,9 @@ public:
KJ_ALWAYS_INLINE(void set(T newValue)) { KJ_ALWAYS_INLINE(void set(T newValue)) {
uint16_t raw; uint16_t raw;
memcpy(&raw, &newValue, sizeof(T)); memcpy(&raw, &newValue, sizeof(T));
value = __builtin_bswap16(raw); // Not all platforms have __builtin_bswap16() for some reason. In particular, it is missing
// on gcc-4.7.3-cygwin32 (but present on gcc-4.8.1-cygwin64).
value = (raw << 8) | (raw >> 8);
} }
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment