[llvm-branch-commits] [compiler-rt-branch] r195460 - Merging r195427:

Evgeniy Stepanov eugeni.stepanov at gmail.com
Fri Nov 22 06:00:02 PST 2013


Author: eugenis
Date: Fri Nov 22 08:00:02 2013
New Revision: 195460

URL: http://llvm.org/viewvc/llvm-project?rev=195460&view=rev
Log:
Merging r195427:
------------------------------------------------------------------------
r195427 | eugenis | 2013-11-22 13:01:50 +0400 (Fri, 22 Nov 2013) | 10 lines

[sanitizer] Change the way we use certain linux kernel headers.

Some linux headers are broken on older kernels.
Instead of depending on the constants and types from such headers directly,
we provide our own definitions and then verify them with compile-time
assertions. This makes the dependency on the headers test-only and would allow
switching to some other way of testing on older kernels, or even disable the
tests as the last resort (after all, kernel interfaces are supposed to be
stable).

------------------------------------------------------------------------

Modified:
    compiler-rt/branches/release_34/   (props changed)
    compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
    compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
    compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Propchange: compiler-rt/branches/release_34/
------------------------------------------------------------------------------
    svn:mergeinfo = /compiler-rt/trunk:195427

Modified: compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_linux.cc?rev=195460&r1=195459&r2=195460&view=diff
==============================================================================
--- compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_linux.cc (original)
+++ compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_linux.cc Fri Nov 22 08:00:02 2013
@@ -40,24 +40,24 @@
 #endif
 
 namespace __sanitizer {
-  unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat);
-  unsigned struct_kernel_stat_sz = sizeof(struct stat);
-  unsigned struct_io_event_sz = sizeof(struct io_event);
   unsigned struct_statfs64_sz = sizeof(struct statfs64);
+}  // namespace __sanitizer
 
-  unsigned iocb_cmd_pread = IOCB_CMD_PREAD;
-  unsigned iocb_cmd_pwrite = IOCB_CMD_PWRITE;
+COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
+COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
 
-#if !defined(_LP64) && !defined(__x86_64__)
-  unsigned struct_kernel_stat64_sz = sizeof(struct stat64);
-#else
-  unsigned struct_kernel_stat64_sz = 0;
+#if defined(__i386__)
+COMPILER_CHECK(struct_kernel_stat64_sz == sizeof(struct stat64));
 #endif
 
+COMPILER_CHECK(struct_io_event_sz == sizeof(struct io_event));
+
 #if !SANITIZER_ANDROID
-  unsigned struct_perf_event_attr_sz = sizeof(struct perf_event_attr);
+COMPILER_CHECK(struct_perf_event_attr_sz == sizeof(struct perf_event_attr));
 #endif
-}  // namespace __sanitizer
+
+COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
+COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
 
 CHECK_TYPE_SIZE(iocb);
 CHECK_SIZE_AND_OFFSET(iocb, aio_data);

Modified: compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.cc?rev=195460&r1=195459&r2=195460&view=diff
==============================================================================
--- compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.cc (original)
+++ compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.cc Fri Nov 22 08:00:02 2013
@@ -108,7 +108,6 @@
 #include <link.h>
 #include <sys/vfs.h>
 #include <sys/epoll.h>
-// #include <asm/stat.h>
 #include <linux/capability.h>
 #endif // SANITIZER_LINUX
 

Modified: compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=195460&r1=195459&r2=195460&view=diff
==============================================================================
--- compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.h (original)
+++ compiler-rt/branches/release_34/lib/sanitizer_common/sanitizer_platform_limits_posix.h Fri Nov 22 08:00:02 2013
@@ -48,17 +48,25 @@ namespace __sanitizer {
 #endif // !SANITIZER_ANDROID
 
 #if SANITIZER_LINUX
-  extern unsigned struct___old_kernel_stat_sz;
-  extern unsigned struct_kernel_stat_sz;
-  extern unsigned struct_kernel_stat64_sz;
-  extern unsigned struct_io_event_sz;
+
+#if defined(__x86_64__)
+  const unsigned struct___old_kernel_stat_sz = 32;
+  const unsigned struct_kernel_stat_sz = 144;
+  const unsigned struct_kernel_stat64_sz = 0;
+#elif defined(__i386__)
+  const unsigned struct___old_kernel_stat_sz = 32;
+  const unsigned struct_kernel_stat_sz = 64;
+  const unsigned struct_kernel_stat64_sz = 96;
+#endif
+  const unsigned struct_io_event_sz = 32;
+  const unsigned struct_perf_event_attr_sz = 72;
+
   extern unsigned struct_utimbuf_sz;
   extern unsigned struct_new_utsname_sz;
   extern unsigned struct_old_utsname_sz;
   extern unsigned struct_oldold_utsname_sz;
   extern unsigned struct_msqid_ds_sz;
   extern unsigned struct_mq_attr_sz;
-  extern unsigned struct_perf_event_attr_sz;
   extern unsigned struct_timex_sz;
   extern unsigned struct_ustat_sz;
 
@@ -85,8 +93,8 @@ namespace __sanitizer {
     u64   aio_reserved3;
   };
 
-  extern unsigned iocb_cmd_pread;
-  extern unsigned iocb_cmd_pwrite;
+  const unsigned iocb_cmd_pread = 0;
+  const unsigned iocb_cmd_pwrite = 1;
 
   struct __sanitizer___sysctl_args {
     int *name;
@@ -942,4 +950,3 @@ namespace __sanitizer {
                  offsetof(struct CLASS, MEMBER))
 
 #endif
-





More information about the llvm-branch-commits mailing list