diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-15 09:41:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-15 09:41:34 +0000 |
commit | 25e43e389c26d56f90f2f20e3cee19c808b2a18c (patch) | |
tree | fdadca249ffd70901103b3f06a98aeab695c6193 /m4/tuklib_integer.m4 | |
parent | Adding debian version 5.6.1+really5.4.5-1. (diff) | |
download | xz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.tar.xz xz-utils-25e43e389c26d56f90f2f20e3cee19c808b2a18c.zip |
Merging upstream version 5.6.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'm4/tuklib_integer.m4')
-rw-r--r-- | m4/tuklib_integer.m4 | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/m4/tuklib_integer.m4 b/m4/tuklib_integer.m4 index ab9a405..906ecf1 100644 --- a/m4/tuklib_integer.m4 +++ b/m4/tuklib_integer.m4 @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: 0BSD + +############################################################################# # # SYNOPSIS # @@ -11,13 +14,11 @@ # - Does the hardware support fast unaligned access to 16-bit, 32-bit, # and 64-bit integers # -# COPYING -# -# Author: Lasse Collin +############################################################################# # -# This file has been put into the public domain. -# You can do whatever you want with this file. +# Author: Lasse Collin # +############################################################################# AC_DEFUN_ONCE([TUKLIB_INTEGER], [ AC_REQUIRE([TUKLIB_COMMON]) @@ -65,22 +66,42 @@ AC_MSG_CHECKING([if unaligned memory access should be used]) AC_ARG_ENABLE([unaligned-access], AS_HELP_STRING([--enable-unaligned-access], [Enable if the system supports *fast* unaligned memory access with 16-bit, 32-bit, and 64-bit integers. By default, - this is enabled only on x86, x86_64, big endian PowerPC, - and some ARM systems.]), + this is enabled on x86, x86-64, + 32/64-bit big endian PowerPC, + 64-bit little endian PowerPC, + and some ARM, ARM64, and RISC-V systems.]), [], [enable_unaligned_access=auto]) if test "x$enable_unaligned_access" = xauto ; then - # TODO: There may be other architectures, on which unaligned access - # is OK. + # NOTE: There might be other architectures on which unaligned access + # is fast. case $host_cpu in - i?86|x86_64|powerpc|powerpc64) + i?86|x86_64|powerpc|powerpc64|powerpc64le) enable_unaligned_access=yes ;; - arm*|aarch64*) + arm*|aarch64*|riscv*) # On 32-bit and 64-bit ARM, GCC and Clang # #define __ARM_FEATURE_UNALIGNED if # unaligned access is supported. + # + # Exception: GCC at least up to 13.2.0 + # defines it even when using -mstrict-align + # so in that case this autodetection goes wrong. + # Most of the time -mstrict-align isn't used so it + # shouldn't be a common problem in practice. See: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111555 + # + # RISC-V C API Specification says that if + # __riscv_misaligned_fast is defined then + # unaligned access is known to be fast. + # + # MSVC is handled as a special case: We assume that + # 32/64-bit ARM supports fast unaligned access. + # If MSVC gets RISC-V support then this will assume + # fast unaligned access on RISC-V too. AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#ifndef __ARM_FEATURE_UNALIGNED +#if !defined(__ARM_FEATURE_UNALIGNED) \ + && !defined(__riscv_misaligned_fast) \ + && !defined(_MSC_VER) compile error #endif int main(void) { return 0; } |