Date: Mon, 22 Jun 2015 08:57:01 +0200 From: Rafał Miłecki <zajec5@...il.com> To: musl@...ts.openwall.com Subject: Using __BYTE_ORDER without endian.h Hi, So far we were using uClibc in OpenWrt and my following code was working fine: #include <byteswap.h> #include <errno.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #if __BYTE_ORDER == __BIG_ENDIAN #define cpu_to_le32(x) bswap_32(x) #define le32_to_cpu(x) bswap_32(x) #elif __BYTE_ORDER == __LITTLE_ENDIAN #define cpu_to_le32(x) (x) #define le32_to_cpu(x) (x) #else #error "Unsupported endianness" #endif Unfortunately is is *silently* broken with musl. When using musl and not including endian.h directly the condition: #if __BYTE_ORDER == __BIG_ENDIAN is always true. Could you fix this? I expect either: 1) __BYTE_ORDER to be always available & set correctly 2) Compile error because of __BYTE_ORDER being undefined I think such silent miscompilation is sth that has to be avoided. -- Rafał
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.