From 0eeb97f88847bd1e2acad398f3123de278a8da1c Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 00:14:27 +0000 Subject: [PATCH 1/7] [libc] Add header. --- libc/config/linux/x86_64/headers.txt | 1 + libc/include/CMakeLists.txt | 8 ++++++ libc/include/llvm-libc-types/CMakeLists.txt | 1 + libc/include/llvm-libc-types/nl_catd.h | 15 ++++++++++ libc/include/nl_types.yaml | 31 +++++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 libc/include/llvm-libc-types/nl_catd.h create mode 100644 libc/include/nl_types.yaml diff --git a/libc/config/linux/x86_64/headers.txt b/libc/config/linux/x86_64/headers.txt index 0573851fbc20b..d0f62eb104dcc 100644 --- a/libc/config/linux/x86_64/headers.txt +++ b/libc/config/linux/x86_64/headers.txt @@ -19,6 +19,7 @@ set(TARGET_PUBLIC_HEADERS libc.include.malloc libc.include.math libc.include.netinet_in + libc.include.nl_types libc.include.poll libc.include.pthread libc.include.sched diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 81360aac984e0..7eceb679133f1 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -768,6 +768,14 @@ add_header_macro( .llvm-libc-macros.poll-macros ) +add_header_macro( + nl_types + ../libc/include/nl_types.yaml + nl_types.h + DEPENDS + .llvm-libc-types.nl_catd + ) + # UEFI spec references "Uefi.h" so we use that name for compatibility add_header_macro( uefi diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt index 5f506c4d25c9b..a428a0e73aab2 100644 --- a/libc/include/llvm-libc-types/CMakeLists.txt +++ b/libc/include/llvm-libc-types/CMakeLists.txt @@ -46,6 +46,7 @@ add_header(mbstate_t HDR mbstate_t.h) add_header(mode_t HDR mode_t.h) add_header(mtx_t HDR mtx_t.h DEPENDS .__futex_word .__mutex_type) add_header(nfds_t HDR nfds_t.h) +add_header(nl_catd HDR nl_catd.h) add_header(nlink_t HDR nlink_t.h) add_header(off_t HDR off_t.h) add_header(once_flag HDR once_flag.h DEPENDS .__futex_word) diff --git a/libc/include/llvm-libc-types/nl_catd.h b/libc/include/llvm-libc-types/nl_catd.h new file mode 100644 index 0000000000000..f80a2df8c8d2a --- /dev/null +++ b/libc/include/llvm-libc-types/nl_catd.h @@ -0,0 +1,15 @@ +//===-- Definition of nl_catd type ----------------------------------------===// +// +// 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_TYPES_NL_CATD_H +#define LLVM_LIBC_TYPES_NL_CATD_H + +typedef void* nl_catd; + +#endif // LLVM_LIBC_TYPES_NL_CATD_H + diff --git a/libc/include/nl_types.yaml b/libc/include/nl_types.yaml new file mode 100644 index 0000000000000..aecbb44a02224 --- /dev/null +++ b/libc/include/nl_types.yaml @@ -0,0 +1,31 @@ +header: nl_types.h +standards: + - posix +macros: [] +types: + - type_name: nl_catd +enums: [] +objects: [] +functions: + - name: catopen + standards: + - posix + return_type: nl_catd + arguments: + - type: const char * + - type: int + - name: catclose + standards: + - posix + return_type: int + arguments: + - type: nl_catd + - name: catgets + standards: + - posix + return_type: char * + arguments: + - type: nl_catd + - type: int + - type: int + - type: const char* From af673d34da5c7bcacae54dbb02ae53a0bfff5f34 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 02:35:10 +0000 Subject: [PATCH 2/7] add catopen impl --- libc/config/linux/x86_64/entrypoints.txt | 5 ++++ libc/src/CMakeLists.txt | 1 + libc/src/nl_types/CMakeLists.txt | 31 ++++++++++++++++++++++++ libc/src/nl_types/catopen.cpp | 23 ++++++++++++++++++ libc/src/nl_types/catopen.h | 21 ++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 libc/src/nl_types/CMakeLists.txt create mode 100644 libc/src/nl_types/catopen.cpp create mode 100644 libc/src/nl_types/catopen.h diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index b4ab073ec912f..c53fd60e54858 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -1373,6 +1373,11 @@ if(LLVM_LIBC_FULL_BUILD) libc.src.wchar.wcstombs libc.src.wchar.wcsrtombs libc.src.wchar.wcsnrtombs + + # nl_types.h entrypoints + libc.src.nl_types.catopen + libc.src.nl_types.catclose + libc.src.nl_types.catgets ) endif() diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt index d7a1e1f49e6ff..b2afe0a33acee 100644 --- a/libc/src/CMakeLists.txt +++ b/libc/src/CMakeLists.txt @@ -37,6 +37,7 @@ add_subdirectory(arpa) add_subdirectory(assert) add_subdirectory(compiler) add_subdirectory(locale) +add_subdirectory(nl_types) add_subdirectory(search) add_subdirectory(setjmp) add_subdirectory(signal) diff --git a/libc/src/nl_types/CMakeLists.txt b/libc/src/nl_types/CMakeLists.txt new file mode 100644 index 0000000000000..9783e0ecb9678 --- /dev/null +++ b/libc/src/nl_types/CMakeLists.txt @@ -0,0 +1,31 @@ +add_entrypoint_object( + catopen + SRCS + catopen.cpp + HDRS + catopen.h + DEPENDS + libc.include.llvm-libc-types.nl_catd + libc.src.errno.errno +) + +add_entrypoint_object( + catclose + SRCS + catclose.cpp + HDRS + catclose.h + DEPENDS + libc.include.llvm-libc-types.nl_catd +) + +add_entrypoint_object( + catgets + SRCS + catgets.cpp + HDRS + catgets.h + DEPENDS + libc.include.llvm-libc-types.nl_catd +) + diff --git a/libc/src/nl_types/catopen.cpp b/libc/src/nl_types/catopen.cpp new file mode 100644 index 0000000000000..21a6d79880de1 --- /dev/null +++ b/libc/src/nl_types/catopen.cpp @@ -0,0 +1,23 @@ +//===-- Implementation of catopen -----------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "src/nl_types/catopen.h" +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/libc_errno.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(nl_catd, catopen, (const char *name, int flag)) { + // Catalog descriptors are not implemented. Return error regardless of input. + libc_errno = EINVAL; + return static_cast(-1); +} + +} // namespace LIBC_NAMESPACE_DECL + diff --git a/libc/src/nl_types/catopen.h b/libc/src/nl_types/catopen.h new file mode 100644 index 0000000000000..08ff71ac3d32d --- /dev/null +++ b/libc/src/nl_types/catopen.h @@ -0,0 +1,21 @@ +//===-- Implementation header for catopen -----------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_NL_TYPES_CATOPEN_H +#define LLVM_LIBC_SRC_NL_TYPES_CATOPEN_H + +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +nl_catd catopen(const char *name, int flag); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_NL_TYPES_CATOPEN_H From 2b965969f94c3191be24088ad97ddabfd815c977 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 05:20:00 +0000 Subject: [PATCH 3/7] add implementation for catclose and catgets --- libc/src/nl_types/catopen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libc/src/nl_types/catopen.cpp b/libc/src/nl_types/catopen.cpp index 21a6d79880de1..f2755cfd9cdeb 100644 --- a/libc/src/nl_types/catopen.cpp +++ b/libc/src/nl_types/catopen.cpp @@ -8,15 +8,17 @@ #include "src/nl_types/catopen.h" #include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/common.h" #include "src/__support/libc_errno.h" #include "src/__support/macros/config.h" namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(nl_catd, catopen, (const char *name, int flag)) { - // Catalog descriptors are not implemented. Return error regardless of input. +LLVM_LIBC_FUNCTION(nl_catd, catopen, ([[maybe_unused]] const char *name, + [[maybe_unused]] int flag)) { + // Message catalogs are not implemented. Return error regardless of input. libc_errno = EINVAL; - return static_cast(-1); + return reinterpret_cast(-1); } } // namespace LIBC_NAMESPACE_DECL From aab915dccc88b3bb8726f6371afd4a51ed7e0719 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 05:20:22 +0000 Subject: [PATCH 4/7] add implementation for catclose and catgets - 2 --- libc/src/nl_types/catclose.cpp | 23 +++++++++++++++++++++++ libc/src/nl_types/catclose.h | 22 ++++++++++++++++++++++ libc/src/nl_types/catgets.cpp | 26 ++++++++++++++++++++++++++ libc/src/nl_types/catgets.h | 24 ++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 libc/src/nl_types/catclose.cpp create mode 100644 libc/src/nl_types/catclose.h create mode 100644 libc/src/nl_types/catgets.cpp create mode 100644 libc/src/nl_types/catgets.h diff --git a/libc/src/nl_types/catclose.cpp b/libc/src/nl_types/catclose.cpp new file mode 100644 index 0000000000000..2cfc3686f4c7e --- /dev/null +++ b/libc/src/nl_types/catclose.cpp @@ -0,0 +1,23 @@ +//===-- Implementation of catclose ----------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "src/nl_types/catclose.h" +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(int, catclose, ([[maybe_unused]] nl_catd catalog)) { + // Message catalogs are not implemented. Return error regardless of input. + return -1; +} + +} // namespace LIBC_NAMESPACE_DECL + + diff --git a/libc/src/nl_types/catclose.h b/libc/src/nl_types/catclose.h new file mode 100644 index 0000000000000..5cbce4fcfafae --- /dev/null +++ b/libc/src/nl_types/catclose.h @@ -0,0 +1,22 @@ +//===-- Implementation header for catclose ----------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_NL_TYPES_CATCLOSE_H +#define LLVM_LIBC_SRC_NL_TYPES_CATCLOSE_H + +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +int catclose(nl_catd catalog); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_NL_TYPES_CATCLOSE_H + diff --git a/libc/src/nl_types/catgets.cpp b/libc/src/nl_types/catgets.cpp new file mode 100644 index 0000000000000..c2f289c9d7090 --- /dev/null +++ b/libc/src/nl_types/catgets.cpp @@ -0,0 +1,26 @@ +//===-- Implementation of catgets -----------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "src/nl_types/catgets.h" +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/common.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +LLVM_LIBC_FUNCTION(char*, catgets, ([[maybe_unused]] nl_catd catalog, + [[maybe_unused]] int set_number, + [[maybe_unused]] int message_number, + const char* message)) { + // Message catalogs are not implemented. + // Return backup message regardless of input. + return const_cast(message); +} + +} // namespace LIBC_NAMESPACE_DECL + diff --git a/libc/src/nl_types/catgets.h b/libc/src/nl_types/catgets.h new file mode 100644 index 0000000000000..c8b53d7aacaff --- /dev/null +++ b/libc/src/nl_types/catgets.h @@ -0,0 +1,24 @@ +//===-- Implementation header for catgets -----------------------*- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_NL_TYPES_CATGETS_H +#define LLVM_LIBC_SRC_NL_TYPES_CATGETS_H + +#include "include/llvm-libc-types/nl_catd.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { + +char *catgets(nl_catd catalog, int set_number, int message_number, + const char *message); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_NL_TYPES_CATGETS_H + + From 86e6afb3e83b8b11b0375319431c5848a0e62d30 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 05:42:46 +0000 Subject: [PATCH 5/7] Add unit tests for nl_types. --- libc/test/src/CMakeLists.txt | 1 + libc/test/src/nl_types/CMakeLists.txt | 15 +++++++++++ libc/test/src/nl_types/nl_types_test.cpp | 33 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 libc/test/src/nl_types/CMakeLists.txt create mode 100644 libc/test/src/nl_types/nl_types_test.cpp diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt index c576e08e84bc1..0c6ec9f07a9b7 100644 --- a/libc/test/src/CMakeLists.txt +++ b/libc/test/src/CMakeLists.txt @@ -96,6 +96,7 @@ add_subdirectory(assert) add_subdirectory(compiler) add_subdirectory(dirent) add_subdirectory(locale) +add_subdirectory(nl_types) add_subdirectory(signal) add_subdirectory(spawn) diff --git a/libc/test/src/nl_types/CMakeLists.txt b/libc/test/src/nl_types/CMakeLists.txt new file mode 100644 index 0000000000000..520066034aef7 --- /dev/null +++ b/libc/test/src/nl_types/CMakeLists.txt @@ -0,0 +1,15 @@ +add_custom_target(libc-nl-types-tests) + +add_libc_test( + nl_types_test + SUITE + libc-nl-types-tests + SRCS + nl_types_test.cpp + DEPENDS + libc.include.llvm-libc-types.nl_catd + libc.src.nl_types.catopen + libc.src.nl_types.catclose + libc.src.nl_types.catgets +) + diff --git a/libc/test/src/nl_types/nl_types_test.cpp b/libc/test/src/nl_types/nl_types_test.cpp new file mode 100644 index 0000000000000..9c5389203197c --- /dev/null +++ b/libc/test/src/nl_types/nl_types_test.cpp @@ -0,0 +1,33 @@ +//===-- Unittests for nl_types --------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "include/llvm-libc-types/nl_catd.h" +#include "src/nl_types/catclose.h" +#include "src/nl_types/catgets.h" +#include "src/nl_types/catopen.h" +#include "test/UnitTest/ErrnoCheckingTest.h" + +using LlvmLibcNlTypesTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest; + +TEST_F(LlvmLibcNlTypesTest, CatopenFails) { + ASSERT_EQ(LIBC_NAMESPACE::catopen("/somepath", 0), + reinterpret_cast(-1)); + ASSERT_ERRNO_EQ(EINVAL); +} + +TEST_F(LlvmLibcNlTypesTest, CatcloseFails) { + ASSERT_EQ(LIBC_NAMESPACE::catclose(nullptr), -1); +} + +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), + const_cast(message)); +} From 859fc6385f47a60c69596d34e77fcd6d6b6d1fe1 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 06:02:32 +0000 Subject: [PATCH 6/7] fix formatting --- libc/include/llvm-libc-types/nl_catd.h | 3 +-- libc/src/nl_types/catclose.cpp | 2 -- libc/src/nl_types/catclose.h | 1 - libc/src/nl_types/catgets.cpp | 11 +++++------ libc/src/nl_types/catgets.h | 2 -- libc/src/nl_types/catopen.cpp | 6 +++--- libc/test/src/nl_types/CMakeLists.txt | 1 - libc/test/src/nl_types/nl_types_test.cpp | 4 ++-- 8 files changed, 11 insertions(+), 19 deletions(-) diff --git a/libc/include/llvm-libc-types/nl_catd.h b/libc/include/llvm-libc-types/nl_catd.h index f80a2df8c8d2a..ccdb0206713a3 100644 --- a/libc/include/llvm-libc-types/nl_catd.h +++ b/libc/include/llvm-libc-types/nl_catd.h @@ -9,7 +9,6 @@ #ifndef LLVM_LIBC_TYPES_NL_CATD_H #define LLVM_LIBC_TYPES_NL_CATD_H -typedef void* nl_catd; +typedef void *nl_catd; #endif // LLVM_LIBC_TYPES_NL_CATD_H - diff --git a/libc/src/nl_types/catclose.cpp b/libc/src/nl_types/catclose.cpp index 2cfc3686f4c7e..09b521bea3512 100644 --- a/libc/src/nl_types/catclose.cpp +++ b/libc/src/nl_types/catclose.cpp @@ -19,5 +19,3 @@ LLVM_LIBC_FUNCTION(int, catclose, ([[maybe_unused]] nl_catd catalog)) { } } // namespace LIBC_NAMESPACE_DECL - - diff --git a/libc/src/nl_types/catclose.h b/libc/src/nl_types/catclose.h index 5cbce4fcfafae..433020a9dabb0 100644 --- a/libc/src/nl_types/catclose.h +++ b/libc/src/nl_types/catclose.h @@ -19,4 +19,3 @@ int catclose(nl_catd catalog); } // namespace LIBC_NAMESPACE_DECL #endif // LLVM_LIBC_SRC_NL_TYPES_CATCLOSE_H - diff --git a/libc/src/nl_types/catgets.cpp b/libc/src/nl_types/catgets.cpp index c2f289c9d7090..5e634151606f6 100644 --- a/libc/src/nl_types/catgets.cpp +++ b/libc/src/nl_types/catgets.cpp @@ -13,14 +13,13 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(char*, catgets, ([[maybe_unused]] nl_catd catalog, - [[maybe_unused]] int set_number, - [[maybe_unused]] int message_number, - const char* message)) { +LLVM_LIBC_FUNCTION(char *, catgets, + ([[maybe_unused]] nl_catd catalog, + [[maybe_unused]] int set_number, + [[maybe_unused]] int message_number, const char *message)) { // Message catalogs are not implemented. // Return backup message regardless of input. - return const_cast(message); + return const_cast(message); } } // namespace LIBC_NAMESPACE_DECL - diff --git a/libc/src/nl_types/catgets.h b/libc/src/nl_types/catgets.h index c8b53d7aacaff..c909bec44ce8d 100644 --- a/libc/src/nl_types/catgets.h +++ b/libc/src/nl_types/catgets.h @@ -20,5 +20,3 @@ char *catgets(nl_catd catalog, int set_number, int message_number, } // namespace LIBC_NAMESPACE_DECL #endif // LLVM_LIBC_SRC_NL_TYPES_CATGETS_H - - diff --git a/libc/src/nl_types/catopen.cpp b/libc/src/nl_types/catopen.cpp index f2755cfd9cdeb..4f8243449797d 100644 --- a/libc/src/nl_types/catopen.cpp +++ b/libc/src/nl_types/catopen.cpp @@ -14,12 +14,12 @@ namespace LIBC_NAMESPACE_DECL { -LLVM_LIBC_FUNCTION(nl_catd, catopen, ([[maybe_unused]] const char *name, - [[maybe_unused]] int flag)) { +LLVM_LIBC_FUNCTION(nl_catd, catopen, + ([[maybe_unused]] const char *name, + [[maybe_unused]] int flag)) { // Message catalogs are not implemented. Return error regardless of input. libc_errno = EINVAL; return reinterpret_cast(-1); } } // namespace LIBC_NAMESPACE_DECL - diff --git a/libc/test/src/nl_types/CMakeLists.txt b/libc/test/src/nl_types/CMakeLists.txt index 520066034aef7..4fce637baa726 100644 --- a/libc/test/src/nl_types/CMakeLists.txt +++ b/libc/test/src/nl_types/CMakeLists.txt @@ -12,4 +12,3 @@ add_libc_test( libc.src.nl_types.catclose libc.src.nl_types.catgets ) - diff --git a/libc/test/src/nl_types/nl_types_test.cpp b/libc/test/src/nl_types/nl_types_test.cpp index 9c5389203197c..5ae5c5ab28546 100644 --- a/libc/test/src/nl_types/nl_types_test.cpp +++ b/libc/test/src/nl_types/nl_types_test.cpp @@ -25,9 +25,9 @@ TEST_F(LlvmLibcNlTypesTest, CatcloseFails) { } TEST_F(LlvmLibcNlTypesTest, CatgetsFails) { - const char* message = "message"; + 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), - const_cast(message)); + const_cast(message)); } From f8e8c8cb8176779c57b22004e1001dbc6c238ecc Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 21 Oct 2025 16:33:53 +0000 Subject: [PATCH 7/7] add TODOs in function implementations. --- libc/src/nl_types/catclose.cpp | 3 ++- libc/src/nl_types/catgets.cpp | 4 ++-- libc/src/nl_types/catopen.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libc/src/nl_types/catclose.cpp b/libc/src/nl_types/catclose.cpp index 09b521bea3512..1f87900d01134 100644 --- a/libc/src/nl_types/catclose.cpp +++ b/libc/src/nl_types/catclose.cpp @@ -14,7 +14,8 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(int, catclose, ([[maybe_unused]] nl_catd catalog)) { - // Message catalogs are not implemented. Return error regardless of input. + // TODO: Add implementation for message catalogs. For now, return error + // regardless of input. return -1; } diff --git a/libc/src/nl_types/catgets.cpp b/libc/src/nl_types/catgets.cpp index 5e634151606f6..37689777aaef6 100644 --- a/libc/src/nl_types/catgets.cpp +++ b/libc/src/nl_types/catgets.cpp @@ -17,8 +17,8 @@ LLVM_LIBC_FUNCTION(char *, catgets, ([[maybe_unused]] nl_catd catalog, [[maybe_unused]] int set_number, [[maybe_unused]] int message_number, const char *message)) { - // Message catalogs are not implemented. - // Return backup message regardless of input. + // TODO: Add implementation for message catalogs. For now, return backup + // message regardless of input. return const_cast(message); } diff --git a/libc/src/nl_types/catopen.cpp b/libc/src/nl_types/catopen.cpp index 4f8243449797d..393d7601545f2 100644 --- a/libc/src/nl_types/catopen.cpp +++ b/libc/src/nl_types/catopen.cpp @@ -17,7 +17,8 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(nl_catd, catopen, ([[maybe_unused]] const char *name, [[maybe_unused]] int flag)) { - // Message catalogs are not implemented. Return error regardless of input. + // TODO: Add implementation for message catalogs. For now, return error + // regardless of input. libc_errno = EINVAL; return reinterpret_cast(-1); }