Path: blob/main/contrib/llvm-project/libc/src/__support/macros/config.h
213799 views
//===-- Portable attributes -------------------------------------*- 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//===----------------------------------------------------------------------===//7// This header file defines a set of macros for checking the presence of8// important compiler and platform features. Such macros can be used to9// produce portable code by parameterizing compilation based on the presence or10// lack of a given feature.1112#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H13#define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H1415// Workaround for compilers that do not support builtin detection.16// FIXME: This is only required for the GPU portion which should be moved.17#ifndef __has_builtin18#define __has_builtin(b) 019#endif2021// Compiler feature-detection.22// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension23#ifdef __has_feature24#define LIBC_HAS_FEATURE(f) __has_feature(f)25#else26#define LIBC_HAS_FEATURE(f) 027#endif2829#ifdef __clang__30// Declare a LIBC_NAMESPACE with hidden visibility. `namespace31// LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions32// for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This33// ensures that all declarations within this namespace have hidden34// visibility, which optimizes codegen for uses of symbols defined in other35// translation units in ways that can be necessary for correctness by avoiding36// dynamic relocations. This does not affect the public C symbols which are37// controlled independently via `LLVM_LIBC_FUNCTION_ATTR`.38#define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE39#else40// TODO(#98548): GCC emits a warning when using the visibility attribute which41// needs to be diagnosed and addressed.42#define LIBC_NAMESPACE_DECL LIBC_NAMESPACE43#endif4445#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H464748