Build: Fix = to += for xz_SOURCES in src/xz/Makefile.am.
[xz/debian.git] / m4 / tuklib_integer.m4
blob2ab72a2f05e43f9e86487562e5248cf57573a471
2 # SYNOPSIS
4 #   TUKLIB_INTEGER
6 # DESCRIPTION
8 #   Checks for tuklib_integer.h:
9 #     - Endianness
10 #     - Does operating system provide byte swapping macros
11 #     - Does the hardware support fast unaligned access to 16-bit
12 #       and 32-bit integers
14 # COPYING
16 #   Author: Lasse Collin
18 #   This file has been put into the public domain.
19 #   You can do whatever you want with this file.
22 AC_DEFUN_ONCE([TUKLIB_INTEGER], [
23 AC_REQUIRE([TUKLIB_COMMON])
24 AC_REQUIRE([AC_C_BIGENDIAN])
25 AC_CHECK_HEADERS([byteswap.h sys/endian.h sys/byteorder.h], [break])
27 # Even if we have byteswap.h, we may lack the specific macros/functions.
28 if test x$ac_cv_header_byteswap_h = xyes ; then
29         m4_foreach([FUNC], [bswap_16,bswap_32,bswap_64], [
30                 AC_MSG_CHECKING([if FUNC is available])
31                 AC_LINK_IFELSE([AC_LANG_SOURCE([
32 #include <byteswap.h>
33 int
34 main(void)
36         FUNC[](42);
37         return 0;
39                 ])], [
40                         AC_DEFINE(HAVE_[]m4_toupper(FUNC), [1],
41                                         [Define to 1 if] FUNC [is available.])
42                         AC_MSG_RESULT([yes])
43                 ], [AC_MSG_RESULT([no])])
45         ])dnl
48 AC_MSG_CHECKING([if unaligned memory access should be used])
49 AC_ARG_ENABLE([unaligned-access], AS_HELP_STRING([--enable-unaligned-access],
50                 [Enable if the system supports *fast* unaligned memory access
51                 with 16-bit and 32-bit integers. By default, this is enabled
52                 only on x86, x86_64, and big endian PowerPC.]),
53         [], [enable_unaligned_access=auto])
54 if test "x$enable_unaligned_access" = xauto ; then
55         # TODO: There may be other architectures, on which unaligned access
56         # is OK.
57         case $host_cpu in
58                 i?86|x86_64|powerpc|powerpc64)
59                         enable_unaligned_access=yes
60                         ;;
61                 *)
62                         enable_unaligned_access=no
63                         ;;
64         esac
66 if test "x$enable_unaligned_access" = xyes ; then
67         AC_DEFINE([TUKLIB_FAST_UNALIGNED_ACCESS], [1], [Define to 1 if
68                 the system supports fast unaligned access to 16-bit and
69                 32-bit integers.])
70         AC_MSG_RESULT([yes])
71 else
72         AC_MSG_RESULT([no])
74 ])dnl