@@ -33,23 +33,17 @@ diff -uNr a/sys/cdefs.h b/sys/cdefs.h
3333 #if defined(__cplusplus)
3434 #define __BEGIN_DECLS extern "C" {
3535 #define __END_DECLS }
36- @@ -139 ,12 +162 ,25 @@
36+ @@ -142 ,12 +165 ,25 @@
3737
3838 #define __wur __attribute__((__warn_unused_result__))
3939
40- - #define __errorattr(msg) __attribute__((unavailable(msg)))
41- - #define __warnattr(msg) __attribute__((deprecated(msg)))
42- - #define __warnattr_real(msg) __attribute__((deprecated(msg)))
43- - #define __enable_if(cond, msg) __attribute__((enable_if(cond, msg)))
44- - #define __clang_error_if(cond, msg) __attribute__((diagnose_if(cond, msg, "error")))
45- - #define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
4640+ #ifdef __clang__
47- + # define __errorattr(msg) __attribute__((unavailable (msg)))
48- + # define __warnattr(msg) __attribute__((deprecated (msg)))
49- + # define __warnattr_real(msg) __attribute__((deprecated (msg)))
50- + # define __enable_if(cond, msg) __attribute__((enable_if (cond, msg)))
51- + # define __clang_error_if(cond, msg) __attribute__((diagnose_if (cond, msg, "error")))
52- + # define __clang_warning_if(cond, msg) __attribute__((diagnose_if (cond, msg, "warning")))
41+ # define __errorattr(msg) __attribute__((__unavailable__ (msg)))
42+ # define __warnattr(msg) __attribute__((__deprecated__ (msg)))
43+ # define __warnattr_real(msg) __attribute__((__deprecated__ (msg)))
44+ # define __enable_if(cond, msg) __attribute__((__enable_if__ (cond, msg)))
45+ # define __clang_error_if(cond, msg) __attribute__((__diagnose_if__ (cond, msg, "error")))
46+ # define __clang_warning_if(cond, msg) __attribute__((__diagnose_if__ (cond, msg, "warning")))
5347+ #else
5448+ # define __errorattr(msg) __attribute__((__error__(msg)))
5549+ # define __warnattr(msg) __attribute__((__warning__(msg)))
@@ -65,82 +59,60 @@ diff -uNr a/sys/cdefs.h b/sys/cdefs.h
6559
6660 #if defined(ANDROID_STRICT)
6761 /*
68- @@ -281,19 +317,20 @@
62+ @@ -251,6 +287,7 @@
6963
7064 #if defined(__BIONIC_FORTIFY)
7165 # define __bos0(s) __bosn((s), 0)
72- - # define __pass_object_size_n(n) __attribute__((pass_object_size(n)))
73- + # if defined(__clang__)
74- + # define __pass_object_size_n(n) __attribute__((pass_object_size(n)))
66+ + #if defined(__clang__)
67+ # define __pass_object_size_n(n) __attribute__((__pass_object_size__(n)))
7568 /*
7669 * FORTIFY'ed functions all have either enable_if or pass_object_size, which
77- * makes taking their address impossible. Saying (&read)(foo, bar, baz); will
78- * therefore call the unFORTIFYed version of read.
79- */
80- - # define __call_bypassing_fortify(fn) (&fn)
81- + # define __call_bypassing_fortify(fn) (&fn)
82- /*
83- * Because clang-FORTIFY uses overloads, we can't mark functions as `extern inline` without making
84- * them available externally. FORTIFY'ed functions try to be as close to possible as 'invisible';
85- * having stack protectors detracts from that (b/182948263).
86- */
87- - # define __BIONIC_FORTIFY_INLINE static __inline__ __attribute__((no_stack_protector)) \
88- + # define __BIONIC_FORTIFY_INLINE static __inline__ __attribute__((no_stack_protector)) \
89- __always_inline __VERSIONER_FORTIFY_INLINE
90- /*
91- * We should use __BIONIC_FORTIFY_VARIADIC instead of __BIONIC_FORTIFY_INLINE
92- @@ -301,9 +338,21 @@
93- * The __always_inline attribute is useless, misleading, and could trigger
94- * clang compiler bug to incorrectly inline variadic functions.
95- */
96- - # define __BIONIC_FORTIFY_VARIADIC static __inline__
97- + # define __BIONIC_FORTIFY_VARIADIC static __inline__
70+ @@ -275,6 +312,18 @@
9871 /* Error functions don't have bodies, so they can just be static. */
99- - # define __BIONIC_ERROR_FUNCTION_VISIBILITY static __attribute__((unused))
100- + # define __BIONIC_ERROR_FUNCTION_VISIBILITY static __attribute__((unused))
101- + # else
72+ # define __BIONIC_ERROR_FUNCTION_VISIBILITY static __unused
73+ #else
10274+ /*
10375+ * Where they can, GCC and clang-style FORTIFY share implementations.
10476+ * So, make these nops in GCC.
10577+ */
106- + # define __pass_object_size_n(n)
107- + # define __call_bypassing_fortify(fn) (fn)
78+ + # define __pass_object_size_n(n)
79+ + # define __call_bypassing_fortify(fn) (fn)
10880+ /* __BIONIC_FORTIFY_NONSTATIC_INLINE is pointless in GCC's FORTIFY */
109- + # define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
81+ + # define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__))
11082+ /* __always_inline is probably okay and ignored by gcc in __BIONIC_FORTIFY_VARIADIC */
111- + # define __BIONIC_FORTIFY_VARIADIC __BIONIC_FORTIFY_INLINE
112- + # endif
113- #else
83+ + # define __BIONIC_FORTIFY_VARIADIC __BIONIC_FORTIFY_INLINE
84+ + #endif
85+ + #else
11486 /* Further increase sharing for some inline functions */
11587 # define __pass_object_size_n(n)
116- @@ -333,7 +382,16 @@
88+ #endif
89+ @@ -303,7 +352,16 @@
11790 # define __BIONIC_INCLUDE_FORTIFY_HEADERS 1
11891 #endif
11992
120- - #define __overloadable __attribute__((overloadable))
12193+ #if !defined(__clang__) && defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
12294+ #undef __BIONIC_INCLUDE_FORTIFY_HEADERS
12395+ #warning "Fortify headers are not supported and will not used without clang."
12496+ #endif
12597+
12698+ #if defined(__clang__)
127- + # define __overloadable __attribute__((overloadable ))
99+ # define __overloadable __attribute__((__overloadable__ ))
128100+ #else
129- + # define __overloadable
101+ + #define __overloadable
130102+ #endif
131103
132- #define __diagnose_as_builtin(...) __attribute__((diagnose_as_builtin (__VA_ARGS__)))
104+ #define __diagnose_as_builtin(...) __attribute__((__diagnose_as_builtin__ (__VA_ARGS__)))
133105
134- @@ -368 ,6 +426 ,7 @@
135- }
136- #endif
106+ @@ -323 ,6 +381 ,7 @@
107+ /* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
108+ #define __RENAME(x) __asm__(#x)
137109
138110+ #if defined(__clang__)
139111 /*
140112 * Used when we need to check for overflow when multiplying x and y. This
141- * should only be used where __size_mul_overflow can not work, because it makes
142- @@ -376 ,6 +435 ,7 @@
143- * __size_mul_overflow .
113+ * should only be used where __builtin_umull_overflow can not work, because it makes
114+ @@ -331 ,6 +390 ,7 @@
115+ * __builtin_umull_overflow .
144116 */
145117 #define __unsafe_check_mul_overflow(x, y) ((__SIZE_TYPE__)-1 / (x) < (y))
146118+ #endif
0 commit comments