| 1 | //===-- interception_type_test.cpp ------------------------------*- C++ -*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file is a part of AddressSanitizer, an address sanity checker. |
| 10 | // |
| 11 | // Compile-time tests of the internal type definitions. |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "interception.h" |
| 15 | #include "sanitizer_common/sanitizer_type_traits.h" |
| 16 | |
| 17 | #if __has_include(<sys/types.h>) |
| 18 | # include <sys/types.h> |
| 19 | #endif |
| 20 | #include <stddef.h> |
| 21 | #include <stdint.h> |
| 22 | |
| 23 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::uptr, ::uintptr_t>::value)); |
| 24 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::sptr, ::intptr_t>::value)); |
| 25 | COMPILER_CHECK((__sanitizer::is_same<__sanitizer::usize, ::size_t>::value)); |
| 26 | COMPILER_CHECK((__sanitizer::is_same<::PTRDIFF_T, ::ptrdiff_t>::value)); |
| 27 | COMPILER_CHECK((__sanitizer::is_same<::SIZE_T, ::size_t>::value)); |
| 28 | #if !SANITIZER_WINDOWS |
| 29 | // No ssize_t on Windows. |
| 30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value)); |
| 31 | #endif |
| 32 | // TODO: These are not actually the same type on Linux (long vs long long) |
| 33 | COMPILER_CHECK(sizeof(::INTMAX_T) == sizeof(intmax_t)); |
| 34 | COMPILER_CHECK(sizeof(::UINTMAX_T) == sizeof(uintmax_t)); |
| 35 | |
| 36 | #if SANITIZER_GLIBC || SANITIZER_ANDROID |
| 37 | COMPILER_CHECK(sizeof(::OFF64_T) == sizeof(off64_t)); |
| 38 | #endif |
| 39 | |
| 40 | // The following are the cases when pread (and friends) is used instead of |
| 41 | // pread64. In those cases we need OFF_T to match off_t. We don't care about the |
| 42 | // rest (they depend on _FILE_OFFSET_BITS setting when building an application). |
| 43 | #if !SANITIZER_WINDOWS && (SANITIZER_ANDROID || !defined _FILE_OFFSET_BITS || \ |
| 44 | _FILE_OFFSET_BITS != 64) |
| 45 | COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t)); |
| 46 | #endif |
| 47 |
