sanitizer_platform_limits_linux.cc revision e041c6024b3ebf1365c0f99732fc69c607577571
1//===-- sanitizer_platform_limits_linux.cc --------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of Sanitizer common code. 11// 12// Sizes and layouts of linux kernel data structures. 13//===----------------------------------------------------------------------===// 14 15// This is a separate compilation unit for linux headers that conflict with 16// userspace headers. 17// Most "normal" includes go in sanitizer_platform_limits_posix.cc 18 19#include "sanitizer_platform.h" 20#if SANITIZER_LINUX 21 22#include "sanitizer_internal_defs.h" 23#include "sanitizer_platform_limits_posix.h" 24 25// For offsetof -> __builtin_offsetof definition. 26#include <stddef.h> 27 28// This header seems to contain the definitions of _kernel_ stat* structs. 29#include <asm/stat.h> 30#include <linux/aio_abi.h> 31 32#if SANITIZER_ANDROID 33#include <asm/statfs.h> 34#else 35#include <sys/statfs.h> 36#endif 37 38#if !SANITIZER_ANDROID 39#include <linux/perf_event.h> 40#endif 41 42namespace __sanitizer { 43 unsigned struct___old_kernel_stat_sz = sizeof(struct __old_kernel_stat); 44 unsigned struct_kernel_stat_sz = sizeof(struct stat); 45 unsigned struct_io_event_sz = sizeof(struct io_event); 46 unsigned struct_statfs64_sz = sizeof(struct statfs64); 47 48 unsigned iocb_cmd_pread = IOCB_CMD_PREAD; 49 unsigned iocb_cmd_pwrite = IOCB_CMD_PWRITE; 50 51#if !defined(_LP64) && !defined(__x86_64__) 52 unsigned struct_kernel_stat64_sz = sizeof(struct stat64); 53#else 54 unsigned struct_kernel_stat64_sz = 0; 55#endif 56 57#if !SANITIZER_ANDROID 58 unsigned struct_perf_event_attr_sz = sizeof(struct perf_event_attr); 59#endif 60} // namespace __sanitizer 61 62CHECK_TYPE_SIZE(iocb); 63CHECK_SIZE_AND_OFFSET(iocb, aio_data); 64// Skip aio_key, it's weird. 65CHECK_SIZE_AND_OFFSET(iocb, aio_lio_opcode); 66CHECK_SIZE_AND_OFFSET(iocb, aio_reqprio); 67CHECK_SIZE_AND_OFFSET(iocb, aio_fildes); 68CHECK_SIZE_AND_OFFSET(iocb, aio_buf); 69CHECK_SIZE_AND_OFFSET(iocb, aio_nbytes); 70CHECK_SIZE_AND_OFFSET(iocb, aio_offset); 71 72#endif // SANITIZER_LINUX 73