Skip to content

Commit 14e20ee

Browse files
authoredJul 23, 2024··
[libc] Fix missing default value for errno config (#100175)
Summary: The configs all need default values which targets then override. This one was an empty string which made the logic report an error. The only reason it wasn't a build failure was because of a stray `:`.
1 parent bb60dd3 commit 14e20ee

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed
 

‎libc/cmake/modules/LibcConfig.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function(load_libc_config config_file)
113113
message(FATAL_ERROR ${json_error})
114114
endif()
115115
if(NOT DEFINED ${opt_name})
116-
message(FATAL_ERROR: " Option ${opt_name} defined in ${config_file} is invalid.")
116+
message(FATAL_ERROR " Option ${opt_name} defined in ${config_file} is invalid.")
117117
endif()
118118
if(ARGN)
119119
list(FIND ARGN ${opt_name} optname_exists)

‎libc/config/config.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"errno": {
33
"LIBC_CONF_ERRNO_MODE": {
4-
"value": "",
5-
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM."
4+
"value": "LIBC_ERRNO_MODE_DEFAULT",
5+
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM."
66
}
77
},
88
"printf": {

‎libc/src/errno/libc_errno.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "libc_errno.h"
1010
#include "src/__support/macros/config.h"
1111

12+
// libc uses a fallback default value, either system or thread local.
13+
#define LIBC_ERRNO_MODE_DEFAULT 0
1214
// libc never stores a value; `errno` macro uses get link-time failure.
1315
#define LIBC_ERRNO_MODE_UNDEFINED 1
1416
// libc maintains per-thread state (requires C++ `thread_local` support).
@@ -23,20 +25,23 @@
2325
// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`.
2426
#define LIBC_ERRNO_MODE_SYSTEM 5
2527

26-
#ifndef LIBC_ERRNO_MODE
28+
#if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT
29+
#undef LIBC_ERRNO_MODE
2730
#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
2831
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
2932
#else
3033
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
3134
#endif
3235
#endif // LIBC_ERRNO_MODE
3336

34-
#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
37+
#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_DEFAULT && \
38+
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
3539
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
3640
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \
3741
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
3842
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
3943
#error LIBC_ERRNO_MODE must be one of the following values: \
44+
LIBC_ERRNO_MODE_DEFAULT, \
4045
LIBC_ERRNO_MODE_UNDEFINED, \
4146
LIBC_ERRNO_MODE_THREAD_LOCAL, \
4247
LIBC_ERRNO_MODE_SHARED, \

0 commit comments

Comments
 (0)
Please sign in to comment.