Path: blob/main/contrib/llvm-project/libc/include/__llvm-libc-common.h
213726 views
//===-- Common definitions for LLVM-libc public header files --------------===//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 _LLVM_LIBC_COMMON_H9#define _LLVM_LIBC_COMMON_H1011#define __LLVM_LIBC__ 11213#ifdef __cplusplus1415#undef __BEGIN_C_DECLS16#define __BEGIN_C_DECLS extern "C" {1718#undef __END_C_DECLS19#define __END_C_DECLS }2021// Standard C++ doesn't have C99 restrict but GNU C++ has it with __ spelling.22#undef __restrict23#ifndef __GNUC__24#define __restrict25#endif2627#undef _Noreturn28#define _Noreturn [[noreturn]]2930#undef _Alignas31#define _Alignas alignas3233#undef _Static_assert34#define _Static_assert static_assert3536#undef _Alignof37#define _Alignof alignof3839#undef _Thread_local40#define _Thread_local thread_local4142#undef __NOEXCEPT43#if __cplusplus >= 201103L44#define __NOEXCEPT noexcept45#else46#define __NOEXCEPT throw()47#endif4849// This macro serves as a generic cast implementation for use in both C and C++,50// similar to `__BIONIC_CAST` in Android.51#undef __LLVM_LIBC_CAST52#define __LLVM_LIBC_CAST(cast, type, value) (cast<type>(value))5354#else // not __cplusplus5556#undef __BEGIN_C_DECLS57#define __BEGIN_C_DECLS5859#undef __END_C_DECLS60#define __END_C_DECLS6162#undef __restrict63#if __STDC_VERSION__ >= 199901L64// C99 and above support the restrict keyword.65#define __restrict restrict66#elif !defined(__GNUC__)67// GNU-compatible compilers accept the __ spelling in all modes.68// Otherwise, omit the qualifier for pure C89 compatibility.69#define __restrict70#endif7172#undef _Noreturn73#if __STDC_VERSION__ >= 201112L74// In C11 and later, _Noreturn is a keyword.75#elif defined(__GNUC__)76// GNU-compatible compilers have an equivalent attribute.77#define _Noreturn __attribute__((__noreturn__))78#else79#define _Noreturn80#endif8182#undef __NOEXCEPT83#ifdef __GNUC__84#define __NOEXCEPT __attribute__((__nothrow__))85#else86#define __NOEXCEPT87#endif8889#undef _Returns_twice90#define _Returns_twice __attribute__((returns_twice))9192#undef __LLVM_LIBC_CAST93#define __LLVM_LIBC_CAST(cast, type, value) ((type)(value))9495#endif // __cplusplus9697#endif // _LLVM_LIBC_COMMON_H9899100