From bf163cbebfec97b83c070d22fed1eabf7a2da629 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Mon, 3 Jan 2011 10:47:30 +0000 Subject: [PATCH] roken: Check for bswap16 and bswap32 defines Our imported roken.h provides definitions for bswap16 and bswap32, but configure doesn't check to see if those functions already exist. On operating systems where they do, and where the header containing them is included in our build, this results in compilation errors. Add a configure test for bswap16 and bswap32, which is complicated by the fact that they may be macros, or static inline functions, so a simple CHECK_FUNCS won't work. Change-Id: Iae3411bf4bb22af8cfd770e01026a28e1863e078 Reviewed-on: http://gerrit.openafs.org/3613 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- acinclude.m4 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 267785bb2..82e2c7ced 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1227,6 +1227,7 @@ AC_CHECK_HEADERS([ \ string.h \ strings.h \ sys/bitypes.h \ + sys/bswap.h \ sys/fcntl.h \ sys/file.h \ sys/fs_types.h \ @@ -1243,6 +1244,7 @@ AC_CHECK_HEADERS([ \ sys/statvfs.h \ sys/socket.h \ sys/time.h \ + sys/types.h \ sys/un.h \ sys/vfs.h \ syslog.h \ @@ -1411,6 +1413,36 @@ AS_IF([test "$ac_cv_header_err_h" != "yes" ], []) AC_SUBST(ROKEN_HEADERS) +dnl Stuff that's harder ... +AC_MSG_CHECKING([for bswap16]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_BSWAP_H +#include +#endif +], +[short a, b; b = bswap16(a); ])], +[AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BSWAP16, 1, [Define to 1 if you have the bswap16 function]) +], +[AC_MSG_RESULT(no)]) + +AC_MSG_CHECKING([for bswap32]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_BSWAP_H +#include +#endif +], +[int a, b; b = bswap32(a); ])], +[AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_BSWAP32, 1, [Define to 1 if you have the bswap32 function]) +], +[AC_MSG_RESULT(no)]) + AC_MSG_CHECKING([for positional I/O]) if test "$ac_cv_func_pread" = "yes" && \ test "$ac_cv_func_pwrite" = "yes"; then -- 2.39.5