aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/m4/efl_attribute.m4
blob: aeb6a6821e87c4a946379e6613c6e477188821d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
dnl Copyright (C) 2011 Vincent Torri <vtorri at univ-evry dot fr>
dnl That code is public domain and can be freely used or copied.

dnl Macros for checking if the compiler supports some __attribute__ uses

dnl Usage: EFL_ATTRIBUTE_UNUSED
dnl call AC_DEFINE for __UNUSED__ if __attribute__((unused)) is available

AC_DEFUN([EFL_ATTRIBUTE_UNUSED],
[
AC_MSG_CHECKING([for __attribute__ ((unused))])
AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM(
       [[
void foo(int x __attribute__ ((unused))) {}
       ]],
       [[
       ]])],
   [have_attribute_unused="yes"],
   [have_attribute_unused="no"])
AC_MSG_RESULT([${have_attribute_unused}])

if test "x${have_attribute_unused}" = "xyes" ; then
   AC_DEFINE([__UNUSED__], [__attribute__ ((unused))], [Macro declaring a function argument to be unused.])
else
   AC_DEFINE([__UNUSED__], [], [__attribute__ ((unused)) is not supported.])
fi
])

dnl Usage: EFL_ATTRIBUTE_VECTOR
dnl call AC_DEFINE for HAVE_GCC_ATTRIBUTE_VECTOR if __attribute__((vector)) is available

AC_DEFUN([EFL_ATTRIBUTE_VECTOR],
[
AC_MSG_CHECKING([for __attribute__ ((vector))])
AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM(
       [[
typedef int v4si __attribute__ ((vector_size (16)));
       ]],
       [[
if (sizeof(v4si) == 16)
  return 0;
else
  return -1;
       ]])],
   [have_attribute_vector="yes"],
   [have_attribute_vector="no"])
AC_MSG_RESULT([${have_attribute_vector}])

if test "x${have_attribute_vector}" = "xyes" ; then
   AC_DEFINE([HAVE_GCC_ATTRIBUTE_VECTOR], [1], [Define to 1 if your compiler supports __attribute__ ((vector)).])
fi
])

dnl Usage: EFL_ATTRIBUTE_ALWAYS_INLINE
dnl call AC_DEFINE for alway_inline if __attribute__((always_inline)) is available

AC_DEFUN([EFL_ATTRIBUTE_ALWAYS_INLINE],
[

have_attribute_forceinline="no"

AC_MSG_CHECKING([for __forceinline])

AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM(
       [[
#include <windows.h>
__forceinline void foo(void) {}
       ]],
       [[
       ]])],
   [
    have_attribute_always_inline="yes"
    have_attribute_forceinline="yes"
   ],
   [have_attribute_always_inline="no"])

AC_MSG_RESULT([${have_attribute_always_inline}])

if test "x${have_attribute_always_inline}" = "xno" ; then
   AC_MSG_CHECKING([for __attribute__ ((__always_inline__))])
   AC_COMPILE_IFELSE(
      [AC_LANG_PROGRAM(
          [[
__attribute__((__always_inline__)) inline void foo(void) {}
          ]],
          [[
          ]])],
      [have_attribute_always_inline="yes"],
      [have_attribute_always_inline="no"])
   AC_MSG_RESULT([${have_attribute_always_inline}])
fi

if test "x${have_attribute_always_inline}" = "xyes" ; then
   if test "x${have_attribute_forceinline}" = "xyes" ; then
      AC_DEFINE([EFL_ALWAYS_INLINE], [__forceinline], [Macro declaring a function to always be inlined.])
   else
      AC_DEFINE([EFL_ALWAYS_INLINE], [__attribute__ ((__always_inline__)) inline], [Macro declaring a function to always be inlined.])
   fi
else
   AC_DEFINE([EFL_ALWAYS_INLINE], [static inline], [Macro declaring a function to always be inlined.])
fi
])

dnl End of efl_attribute.m4