2024-05-11 20:16:48 +00:00
|
|
|
# byteswap.m4
|
2024-05-20 17:12:56 +00:00
|
|
|
# serial 7
|
2024-01-02 01:47:10 +00:00
|
|
|
dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc.
|
Use hardware support for byteswapping on glibc x86 etc.
On Fedora 19 x86-64, the new bswap_64 needs 1 instruction,
whereas the old swap64 needed 30.
* admin/merge-gnulib (GNULIB_MODULES): Add byteswap.
* lib/byteswap.in.h, m4/byteswap.m4: New files, copied from Gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* src/fringe.c (init_fringe_bitmap) [WORDS_BIGENDIAN]:
* src/sound.c (le2hl, le2hs, be2hl) [!WINDOWSNT]:
Use byteswap.h's macros to swap bytes.
* src/lisp.h (swap16, swap32, swap64): Remove.
All uses replaced by bswap_16, bswap_32, bswap_64.
2013-10-04 07:36:22 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
|
|
|
dnl Written by Oskar Liljeblad.
|
|
|
|
|
|
|
|
AC_DEFUN([gl_BYTESWAP],
|
|
|
|
[
|
|
|
|
dnl Prerequisites of lib/byteswap.in.h.
|
2024-05-18 16:33:03 +00:00
|
|
|
AC_CHECK_HEADERS_ONCE([byteswap.h])
|
|
|
|
if test $ac_cv_header_byteswap_h = yes; then
|
|
|
|
AC_CACHE_CHECK([for working bswap_16, bswap_32, bswap_64],
|
|
|
|
[gl_cv_header_working_byteswap_h],
|
|
|
|
[gl_cv_header_working_byteswap_h=no
|
2024-05-20 17:12:56 +00:00
|
|
|
dnl Check that floating point arguments work.
|
|
|
|
dnl This also checks C libraries with implementations like
|
|
|
|
dnl '#define bswap_16(x) (((x) >> 8 & 0xff) | (((x) & 0xff) << 8))'
|
|
|
|
dnl that mistakenly evaluate their arguments multiple times.
|
2024-05-18 16:33:03 +00:00
|
|
|
AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[[#include <byteswap.h>
|
|
|
|
]],
|
|
|
|
[[int value_16 = bswap_16 (0.0);
|
|
|
|
int value_32 = bswap_32 (0.0);
|
|
|
|
int value_64 = bswap_64 (0.0);
|
|
|
|
return !(value_16 + value_32 + value_64);
|
|
|
|
]])
|
|
|
|
],
|
|
|
|
[gl_cv_header_working_byteswap_h=yes],
|
|
|
|
[gl_cv_header_working_byteswap_h=no])
|
|
|
|
])
|
|
|
|
fi
|
2024-05-20 17:12:56 +00:00
|
|
|
if test "$gl_cv_header_working_byteswap_h" = yes; then
|
2021-12-19 00:12:38 +00:00
|
|
|
GL_GENERATE_BYTESWAP_H=false
|
2024-05-18 16:33:03 +00:00
|
|
|
else
|
2021-12-19 00:12:38 +00:00
|
|
|
GL_GENERATE_BYTESWAP_H=true
|
2024-05-18 16:33:03 +00:00
|
|
|
fi
|
Use hardware support for byteswapping on glibc x86 etc.
On Fedora 19 x86-64, the new bswap_64 needs 1 instruction,
whereas the old swap64 needed 30.
* admin/merge-gnulib (GNULIB_MODULES): Add byteswap.
* lib/byteswap.in.h, m4/byteswap.m4: New files, copied from Gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
* src/fringe.c (init_fringe_bitmap) [WORDS_BIGENDIAN]:
* src/sound.c (le2hl, le2hs, be2hl) [!WINDOWSNT]:
Use byteswap.h's macros to swap bytes.
* src/lisp.h (swap16, swap32, swap64): Remove.
All uses replaced by bswap_16, bswap_32, bswap_64.
2013-10-04 07:36:22 +00:00
|
|
|
])
|