diff options
Diffstat (limited to 'include/fortify-headers.h')
| -rw-r--r-- | include/fortify-headers.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index a173466..4fbc808 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -17,9 +17,21 @@ | |||
| 17 | #ifndef _FORTIFY_HEADERS_H | 17 | #ifndef _FORTIFY_HEADERS_H |
| 18 | #define _FORTIFY_HEADERS_H | 18 | #define _FORTIFY_HEADERS_H |
| 19 | 19 | ||
| 20 | #ifdef __has_attribute | ||
| 21 | # define __fortify_has_attribute(v) __has_attribute(v) | ||
| 22 | #else | ||
| 23 | # define __fortify_has_attribute(v) 0 | ||
| 24 | #endif | ||
| 25 | |||
| 26 | #ifdef __has_builtin | ||
| 27 | # define __fortify_has_builtin(v) __has_builtin(v) | ||
| 28 | #else | ||
| 29 | # define __fortify_has_builtin(v) 0 | ||
| 30 | #endif | ||
| 31 | |||
| 20 | #ifdef __clang__ | 32 | #ifdef __clang__ |
| 21 | 33 | ||
| 22 | #if _FORTIFY_SOURCE > 2 && defined __has_attribute && __has_attribute(pass_dynamic_object_size) | 34 | #if _FORTIFY_SOURCE > 2 && __fortify_has_attribute(pass_dynamic_object_size) |
| 23 | #define _FORTIFY_POSN(n) const __attribute__((pass_dynamic_object_size(n))) | 35 | #define _FORTIFY_POSN(n) const __attribute__((pass_dynamic_object_size(n))) |
| 24 | #else | 36 | #else |
| 25 | /* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */ | 37 | /* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */ |
| @@ -53,38 +65,28 @@ | |||
| 53 | #define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE | 65 | #define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE |
| 54 | 66 | ||
| 55 | 67 | ||
| 56 | #if _FORTIFY_SOURCE > 2 && defined __has_builtin && __has_builtin (__builtin_dynamic_object_size) | 68 | #if _FORTIFY_SOURCE > 2 && __fortify_has_builtin(__builtin_dynamic_object_size) |
| 57 | #define __bos(ptr, type) __builtin_dynamic_object_size (ptr, type) | 69 | #define __bos(ptr, type) __builtin_dynamic_object_size (ptr, type) |
| 58 | #else | 70 | #else |
| 59 | #define __bos(ptr, type) __builtin_object_size (ptr, type) | 71 | #define __bos(ptr, type) __builtin_object_size (ptr, type) |
| 60 | #endif | 72 | #endif |
| 61 | 73 | ||
| 62 | #if defined __has_attribute | 74 | #if __fortify_has_attribute(access) |
| 63 | |||
| 64 | #if __has_attribute (access) | ||
| 65 | #define __fortify_access(...) __attribute__ ((access (__VA_ARGS__))) | 75 | #define __fortify_access(...) __attribute__ ((access (__VA_ARGS__))) |
| 66 | #else | 76 | #else |
| 67 | #define __fortify_access(...) | 77 | #define __fortify_access(...) |
| 68 | #endif | 78 | #endif |
| 69 | 79 | ||
| 70 | #if __has_attribute (format) | 80 | #if __fortify_has_attribute(format) |
| 71 | #define __fortify__format(...) __attribute__ ((format (__VA_ARGS__))) | 81 | #define __fortify__format(...) __attribute__ ((format (__VA_ARGS__))) |
| 72 | #else | 82 | #else |
| 73 | #define __fortify__format(...) | 83 | #define __fortify__format(...) |
| 74 | #endif | 84 | #endif |
| 75 | 85 | ||
| 76 | #if __has_attribute (__diagnose_if) | 86 | #if __fortify_has_attribute(__diagnose_if) |
| 77 | #define __fortify_warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) | 87 | #define __fortify_warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) |
| 78 | #else | 88 | #else |
| 79 | #define __fortify_warning_if(cond, msg) | 89 | #define __fortify_warning_if(cond, msg) |
| 80 | #endif | 90 | #endif |
| 81 | 91 | ||
| 82 | #else /* ! __has_attribute */ | ||
| 83 | |||
| 84 | #define __fortify_access(...) | ||
| 85 | #define __fortify__format(...) | ||
| 86 | #define __fortify_warning_if(cond, msg) | ||
| 87 | |||
| 88 | #endif | ||
| 89 | |||
| 90 | #endif | 92 | #endif |
