summaryrefslogtreecommitdiff
path: root/m4/ax_asm_inline.m4
blob: 7c4d2d66ba12abe6f828a587bba442137c374096 (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
# ===========================================================================
#      https://www.gnu.org/software/autoconf-archive/ax_asm_inline.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_ASM_INLINE()
#
# DESCRIPTION
#
#   Tests for C compiler support of inline assembly instructions. If inline
#   assembly is supported, this macro #defines ASM_INLINE to be the
#   appropriate keyword.
#
# LICENSE
#
#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
#   Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
#   Copyright (c) 2017 Reini Urban <rurban@cpan.org>
#
#   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 5

AC_DEFUN([AX_ASM_INLINE], [
  AC_LANG_PUSH([C])
  AC_MSG_CHECKING(for inline assembly style)
  AC_CACHE_VAL(ac_cv_asm_inline, [
    ax_asm_inline_keywords="__asm__ __asm asm none"
    for ax_asm_inline_keyword in $ax_asm_inline_keywords; do
       case $ax_asm_inline_keyword in
          none) ac_cv_asm_inline=none ; break ;;
      *)
             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
                [#include <stdlib.h>
                 static void
                 foo(void) {
                 ] $ax_asm_inline_keyword [("");
                 exit(1);
                 }],
                 [])],
                 [ac_cv_asm_inline=$ax_asm_inline_keyword ; break],
                 ac_cv_asm_inline=none
             )
      esac
    done
])

  if test "$ac_cv_asm_inline" != "none"; then
    AC_DEFINE_UNQUOTED([ASM_INLINE], $ac_cv_asm_inline, [If the compiler supports inline assembly define it to that keyword here])
  fi
  AC_MSG_RESULT($ac_cv_asm_inline)
  AC_LANG_POP([C])
])