source: m4/attributes.m4 @ 4007dbb

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 4007dbb was 4007dbb, checked in by Richard Sanger <rsangerarj@…>, 5 years ago

Updates the new interface to be more complete

This should work around any issues with systems without thread support.
This still remains compatible with existing code.
Examples/tools/tests still need to be updated to make use of the new interface.
And tests also need to be updated.
Adds debug memory stats as an option to configure.

  • Property mode set to 100644
File size: 5.4 KB
Line 
1dnl Macros for checking if various gcc compiler attributes are present
2dnl
3dnl Written by Shane Alcock <salcock@waikato.ac.nz>, but some credit
4dnl should be given to Diego Pettenò <flameeyes@gmail.com> whose
5dnl macros were very useful in helping me figure out how to write my
6dnl own.
7dnl
8dnl
9
10AC_DEFUN([check_WERROR],
11[
12  AC_REQUIRE([AC_PROG_CC])
13  AC_CACHE_CHECK(
14    [if -Werror flag is supported by compiler],
15    [lt_cv_werror_flag],
16    [saved="$CFLAGS"
17     CFLAGS="$CFLAGS -Werror"
18     AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],
19       [eval lt_cv_werror_flag='yes'],
20       [eval lt_cv_werror_flag='no'])
21     CFLAGS="$saved"
22
23    ])
24]) 
25
26AC_DEFUN([gcc_PACKED],
27[
28  AC_REQUIRE([check_WERROR])
29  HAVE_ATTRIBUTE_PACKED=0
30  if test -n "$CC"; then
31    AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
32    AC_CACHE_CHECK([if compiler supports __attribute__((packed))],
33      [lt_cv_attribute_packed],
34      [saved="$CFLAGS"
35       CFLAGS="$CFLAGS $errflag"
36       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
37         [struct s { char a; char b; int val; long val2; void *ptr;} __attribute__((packed));])],
38         [lt_cv_attribute_packed=yes],
39         [lt_cv_attribute_packed=no]
40       )
41       CFLAGS="$saved"
42      ])
43    if test x$lt_cv_attribute_packed = xyes; then
44      HAVE_ATTRIBUTE_PACKED=1
45    fi
46  fi
47  AC_SUBST([HAVE_ATTRIBUTE_PACKED])
48  AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_PACKED], [$HAVE_ATTRIBUTE_PACKED],
49    [Define to 1 or 0, depending on whether the compiler supports the gcc packed attribute.])
50])
51
52AC_DEFUN([gcc_UNUSED],
53[
54  AC_REQUIRE([check_WERROR])
55  HAVE_ATTRIBUTE_UNUSED=0
56  if test -n "$CC"; then
57    AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
58    AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
59      [lt_cv_attribute_unused],
60      [saved="$CFLAGS"
61       CFLAGS="$CFLAGS $errflag"
62       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
63         [void func(int a, __attribute__((unused)) int b);])],
64         [lt_cv_attribute_unused=yes],
65         [lt_cv_attribute_unused=no]
66       )
67       CFLAGS="$saved"
68      ])
69    if test x$lt_cv_attribute_unused = xyes; then
70      HAVE_ATTRIBUTE_UNUSED=1
71    fi
72  fi
73  AC_SUBST([HAVE_ATTRIBUTE_UNUSED])
74  AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_UNUSED], [$HAVE_ATTRIBUTE_UNUSED],
75    [Define to 1 or 0, depending on whether the compiler supports the gcc unused attribute.])
76])
77
78AC_DEFUN([gcc_DEPRECATED],
79[
80  AC_REQUIRE([check_WERROR])
81  HAVE_ATTRIBUTE_DEPRECATED=0
82  if test -n "$CC"; then
83    AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
84    AC_CACHE_CHECK([if compiler supports __attribute__((deprecated))],
85      [lt_cv_attribute_deprecated],
86      [saved="$CFLAGS"
87       CFLAGS="$CFLAGS $errflag"
88       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
89         [void func(int a, int b) __attribute__((deprecated));])],
90         [lt_cv_attribute_deprecated=yes],
91         [lt_cv_attribute_deprecated=no]
92       )
93       CFLAGS="$saved"
94      ])
95    if test x$lt_cv_attribute_deprecated = xyes; then
96      HAVE_ATTRIBUTE_DEPRECATED=1
97    fi
98  fi
99  AC_SUBST([HAVE_ATTRIBUTE_DEPRECATED])
100  AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_DEPRECATED], [$HAVE_ATTRIBUTE_DEPRECATED],
101    [Define to 1 or 0, depending on whether the compiler supports the gcc deprecated attribute.])
102])
103
104AC_DEFUN([gcc_FORMAT],
105[
106  AC_REQUIRE([check_WERROR])
107  HAVE_ATTRIBUTE_FORMAT=0
108  if test -n "$CC"; then
109    AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
110    AC_CACHE_CHECK([if compiler supports __attribute__((format(printf)))],
111      [lt_cv_attribute_format],
112      [saved="$CFLAGS"
113       CFLAGS="$CFLAGS $errflag"
114       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
115         [void __attribute__((format(printf, 1, 2))) foo(const char *fmt, ...);])],
116         [lt_cv_attribute_format=yes],
117         [lt_cv_attribute_format=no]
118       )
119       CFLAGS="$saved"
120      ])
121    if test x$lt_cv_attribute_format = xyes; then
122      HAVE_ATTRIBUTE_FORMAT=1
123    fi
124  fi
125  AC_SUBST([HAVE_ATTRIBUTE_FORMAT])
126  AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_FORMAT], [$HAVE_ATTRIBUTE_FORMAT],
127    [Define to 1 or 0, depending on whether the compiler supports the format(printf) attribute.])
128])
129
130AC_DEFUN([gcc_PURE],
131[
132  AC_REQUIRE([check_WERROR])
133  HAVE_ATTRIBUTE_PURE=0
134  if test -n "$CC"; then
135    AS_IF([eval test x$lt_cv_werror_flag = xyes], [errflag=-Werror], [])
136    AC_CACHE_CHECK([if compiler supports __attribute__((pure))],
137      [lt_cv_attribute_pure],
138      [saved="$CFLAGS"
139       CFLAGS="$CFLAGS $errflag"
140       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
141         [void func(int a, int b) __attribute__((pure));])],
142         [lt_cv_attribute_pure=yes],
143         [lt_cv_attribute_pure=no]
144       )
145       CFLAGS="$saved"
146      ])
147    if test x$lt_cv_attribute_pure = xyes; then
148      HAVE_ATTRIBUTE_PURE=1
149    fi
150  fi
151  AC_SUBST([HAVE_ATTRIBUTE_PURE])
152  AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_PURE], [$HAVE_ATTRIBUTE_PURE],
153    [Define to 1 or 0, depending on whether the compiler supports the pure attribute.])
154])
155
156AC_DEFUN([gcc_TLS],
157[
158  HAVE_TLS=0
159  if test -n "$CC"; then
160    AC_CACHE_CHECK([if compiler supports TLS __thread],
161      [lt_cv_attribute_tls],
162      [
163       AC_COMPILE_IFELSE([AC_LANG_SOURCE(
164         [static __thread int apples;])],
165         [lt_cv_attribute_tls=yes],
166         [lt_cv_attribute_tls=no]
167       )
168      ])
169    if test x$lt_cv_attribute_tls = xyes; then
170      HAVE_TLS=1
171    fi
172  fi
173  AC_SUBST([HAVE_TLS])
174  AC_DEFINE_UNQUOTED([HAVE_TLS], [$HAVE_TLS],
175    [Define to 1 or 0, depending on whether the compiler supports tls via __thread.])
176])
177
Note: See TracBrowser for help on using the repository browser.