Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ add_macro_header(
locale-macros.h
)

add_macro_header(
nl_types_macros
HDR
nl-types-macros.h
)

add_macro_header(
pthread_macros
HDR
Expand Down
15 changes: 15 additions & 0 deletions libc/include/llvm-libc-macros/nl-types-macros.h
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion libc/include/nl_types.yaml
Original file line number Diff line number Diff line change
@@ -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: []
Expand Down
1 change: 1 addition & 0 deletions libc/test/src/nl_types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions libc/test/src/nl_types/nl_types_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
}
Expand All @@ -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));
}
Loading