2013-09-06 22:20:01 +08:00
|
|
|
//===-- sanitizer_platform_limits_linux.cc --------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-09-06 22:20:01 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of Sanitizer common code.
|
|
|
|
//
|
|
|
|
// Sizes and layouts of linux kernel data structures.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// This is a separate compilation unit for linux headers that conflict with
|
|
|
|
// userspace headers.
|
|
|
|
// Most "normal" includes go in sanitizer_platform_limits_posix.cc
|
|
|
|
|
|
|
|
#include "sanitizer_platform.h"
|
|
|
|
#if SANITIZER_LINUX
|
|
|
|
|
2013-11-01 09:20:39 +08:00
|
|
|
#include "sanitizer_internal_defs.h"
|
|
|
|
#include "sanitizer_platform_limits_posix.h"
|
|
|
|
|
|
|
|
// For offsetof -> __builtin_offsetof definition.
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-11-22 19:01:43 +08:00
|
|
|
// With old kernels (and even new kernels on powerpc) asm/stat.h uses types that
|
|
|
|
// are not defined anywhere in userspace headers. Fake them. This seems to work
|
|
|
|
// fine with newer headers, too.
|
[compiler-rt] adjust platform_limits_linux.cc #include of posix_types
Summary:
Hello,
Building a recent gcc on a powerpc-linux system advertsing:
Red Hat Enterprise Linux Server release 5.10 (Tikanga)
we stumbled on a compilation error on a file originating
from compiler-rt/lib/sanitizer-common.
sanitizer_platform_limits_linux.cc #includes asm/posix_types.h,
which, on our system, uses __kernel_fd_set and associated macros.
These aren't defined at the point of their use, and the compilation
fails with symptoms like:
In file included from ../../../../src/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc:29:0:
/usr/include/asm/posix_types.h:72:51: error: '__kernel_fd_set' has not been declared
static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
...
The attached patch is a suggestion to fix this, by including linux/posix_types.h
instead of asm/posix_types.h. linux/posix_types defines the necessary types and
macros, then #includes asm/posix_types.h.
We have been using it locally for gcc without problems for a couple of years
on powerpc, x86 and x86_64-linux platforms. It is still needed for gcc-6 on
our powerpc host and applies cleanly on the compiler-rt trunk.
Comments ?
Thanks much in advance for your feedback,
With Kind Regards,
Olivier
Reviewers: llvm-commits, kcc
Subscribers: kcc, kubabrecka
Differential Revision: http://reviews.llvm.org/D19799
llvm-svn: 268283
2016-05-03 03:10:48 +08:00
|
|
|
#include <linux/posix_types.h>
|
2014-06-24 20:08:18 +08:00
|
|
|
#if defined(__x86_64__) || defined(__mips__)
|
2014-01-14 15:38:53 +08:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#else
|
2013-11-22 19:01:43 +08:00
|
|
|
#define ino_t __kernel_ino_t
|
|
|
|
#define mode_t __kernel_mode_t
|
|
|
|
#define nlink_t __kernel_nlink_t
|
|
|
|
#define uid_t __kernel_uid_t
|
|
|
|
#define gid_t __kernel_gid_t
|
|
|
|
#define off_t __kernel_off_t
|
2016-12-02 16:07:35 +08:00
|
|
|
#define time_t __kernel_time_t
|
2013-09-06 22:20:01 +08:00
|
|
|
// This header seems to contain the definitions of _kernel_ stat* structs.
|
|
|
|
#include <asm/stat.h>
|
2013-11-22 19:01:43 +08:00
|
|
|
#undef ino_t
|
|
|
|
#undef mode_t
|
|
|
|
#undef nlink_t
|
|
|
|
#undef uid_t
|
|
|
|
#undef gid_t
|
|
|
|
#undef off_t
|
2014-01-14 15:38:53 +08:00
|
|
|
#endif
|
2013-11-22 19:01:43 +08:00
|
|
|
|
2013-09-06 22:20:01 +08:00
|
|
|
#include <linux/aio_abi.h>
|
|
|
|
|
|
|
|
#if !SANITIZER_ANDROID
|
2014-07-03 22:20:56 +08:00
|
|
|
#include <sys/statfs.h>
|
2013-09-06 22:20:01 +08:00
|
|
|
#include <linux/perf_event.h>
|
|
|
|
#endif
|
|
|
|
|
2016-09-16 05:02:18 +08:00
|
|
|
using namespace __sanitizer;
|
|
|
|
|
2013-09-06 22:20:01 +08:00
|
|
|
namespace __sanitizer {
|
2014-07-03 22:20:56 +08:00
|
|
|
#if !SANITIZER_ANDROID
|
2013-10-30 08:58:17 +08:00
|
|
|
unsigned struct_statfs64_sz = sizeof(struct statfs64);
|
2014-07-03 22:20:56 +08:00
|
|
|
#endif
|
2013-11-22 17:01:50 +08:00
|
|
|
} // namespace __sanitizer
|
2013-09-06 22:20:01 +08:00
|
|
|
|
2014-06-24 20:08:18 +08:00
|
|
|
#if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__aarch64__)\
|
2016-12-02 16:07:35 +08:00
|
|
|
&& !defined(__mips__) && !defined(__s390__)\
|
|
|
|
&& !defined(__sparc__)
|
2013-11-22 17:01:50 +08:00
|
|
|
COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
|
2013-11-22 19:01:43 +08:00
|
|
|
#endif
|
|
|
|
|
2013-11-22 17:01:50 +08:00
|
|
|
COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
|
2013-11-01 09:20:39 +08:00
|
|
|
|
2013-11-22 17:01:50 +08:00
|
|
|
#if defined(__i386__)
|
|
|
|
COMPILER_CHECK(struct_kernel_stat64_sz == sizeof(struct stat64));
|
2013-09-06 22:20:01 +08:00
|
|
|
#endif
|
|
|
|
|
2013-11-27 17:59:11 +08:00
|
|
|
CHECK_TYPE_SIZE(io_event);
|
2013-11-27 17:10:47 +08:00
|
|
|
CHECK_SIZE_AND_OFFSET(io_event, data);
|
|
|
|
CHECK_SIZE_AND_OFFSET(io_event, obj);
|
|
|
|
CHECK_SIZE_AND_OFFSET(io_event, res);
|
|
|
|
CHECK_SIZE_AND_OFFSET(io_event, res2);
|
2013-11-22 17:01:50 +08:00
|
|
|
|
2013-11-22 17:32:39 +08:00
|
|
|
#if !SANITIZER_ANDROID
|
|
|
|
COMPILER_CHECK(sizeof(struct __sanitizer_perf_event_attr) <=
|
|
|
|
sizeof(struct perf_event_attr));
|
|
|
|
CHECK_SIZE_AND_OFFSET(perf_event_attr, type);
|
|
|
|
CHECK_SIZE_AND_OFFSET(perf_event_attr, size);
|
|
|
|
#endif
|
|
|
|
|
2013-11-22 17:01:50 +08:00
|
|
|
COMPILER_CHECK(iocb_cmd_pread == IOCB_CMD_PREAD);
|
|
|
|
COMPILER_CHECK(iocb_cmd_pwrite == IOCB_CMD_PWRITE);
|
2013-11-27 19:20:55 +08:00
|
|
|
#if !SANITIZER_ANDROID
|
2013-11-27 17:59:11 +08:00
|
|
|
COMPILER_CHECK(iocb_cmd_preadv == IOCB_CMD_PREADV);
|
|
|
|
COMPILER_CHECK(iocb_cmd_pwritev == IOCB_CMD_PWRITEV);
|
2013-11-27 19:20:55 +08:00
|
|
|
#endif
|
2013-09-06 22:20:01 +08:00
|
|
|
|
2013-11-01 09:20:39 +08:00
|
|
|
CHECK_TYPE_SIZE(iocb);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_data);
|
|
|
|
// Skip aio_key, it's weird.
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_lio_opcode);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_reqprio);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_fildes);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_buf);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_nbytes);
|
|
|
|
CHECK_SIZE_AND_OFFSET(iocb, aio_offset);
|
|
|
|
|
2013-09-06 22:20:01 +08:00
|
|
|
#endif // SANITIZER_LINUX
|