libsanitizer: Use pre-computed size of struct ustat for Linux
authorH.J. Lu <hongjiu.lu@intel.com>
Thu, 24 May 2018 19:52:32 +0000 (19:52 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Thu, 24 May 2018 19:52:32 +0000 (12:52 -0700)
Cherry-pick compiler-rt revision 333213:

<sys/ustat.h> has been removed from glibc 2.28 by:

commit cf2478d53ad7071e84c724a986b56fe17f4f4ca7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sun Mar 18 11:28:59 2018 +0800

    Deprecate ustat syscall interface

This patch uses pre-computed size of struct ustat for Linux.

PR sanitizer/85835
* sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
include <sys/ustat.h> for Linux.
(SIZEOF_STRUCT_USTAT): New.
(struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.

From-SVN: r260684

libsanitizer/ChangeLog
libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc

index 2ec1a9a14996807d0fcef8f0704622ac402b1caf..286b7898a43e90cfcb7b6e26a2361abf4c29e698 100644 (file)
@@ -1,3 +1,11 @@
+2018-05-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR sanitizer/85835
+       * sanitizer_common/sanitizer_platform_limits_posix.cc: Don't
+       include <sys/ustat.h> for Linux.
+       (SIZEOF_STRUCT_USTAT): New.
+       (struct_ustat_sz): Use SIZEOF_STRUCT_USTAT for Linux.
+
 2018-04-26  Hans-Peter Nilsson  <hp@axis.com>
 
        * configure.tgt <mips*-*-linux*>: Enable build, excluding
index 858bb2184505829ad7aae5def4cda515d3a48426..de18e56d11cf02e40b1cc90b0111890065dc319c 100644 (file)
@@ -157,7 +157,6 @@ typedef struct user_fpregs elf_fpregset_t;
 # include <sys/procfs.h>
 #endif
 #include <sys/user.h>
-#include <sys/ustat.h>
 #include <linux/cyclades.h>
 #include <linux/if_eql.h>
 #include <linux/if_plip.h>
@@ -250,7 +249,19 @@ namespace __sanitizer {
 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
-  unsigned struct_ustat_sz = sizeof(struct ustat);
+  // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
+  // has been removed from glibc 2.28.
+#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
+  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
+  || defined(__x86_64__)
+#define SIZEOF_STRUCT_USTAT 32
+#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
+  || defined(__powerpc__) || defined(__s390__)
+#define SIZEOF_STRUCT_USTAT 20
+#else
+#error Unknown size of struct ustat
+#endif
+  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID