mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
[libc] Introduce a config macro file
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#ifndef LLVM_LIBC_SUPPORT_CPP_BIT_H
|
||||
#define LLVM_LIBC_SUPPORT_CPP_BIT_H
|
||||
|
||||
#include "src/__support/macros/properties/compiler.h"
|
||||
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
|
||||
|
||||
namespace __llvm_libc::cpp {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "named_pair.h"
|
||||
#include "src/__support/CPP/type_traits.h"
|
||||
#include "src/__support/macros/attributes.h" // LIBC_INLINE
|
||||
#include "src/__support/macros/properties/compiler.h" // LIBC_HAS_BUILTIN
|
||||
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
|
||||
|
||||
namespace __llvm_libc {
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
add_subdirectory(properties)
|
||||
|
||||
add_header_library(
|
||||
config
|
||||
HDRS
|
||||
config.h
|
||||
)
|
||||
|
||||
add_header_library(
|
||||
attributes
|
||||
HDRS
|
||||
|
||||
43
libc/src/__support/macros/config.h
Normal file
43
libc/src/__support/macros/config.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//===-- Portable attributes -------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
// This header file defines a set of macros for checking the presence of
|
||||
// important compiler and platform features. Such macros can be used to
|
||||
// produce portable code by parameterizing compilation based on the presence or
|
||||
// lack of a given feature.
|
||||
|
||||
#ifndef LLVM_LIBC_SUPPORT_MACROS_CONFIG_H
|
||||
#define LLVM_LIBC_SUPPORT_MACROS_CONFIG_H
|
||||
|
||||
// LIBC_HAS_BUILTIN()
|
||||
//
|
||||
// Checks whether the compiler supports a Clang Feature Checking Macro, and if
|
||||
// so, checks whether it supports the provided builtin function "x" where x
|
||||
// is one of the functions noted in
|
||||
// https://clang.llvm.org/docs/LanguageExtensions.html
|
||||
//
|
||||
// Note: Use this macro to avoid an extra level of #ifdef __has_builtin check.
|
||||
// http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html
|
||||
|
||||
|
||||
// Compiler builtin-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-builtin
|
||||
#ifdef __has_builtin
|
||||
#define LIBC_HAS_BUILTIN(x) __has_builtin(x)
|
||||
#else
|
||||
#define LIBC_HAS_BUILTIN(x) 0
|
||||
#endif
|
||||
|
||||
// Compiler feature-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
||||
#ifdef __has_feature
|
||||
#define LIBC_HAS_FEATURE(f) __has_feature(f)
|
||||
#else
|
||||
#define LIBC_HAS_FEATURE(f) 0
|
||||
#endif
|
||||
|
||||
#endif // LLVM_LIBC_SUPPORT_MACROS_CONFIG_H
|
||||
@@ -21,21 +21,4 @@
|
||||
#define LIBC_COMPILER_IS_MSC
|
||||
#endif
|
||||
|
||||
// Compiler builtin-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-builtin
|
||||
#if defined(LIBC_COMPILER_IS_CLANG) || \
|
||||
(defined(LIBC_COMPILER_IS_GCC) && (__GNUC__ >= 10))
|
||||
#define LIBC_HAS_BUILTIN(BUILTIN) __has_builtin(BUILTIN)
|
||||
#else
|
||||
#define LIBC_HAS_BUILTIN(BUILTIN) 0
|
||||
#endif
|
||||
|
||||
// Compiler feature-detection.
|
||||
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
||||
#if defined(LIBC_COMPILER_IS_CLANG)
|
||||
#define LIBC_HAS_FEATURE(FEATURE) __has_feature(FEATURE)
|
||||
#else
|
||||
#define LIBC_HAS_FEATURE(FEATURE) 0
|
||||
#endif
|
||||
|
||||
#endif // LLVM_LIBC_SUPPORT_MACROS_PROPERTIES_COMPILER_H
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef LLVM_LIBC_SRC_SUPPORT_MACROS_SANITIZER_H
|
||||
#define LLVM_LIBC_SRC_SUPPORT_MACROS_SANITIZER_H
|
||||
|
||||
#include "src/__support/macros/properties/compiler.h"
|
||||
#include "src/__support/macros/config.h" //LIBC_HAS_FEATURE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Properties to check the presence or absence or sanitizers
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "src/__support/CPP/cstddef.h"
|
||||
#include "src/__support/CPP/type_traits.h"
|
||||
#include "src/__support/macros/attributes.h" //LIBC_INLINE
|
||||
#include "src/__support/macros/properties/compiler.h" // LIBC_HAS_BUILTIN
|
||||
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
#include <stdint.h> // intptr_t / uintptr_t
|
||||
|
||||
@@ -78,6 +78,12 @@ libc_support_library(
|
||||
deps = [":libc_root"],
|
||||
)
|
||||
|
||||
libc_support_library(
|
||||
name = "__support_macros_config",
|
||||
hdrs = ["src/__support/macros/config.h"],
|
||||
deps = [":libc_root"],
|
||||
)
|
||||
|
||||
libc_support_library(
|
||||
name = "__support_macros_attributes",
|
||||
hdrs = ["src/__support/macros/attributes.h"],
|
||||
@@ -122,7 +128,7 @@ libc_support_library(
|
||||
name = "__support_cpp_bit",
|
||||
hdrs = ["src/__support/CPP/bit.h"],
|
||||
deps = [
|
||||
":__support_macros_properties_compiler",
|
||||
":__support_macros_config",
|
||||
":libc_root",
|
||||
],
|
||||
)
|
||||
@@ -303,7 +309,7 @@ libc_support_library(
|
||||
deps = [
|
||||
":__support_cpp_type_traits",
|
||||
":__support_macros_attributes",
|
||||
":__support_macros_properties_compiler",
|
||||
":__support_macros_config",
|
||||
":__support_named_pair",
|
||||
":libc_root",
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user