On Wed, 2013-08-28 at 15:31 +0200, Lukas Slebodnik wrote:
+/* Endianness-compatibility for systems running older versions of
glibc */
+
+#ifndef le32toh
+#ifdef HAVE_BYTESWAP_H
+# include <byteswap.h>
+#endif /* HAVE_BYTESWAP_H */
+
+/* support RHEL5 lack of definitions */
+/* Copied from endian.h on glibc 2.15 */
+#ifdef __USE_BSD
+/* Conversion interfaces. */
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define le32toh(x) (x)
+# define htole32(x) (x)
+# else
+# define le32toh(x) __bswap_32 (x)
+# define htole32(x) __bswap_32 (x)
+# endif
+#endif /* __USE_BSD */
+
+#endif /* le32toh */
+
If byteswap is not defined does the rest of the define work ?
In the code you replace byteswap is included unconditionally as I assume
it is the file that contains __BYTE_ORDER__ , __LITTLE_ENDIAN and other
definitions needed to reimplement le32toh, so the if byteswap.h is not
available I guess the rest of the ifdef will just fail ?
maybe you should have instead:
#ifndef le32toh
#ifndef HAVE_BYTESWAP_H
#error missing le32toh and byteswap.h
#else
/* support RHEL5 lack of definitions */
...
...
#endif /* HAVE_BYTESWAP_H */
#endif /* le32toh */
Simo.
--
Simo Sorce * Red Hat, Inc * New York