Fix memory leak in RiscV assembler.
[binutils-gdb.git] / gas / acinclude.m4
blobbf6dba6825f57dee8343520b97611b30c5e42f75
1 dnl GAS_CHECK_DECL_NEEDED(name, typedefname, typedef, headers)
2 AC_DEFUN([GAS_CHECK_DECL_NEEDED],[
3 AC_MSG_CHECKING(whether declaration is required for $1)
4 AC_CACHE_VAL(gas_cv_decl_needed_$1,
5 AC_TRY_LINK([$4],
7 typedef $3;
8 $2 x;
9 x = ($2) $1;
10 ], gas_cv_decl_needed_$1=no, gas_cv_decl_needed_$1=yes))dnl
11 AC_MSG_RESULT($gas_cv_decl_needed_$1)
12 if test $gas_cv_decl_needed_$1 = yes; then
13  AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
14            [Define if $1 is not declared in system header files.])
16 ])dnl
17 dnl
18 dnl Some non-ANSI preprocessors botch requoting inside strings.  That's bad
19 dnl enough, but on some of those systems, the assert macro relies on requoting
20 dnl working properly!
21 dnl GAS_WORKING_ASSERT
22 AC_DEFUN([GAS_WORKING_ASSERT],
23 [AC_MSG_CHECKING([for working assert macro])
24 AC_CACHE_VAL(gas_cv_assert_ok,
25 AC_TRY_LINK([#include <assert.h>
26 #include <string.h>
27 #include <stdio.h>], [
28 /* check for requoting problems */
29 static int a, b, c, d;
30 static char *s;
31 assert (!strcmp(s, "foo bar baz quux"));
32 /* check for newline handling */
33 assert (a == b
34         || c == d);
35 ], gas_cv_assert_ok=yes, gas_cv_assert_ok=no))dnl
36 AC_MSG_RESULT($gas_cv_assert_ok)
37 test $gas_cv_assert_ok = yes || AC_DEFINE(BROKEN_ASSERT, 1, [assert broken?])
38 ])dnl
39 dnl
40 dnl Since many Bourne shell implementations lack subroutines, use this
41 dnl hack to simplify the code in configure.ac.
42 dnl GAS_UNIQ(listvar)
43 AC_DEFUN([GAS_UNIQ],
44 [_gas_uniq_list="[$]$1"
45 _gas_uniq_newlist=""
46 dnl Protect against empty input list.
47 for _gas_uniq_i in _gas_uniq_dummy [$]_gas_uniq_list ; do
48   case [$]_gas_uniq_i in
49   _gas_uniq_dummy) ;;
50   *) case " [$]_gas_uniq_newlist " in
51        *" [$]_gas_uniq_i "*) ;;
52        *) _gas_uniq_newlist="[$]_gas_uniq_newlist [$]_gas_uniq_i" ;;
53      esac ;;
54   esac
55 done
56 $1=[$]_gas_uniq_newlist
57 ])dnl
58 dnl
59 dnl Check for existence of member $2 in type $1 in time.h
60 dnl
61 AC_DEFUN([GAS_HAVE_TIME_TYPE_MEMBER],
62 [AC_MSG_CHECKING([for $1.$2 in time.h])
63  AC_CACHE_VAL(gas_cv_have_time_type_member_$2,
64    [AC_TRY_COMPILE([
65 #define _BSD_SOURCE 1
66 #include <time.h>],
67       [$1 avar; void* aref = (void*) &avar.$2],
68       gas_cv_have_time_type_member_$2=yes,
69       gas_cv_have_time_type_member_$2=no
70    )])
71  if test $gas_cv_have_time_type_member_$2 = yes; then
72    AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z]), 1,
73              [Define if <time.h> has $1.$2.])
74  fi
75  AC_MSG_RESULT($gas_cv_have_time_type_member_$2)
76 ])dnl
77 dnl
78 dnl Check for existence of member $2.$3 in type $1 in sys/stat.h
79 dnl
80 AC_DEFUN([GAS_HAVE_SYS_STAT_TYPE_MEMBER],
81 [AC_MSG_CHECKING([for $1.$2.$3 in sys/stat.h])
82  AC_CACHE_VAL(gas_cv_have_sys_stat_type_member_$2_$3,
83    [AC_TRY_COMPILE([
84 #define _BSD_SOURCE 1
85 #include <sys/stat.h>],
86       [$1 avar; void* aref = (void*) &avar.$2.$3],
87       gas_cv_have_sys_stat_type_member_$2_$3=yes,
88       gas_cv_have_sys_stat_type_member_$2_$3=no
89    )])
90  if test $gas_cv_have_sys_stat_type_member_$2_$3 = yes; then
91    AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_]translit($3, [a-z], [A-Z]), 1,
92              [Define if <sys/stat.h> has $1.$2.$3])
93  fi
94  AC_MSG_RESULT($gas_cv_have_sys_stat_type_member_$2_$3)
95 ])dnl