~ubuntu-branches/ubuntu/wily/libtorrent/wily-proposed

« back to all changes in this revision

Viewing changes to scripts/attributes.m4

  • Committer: Bazaar Package Importer
  • Author(s): Rogério Brito
  • Date: 2011-03-20 01:06:18 UTC
  • mfrom: (1.1.13 upstream) (4.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110320010618-g3wyylccqzqko73c
Tags: 0.12.7-5
* Use Steinar's "real" patch for IPv6. Addresses #490277, #618275,
  and Closes: #617791.
* Adapt libtorrent-0.12.6-ipv6-07.patch. It FTBFS otherwise.
* Add proper attibution to the IPv6 patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Functions to check for attributes support in compiler
 
2
 
 
3
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
 
4
        AC_CACHE_CHECK([if compiler supports __attribute__((constructor))],
 
5
                [cc_cv_attribute_constructor],
 
6
                [AC_COMPILE_IFELSE([
 
7
                        void ctor() __attribute__((constructor));
 
8
                        void ctor() { };
 
9
                        ],
 
10
                        [cc_cv_attribute_constructor=yes],
 
11
                        [cc_cv_attribute_constructor=no])
 
12
                ])
 
13
        
 
14
        if test "x$cc_cv_attribute_constructor" = "xyes"; then
 
15
                AC_DEFINE([SUPPORT_ATTRIBUTE_CONSTRUCTOR], 1, [Define this if the compiler supports the constructor attribute])
 
16
                $1
 
17
        else
 
18
                true
 
19
                $2
 
20
        fi
 
21
])
 
22
 
 
23
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
 
24
        AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))],
 
25
                [cc_cv_attribute_format],
 
26
                [AC_COMPILE_IFELSE([
 
27
                        void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { }
 
28
                        ],
 
29
                        [cc_cv_attribute_format=yes],
 
30
                        [cc_cv_attribute_format=no])
 
31
                ])
 
32
        
 
33
        if test "x$cc_cv_attribute_format" = "xyes"; then
 
34
                AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT], 1, [Define this if the compiler supports the format attribute])
 
35
                $1
 
36
        else
 
37
                true
 
38
                $2
 
39
        fi
 
40
])
 
41
 
 
42
AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [
 
43
        AC_CACHE_CHECK([if compiler supports __attribute__((visibility("internal")))],
 
44
                [cc_cv_attribute_internal],
 
45
                [AC_COMPILE_IFELSE([
 
46
                        void __attribute__((visibility("internal"))) internal_function() { }
 
47
                        ],
 
48
                        [cc_cv_attribute_internal=yes],
 
49
                        [cc_cv_attribute_internal=no])
 
50
                ])
 
51
        
 
52
        if test "x$cc_cv_attribute_internal" = "xyes"; then
 
53
                AC_DEFINE([SUPPORT_ATTRIBUTE_INTERNAL], 1, [Define this if the compiler supports the internal visibility attribute])
 
54
                $1
 
55
        else
 
56
                true
 
57
                $2
 
58
        fi
 
59
])
 
60
 
 
61
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
 
62
        AC_LANG_PUSH(C++)
 
63
 
 
64
        tmp_CXXFLAGS=$CXXFLAGS
 
65
        CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
 
66
 
 
67
        AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))],
 
68
                [cc_cv_attribute_visibility],
 
69
                [AC_COMPILE_IFELSE([
 
70
                        void __attribute__((visibility("default"))) visibility_function() { }
 
71
                        ],
 
72
                        [cc_cv_attribute_visibility=yes],
 
73
                        [cc_cv_attribute_visibility=no])
 
74
                ])
 
75
        
 
76
        CXXFLAGS=$tmp_CXXFLAGS
 
77
        AC_LANG_POP(C++)
 
78
 
 
79
        if test "x$cc_cv_attribute_visibility" = "xyes"; then
 
80
                AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.])
 
81
                CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
 
82
                $1
 
83
        else
 
84
                true
 
85
                $2
 
86
        fi
 
87
 
 
88
])
 
89
 
 
90
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
 
91
        AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))],
 
92
                [cc_cv_attribute_nonnull],
 
93
                [AC_COMPILE_IFELSE([
 
94
                        void some_function(void *foo, void *bar) __attribute__((nonnull()));
 
95
                        void some_function(void *foo, void *bar) { }
 
96
                        ],
 
97
                        [cc_cv_attribute_nonnull=yes],
 
98
                        [cc_cv_attribute_nonnull=no])
 
99
                ])
 
100
        
 
101
        if test "x$cc_cv_attribute_nonnull" = "xyes"; then
 
102
                AC_DEFINE([SUPPORT_ATTRIBUTE_NONNULL], 1, [Define this if the compiler supports the nonnull attribute])
 
103
                $1
 
104
        else
 
105
                true
 
106
                $2
 
107
        fi
 
108
])
 
109
 
 
110
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
 
111
        AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
 
112
                [cc_cv_attribute_unused],
 
113
                [AC_COMPILE_IFELSE([
 
114
                        void some_function(void *foo, __attribute__((unused)) void *bar);
 
115
                        ],
 
116
                        [cc_cv_attribute_unused=yes],
 
117
                        [cc_cv_attribute_unused=no])
 
118
                ])
 
119
        
 
120
        if test "x$cc_cv_attribute_unused" = "xyes"; then
 
121
                AC_DEFINE([SUPPORT_ATTRIBUTE_UNUSED], 1, [Define this if the compiler supports the unused attribute])
 
122
                $1
 
123
        else
 
124
                true
 
125
                $2
 
126
        fi
 
127
])
 
128
 
 
129
AC_DEFUN([CC_FUNC_EXPECT], [
 
130
        AC_CACHE_CHECK([if compiler has __builtin_expect function],
 
131
                [cc_cv_func_expect],
 
132
                [AC_COMPILE_IFELSE([
 
133
                        int some_function()
 
134
                        {
 
135
                                int a = 3;
 
136
                                return (int)__builtin_expect(a, 3);
 
137
                        }
 
138
                        ],
 
139
                        [cc_cv_func_expect=yes],
 
140
                        [cc_cv_func_expect=no])
 
141
                ])
 
142
        
 
143
        if test "x$cc_cv_func_expect" = "xyes"; then
 
144
                AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function])
 
145
                $1
 
146
        else
 
147
                true
 
148
                $2
 
149
        fi
 
150
])