sanitizer_platform_limits_linux.cc revision e1e68833ddbebf4827690218763c0be5b91104e7
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_statfs64_sz = sizeof(struct statfs64);
44}  // namespace __sanitizer
45
46COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
47COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
48
49#if defined(__i386__)
50COMPILER_CHECK(struct_kernel_stat64_sz == sizeof(struct stat64));
51#endif
52
53COMPILER_CHECK(struct_io_event_sz == sizeof(struct io_event));
54
55#if !SANITIZER_ANDROID
56COMPILER_CHECK(struct_perf_event_attr_sz == sizeof(struct perf_event_attr));
57#endif
58
59COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
60COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
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