[libc-commits] [libc] [libc][annex_k] Add Annex K support macros. (PR #163100)
Victor Campos via libc-commits
libc-commits at lists.llvm.org
Wed Mar 11 08:48:59 PDT 2026
================
@@ -0,0 +1,27 @@
+//===-- Definition of macros to be used with Annex K functions ------------===//
+//
+// 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_INCLUDE_LLVM_LIBC_MACROS_ANNEX_K_MACROS_H
+#define LLVM_LIBC_INCLUDE_LLVM_LIBC_MACROS_ANNEX_K_MACROS_H
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
+ (defined(__cplusplus) && __cplusplus >= 201703L)
+
+// TODO(bassiounix): Who should def this macro (clang vs libc)? Where?
+// TODO(bassiounix): uncomment/move when Annex K is fully implemented.
+// #define __STDC_LIB_EXT1__ 201112L
+
+#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1
+
+#define LIBC_HAS_ANNEX_K
+
+#endif // defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ == 1
----------------
vhscampos wrote:
I believe the semantics of `LIBC_HAS_ANNEX_K` is unclear.
In your PR for `errno_t` ([link](https://github.com/llvm/llvm-project/pull/163094/changes#diff-1c207e85de1759c3caaa5d72d13b8eadecac26facab0fac81aabc45019912003:~:text=//-,LIBC_HAS_ANNEX_K,-is%20used%20to)), it says that the macro signifies if libc has the Annex K functions. That is, it's an implementation internal macro by which the developer can choose if the Annex K functions are to be included in the build.
However, in this PR here, `LIBC_HAS_ANNEX_K`is defined depending on `__STDC_WANT_LIB_EXT1__`. The latter is a macro to be defined by the user of the C library, not the builder or the developer.
Whether or not libc has the Annex K functions cannot depend on `__STDC_WANT_LIB_EXT1__`.
I think an implementation internal macro doesn't make a lot of sense. Do you believe we should give the developer a way to disable the build of Annex K? IMO if we strive to have the tests always passing, it's fine to build Annex K unconditionally.
https://github.com/llvm/llvm-project/pull/163100
More information about the libc-commits
mailing list