Unfortunately this patch suffers from the problem we discussed earlier, e.g., the substitute be16toh (n++) has undefined behavior but it should add 1 to n and otherwise act as if be16toh (n) was called.

Also, the returned values and types are sometimes wrong. E.g., on x86-64 be16toh (-1) should return 0xffff of type uint16_t, but it returns -1 of type int.

These problems arise because Gnulib byteswap.h's macros can evaluate their arguments more than once, and are type-generic in a way that is incompatible with what POSIX wants for endian.h functions.

Also, there's a bizarre compatibility issue, in that some floating-point args have well-defined behavior in the POSIX spec, e.g., be16toh (0.0) yields 0, but this implementation rejects these calls. Although this is lower priority it's easy to fix so we might as well do it.

To fix this, please use _GL_INLINE and implement with inline functions. And add please add test cases to catch these issues.

Reply via email to