-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Add stubs for 'langinfo.h' #106620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jhuber6
wants to merge
1
commit into
llvm:main
Choose a base branch
from
jhuber6:langinfo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- C standard library header langinfo.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_LANGINFO_H | ||
#define LLVM_LIBC_LANGINFO_H | ||
|
||
#include "__llvm-libc-common.h" | ||
|
||
#include "llvm-libc-types/locale_t.h" | ||
#include "llvm-libc-macros/langinfo-macros.h" | ||
|
||
%%public_api() | ||
|
||
#endif // LLVM_LIBC_LANGINFO_H | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,3 +301,9 @@ add_macro_header( | |
HDR | ||
locale-macros.h | ||
) | ||
|
||
add_macro_header( | ||
langinfo_macros | ||
HDR | ||
langinfo-macros.h | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//===-- Definition of macros from langinfo.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_LANGINFO_MACROS_H | ||
#define LLVM_LIBC_MACROS_LANGINFO_MACROS_H | ||
|
||
// TODO: Define these for the C locale. | ||
#define CODESET 0 | ||
|
||
#define D_T_FMT 0 | ||
#define D_FMT 0 | ||
#define T_FMT 0 | ||
#define T_FMT_AMPM 0 | ||
|
||
#define AM_STR 0 | ||
#define PM_STR 0 | ||
|
||
#define DAY_1 0 | ||
#define DAY_2 0 | ||
#define DAY_3 0 | ||
#define DAY_4 0 | ||
#define DAY_5 0 | ||
#define DAY_6 0 | ||
#define DAY_7 0 | ||
|
||
#define ABDAY_1 0 | ||
#define ABDAY_2 0 | ||
#define ABDAY_3 0 | ||
#define ABDAY_4 0 | ||
#define ABDAY_5 0 | ||
#define ABDAY_6 0 | ||
#define ABDAY_7 0 | ||
|
||
#define MON_1 0 | ||
#define MON_2 0 | ||
#define MON_3 0 | ||
#define MON_4 0 | ||
#define MON_5 0 | ||
#define MON_6 0 | ||
#define MON_7 0 | ||
#define MON_8 0 | ||
#define MON_9 0 | ||
#define MON_10 0 | ||
#define MON_11 0 | ||
#define MON_12 0 | ||
|
||
#define ABMON_1 0 | ||
#define ABMON_2 0 | ||
#define ABMON_3 0 | ||
#define ABMON_4 0 | ||
#define ABMON_5 0 | ||
#define ABMON_6 0 | ||
#define ABMON_7 0 | ||
#define ABMON_8 0 | ||
#define ABMON_9 0 | ||
#define ABMON_10 0 | ||
#define ABMON_11 0 | ||
#define ABMON_12 0 | ||
|
||
#define ERA 0 | ||
#define ERA_D_FMT 0 | ||
#define ERA_D_T_FMT 0 | ||
#define ERA_T_FMT 0 | ||
|
||
#define ALT_DIGITS 0 | ||
|
||
#define RADIXCHAR 0 | ||
|
||
#define THOUSEP 0 | ||
|
||
#define YESEXPR 0 | ||
#define NOEXPR 0 | ||
|
||
#define CRNCYSTR 0 | ||
|
||
#endif // LLVM_LIBC_MACROS_LANGINFO_MACROS_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//===-- Definition of type nl_item ----------------------------------------===// | ||
// | ||
// 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_ITEM_H | ||
#define LLVM_LIBC_TYPES_NL_ITEM_H | ||
|
||
typedef int nl_item; | ||
|
||
#endif // LLVM_LIBC_TYPES_NL_ITEM_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
header: langinfo.h | ||
macros: [] | ||
types: [] | ||
enums: [] | ||
objects: [] | ||
functions: | ||
- name: nl_langinfo | ||
standards: | ||
- POSIX | ||
return_type: char * | ||
arguments: | ||
- type: nl_item | ||
- name: nl_langinfo_l | ||
standards: | ||
- POSIX | ||
return_type: char * | ||
arguments: | ||
- type: nl_item | ||
- type: locale_t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ def StdC : StandardSpec<"stdc"> { | |
PtrType TimeTTypePtr = PtrType<TimeTType>; | ||
NamedType ClockT = NamedType<"clock_t">; | ||
NamedType LocaleT = NamedType<"locale_t">; | ||
NamedType NLItem = NamedType<"nl_item">; | ||
|
||
NamedType DivTType = NamedType<"div_t">; | ||
NamedType LDivTType = NamedType<"ldiv_t">; | ||
|
@@ -1754,6 +1755,30 @@ def StdC : StandardSpec<"stdc"> { | |
] // Functions | ||
>; | ||
|
||
HeaderSpec LangInfo = HeaderSpec< | ||
"langinfo.h", | ||
[], | ||
[], // Types | ||
[], // Enumerations | ||
[ | ||
FunctionSpec< | ||
"nl_langinfo", | ||
RetValSpec<CharPtr>, | ||
[ | ||
ArgSpec<NLItem> | ||
] | ||
>, | ||
FunctionSpec< | ||
"nl_langinfo", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be |
||
RetValSpec<CharPtr>, | ||
[ | ||
ArgSpec<NLItem>, | ||
ArgSpec<LocaleT> | ||
] | ||
> | ||
] // Functions | ||
>; | ||
|
||
let Headers = [ | ||
Assert, | ||
CType, | ||
|
@@ -1776,5 +1801,6 @@ def StdC : StandardSpec<"stdc"> { | |
UChar, | ||
WChar, | ||
Locale, | ||
LangInfo, | ||
]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
add_object_library( | ||
nl_langinfo | ||
SRCS | ||
nl_langinfo.cpp | ||
HDRS | ||
nl_langinfo.h | ||
DEPENDS | ||
libc.include.langinfo | ||
libc.include.locale | ||
) | ||
|
||
add_object_library( | ||
nl_langinfo_l | ||
SRCS | ||
nl_langinfo_l.cpp | ||
HDRS | ||
nl_langinfo_l.h | ||
DEPENDS | ||
libc.include.locale | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of nl_langinfo -------------------------------------===// | ||
// | ||
// 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/langinfo/nl_langinfo.h" | ||
|
||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
|
||
LLVM_LIBC_FUNCTION(char *, nl_langinfo, (nl_item)) { | ||
static char EMPTY[] = ""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if these aren't implemented we should provide an error to the user. I'd recommend setting |
||
return EMPTY; | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE_DECL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===-- Implementation header for nl_langinfo -------------------*- 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_LANGINFO_NL_LANGINFO_H | ||
#define LLVM_LIBC_SRC_LANGINFO_NL_LANGINFO_H | ||
|
||
#include "include/llvm-libc-types/nl_item.h" | ||
#include "src/__support/macros/config.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
|
||
char *nl_langinfo(nl_item); | ||
|
||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SRC_LANGINFO_NL_LANGINFO_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- Implementation of nl_langinfo_l -----------------------------------===// | ||
// | ||
// 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/langinfo/nl_langinfo_l.h" | ||
|
||
#include "src/__support/common.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
|
||
LLVM_LIBC_FUNCTION(char *, nl_langinfo_l, (nl_item, locale_t locale)) { | ||
static char EMPTY[] = ""; | ||
return EMPTY; | ||
} | ||
|
||
} // namespace LIBC_NAMESPACE_DECL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===-- Implementation header for nl_langinfo_l -----------------*- 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_LANGINFO_NL_LANGINFO_L_H | ||
#define LLVM_LIBC_SRC_LANGINFO_NL_LANGINFO_L_H | ||
|
||
#include "include/llvm-libc-types/locale_t.h" | ||
#include "include/llvm-libc-types/nl_item.h" | ||
#include "src/__support/macros/config.h" | ||
|
||
namespace LIBC_NAMESPACE_DECL { | ||
|
||
char *nl_langinfo_l(nl_item, locale_t locale); | ||
|
||
} // namespace LIBC_NAMESPACE_DECL | ||
|
||
#endif // LLVM_LIBC_SRC_LANGINFO_NL_LANGINFO_L_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are going to be hardcoded to the default locale, is it worthwhile to just set the obvious ones now? Like
AM_STR
is going to be"AM"
, etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the C locale is most likely going to be the only one we're going to support in LLVM libc so we might as well make it usable right away.