File: pa_func_attribute.m4

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (93 lines) | stat: -rw-r--r-- 3,472 bytes parent folder | download | duplicates (6)
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
dnl --------------------------------------------------------------------------
dnl PA_FUNC_ATTRIBUTE(attribute_name)
dnl
dnl See if this compiler supports the equivalent of a specific gcc
dnl attribute on a function, using the __attribute__(()) syntax.
dnl All arguments except the attribute name are optional.
dnl
dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
dnl                   prototype_args, call_args, altname)
dnl
dnl This tests the attribute both on a function pointer and on a
dnl direct function, as some gcc [and others?] versions have problems
dnl with attributes on function pointers, and we might as well check both.
dnl --------------------------------------------------------------------------
AC_DEFUN([_PA_FUNC_ATTRIBUTE],
[m4_define([_pa_faa],ifelse([$2],[],[],[($2)]))
 m4_define([_pa_fam],ifelse([$2],[],[],[(m4_join([,],m4_for(_pa_n,1,m4_count($2),1,[m4_quote([x]_pa_n),])))]))
 m4_define([_pa_suf],ifelse([$2],[],[],[m4_count($2)]))
 m4_define([_pa_mac],ifelse([$6],[],[$1_func]_pa_suf,[$6]))
 AC_MSG_CHECKING([if $CC supports the $1]_pa_faa[ function attribute])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
AC_INCLUDES_DEFAULT
PA_ATTRIBUTE_SYNTAX

extern ifelse([$3],[],[void *],[$3]) ATTRIBUTE([$1]_pa_faa)
  bar(ifelse([$4],[],[int],[$4]));
ifelse([$3],[],[void *],[$3]) foo(void);
ifelse([$3],[],[void *],[$3]) foo(void)
{
	ifelse([$3],[void],[],[return])
		bar(ifelse([$5],[],[1],[$5]));
}
 ])],
 [AC_MSG_RESULT([yes])
  AC_DEFINE(PA_SYM([HAVE_FUNC_ATTRIBUTE],_pa_suf,[_$1]), 1,
    [Define to 1 if your compiler supports the $1 function attribute])],
 [AC_MSG_RESULT([no])])
 AH_BOTTOM(m4_quote(m4_join([],
 [#ifndef ],_pa_mac,[
# ifdef ],PA_SYM([HAVE_FUNC_ATTRIBUTE],_pa_suf,[_$1]),[
#  define ],_pa_mac,m4_quote(_pa_fam),[ ATTRIBUTE($1],m4_quote(_pa_fam),[)
# else
#  define ],_pa_mac,m4_quote(_pa_fam),[
# endif
#endif])))
])

AC_DEFUN([_PA_FUNC_PTR_ATTRIBUTE],
[m4_define([_pa_faa],ifelse([$2],[],[],[($2)]))
 m4_define([_pa_fam],ifelse([$2],[],[],[(m4_join([,],m4_for(_pa_n,1,m4_count($2),1,[m4_quote([x]_pa_n),])))]))
 m4_define([_pa_suf],ifelse([$2],[],[],[m4_count($2)]))
 m4_define([_pa_mac],ifelse([$6],[],[$1_func]_pa_suf,[$6])_ptr)
 AC_MSG_CHECKING([if $CC supports the $1]_pa_faa[ function attribute on pointers])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
AC_INCLUDES_DEFAULT
PA_ATTRIBUTE_SYNTAX

extern ifelse([$3],[],[void *],[$3]) ATTRIBUTE([$1]_pa_faa)
  (*bar1)(ifelse([$4],[],[int],[$4]));
ifelse([$3],[],[void *],[$3]) foo1(void);
ifelse([$3],[],[void *],[$3]) foo1(void)
{
	ifelse([$3],[void],[],[return])
		bar1(ifelse([$5],[],[1],[$5]));
}

typedef ifelse([$3],[],[void *],[$3]) ATTRIBUTE([$1]_pa_faa)
  (*bar_t)(ifelse([$4],[],[int],[$4]));
extern bar_t bar2;
ifelse([$3],[],[void *],[$3]) foo2(void);
ifelse([$3],[],[void *],[$3]) foo2(void)
{
	ifelse([$3],[void],[],[return])
		bar2(ifelse([$5],[],[1],[$5]));
}
 ])],
 [AC_MSG_RESULT([yes])
  AC_DEFINE(PA_SYM([HAVE_FUNC_PTR_ATTRIBUTE],_pa_suf,[_$1]), 1,
    [Define to 1 if your compiler supports the $1 attribute on function pointers])],
 [AC_MSG_RESULT([no])])
 AH_BOTTOM(m4_quote(m4_join([],
 [#ifndef ],_pa_mac,[
# ifdef ],PA_SYM([HAVE_FUNC_PTR_ATTRIBUTE],_pa_suf,[_$1]),[
#  define ],_pa_mac,m4_quote(_pa_fam),[ ATTRIBUTE($1],m4_quote(_pa_fam),[)
# else
#  define ],_pa_mac,m4_quote(_pa_fam),[
# endif
#endif])))
])

AC_DEFUN([PA_FUNC_ATTRIBUTE],
[_PA_FUNC_ATTRIBUTE([$1],[$2],[$3],[$4],[$5],[$6])
 _PA_FUNC_PTR_ATTRIBUTE([$1],[$2],[$3],[$4],[$5],[$6])])