msoeken / kitty

C++ truth table library
MIT License
50 stars 77 forks source link

Allow kitty to run on big-endian platforms. #122

Closed boschmitt closed 2 years ago

boschmitt commented 3 years ago

Most of the code is not influenced by the endianness. However the combination of bit-filed struct and union is.

For example. Take this code:

union {
    struct
    {
        uint32_t _bits;
        uint32_t _mask;
    };
    uint64_t _value;
  };

If we try to change the value of '_bits' using (_value ^ 1), then things will break. This commit adds compile-time macros to identify the endianness of the platform, and change the order of '_bits' and '_mask' accordingly.