5a9aa2327b8dbd218a4d5661a1c2fc3b4c45ba11
[gentoo.git] /
1 From 2e8240309f5ce36eae8f1f9dfcd8c060c040ca5c Mon Sep 17 00:00:00 2001
2 From: Craig Topper <craig.topper@intel.com>
3 Date: Thu, 24 May 2018 17:59:47 +0000
4 Subject: [PATCH] sanitizer: Use pre-computed size of struct ustat for Linux
5
6 <sys/ustat.h> has been removed from glibc 2.28 by:
7
8 commit cf2478d53ad7071e84c724a986b56fe17f4f4ca7
9 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
10 Date: Sun Mar 18 11:28:59 2018 +0800
11
12 Deprecate ustat syscall interface
13 This patch uses pre-computed size of struct ustat for Linux to fix
14
15 https://bugs.llvm.org/show_bug.cgi?id=37418
16
17 Patch by H.J. Lu.
18
19 Differential Revision: https://reviews.llvm.org/D47281
20
21 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@333213 91177308-0d34-0410-b5e6-96231b3b80d8
22 ---
23  .../sanitizer_platform_limits_posix.cc            | 15 +++++++++++++--
24  1 file changed, 13 insertions(+), 2 deletions(-)
25
26 diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
27 index 83f4fd22f..804abd9e4 100644
28 --- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
29 +++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
30 @@ -159,7 +159,6 @@ typedef struct user_fpregs elf_fpregset_t;
31  # include <sys/procfs.h>
32  #endif
33  #include <sys/user.h>
34 -#include <sys/ustat.h>
35  #include <linux/cyclades.h>
36  #include <linux/if_eql.h>
37  #include <linux/if_plip.h>
38 @@ -252,7 +251,19 @@ namespace __sanitizer {
39  #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
40  
41  #if SANITIZER_LINUX && !SANITIZER_ANDROID
42 -  unsigned struct_ustat_sz = sizeof(struct ustat);
43 +  // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
44 +  // has been removed from glibc 2.28.
45 +#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
46 +  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
47 +  || defined(__x86_64__)
48 +#define SIZEOF_STRUCT_USTAT 32
49 +#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
50 +  || defined(__powerpc__) || defined(__s390__)
51 +#define SIZEOF_STRUCT_USTAT 20
52 +#else
53 +#error Unknown size of struct ustat
54 +#endif
55 +  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
56    unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
57    unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
58  #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
59 -- 
60 2.20.1
61