Blame src/openpa/confdb/ax_gcc_var_attribute.m4

Packit Service c5cf8c
# ===========================================================================
Packit Service c5cf8c
#   https://www.gnu.org/software/autoconf-archive/ax_gcc_var_attribute.html
Packit Service c5cf8c
# ===========================================================================
Packit Service c5cf8c
#
Packit Service c5cf8c
# SYNOPSIS
Packit Service c5cf8c
#
Packit Service c5cf8c
#   AX_GCC_VAR_ATTRIBUTE(ATTRIBUTE)
Packit Service c5cf8c
#
Packit Service c5cf8c
# DESCRIPTION
Packit Service c5cf8c
#
Packit Service c5cf8c
#   This macro checks if the compiler supports one of GCC's variable
Packit Service c5cf8c
#   attributes; many other compilers also provide variable attributes with
Packit Service c5cf8c
#   the same syntax. Compiler warnings are used to detect supported
Packit Service c5cf8c
#   attributes as unsupported ones are ignored by default so quieting
Packit Service c5cf8c
#   warnings when using this macro will yield false positives.
Packit Service c5cf8c
#
Packit Service c5cf8c
#   The ATTRIBUTE parameter holds the name of the attribute to be checked.
Packit Service c5cf8c
#
Packit Service c5cf8c
#   If ATTRIBUTE is supported define HAVE_VAR_ATTRIBUTE_<ATTRIBUTE>.
Packit Service c5cf8c
#
Packit Service c5cf8c
#   The macro caches its result in the ax_cv_have_var_attribute_<attribute>
Packit Service c5cf8c
#   variable.
Packit Service c5cf8c
#
Packit Service c5cf8c
#   The macro currently supports the following variable attributes:
Packit Service c5cf8c
#
Packit Service c5cf8c
#    aligned
Packit Service c5cf8c
#    cleanup
Packit Service c5cf8c
#    common
Packit Service c5cf8c
#    nocommon
Packit Service c5cf8c
#    deprecated
Packit Service c5cf8c
#    mode
Packit Service c5cf8c
#    packed
Packit Service c5cf8c
#    tls_model
Packit Service c5cf8c
#    unused
Packit Service c5cf8c
#    used
Packit Service c5cf8c
#    vector_size
Packit Service c5cf8c
#    weak
Packit Service c5cf8c
#    dllimport
Packit Service c5cf8c
#    dllexport
Packit Service c5cf8c
#    init_priority
Packit Service c5cf8c
#
Packit Service c5cf8c
#   Unsupported variable attributes will be tested against a global integer
Packit Service c5cf8c
#   variable and without any arguments given to the attribute itself; the
Packit Service c5cf8c
#   result of this check might be wrong or meaningless so use with care.
Packit Service c5cf8c
#
Packit Service c5cf8c
# LICENSE
Packit Service c5cf8c
#
Packit Service c5cf8c
#   Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
Packit Service c5cf8c
#
Packit Service c5cf8c
#   Copying and distribution of this file, with or without modification, are
Packit Service c5cf8c
#   permitted in any medium without royalty provided the copyright notice
Packit Service c5cf8c
#   and this notice are preserved.  This file is offered as-is, without any
Packit Service c5cf8c
#   warranty.
Packit Service c5cf8c
Packit Service c5cf8c
#serial 5
Packit Service c5cf8c
Packit Service c5cf8c
AC_DEFUN([AX_GCC_VAR_ATTRIBUTE], [
Packit Service c5cf8c
    AS_VAR_PUSHDEF([ac_var], [ax_cv_have_var_attribute_$1])
Packit Service c5cf8c
Packit Service c5cf8c
    AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
Packit Service c5cf8c
        AC_LINK_IFELSE([AC_LANG_PROGRAM([
Packit Service c5cf8c
            m4_case([$1],
Packit Service c5cf8c
                [aligned], [
Packit Service c5cf8c
                    int foo __attribute__(($1(32)));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [cleanup], [
Packit Service c5cf8c
                    int bar(int *t) { return *t; };
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [common], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [nocommon], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [deprecated], [
Packit Service c5cf8c
                    int foo __attribute__(($1)) = 0;
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [mode], [
Packit Service c5cf8c
                    long foo __attribute__(($1(word)));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [packed], [
Packit Service c5cf8c
                    struct bar {
Packit Service c5cf8c
                        int baz __attribute__(($1));
Packit Service c5cf8c
                    };
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [tls_model], [
Packit Service c5cf8c
                    __thread int bar1 __attribute__(($1("global-dynamic")));
Packit Service c5cf8c
                    __thread int bar2 __attribute__(($1("local-dynamic")));
Packit Service c5cf8c
                    __thread int bar3 __attribute__(($1("initial-exec")));
Packit Service c5cf8c
                    __thread int bar4 __attribute__(($1("local-exec")));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [unused], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [used], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [vector_size], [
Packit Service c5cf8c
                    int foo __attribute__(($1(16)));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [weak], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [dllimport], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [dllexport], [
Packit Service c5cf8c
                    int foo __attribute__(($1));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [init_priority], [
Packit Service c5cf8c
                    struct bar { bar() {} ~bar() {} };
Packit Service c5cf8c
                    bar b __attribute__(($1(65535/2)));
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                [
Packit Service c5cf8c
                 m4_warn([syntax], [Unsupported attribute $1, the test may fail])
Packit Service c5cf8c
                 int foo __attribute__(($1));
Packit Service c5cf8c
                ]
Packit Service c5cf8c
            )], [
Packit Service c5cf8c
            m4_case([$1],
Packit Service c5cf8c
                [cleanup], [
Packit Service c5cf8c
                    int foo __attribute__(($1(bar))) = 0;
Packit Service c5cf8c
                    foo = foo + 1;
Packit Service c5cf8c
                ],
Packit Service c5cf8c
                []
Packit Service c5cf8c
            )])
Packit Service c5cf8c
            ],
Packit Service c5cf8c
            dnl GCC doesn't exit with an error if an unknown attribute is
Packit Service c5cf8c
            dnl provided but only outputs a warning, so accept the attribute
Packit Service c5cf8c
            dnl only if no warning were issued.
Packit Service c5cf8c
            [AS_IF([test -s conftest.err],
Packit Service c5cf8c
                [AS_VAR_SET([ac_var], [no])],
Packit Service c5cf8c
                [AS_VAR_SET([ac_var], [yes])])],
Packit Service c5cf8c
            [AS_VAR_SET([ac_var], [no])])
Packit Service c5cf8c
    ])
Packit Service c5cf8c
Packit Service c5cf8c
    AS_IF([test yes = AS_VAR_GET([ac_var])],
Packit Service c5cf8c
        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_VAR_ATTRIBUTE_$1), 1,
Packit Service c5cf8c
            [Define to 1 if the system has the `$1' variable attribute])], [])
Packit Service c5cf8c
Packit Service c5cf8c
    AS_VAR_POPDEF([ac_var])
Packit Service c5cf8c
])