[libc][annex_k] Add errno_t (#163094)
RFC https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685 Add `errno_t` type required by Annex K interface in LLVM libc.
This commit is contained in:
parent
abdcde9bbc
commit
8e06210559
@ -162,6 +162,14 @@ add_proxy_header_library(
|
||||
libc.include.fcntl
|
||||
)
|
||||
|
||||
add_proxy_header_library(
|
||||
errno_t
|
||||
HDRS
|
||||
errno_t.h
|
||||
FULL_BUILD_DEPENDS
|
||||
libc.include.llvm-libc-types.errno_t
|
||||
)
|
||||
|
||||
add_proxy_header_library(
|
||||
fenv_t
|
||||
HDRS
|
||||
|
||||
30
libc/hdr/types/errno_t.h
Normal file
30
libc/hdr/types/errno_t.h
Normal file
@ -0,0 +1,30 @@
|
||||
//===-- Proxy for errno_t -------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIBC_HDR_TYPES_ERRNO_T_H
|
||||
#define LLVM_LIBC_HDR_TYPES_ERRNO_T_H
|
||||
|
||||
#ifndef __STDC_WANT_LIB_EXT1__
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
#endif
|
||||
|
||||
#ifdef LIBC_FULL_BUILD
|
||||
|
||||
#include "include/llvm-libc-types/errno_t.h"
|
||||
|
||||
#else // Overlay mode
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#endif // LIBC_FULL_BUILD
|
||||
|
||||
#ifdef __STDC_WANT_LIB_EXT1__
|
||||
#undef __STDC_WANT_LIB_EXT1__
|
||||
#endif
|
||||
|
||||
#endif // LLVM_LIBC_HDR_TYPES_ERRNO_T_H
|
||||
@ -318,6 +318,7 @@ add_header_macro(
|
||||
DEPENDS
|
||||
.llvm-libc-macros.generic_error_number_macros
|
||||
.llvm-libc-macros.error_number_macros
|
||||
.llvm-libc-types.errno_t
|
||||
)
|
||||
|
||||
add_header_macro(
|
||||
|
||||
@ -5,7 +5,8 @@ standards:
|
||||
- Linux
|
||||
- POSIX
|
||||
macros: []
|
||||
types: []
|
||||
types:
|
||||
- type_name: errno_t
|
||||
enums: []
|
||||
objects: []
|
||||
functions: []
|
||||
|
||||
@ -29,6 +29,7 @@ add_header(double_t HDR double_t.h)
|
||||
add_header(DIR HDR DIR.h)
|
||||
add_header(dev_t HDR dev_t.h)
|
||||
add_header(div_t HDR div_t.h)
|
||||
add_header(errno_t HDR errno_t.h DEPENDS libc.include.llvm-libc-macros.annex_k_macros)
|
||||
add_header(ldiv_t HDR ldiv_t.h)
|
||||
add_header(lldiv_t HDR lldiv_t.h)
|
||||
add_header(FILE HDR FILE.h)
|
||||
|
||||
26
libc/include/llvm-libc-types/errno_t.h
Normal file
26
libc/include/llvm-libc-types/errno_t.h
Normal file
@ -0,0 +1,26 @@
|
||||
//===-- Definition of type errno_t ----------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
|
||||
#define LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
|
||||
|
||||
#include "../llvm-libc-macros/annex-k-macros.h"
|
||||
|
||||
// LIBC_HAS_ANNEX_K is used to check whether C11 Annex K (the optional
|
||||
// “Bounds-checking interfaces”) is enabled in this libc implementation. Annex K
|
||||
// introduces additional types and functions, including `errno_t` (a typedef
|
||||
// used by the *_s functions). Since `errno_t` is *not defined* in the standard
|
||||
// library unless Annex K is enabled, we must guard any code that uses it with
|
||||
// LIBC_HAS_ANNEX_K.
|
||||
#ifdef LIBC_HAS_ANNEX_K
|
||||
|
||||
typedef int errno_t;
|
||||
|
||||
#endif // LIBC_HAS_ANNEX_K
|
||||
|
||||
#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_TYPES_ERRNO_T_H
|
||||
Loading…
x
Reference in New Issue
Block a user