summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-11-22 09:01:50 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2013-11-22 09:01:50 +0000
commit29d306afd9c2cab2eaac1dab237892df327d166f (patch)
treecd3926c49f0dfec5f9b02aceaa81de27f29ba53c /lib/sanitizer_common/sanitizer_platform_limits_linux.cc
parent233fddf8d0721b5c0a856a92611a6478805d9696 (diff)
[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). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195427 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_platform_limits_linux.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_platform_limits_linux.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_linux.cc b/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
index 18147daf8..5331a91db 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -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);