| 1 | dnl @synopsis AX_BSWAP64 |
|---|
| 2 | dnl |
|---|
| 3 | dnl This macro will check for a built in way of endian reversing an int64_t. |
|---|
| 4 | dnl If one is found then HAVE_BSWAP64 is set to 1 and BSWAP64 will be defined |
|---|
| 5 | dnl to the name of the endian swap function. |
|---|
| 6 | dnl |
|---|
| 7 | dnl @category C |
|---|
| 8 | dnl @author Martin Ebourne |
|---|
| 9 | dnl @version 2006/02/02 |
|---|
| 10 | dnl @license AllPermissive |
|---|
| 11 | |
|---|
| 12 | AC_DEFUN([AX_BSWAP64], [ |
|---|
| 13 | bswap64_function="" |
|---|
| 14 | AC_CHECK_HEADERS([sys/endian.h asm/byteorder.h]) |
|---|
| 15 | if test "x$ac_cv_header_sys_endian_h" = "xyes"; then |
|---|
| 16 | AC_CACHE_CHECK([for htobe64], [box_cv_have_htobe64], |
|---|
| 17 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|---|
| 18 | $ac_includes_default |
|---|
| 19 | #include <sys/endian.h> |
|---|
| 20 | ]], [[ |
|---|
| 21 | htobe64(0); |
|---|
| 22 | return 1; |
|---|
| 23 | ]])], |
|---|
| 24 | [box_cv_have_htobe64=yes], [box_cv_have_htobe64=no] |
|---|
| 25 | )]) |
|---|
| 26 | if test "x$box_cv_have_htobe64" = "xyes"; then |
|---|
| 27 | bswap64_function=htobe64 |
|---|
| 28 | fi |
|---|
| 29 | fi |
|---|
| 30 | if test "x$bswap64_function" = "x" && \ |
|---|
| 31 | test "x$ac_cv_header_asm_byteorder_h" = "xyes"; then |
|---|
| 32 | AC_CACHE_CHECK([for __cpu_to_be64], [box_cv_have___cpu_to_be64], |
|---|
| 33 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|---|
| 34 | $ac_includes_default |
|---|
| 35 | #include <asm/byteorder.h> |
|---|
| 36 | ]], [[ |
|---|
| 37 | __cpu_to_be64(0); |
|---|
| 38 | return 1; |
|---|
| 39 | ]])], |
|---|
| 40 | [box_cv_have___cpu_to_be64=yes], [box_cv_have___cpu_to_be64=no] |
|---|
| 41 | )]) |
|---|
| 42 | if test "x$box_cv_have___cpu_to_be64" = "xyes"; then |
|---|
| 43 | bswap64_function=__cpu_to_be64 |
|---|
| 44 | fi |
|---|
| 45 | fi |
|---|
| 46 | |
|---|
| 47 | if test "x$bswap64_function" != "x"; then |
|---|
| 48 | AC_DEFINE([HAVE_BSWAP64], 1, |
|---|
| 49 | [Define to 1 if BSWAP64 is defined to the name of a valid 64 bit endian swapping function]) |
|---|
| 50 | AC_DEFINE_UNQUOTED([BSWAP64], [$bswap64_function], [Name of the 64 bit endian swapping function]) |
|---|
| 51 | fi |
|---|
| 52 | ])dnl |
|---|