From 62ddf57c538ee361cf5769a34058f222cc9a557e Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Thu, 25 Feb 2010 18:02:54 +0000 Subject: [PATCH] Rework byteswap.h inclusion. This header is not available on e.g. FreeBSD so detect it's presence in configure.ac and only include it if appropriate. Then, if byte order manipulation macros are not defined (old glibc like the one provided by Debian GNU/Linux) define them. --- configure.ac | 2 ++ libfreefare/freefare_internal.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8f834a1..84f178f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,8 @@ if test $ac_cv_header_endian_h = "no" -a $ac_cv_header_sys_endian_h = "no"; then AC_MSG_ERROR(["Can't locate header endian.h."]); fi +AC_CHECK_HEADERS([byteswap.h]) + AC_DEFINE([_XOPEN_SOURCE], [600], [Define to 500 if Single Unix conformance is wanted, 600 for sixth revision.]) CFLAGS="$CFLAGS -std=c99" diff --git a/libfreefare/freefare_internal.h b/libfreefare/freefare_internal.h index 4a9f5f8..4abe4f2 100644 --- a/libfreefare/freefare_internal.h +++ b/libfreefare/freefare_internal.h @@ -20,8 +20,11 @@ #ifndef __FREEFARE_INTERNAL_H__ #define __FREEFARE_INTERNAL_H__ +#include "config.h" + +#if defined(HAVE_BYTESWAP_H) +#include #if !defined(le32toh) || !defined(htole32) - #include #if BYTE_ORDER == LITTLE_ENDIAN #define le32toh(x) (x) #define htole32(x) bswap_32(x) @@ -30,6 +33,7 @@ #define htole32(x) (x) #endif #endif +#endif struct mad_sector_0x00;