summaryrefslogtreecommitdiff
path: root/include/fortify-headers.h
diff options
context:
space:
mode:
authorDaniel Kolesa2022-10-26 00:30:00 +0200
committerjvoisin2023-06-25 18:26:45 +0200
commitfe149628eaae9748be08815d726cc56e8e492c73 (patch)
tree252ed41ea13504b67b3c03e648113015b8f85dda /include/fortify-headers.h
parentadae76af26e498af6c3004a52a4b1de2c6fd91c3 (diff)
add initial clang support
Diffstat (limited to 'include/fortify-headers.h')
-rw-r--r--include/fortify-headers.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index 5a3c6e5..42c8317 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org> 2 * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
3 * Copyright (C) 2022 q66 <q66@chimera-linux.org>
3 * 4 *
4 * Permission to use, copy, modify, and/or distribute this software for any 5 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted. 6 * purpose with or without fee is hereby granted.
@@ -16,10 +17,30 @@
16#ifndef _FORTIFY_HEADERS_H 17#ifndef _FORTIFY_HEADERS_H
17#define _FORTIFY_HEADERS_H 18#define _FORTIFY_HEADERS_H
18 19
20#ifdef __clang__
21
22/* clang uses overloads; see https://github.com/llvm/llvm-project/issues/53516 */
23#define _FORTIFY_POSN(n) const __attribute__((__pass_object_size__(n)))
24/* we can't use extern inline with overloads without making them external */
25#define _FORTIFY_INLINE static __inline__ \
26 __attribute__((__always_inline__,__artificial__,__overloadable__))
27
28#else /* !__clang__ */
29
30#define _FORTIFY_POSN(n)
31#define _FORTIFY_INLINE extern __inline__ \
32 __attribute__((__always_inline__,__gnu_inline__,__artificial__))
33
34#endif /* __clang__ */
35
36#define _FORTIFY_POS0 _FORTIFY_POSN(0)
37#define _FORTIFY_POS1 _FORTIFY_POSN(1)
38#define _FORTIFY_POS2 _FORTIFY_POSN(2)
39
19#define _FORTIFY_STR(s) #s 40#define _FORTIFY_STR(s) #s
20#define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn) 41#define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn)
21#define _FORTIFY_FN(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn); \ 42#define _FORTIFY_FNB(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn)
22 extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__)) 43#define _FORTIFY_FN(fn) _FORTIFY_FNB(fn); _FORTIFY_INLINE
23 44
24 45
25/* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */ 46/* Use __builtin_dynamic_object_size with _FORTIFY_SOURCE>2, if available. */