]> git.notmuchmail.org Git - notmuch/blob - compat/function-attributes.h
Merge branch 'release'
[notmuch] / compat / function-attributes.h
1 /* function-attributes.h - Provides compiler abstractions for
2  *                         function attributes
3  *
4  * Copyright (c) 2012 Justus Winter <4winter@informatik.uni-hamburg.de>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see https://www.gnu.org/licenses/ .
18  */
19
20 #ifndef FUNCTION_ATTRIBUTES_H
21 #define FUNCTION_ATTRIBUTES_H
22
23 /* clang provides this macro to test for support for function
24  * attributes. If it isn't defined, this provides a compatibility
25  * macro for other compilers.
26  */
27 #ifndef __has_attribute
28 #define __has_attribute(x) 0
29 #endif
30
31 /* Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE from
32  * talloc.
33  *
34  * This attribute is understood by gcc since version 2.5. clang
35  * provides support for testing for function attributes.
36  */
37 #ifndef NORETURN_ATTRIBUTE
38 #if (__GNUC__ >= 3 ||                           \
39      (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) ||  \
40     __has_attribute (noreturn))
41 #define NORETURN_ATTRIBUTE __attribute__ ((noreturn))
42 #else
43 #define NORETURN_ATTRIBUTE
44 #endif
45 #endif
46
47 #endif