summaryrefslogtreecommitdiffstats
path: root/main/fortify-headers/0003-Use-the-__inline__-keyword-instead-of-__inline-to-av.patch
blob: 17f6a3ab3ad5ef00abb00a2fdd0e18cedb40b428 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 4cdac9cbdaa01f884e0e8b3f947b7f0cb1170729 Mon Sep 17 00:00:00 2001
From: Trutz Behn <me@trutz.be>
Date: Thu, 4 Jun 2015 15:01:37 +0200
Subject: [PATCH 3/3] Use the __inline__ keyword instead of __inline to avoid
 breakage

Newer compilers default to GNU11, a C11 dialect. Some software however
is unprepared for this or has wrong compatibility checks. What happens
is that some software will for compatibility with C89

  #define inline

before inclusion of a standard header, which is undefined behaviour in
C99 and above (C99/C11 7.1.2/4), as inline is a keyword.

If any libc headers that are then included via #include_next provide an
__inline macro definition (current musl does this if C++ or C99 and
above is detected) like the following

  #define __inline inline

this results in any __inline token to be preprocessed away.

This breaks use of __builtin_va_arg_pack() in our stdio.h at
compile-time as it can only be used in always inlined functions. The
function attributes __always_inline__ and __gnu_inline__ themselves
require an inline specifier on the function to be applied.
---
 include/fortify-headers.h | 2 +-
 include/sys/select.h      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index 288a973..c4e6495 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -19,6 +19,6 @@
 #define _FORTIFY_STR(s) #s
 #define _FORTIFY_ORIG(p,fn) __typeof__(fn) __orig_##fn __asm__(_FORTIFY_STR(p) #fn)
 #define _FORTIFY_FN(fn) _FORTIFY_ORIG(__USER_LABEL_PREFIX__,fn); \
-	extern __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
+	extern __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
 
 #endif
diff --git a/include/sys/select.h b/include/sys/select.h
index 4623071..db6135d 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -24,7 +24,7 @@
 extern "C" {
 #endif
 
-static __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
+static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
 void __fortify_FD_CLR(int __f, fd_set *__s)
 {
 	size_t __b = __builtin_object_size(__s, 0);
@@ -34,7 +34,7 @@ void __fortify_FD_CLR(int __f, fd_set *__s)
 	FD_CLR(__f, __s);
 }
 
-static __inline __attribute__((__always_inline__,__gnu_inline__,__artificial__))
+static __inline__ __attribute__((__always_inline__,__gnu_inline__,__artificial__))
 void __fortify_FD_SET(int __f, fd_set *__s)
 {
 	size_t __b = __builtin_object_size(__s, 0);
-- 
2.4.2