[libc-commits] [libc] [libc] Support configurable errno modes (PR #98287)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Wed Jul 10 16:34:01 PDT 2024


================
@@ -1,4 +1,10 @@
 {
+  "errno": {
+    "LIBC_CONF_ERRNO_MODE": {
+      "value": "",
+      "doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_NONE, LIBC_ERRNO_MODE_INTERNAL, LIBC_ERRNO_MODE_EXTERNAL, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_GLOBAL, and LIBC_ERRNO_MODE_SYSTEM."
----------------
frobtech wrote:

I really think this needs to not only enumerate the modes but document what each one means.  That would make this spot the right place to bikeshed the names, none of which I really like so far.

Perhaps:
* `UNDEFINED`: libc never stores a value; `errno` macro uses get link-time failure
* `EXTERNAL_ABI`: embedder must define `int *__llvm_libc_errno(void);` C function
* `THREAD_LOCAL`: libc maintains per-thread state (requires C++ `thread_local` support for libc implementation code)
* `SHARED_ATOMIC`: libc maintains an `atomic_int` used by all threads, contrary to standard C semantics (requires use of atomics in libc implementation code, may produce libcalls an embedder must supply)
* `SHARED_THREAD_UNSAFE`: libc maintains a plain `int` used by all threads, contrary to standard C semantics unless always single-threaded; nothing prevents data races
* `SYSTEM_HEADER`: In overlay mode, system `<errno.h>` `errno` macro is used directly by libc.  In fullbuild mode, effectively the same as `EXTERNAL_ABI` (or perhaps we make it an error to choose this in fullbuild mode).


https://github.com/llvm/llvm-project/pull/98287


More information about the libc-commits mailing list