diff --git a/libc/config/config.json b/libc/config/config.json index 1b0546980e6ba..cfbe9a43948ea 100644 --- a/libc/config/config.json +++ b/libc/config/config.json @@ -2,7 +2,7 @@ "errno": { "LIBC_CONF_ERRNO_MODE": { "value": "LIBC_ERRNO_MODE_DEFAULT", - "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, LIBC_ERRNO_MODE_SYSTEM, and LIBC_ERRNO_MODE_SYSTEM_INLINE." + "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_INLINE." } }, "threads": { diff --git a/libc/docs/configure.rst b/libc/docs/configure.rst index 95c51b8517e64..e23fc824ce7c8 100644 --- a/libc/docs/configure.rst +++ b/libc/docs/configure.rst @@ -29,7 +29,7 @@ to learn about the defaults for your platform and target. - ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack. - ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience. * **"errno" options** - - ``LIBC_CONF_ERRNO_MODE``: 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, LIBC_ERRNO_MODE_SYSTEM, and LIBC_ERRNO_MODE_SYSTEM_INLINE. + - ``LIBC_CONF_ERRNO_MODE``: 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_INLINE. * **"general" options** - ``LIBC_ADD_NULL_CHECKS``: Add nullptr checks in the library's implementations to some functions for which passing nullptr is undefined behavior. * **"math" options** diff --git a/libc/src/__support/libc_errno.h b/libc/src/__support/libc_errno.h index ab5f6a9c4b9d9..3720cdebd5d2a 100644 --- a/libc/src/__support/libc_errno.h +++ b/libc/src/__support/libc_errno.h @@ -37,18 +37,11 @@ // libc doesn't maintain any internal state, instead the embedder must define // `int *__llvm_libc_errno(void);` C function. #define LIBC_ERRNO_MODE_EXTERNAL 4 -// libc uses system `` `errno` macro directly in the overlay mode; in -// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`. -// In this mode, the public C++ symbol `LIBC_NAMESPACE::libc_errno ` is still -// exported and get redirected to the system `errno` inside its implementation. - -// TODO: Investigate deprecating LIBC_ERRNO_MODE_SYSTEM in favor of -// LIBC_ERRNO_MODE_SYSTEM_INLINE. -// https://github.com/llvm/llvm-project/issues/143454 -#define LIBC_ERRNO_MODE_SYSTEM 5 +// DEPRECATED: #define LIBC_ERRNO_MODE_SYSTEM 5 // In this mode, the libc_errno is simply a macro resolved to `errno` from the // system header . There is no need to link against the -// `libc.src.errno.errno` object. +// `libc.src.errno.errno` object, and public C++ symbol +// `LIBC_NAMESPACE::libc_errno` doesn't exist. #define LIBC_ERRNO_MODE_SYSTEM_INLINE 6 #if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT @@ -56,7 +49,7 @@ #if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING) #define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL #else -#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM +#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM_INLINE #endif #endif // LIBC_ERRNO_MODE @@ -65,7 +58,6 @@ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \ - LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM && \ LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM_INLINE #error LIBC_ERRNO_MODE must be one of the following values: \ LIBC_ERRNO_MODE_DEFAULT, \ @@ -73,7 +65,6 @@ LIBC_ERRNO_MODE_UNDEFINED, \ LIBC_ERRNO_MODE_THREAD_LOCAL, \ LIBC_ERRNO_MODE_SHARED, \ LIBC_ERRNO_MODE_EXTERNAL, \ -LIBC_ERRNO_MODE_SYSTEM, \ LIBC_ERRNO_MODE_SYSTEM_INLINE. #endif diff --git a/libc/src/errno/libc_errno.cpp b/libc/src/errno/libc_errno.cpp index 8ff1eec1b1035..e8960fcd89500 100644 --- a/libc/src/errno/libc_errno.cpp +++ b/libc/src/errno/libc_errno.cpp @@ -46,11 +46,6 @@ Errno::operator int() { return shared_errno; } void Errno::operator=(int a) { *__llvm_libc_errno() = a; } Errno::operator int() { return *__llvm_libc_errno(); } -#elif LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_SYSTEM - -void Errno::operator=(int a) { errno = a; } -Errno::operator int() { return errno; } - #endif // Define the global `libc_errno` instance.