summaryrefslogtreecommitdiff
path: root/m4/ax_forceinline.m4
blob: 1a36947f42d3f903ebd1238ba8bab9452ab24a6b (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
# ===========================================================================
#      https://www.gnu.org/software/autoconf-archive/ax_forceinline.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_FORCEINLINE()
#
# DESCRIPTION
#
#   Provides a test for C compiler support of forced inlining.  If usable,
#   #define FORCEINLINE to the appropriate force inline keyword.  Otherwise
#   #define FORCEINLINE to be 'inline'.
#
# LICENSE
#
#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
#   Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 3

AC_DEFUN([AX_FORCEINLINE], [
  AC_LANG_PUSH([C])
  AC_MSG_CHECKING(for forced inline keyword)
  AC_CACHE_VAL(ac_cv_forceinline, [
    ax_forceinline_keywords="__forceinline inline none"
    for ax_forceinline_keyword in $ax_forceinline_keywords; do
       case $ax_forceinline_keyword in
          none) ac_cv_forceinline=none ; break ;;
      *)
             AC_TRY_COMPILE(
                [#include <stdlib.h>
                 ] $ax_forceinline_keyword [
                 static void
                 foo(void) {
                 exit(1);
                 }],
                 [],
                 [ac_cv_forceinline=$ax_forceinline_keyword ; break],
                 ac_cv_forceinline=none
             )
      esac
    done
])

  if test "$ac_cv_forceinline" = "none"; then
    ax_forceinline_keyword=
  else
    ax_forceinline_keyword=$ac_cv_forceinline
  fi
  AC_DEFINE_UNQUOTED([FORCEINLINE],$ax_forceinline_keyword,
    [The most forceful inline keyword known by the compiler])
  AC_MSG_RESULT($ac_cv_forceinline)
  AC_LANG_POP([C])
])