[libc-commits] [libc] [libc][annex_k] Add Annex K support macros. (PR #163100)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Sat Oct 18 07:40:44 PDT 2025


https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/163100

>From dace5512eaa2210318cc44f6c3168cc219c9d386 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Sun, 12 Oct 2025 23:58:37 +0300
Subject: [PATCH 1/2] [libc][annex_k] Add Annex K support macros.

---
 libc/include/llvm-libc-macros/CMakeLists.txt  |  6 +++++
 .../include/llvm-libc-macros/annex-k-macros.h | 26 +++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 libc/include/llvm-libc-macros/annex-k-macros.h

diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index 76c03d913ee12..f41da94e1d726 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -31,6 +31,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
 endif()
 
+add_macro_header(
+  annex_k_macros
+  HDR
+    annex-k-macros.h
+)
+
 add_macro_header(
   assert_macros
   HDR
diff --git a/libc/include/llvm-libc-macros/annex-k-macros.h b/libc/include/llvm-libc-macros/annex-k-macros.h
new file mode 100644
index 0000000000000..c3f845cd77574
--- /dev/null
+++ b/libc/include/llvm-libc-macros/annex-k-macros.h
@@ -0,0 +1,26 @@
+//===-- 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?
+#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
+
+#endif // (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) ||
+       // (defined(__cplusplus) && __cplusplus >= 201703L)
+#endif // LLVM_LIBC_INCLUDE_LLVM_LIBC_MACROS_ANNEX_K_MACROS_H

>From b16ae89e51449935ef0011a65568cfc186f248a9 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Fri, 17 Oct 2025 16:13:13 +0300
Subject: [PATCH 2/2] comment define macro

---
 libc/include/llvm-libc-macros/annex-k-macros.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libc/include/llvm-libc-macros/annex-k-macros.h b/libc/include/llvm-libc-macros/annex-k-macros.h
index c3f845cd77574..7cfb5c1d3060b 100644
--- a/libc/include/llvm-libc-macros/annex-k-macros.h
+++ b/libc/include/llvm-libc-macros/annex-k-macros.h
@@ -13,7 +13,8 @@
     (defined(__cplusplus) && __cplusplus >= 201703L)
 
 // TODO(bassiounix): Who should def this macro (clang vs libc)? Where?
-#define __STDC_LIB_EXT1__ 201112L
+// 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
 



More information about the libc-commits mailing list