Estonian translation of Window Maker 0.95.4
[wmaker-crm.git] / m4 / wm_attributes.m4
blob545fe820134b0f7b8107363f44fec1ac0a90d8ec
1 # wm_attributes.m4 - Macros to check compiler attributes and define macros
3 # Copyright (c) 2013 Christophe Curis
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # WM_C_NORETURN
20 # -------------
22 # Checks if the compiler supports ISO C11 noreturn attribute, if not
23 # try to define the keyword to a known syntax that does the job, or
24 # if nothing works sets it to empty to, at least, be able to
25 # compile the sources
26 AC_DEFUN_ONCE([WM_C_NORETURN],
27 [AC_REQUIRE([_WM_SHELLFN_FUNCATTR])
28 AC_CACHE_CHECK([for noreturn], [wm_cv_c_noreturn],
29     [wm_cv_c_noreturn=no
30      AC_COMPILE_IFELSE(
31       [AC_LANG_PROGRAM(
32           [#include <unistd.h>
33 #include <stdnoreturn.h>
35 /* Attribute in the prototype of the function */
36 noreturn int test_function(void);
38 /* Attribute on the function itself */
39 noreturn int test_function(void) {
40   _exit(1);
42 ], [  test_function();])],
43           [wm_cv_c_noreturn=stdnoreturn],
44           [for wm_attr in  dnl
45              "__attribute__((noreturn))"   dnl for modern GCC-like compilers
46              "__attribute__((__noreturn__))"   dnl for older GCC-like compilers
47              "__declspec(noreturn)"   dnl for some other compilers
48            ; do
49              AS_IF([wm_fn_c_try_compile_funcattr "$wm_attr"],
50                  [wm_cv_c_noreturn="$wm_attr" ; break])
51            done]) dnl
52     ])
53 AS_CASE([$wm_cv_c_noreturn],
54     [stdnoreturn],
55         [AC_DEFINE([HAVE_STDNORETURN], 1,
56             [Defined if header "stdnoreturn.h" exists, it defines ISO C11 attribute 'noreturn' and it works])],
57     [no],
58         [AC_DEFINE([noreturn], [],
59             [Defines the attribute to tell the compiler that a function never returns, if the ISO C11 attribute does not work])],
60     [AC_DEFINE_UNQUOTED([noreturn], [${wm_cv_c_noreturn}],
61         [Defines the attribute to tell the compiler that a function never returns, if the ISO C11 attribute does not work])])
64 # _WM_SHELLFN_FUNCATTRIBUTE
65 # ----------------------
66 # (internal shell function only!)
68 # Create a shell function to check if we can compile with special
69 # function attributes
70 AC_DEFUN([_WM_SHELLFN_FUNCATTR],
71 [@%:@ wm_fn_c_try_compile_funcattr ATTRIBUTE
72 @%:@ ---------------------------------------
73 @%:@ Try compiling a function with the attribute ATTRIBUTE
74 wm_fn_c_try_compile_funcattr ()
76   AC_COMPILE_IFELSE(
77       [AC_LANG_PROGRAM(
78           [
79 /* Attribute in the prototype of the function */
80 int test_function(int arg) $[]1;
82 /* Attribute on the function itself */
83 $[]1 int test_function(int arg) {
84   return arg - 1;
85 }], [int val;
86 val = test_function(1);
87 return val;])],
88       [wm_retval=0],
89       [wm_retval=1])
90   AS_SET_STATUS([$wm_retval])