Path: blob/main/contrib/llvm-project/libc/src/__support/macros/attributes.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 macros for declaring attributes for functions,8// types, and variables.9//10// These macros are used within llvm-libc and allow the compiler to optimize,11// where applicable, certain function calls.12//13// Most macros here are exposing GCC or Clang features, and are stubbed out for14// other compilers.1516#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H17#define LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H1819#include "properties/architectures.h"2021#ifndef __has_attribute22#define __has_attribute(x) 023#endif2425#define LIBC_INLINE inline26#define LIBC_INLINE_VAR inline27#define LIBC_INLINE_ASM __asm__ __volatile__28#define LIBC_UNUSED __attribute__((unused))2930#ifdef LIBC_TARGET_ARCH_IS_GPU31#define LIBC_THREAD_LOCAL32#else33#define LIBC_THREAD_LOCAL thread_local34#endif3536#if __cplusplus >= 202002L37#define LIBC_CONSTINIT constinit38#elif __has_attribute(__require_constant_initialization__)39#define LIBC_CONSTINIT __attribute__((__require_constant_initialization__))40#else41#define LIBC_CONSTINIT42#endif4344#if defined(__clang__) && __has_attribute(preferred_type)45#define LIBC_PREFERED_TYPE(TYPE) [[clang::preferred_type(TYPE)]]46#else47#define LIBC_PREFERED_TYPE(TYPE)48#endif4950#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H515253