diff --git a/configure.ac b/configure.ac index a40bfa3..a1fcb63 100644 --- a/configure.ac +++ b/configure.ac @@ -40,9 +40,9 @@ AC_FUNC_REALLOC AC_CHECK_HEADERS([sys/types.h]) AC_CHECK_FUNCS([memset letoh32 htole32 pow strerror]) -AC_CHECK_HEADERS([endian.h sys/endian.h]) -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."]); +AC_CHECK_HEADERS([endian.h sys/endian.h CoreFoundation/CoreFoundation.h]) +if test $ac_cv_header_endian_h = "no" -a $ac_cv_header_sys_endian_h = "no" -a $ac_cv_header_CoreFoundation_CoreFoundation_h = "no"; then + AC_MSG_ERROR(["Can't locate usable header file for endianness convertions."]); fi AC_CHECK_HEADERS([byteswap.h]) diff --git a/libfreefare/freefare_internal.h b/libfreefare/freefare_internal.h index 82cb996..eb28dcd 100644 --- a/libfreefare/freefare_internal.h +++ b/libfreefare/freefare_internal.h @@ -51,6 +51,20 @@ # define be16toh(x) betoh16(x) #endif +#if !defined(le32toh) && defined(CFSwapInt32LittleToHost) +# define be32toh(x) CFSwapInt32BigToHost(x) +# define htobe32(x) CFSwapInt32HostToBig(x) +# define le32toh(x) CFSwapInt32LittleToHost(x) +# define htole32(x) CFSwapInt32HostToLittle(x) +#endif + +#if !defined(le16toh) && defined(CFSwapInt16LittleToHost) +# define be16toh(x) CFSwapInt16BigToHost(x) +# define htobe16(x) CFSwapInt16HostToBig(x) +# define le16toh(x) CFSwapInt16LittleToHost(x) +# define htole16(x) CFSwapInt16HostToLittle(x) +#endif + #if !defined(le32toh) && defined(bswap_32) # if BYTE_ORDER == LITTLE_ENDIAN # define be32toh(x) bswap_32(x) diff --git a/libfreefare/mifare_classic.c b/libfreefare/mifare_classic.c index 7a6efe0..89fc4c1 100644 --- a/libfreefare/mifare_classic.c +++ b/libfreefare/mifare_classic.c @@ -52,6 +52,10 @@ # include #endif +#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) +# include +#endif + #if defined(HAVE_BYTESWAP_H) # include #endif diff --git a/libfreefare/mifare_desfire.c b/libfreefare/mifare_desfire.c index 77478c6..7265595 100644 --- a/libfreefare/mifare_desfire.c +++ b/libfreefare/mifare_desfire.c @@ -35,6 +35,10 @@ # include #endif +#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) +# include +#endif + #if defined(HAVE_BYTESWAP_H) # include #endif diff --git a/libfreefare/mifare_desfire_aid.c b/libfreefare/mifare_desfire_aid.c index 279ca88..31e22da 100644 --- a/libfreefare/mifare_desfire_aid.c +++ b/libfreefare/mifare_desfire_aid.c @@ -40,6 +40,10 @@ # include #endif +#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) +# include +#endif + #if defined(HAVE_BYTESWAP_H) # include #endif diff --git a/libfreefare/tlv.c b/libfreefare/tlv.c index e3459f8..38db0af 100644 --- a/libfreefare/tlv.c +++ b/libfreefare/tlv.c @@ -40,6 +40,10 @@ # include #endif +#if defined(HAVE_COREFOUNDATION_COREFOUNDATION_H) +# include +#endif + #if defined(HAVE_BYTESWAP_H) # include #endif