Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/platform.h
35292 views
//===-- platform.h ----------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef SCUDO_PLATFORM_H_9#define SCUDO_PLATFORM_H_1011// Transitive includes of stdint.h specify some of the defines checked below.12#include <stdint.h>1314#if defined(__linux__) && !defined(__TRUSTY__)15#define SCUDO_LINUX 116#else17#define SCUDO_LINUX 018#endif1920// See https://android.googlesource.com/platform/bionic/+/master/docs/defines.md21#if defined(__BIONIC__)22#define SCUDO_ANDROID 123#else24#define SCUDO_ANDROID 025#endif2627#if defined(__Fuchsia__)28#define SCUDO_FUCHSIA 129#else30#define SCUDO_FUCHSIA 031#endif3233#if defined(__TRUSTY__)34#define SCUDO_TRUSTY 135#else36#define SCUDO_TRUSTY 037#endif3839#if defined(__riscv) && (__riscv_xlen == 64)40#define SCUDO_RISCV64 141#else42#define SCUDO_RISCV64 043#endif4445#if defined(__LP64__)46#define SCUDO_WORDSIZE 64U47#else48#define SCUDO_WORDSIZE 32U49#endif5051#if SCUDO_WORDSIZE == 64U52#define FIRST_32_SECOND_64(a, b) (b)53#else54#define FIRST_32_SECOND_64(a, b) (a)55#endif5657#ifndef SCUDO_CAN_USE_PRIMARY6458#define SCUDO_CAN_USE_PRIMARY64 (SCUDO_WORDSIZE == 64U)59#endif6061#ifndef SCUDO_CAN_USE_MTE62#define SCUDO_CAN_USE_MTE (SCUDO_LINUX || SCUDO_TRUSTY)63#endif6465#ifndef SCUDO_ENABLE_HOOKS66#define SCUDO_ENABLE_HOOKS 067#endif6869#ifndef SCUDO_MIN_ALIGNMENT_LOG70// We force malloc-type functions to be aligned to std::max_align_t, but there71// is no reason why the minimum alignment for all other functions can't be 872// bytes. Except obviously for applications making incorrect assumptions.73// TODO(kostyak): define SCUDO_MIN_ALIGNMENT_LOG 374#define SCUDO_MIN_ALIGNMENT_LOG FIRST_32_SECOND_64(3, 4)75#endif7677#if defined(__aarch64__)78#define SCUDO_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 48)79#else80#define SCUDO_MMAP_RANGE_SIZE FIRST_32_SECOND_64(1ULL << 32, 1ULL << 47)81#endif8283// Older gcc have issues aligning to a constexpr, and require an integer.84// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56859 among others.85#if defined(__powerpc__) || defined(__powerpc64__)86#define SCUDO_CACHE_LINE_SIZE 12887#else88#define SCUDO_CACHE_LINE_SIZE 6489#endif9091#define SCUDO_POINTER_FORMAT_LENGTH FIRST_32_SECOND_64(8, 12)9293#endif // SCUDO_PLATFORM_H_949596