[asan] Include <sys/stat.h> if __x86_64__ is defined

struct stat defined in <asm/stat.h> is incorrect for x32.  <asm/stat.h>
is included to get struct __old_kernel_stat.  But struct __old_kernel_stat
isn't used for x86-64 nor x32.  This patch includes <sys/stat.h> instead
of <asm/stat.h> and comments out size check of struct __old_kernel_stat
for x86-64.

Patch by H.J. Lu

llvm-svn: 199192
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
index 034b3200..54c0809 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -29,6 +29,9 @@
 // are not defined anywhere in userspace headers. Fake them. This seems to work
 // fine with newer headers, too.
 #include <asm/posix_types.h>
+#if defined(__x86_64__)
+#include <sys/stat.h>
+#else
 #define ino_t __kernel_ino_t
 #define mode_t __kernel_mode_t
 #define nlink_t __kernel_nlink_t
@@ -43,6 +46,7 @@
 #undef uid_t
 #undef gid_t
 #undef off_t
+#endif
 
 #include <linux/aio_abi.h>
 
@@ -60,7 +64,7 @@
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
 }  // namespace __sanitizer
 
-#if !defined(__powerpc64__)
+#if !defined(__powerpc64__) && !defined(__x86_64__)
 COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
 #endif
 
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 97866b81..5293ed0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -169,6 +169,11 @@
   #elif !defined(__powerpc64__)
     uptr __unused0;
   #endif
+  #if defined(__x86_64__) && !defined(_LP64)
+    u64 shm_atime;
+    u64 shm_dtime;
+    u64 shm_ctime;
+  #else
     uptr shm_atime;
   #ifndef _LP64
     uptr __unused1;
@@ -181,14 +186,21 @@
   #ifndef _LP64
     uptr __unused3;
   #endif
+  #endif
   #ifdef __powerpc__
     uptr shm_segsz;
   #endif
     int shm_cpid;
     int shm_lpid;
+  #if defined(__x86_64__) && !defined(_LP64)
+    u64 shm_nattch;
+    u64 __unused4;
+    u64 __unused5;
+  #else
     uptr shm_nattch;
     uptr __unused4;
     uptr __unused5;
+  #endif
   };
   #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
 
@@ -296,7 +308,11 @@
   };
 #endif
 
+#if defined(__x86_64__) && !defined(_LP64)
+  typedef long long __sanitizer_clock_t;
+#else
   typedef long __sanitizer_clock_t;
+#endif
 
 #if SANITIZER_LINUX
 #if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__)