Blame acinclude.m4

Packit 64f477
dnl AC_C_RESTRICT
Packit 64f477
dnl Do nothing if the compiler accepts the restrict keyword.
Packit 64f477
dnl Otherwise define restrict to __restrict__ or __restrict if one of
Packit 64f477
dnl those work, otherwise define restrict to be empty.
Packit 64f477
AC_DEFUN([AC_C_RESTRICT],
Packit 64f477
    [AC_MSG_CHECKING([for restrict])
Packit 64f477
    ac_cv_c_restrict=no
Packit 64f477
    for ac_kw in restrict __restrict__ __restrict; do
Packit 64f477
	AC_TRY_COMPILE([],[char * $ac_kw p;],[ac_cv_c_restrict=$ac_kw; break])
Packit 64f477
    done
Packit 64f477
    AC_MSG_RESULT([$ac_cv_c_restrict])
Packit 64f477
    case $ac_cv_c_restrict in
Packit 64f477
	restrict) ;;
Packit 64f477
	no)	AC_DEFINE([restrict],,
Packit 64f477
		    [Define as `__restrict' if that's what the C compiler calls
Packit 64f477
		    it, or to nothing if it is not supported.]) ;;
Packit 64f477
	*)	AC_DEFINE_UNQUOTED([restrict],$ac_cv_c_restrict) ;;
Packit 64f477
    esac])
Packit 64f477
Packit 64f477
dnl AC_C_ALWAYS_INLINE
Packit 64f477
dnl Define inline to something appropriate, including the new always_inline
Packit 64f477
dnl attribute from gcc 3.1
Packit 64f477
AC_DEFUN([AC_C_ALWAYS_INLINE],
Packit 64f477
    [AC_C_INLINE
Packit 64f477
    if test x"$GCC" = x"yes" -a x"$ac_cv_c_inline" = x"inline"; then
Packit 64f477
	AC_MSG_CHECKING([for always_inline])
Packit 64f477
	SAVE_CFLAGS="$CFLAGS"
Packit 64f477
	CFLAGS="$CFLAGS -Wall -Werror"
Packit 64f477
	AC_TRY_COMPILE([],[__attribute__ ((__always_inline__)) void f (void);],
Packit 64f477
	    [ac_cv_always_inline=yes],[ac_cv_always_inline=no])
Packit 64f477
	CFLAGS="$SAVE_CFLAGS"
Packit 64f477
	AC_MSG_RESULT([$ac_cv_always_inline])
Packit 64f477
	if test x"$ac_cv_always_inline" = x"yes"; then
Packit 64f477
	    AC_DEFINE_UNQUOTED([inline],[__attribute__ ((__always_inline__))])
Packit 64f477
	fi
Packit 64f477
    fi])
Packit 64f477
Packit 64f477
dnl AC_C_ATTRIBUTE_ALIGNED
Packit 64f477
dnl define ATTRIBUTE_ALIGNED_MAX to the maximum alignment if this is supported
Packit 64f477
AC_DEFUN([AC_C_ATTRIBUTE_ALIGNED],
Packit 64f477
    [AC_CACHE_CHECK([__attribute__ ((aligned ())) support],
Packit 64f477
	[ac_cv_c_attribute_aligned],
Packit 64f477
	[ac_cv_c_attribute_aligned=0
Packit 64f477
	for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do
Packit 64f477
	    AC_TRY_COMPILE([],
Packit 64f477
		[static char c __attribute__ ((aligned($ac_cv_c_attr_align_try))) = 0; return c;],
Packit 64f477
		[ac_cv_c_attribute_aligned=$ac_cv_c_attr_align_try])
Packit 64f477
	done])
Packit 64f477
    if test x"$ac_cv_c_attribute_aligned" != x"0"; then
Packit 64f477
	AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
Packit 64f477
	    [$ac_cv_c_attribute_aligned],[maximum supported data alignment])
Packit 64f477
    fi])
Packit 64f477
Packit 64f477
dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS])
Packit 64f477
dnl check if $CC supports a given set of cflags
Packit 64f477
AC_DEFUN([AC_TRY_CFLAGS],
Packit 64f477
    [AC_MSG_CHECKING([if $CC supports $1 flags])
Packit 64f477
    SAVE_CFLAGS="$CFLAGS"
Packit 64f477
    CFLAGS="$1"
Packit 64f477
    AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no])
Packit 64f477
    CFLAGS="$SAVE_CFLAGS"
Packit 64f477
    AC_MSG_RESULT([$ac_cv_try_cflags_ok])
Packit 64f477
    if test x"$ac_cv_try_cflags_ok" = x"yes"; then
Packit 64f477
	ifelse([$2],[],[:],[$2])
Packit 64f477
    else
Packit 64f477
	ifelse([$3],[],[:],[$3])
Packit 64f477
    fi])
Packit 64f477
Packit 64f477
Packit 64f477
dnl AC_CHECK_GENERATE_INTTYPES_H (INCLUDE-DIRECTORY)
Packit 64f477
dnl generate a default inttypes.h if the header file does not exist already
Packit 64f477
AC_DEFUN([AC_CHECK_GENERATE_INTTYPES],
Packit 64f477
    [rm -f $1/inttypes.h
Packit 64f477
    AC_CHECK_HEADER([inttypes.h],[],
Packit 64f477
	[AC_CHECK_SIZEOF([char])
Packit 64f477
	AC_CHECK_SIZEOF([short])
Packit 64f477
	AC_CHECK_SIZEOF([int])
Packit 64f477
	if test x"$ac_cv_sizeof_char" != x"1" -o \
Packit 64f477
	    x"$ac_cv_sizeof_short" != x"2" -o \
Packit 64f477
	    x"$ac_cv_sizeof_int" != x"4"; then
Packit 64f477
	    AC_MSG_ERROR([can not build a default inttypes.h])
Packit 64f477
	fi
Packit 64f477
	cat >$1/inttypes.h << EOF
Packit 64f477
/* default inttypes.h for people who do not have it on their system */
Packit 64f477
Packit 64f477
#ifndef _INTTYPES_H
Packit 64f477
#define _INTTYPES_H
Packit 64f477
#if (!defined __int8_t_defined) && (!defined __BIT_TYPES_DEFINED__)
Packit 64f477
#define __int8_t_defined
Packit 64f477
typedef signed char int8_t;
Packit 64f477
typedef signed short int16_t;
Packit 64f477
typedef signed int int32_t;
Packit 64f477
#ifdef ARCH_X86
Packit 64f477
typedef signed long long int64_t;
Packit 64f477
#endif
Packit 64f477
#endif
Packit 64f477
#if (!defined _LINUX_TYPES_H)
Packit 64f477
typedef unsigned char uint8_t;
Packit 64f477
typedef unsigned short uint16_t;
Packit 64f477
typedef unsigned int uint32_t;
Packit 64f477
#ifdef ARCH_X86
Packit 64f477
typedef unsigned long long uint64_t;
Packit 64f477
#endif
Packit 64f477
#endif
Packit 64f477
#endif
Packit 64f477
EOF
Packit 64f477
	])])