1
# Functions to check for attributes support in compiler
3
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
4
AC_CACHE_CHECK([if compiler supports __attribute__((constructor))],
5
[cc_cv_attribute_constructor],
7
void ctor() __attribute__((constructor));
10
[cc_cv_attribute_constructor=yes],
11
[cc_cv_attribute_constructor=no])
14
if test "x$cc_cv_attribute_constructor" = "xyes"; then
15
AC_DEFINE([SUPPORT_ATTRIBUTE_CONSTRUCTOR], 1, [Define this if the compiler supports the constructor attribute])
23
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
24
AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))],
25
[cc_cv_attribute_format],
27
void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { }
29
[cc_cv_attribute_format=yes],
30
[cc_cv_attribute_format=no])
33
if test "x$cc_cv_attribute_format" = "xyes"; then
34
AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT], 1, [Define this if the compiler supports the format attribute])
42
AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [
43
AC_CACHE_CHECK([if compiler supports __attribute__((visibility("internal")))],
44
[cc_cv_attribute_internal],
46
void __attribute__((visibility("internal"))) internal_function() { }
48
[cc_cv_attribute_internal=yes],
49
[cc_cv_attribute_internal=no])
52
if test "x$cc_cv_attribute_internal" = "xyes"; then
53
AC_DEFINE([SUPPORT_ATTRIBUTE_INTERNAL], 1, [Define this if the compiler supports the internal visibility attribute])
61
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
64
tmp_CXXFLAGS=$CXXFLAGS
65
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
67
AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))],
68
[cc_cv_attribute_visibility],
70
void __attribute__((visibility("default"))) visibility_function() { }
72
[cc_cv_attribute_visibility=yes],
73
[cc_cv_attribute_visibility=no])
76
CXXFLAGS=$tmp_CXXFLAGS
79
if test "x$cc_cv_attribute_visibility" = "xyes"; then
80
AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.])
81
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
90
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
91
AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))],
92
[cc_cv_attribute_nonnull],
94
void some_function(void *foo, void *bar) __attribute__((nonnull()));
95
void some_function(void *foo, void *bar) { }
97
[cc_cv_attribute_nonnull=yes],
98
[cc_cv_attribute_nonnull=no])
101
if test "x$cc_cv_attribute_nonnull" = "xyes"; then
102
AC_DEFINE([SUPPORT_ATTRIBUTE_NONNULL], 1, [Define this if the compiler supports the nonnull attribute])
110
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
111
AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
112
[cc_cv_attribute_unused],
114
void some_function(void *foo, __attribute__((unused)) void *bar);
116
[cc_cv_attribute_unused=yes],
117
[cc_cv_attribute_unused=no])
120
if test "x$cc_cv_attribute_unused" = "xyes"; then
121
AC_DEFINE([SUPPORT_ATTRIBUTE_UNUSED], 1, [Define this if the compiler supports the unused attribute])
129
AC_DEFUN([CC_FUNC_EXPECT], [
130
AC_CACHE_CHECK([if compiler has __builtin_expect function],
136
return (int)__builtin_expect(a, 3);
139
[cc_cv_func_expect=yes],
140
[cc_cv_func_expect=no])
143
if test "x$cc_cv_func_expect" = "xyes"; then
144
AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function])