1*8975f5c5SAndroid Build Coastguard Worker // Copyright 2023 The Chromium Authors 2*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file. 4*8975f5c5SAndroid Build Coastguard Worker 5*8975f5c5SAndroid Build Coastguard Worker // This file has been copied from //base/compiler_specific.h (and then 6*8975f5c5SAndroid Build Coastguard Worker // significantly trimmed to just the APIs / macros needed by //build/rust/std). 7*8975f5c5SAndroid Build Coastguard Worker // 8*8975f5c5SAndroid Build Coastguard Worker // TODO(crbug.com/40279749): Avoid code duplication / reuse code. 9*8975f5c5SAndroid Build Coastguard Worker 10*8975f5c5SAndroid Build Coastguard Worker #ifndef BUILD_RUST_STD_COMPILER_SPECIFIC_H_ 11*8975f5c5SAndroid Build Coastguard Worker #define BUILD_RUST_STD_COMPILER_SPECIFIC_H_ 12*8975f5c5SAndroid Build Coastguard Worker 13*8975f5c5SAndroid Build Coastguard Worker #include "build/build_config.h" 14*8975f5c5SAndroid Build Coastguard Worker 15*8975f5c5SAndroid Build Coastguard Worker #if defined(COMPILER_MSVC) && !defined(__clang__) 16*8975f5c5SAndroid Build Coastguard Worker #error "Only clang-cl is supported on Windows, see https://crbug.com/988071" 17*8975f5c5SAndroid Build Coastguard Worker #endif 18*8975f5c5SAndroid Build Coastguard Worker 19*8975f5c5SAndroid Build Coastguard Worker #if defined(__has_attribute) 20*8975f5c5SAndroid Build Coastguard Worker #define HAS_ATTRIBUTE(x) __has_attribute(x) 21*8975f5c5SAndroid Build Coastguard Worker #else 22*8975f5c5SAndroid Build Coastguard Worker #define HAS_ATTRIBUTE(x) 0 23*8975f5c5SAndroid Build Coastguard Worker #endif 24*8975f5c5SAndroid Build Coastguard Worker 25*8975f5c5SAndroid Build Coastguard Worker // Annotate a function indicating it should not be inlined. 26*8975f5c5SAndroid Build Coastguard Worker // Use like: 27*8975f5c5SAndroid Build Coastguard Worker // NOINLINE void DoStuff() { ... } 28*8975f5c5SAndroid Build Coastguard Worker #if defined(__clang__) && HAS_ATTRIBUTE(noinline) 29*8975f5c5SAndroid Build Coastguard Worker #define NOINLINE [[clang::noinline]] 30*8975f5c5SAndroid Build Coastguard Worker #elif defined(COMPILER_GCC) && HAS_ATTRIBUTE(noinline) 31*8975f5c5SAndroid Build Coastguard Worker #define NOINLINE __attribute__((noinline)) 32*8975f5c5SAndroid Build Coastguard Worker #elif defined(COMPILER_MSVC) 33*8975f5c5SAndroid Build Coastguard Worker #define NOINLINE __declspec(noinline) 34*8975f5c5SAndroid Build Coastguard Worker #else 35*8975f5c5SAndroid Build Coastguard Worker #define NOINLINE 36*8975f5c5SAndroid Build Coastguard Worker #endif 37*8975f5c5SAndroid Build Coastguard Worker 38*8975f5c5SAndroid Build Coastguard Worker #endif // BUILD_RUST_STD_COMPILER_SPECIFIC_H_ 39