diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/include/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libc/include/llvm-libc-macros/CMakeLists.txt | 12 | ||||
-rw-r--r-- | libc/include/llvm-libc-macros/annex-k-macros.h | 27 | ||||
-rw-r--r-- | libc/include/llvm-libc-macros/nl-types-macros.h | 15 | ||||
-rw-r--r-- | libc/include/nl_types.yaml | 6 | ||||
-rw-r--r-- | libc/include/wchar.yaml | 11 | ||||
-rw-r--r-- | libc/src/wchar/wcsnrtombs.cpp | 2 | ||||
-rw-r--r-- | libc/src/wchar/wcsnrtombs.h | 2 | ||||
-rw-r--r-- | libc/src/wchar/wcsrtombs.cpp | 2 | ||||
-rw-r--r-- | libc/src/wchar/wcsrtombs.h | 2 | ||||
-rw-r--r-- | libc/test/src/nl_types/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libc/test/src/nl_types/nl_types_test.cpp | 5 |
12 files changed, 74 insertions, 12 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 09f169b..a277690 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -776,6 +776,7 @@ add_header_macro( ../libc/include/nl_types.yaml nl_types.h DEPENDS + .llvm-libc-macros.nl_types_macros .llvm-libc-types.nl_catd ) diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt index 76c03d9..b16337c 100644 --- a/libc/include/llvm-libc-macros/CMakeLists.txt +++ b/libc/include/llvm-libc-macros/CMakeLists.txt @@ -32,6 +32,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) endif() add_macro_header( + annex_k_macros + HDR + annex-k-macros.h +) + +add_macro_header( assert_macros HDR assert-macros.h @@ -346,6 +352,12 @@ add_macro_header( ) add_macro_header( + nl_types_macros + HDR + nl-types-macros.h +) + +add_macro_header( pthread_macros HDR pthread-macros.h diff --git a/libc/include/llvm-libc-macros/annex-k-macros.h b/libc/include/llvm-libc-macros/annex-k-macros.h new file mode 100644 index 0000000..7cfb5c1 --- /dev/null +++ b/libc/include/llvm-libc-macros/annex-k-macros.h @@ -0,0 +1,27 @@ +//===-- Definition of macros to be used with Annex K functions ------------===// +// +// 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_MACROS_ANNEX_K_MACROS_H +#define LLVM_LIBC_INCLUDE_LLVM_LIBC_MACROS_ANNEX_K_MACROS_H + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) + +// TODO(bassiounix): Who should def this macro (clang vs libc)? Where? +// TODO(bassiounix): uncomment/move when Annex K is fully implemented. +// #define __STDC_LIB_EXT1__ 201112L + +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1 + +#define LIBC_HAS_ANNEX_K + +#endif // defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1 + +#endif // (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || + // (defined(__cplusplus) && __cplusplus >= 201703L) +#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_MACROS_ANNEX_K_MACROS_H diff --git a/libc/include/llvm-libc-macros/nl-types-macros.h b/libc/include/llvm-libc-macros/nl-types-macros.h new file mode 100644 index 0000000..b6d0d35 --- /dev/null +++ b/libc/include/llvm-libc-macros/nl-types-macros.h @@ -0,0 +1,15 @@ +//===-- Definition of macros from nl_types.h ------------------------------===// +// +// 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_MACROS_NL_TYPES_MACROS_H +#define LLVM_LIBC_MACROS_NL_TYPES_MACROS_H + +#define NL_SETD 1 +#define NL_CAT_LOCALE 1 + +#endif // LLVM_LIBC_MACROS_NL_TYPES_MACROS_H diff --git a/libc/include/nl_types.yaml b/libc/include/nl_types.yaml index aecbb44..bdb59a8 100644 --- a/libc/include/nl_types.yaml +++ b/libc/include/nl_types.yaml @@ -1,7 +1,11 @@ header: nl_types.h standards: - posix -macros: [] +macros: + - macro_name: NL_SETD + macro_header: nl-types-macros.h + - macro_name: NL_CAT_LOCALE + macro_header: nl-types-macros.h types: - type_name: nl_catd enums: [] diff --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml index 8178091..b8a0a74 100644 --- a/libc/include/wchar.yaml +++ b/libc/include/wchar.yaml @@ -4,6 +4,7 @@ macros: - macro_name: NULL macro_header: null-macro.h types: + - type_name: FILE - type_name: size_t - type_name: wint_t - type_name: wchar_t @@ -104,9 +105,9 @@ functions: - name: wmemset standards: - stdc - return_type: wchar_t* + return_type: wchar_t * arguments: - - type: wchar_t* + - type: wchar_t * - type: wchar_t - type: size_t - name: wcschr @@ -246,7 +247,7 @@ functions: - type: const wchar_t **__restrict - type: size_t - type: size_t - - type: mbstate_t + - type: mbstate_t *__restrict - name: wcsrtombs standards: - stdc @@ -255,7 +256,7 @@ functions: - type: char *__restrict - type: const wchar_t **__restrict - type: size_t - - type: mbstate_t + - type: mbstate_t *__restrict - name: wcrtomb standards: - stdc @@ -299,7 +300,7 @@ functions: arguments: - type: wchar_t *__restrict - type: const wchar_t *__restrict - - type: wchar_t** __restrict + - type: wchar_t **__restrict - name: wcpcpy standards: - stdc diff --git a/libc/src/wchar/wcsnrtombs.cpp b/libc/src/wchar/wcsnrtombs.cpp index 7f25b24..a344c23 100644 --- a/libc/src/wchar/wcsnrtombs.cpp +++ b/libc/src/wchar/wcsnrtombs.cpp @@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(size_t, wcsnrtombs, (char *__restrict s, const wchar_t **__restrict pwcs, - size_t nwc, size_t len, mbstate_t *ps)) { + size_t nwc, size_t len, mbstate_t *__restrict ps)) { LIBC_CRASH_ON_NULLPTR(pwcs); static internal::mbstate internal_mbstate; auto result = internal::wcsnrtombs( diff --git a/libc/src/wchar/wcsnrtombs.h b/libc/src/wchar/wcsnrtombs.h index bf8add7..2ca42c7 100644 --- a/libc/src/wchar/wcsnrtombs.h +++ b/libc/src/wchar/wcsnrtombs.h @@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL { size_t wcsnrtombs(char *__restrict s, const wchar_t **__restrict pwcs, - size_t nwc, size_t len, mbstate_t *ps); + size_t nwc, size_t len, mbstate_t *__restrict ps); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/wchar/wcsrtombs.cpp b/libc/src/wchar/wcsrtombs.cpp index 9d2508c..0167e85 100644 --- a/libc/src/wchar/wcsrtombs.cpp +++ b/libc/src/wchar/wcsrtombs.cpp @@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(size_t, wcsrtombs, (char *__restrict s, const wchar_t **__restrict pwcs, - size_t n, mbstate_t *ps)) { + size_t n, mbstate_t *__restrict ps)) { LIBC_CRASH_ON_NULLPTR(pwcs); static internal::mbstate internal_mbstate; auto result = internal::wcsnrtombs( diff --git a/libc/src/wchar/wcsrtombs.h b/libc/src/wchar/wcsrtombs.h index d23573f..b85e2c6 100644 --- a/libc/src/wchar/wcsrtombs.h +++ b/libc/src/wchar/wcsrtombs.h @@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL { size_t wcsrtombs(char *__restrict s, const wchar_t **__restrict pwcs, size_t n, - mbstate_t *ps); + mbstate_t *__restrict ps); } // namespace LIBC_NAMESPACE_DECL diff --git a/libc/test/src/nl_types/CMakeLists.txt b/libc/test/src/nl_types/CMakeLists.txt index 4fce637..6bafb32 100644 --- a/libc/test/src/nl_types/CMakeLists.txt +++ b/libc/test/src/nl_types/CMakeLists.txt @@ -7,6 +7,7 @@ add_libc_test( SRCS nl_types_test.cpp DEPENDS + libc.include.llvm-libc-macros.nl_types_macros libc.include.llvm-libc-types.nl_catd libc.src.nl_types.catopen libc.src.nl_types.catclose diff --git a/libc/test/src/nl_types/nl_types_test.cpp b/libc/test/src/nl_types/nl_types_test.cpp index 5ae5c5a..7392200 100644 --- a/libc/test/src/nl_types/nl_types_test.cpp +++ b/libc/test/src/nl_types/nl_types_test.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "include/llvm-libc-macros/nl-types-macros.h" #include "include/llvm-libc-types/nl_catd.h" #include "src/nl_types/catclose.h" #include "src/nl_types/catgets.h" @@ -15,7 +16,7 @@ using LlvmLibcNlTypesTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; TEST_F(LlvmLibcNlTypesTest, CatopenFails) { - ASSERT_EQ(LIBC_NAMESPACE::catopen("/somepath", 0), + ASSERT_EQ(LIBC_NAMESPACE::catopen("/somepath", NL_CAT_LOCALE), reinterpret_cast<nl_catd>(-1)); ASSERT_ERRNO_EQ(EINVAL); } @@ -28,6 +29,6 @@ TEST_F(LlvmLibcNlTypesTest, CatgetsFails) { const char *message = "message"; // Note that we test for pointer equality here, since catgets // is expected to return the input argument as-is. - ASSERT_EQ(LIBC_NAMESPACE::catgets(nullptr, 0, 0, message), + ASSERT_EQ(LIBC_NAMESPACE::catgets(nullptr, NL_SETD, 1, message), const_cast<char *>(message)); } |