[libc-commits] [libc] [libc] Add __isoc99_fscanf alias. (PR #213125)

via libc-commits libc-commits at lists.llvm.org
Sat Aug 1 09:48:39 PDT 2026


https://github.com/lntue updated https://github.com/llvm/llvm-project/pull/213125

>From 1370b6876395ff3876fd4391280e593a5c2d77ff Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Thu, 30 Jul 2026 19:59:22 +0000
Subject: [PATCH 1/9] [libc] Add __iso99_fscanf alias.

---
 libc/src/__support/common.h         | 17 +++++++++++++++++
 libc/src/stdio/baremetal/fscanf.cpp |  5 +++++
 2 files changed, 22 insertions(+)

diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h
index d90fe7b8ae98d..e946ee4e0fb20 100644
--- a/libc/src/__support/common.h
+++ b/libc/src/__support/common.h
@@ -56,17 +56,34 @@
       __##name##_impl__ asm(c_alias);                                          \
   decltype(LIBC_NAMESPACE::name) name [[gnu::alias(c_alias)]];                 \
   type __##name##_impl__ arglist
+
+#define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)                          \
+  extern "C" decltype(LIBC_NAMESPACE::name) c_alias [[gnu::alias(#name)]];     \
+  static_assert(true, "Require semicolon.")
+
 #else // __APPLE__
 #define LLVM_LIBC_FUNCTION_IMPL_4(type, name, arglist, c_alias)                \
   LLVM_LIBC_ATTR(name)                                                         \
   LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) name asm(             \
       "_" c_alias);                                                            \
   type name arglist
+
+// clang-format off
+#define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)                          \
+  asm(".text\n"                                                                \
+      ".global " "_" #c_alias "\n"                                             \
+      ".type " "_" #c_alias ", @function\n"                                    \
+      "_" #c_alias " = " "_" #name "\n");                                      \
+  static_assert(true, "Require semicolon.")
+// clang-format on
 #endif // __APPLE__
 
 #else  // LIBC_COPT_PUBLIC_PACKAGING
 #define LLVM_LIBC_FUNCTION_IMPL_4(type, name, arglist, c_alias)                \
   type name arglist
+
+#define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)
+
 #endif // LIBC_COPT_PUBLIC_PACKAGING
 
 #define LLVM_LIBC_FUNCTION_IMPL_3(type, name, arglist)                         \
diff --git a/libc/src/stdio/baremetal/fscanf.cpp b/libc/src/stdio/baremetal/fscanf.cpp
index eb8b2326ad6b7..d20dd51cce657 100644
--- a/libc/src/stdio/baremetal/fscanf.cpp
+++ b/libc/src/stdio/baremetal/fscanf.cpp
@@ -36,3 +36,8 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#if ...
+// comments...
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
+#endif

>From 7f08fc197cdad2dd50721f9309f524c17d93c9ce Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Fri, 31 Jul 2026 14:58:58 +0000
Subject: [PATCH 2/9] Specify guard.

---
 libc/src/stdio/baremetal/fscanf.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libc/src/stdio/baremetal/fscanf.cpp b/libc/src/stdio/baremetal/fscanf.cpp
index d20dd51cce657..36ecd27ea0e98 100644
--- a/libc/src/stdio/baremetal/fscanf.cpp
+++ b/libc/src/stdio/baremetal/fscanf.cpp
@@ -37,7 +37,6 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#if ...
-// comments...
+#ifdef LIBC_STDIO_ADD_ISO99_FSCANF
 LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
-#endif
+#endif // LIBC_STDIO_ADD_ISO99_FSCANF

>From ab8b308fef4f90fa8616671b72394ec644e3e5b5 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Fri, 31 Jul 2026 21:47:45 +0000
Subject: [PATCH 3/9] Add config flag.

---
 libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 4 ++++
 libc/config/config.json                             | 4 ++++
 libc/src/stdio/baremetal/fscanf.cpp                 | 4 ++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 600df74f552b0..3e9755c221c07 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -193,6 +193,10 @@ function(_get_compile_options_from_config output_var)
     list(APPEND config_options "-DLIBC_COPT_USE_C_ASSERT")
   endif()
 
+  if(LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES)
+    list(APPEND config_options "-DLIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES")
+  endif()
+
   set(${output_var} ${config_options} PARENT_SCOPE)
 endfunction(_get_compile_options_from_config)
 
diff --git a/libc/config/config.json b/libc/config/config.json
index d576d7d14e4af..94fef76a74799 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -73,6 +73,10 @@
     "LIBC_CONF_SCANF_DISABLE_INDEX_MODE": {
       "value": false,
       "doc": "Disable index mode in the scanf format string."
+    },
+    "LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES": {
+      "value": false,
+      "doc": "Add __iso99_* aliases for scanf's functions."
     }
   },
   "str_to_float": {
diff --git a/libc/src/stdio/baremetal/fscanf.cpp b/libc/src/stdio/baremetal/fscanf.cpp
index 36ecd27ea0e98..0ea3d97230269 100644
--- a/libc/src/stdio/baremetal/fscanf.cpp
+++ b/libc/src/stdio/baremetal/fscanf.cpp
@@ -37,6 +37,6 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#ifdef LIBC_STDIO_ADD_ISO99_FSCANF
+#ifdef LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
 LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
-#endif // LIBC_STDIO_ADD_ISO99_FSCANF
+#endif // LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES

>From 48062410e662154961d997f089e88bff7c0b1bdb Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Fri, 31 Jul 2026 21:54:27 +0000
Subject: [PATCH 4/9] Update generic/fscanf.cpp instead of
 baremetal/fscanf.cpp.

---
 libc/src/stdio/baremetal/fscanf.cpp | 4 ----
 libc/src/stdio/generic/fscanf.cpp   | 4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/src/stdio/baremetal/fscanf.cpp b/libc/src/stdio/baremetal/fscanf.cpp
index 0ea3d97230269..eb8b2326ad6b7 100644
--- a/libc/src/stdio/baremetal/fscanf.cpp
+++ b/libc/src/stdio/baremetal/fscanf.cpp
@@ -36,7 +36,3 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
-
-#ifdef LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
-LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
-#endif // LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
diff --git a/libc/src/stdio/generic/fscanf.cpp b/libc/src/stdio/generic/fscanf.cpp
index 94b843978749e..570656f7b9f4f 100644
--- a/libc/src/stdio/generic/fscanf.cpp
+++ b/libc/src/stdio/generic/fscanf.cpp
@@ -34,3 +34,7 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
+#endif // LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES

>From 4f5c8ea298c31959865f3a429f311f5c487db10b Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 1 Aug 2026 00:23:47 +0000
Subject: [PATCH 5/9] Enable LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES on Linux
 overlay mode by default.

---
 libc/CMakeLists.txt                 | 5 +++++
 libc/cmake/modules/LibcConfig.cmake | 4 +++-
 libc/config/linux/config.json       | 5 ++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 3aa975ba51416..b33ff3f239ccf 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -152,6 +152,11 @@ if(LIBC_TARGET_OS_IS_GPU)
 endif()
 
 option(LLVM_LIBC_FULL_BUILD "Build and test LLVM libc as if it is the full libc" ${default_to_full_build})
+if(LLVM_LIBC_FULL_BUILD)
+  set(LLVM_LIBC_OVERLAY OFF)
+else()
+  set(LLVM_LIBC_OVERLAY ON)
+endif()
 option(LLVM_LIBC_IMPLEMENTATION_DEFINED_TEST_BEHAVIOR "Build LLVM libc tests assuming our implementation-defined behavior" ON)
 option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" OFF)
 option(LLVM_LIBC_ALL_HEADERS "Outputs all functions in header files, regardless of whether they are enabled on this target" OFF)
diff --git a/libc/cmake/modules/LibcConfig.cmake b/libc/cmake/modules/LibcConfig.cmake
index 19bdf44d96bfc..dd6e3cf49375c 100644
--- a/libc/cmake/modules/LibcConfig.cmake
+++ b/libc/cmake/modules/LibcConfig.cmake
@@ -37,7 +37,9 @@ function(read_libc_config config_file opt_list)
     DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     PROPERTY CMAKE_CONFIGURE_DEPENDS ${config_file})
 
-  file(READ ${config_file} json_config)
+  file(READ ${config_file} json_config_raw)
+  # Expand all CMake variables in the JSON string first
+  string(CONFIGURE "${json_config_raw}" json_config)
   string(JSON group_count ERROR_VARIABLE json_error LENGTH ${json_config})
   if(json_error)
     message(FATAL_ERROR "${config_file}: ${json_error}")
diff --git a/libc/config/linux/config.json b/libc/config/linux/config.json
index a3676986721b4..0f22d976ba668 100644
--- a/libc/config/linux/config.json
+++ b/libc/config/linux/config.json
@@ -5,6 +5,9 @@
     },
     "LIBC_CONF_FIND_FIRST_CHARACTER_IMPL": {
       "value": "word"
-    }
+    },
+    "LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES": {
+      "value": "${LLVM_LIBC_OVERLAY}"
+    }    
   }
 }

>From e414de53db9c4541ef7387f804686f8095c7a4d3 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 1 Aug 2026 00:27:32 +0000
Subject: [PATCH 6/9] Change _ISO99_ to _ISOC99_.

---
 libc/cmake/modules/LLVMLibCCompileOptionRules.cmake | 4 ++--
 libc/config/config.json                             | 2 +-
 libc/config/linux/config.json                       | 2 +-
 libc/src/stdio/generic/fscanf.cpp                   | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 3e9755c221c07..101d14de557e3 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -193,8 +193,8 @@ function(_get_compile_options_from_config output_var)
     list(APPEND config_options "-DLIBC_COPT_USE_C_ASSERT")
   endif()
 
-  if(LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES)
-    list(APPEND config_options "-DLIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES")
+  if(LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES)
+    list(APPEND config_options "-DLIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES")
   endif()
 
   set(${output_var} ${config_options} PARENT_SCOPE)
diff --git a/libc/config/config.json b/libc/config/config.json
index 94fef76a74799..0cb7965d01196 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -74,7 +74,7 @@
       "value": false,
       "doc": "Disable index mode in the scanf format string."
     },
-    "LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES": {
+    "LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES": {
       "value": false,
       "doc": "Add __iso99_* aliases for scanf's functions."
     }
diff --git a/libc/config/linux/config.json b/libc/config/linux/config.json
index 0f22d976ba668..2d9bb739c58b6 100644
--- a/libc/config/linux/config.json
+++ b/libc/config/linux/config.json
@@ -6,7 +6,7 @@
     "LIBC_CONF_FIND_FIRST_CHARACTER_IMPL": {
       "value": "word"
     },
-    "LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES": {
+    "LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES": {
       "value": "${LLVM_LIBC_OVERLAY}"
     }    
   }
diff --git a/libc/src/stdio/generic/fscanf.cpp b/libc/src/stdio/generic/fscanf.cpp
index 570656f7b9f4f..1dcf9c058af0a 100644
--- a/libc/src/stdio/generic/fscanf.cpp
+++ b/libc/src/stdio/generic/fscanf.cpp
@@ -35,6 +35,6 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#ifdef LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
+#ifdef LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES
 LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
-#endif // LIBC_CONF_SCANF_PROVIDE_ISO99_ALIASES
+#endif // LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES

>From 550de55341e03f69a57ca5f535feb61c01113436 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 1 Aug 2026 00:54:50 +0000
Subject: [PATCH 7/9] Fix require ;.

---
 libc/src/__support/common.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h
index e946ee4e0fb20..64ef73a8d56b4 100644
--- a/libc/src/__support/common.h
+++ b/libc/src/__support/common.h
@@ -58,8 +58,7 @@
   type __##name##_impl__ arglist
 
 #define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)                          \
-  extern "C" decltype(LIBC_NAMESPACE::name) c_alias [[gnu::alias(#name)]];     \
-  static_assert(true, "Require semicolon.")
+  extern "C" decltype(LIBC_NAMESPACE::name) c_alias [[gnu::alias(#name)]]
 
 #else // __APPLE__
 #define LLVM_LIBC_FUNCTION_IMPL_4(type, name, arglist, c_alias)                \
@@ -73,8 +72,7 @@
   asm(".text\n"                                                                \
       ".global " "_" #c_alias "\n"                                             \
       ".type " "_" #c_alias ", @function\n"                                    \
-      "_" #c_alias " = " "_" #name "\n");                                      \
-  static_assert(true, "Require semicolon.")
+      "_" #c_alias " = " "_" #name "\n")
 // clang-format on
 #endif // __APPLE__
 
@@ -82,7 +80,8 @@
 #define LLVM_LIBC_FUNCTION_IMPL_4(type, name, arglist, c_alias)                \
   type name arglist
 
-#define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)
+#define LLVM_LIBC_ADD_FUNCTION_C_ALIAS(name, c_alias)                          \
+  static_assert(true, "Require semicolon.")
 
 #endif // LIBC_COPT_PUBLIC_PACKAGING
 

>From 54abad412ca0509d3b4f8b87e9541e8ced47aeaa Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 1 Aug 2026 02:01:54 +0000
Subject: [PATCH 8/9] Address comments.

---
 libc/cmake/modules/LLVMLibCCompileOptionRules.cmake |  2 +-
 libc/config/config.json                             |  2 +-
 libc/config/linux/config.json                       | 10 ++++++----
 libc/src/stdio/generic/fscanf.cpp                   |  4 ++--
 libc/src/stdio/generic/scanf.cpp                    |  4 ++++
 libc/src/stdio/generic/vfscanf.cpp                  |  4 ++++
 libc/src/stdio/generic/vscanf.cpp                   |  4 ++++
 7 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 101d14de557e3..4f8f3f5d13b82 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -194,7 +194,7 @@ function(_get_compile_options_from_config output_var)
   endif()
 
   if(LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES)
-    list(APPEND config_options "-DLIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES")
+    list(APPEND config_options "-DLIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES")
   endif()
 
   set(${output_var} ${config_options} PARENT_SCOPE)
diff --git a/libc/config/config.json b/libc/config/config.json
index 0cb7965d01196..01909fb9abf8a 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -76,7 +76,7 @@
     },
     "LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES": {
       "value": false,
-      "doc": "Add __iso99_* aliases for scanf's functions."
+      "doc": "Add __isoc99_* aliases for scanf's functions."
     }
   },
   "str_to_float": {
diff --git a/libc/config/linux/config.json b/libc/config/linux/config.json
index 2d9bb739c58b6..260ec3b43f72c 100644
--- a/libc/config/linux/config.json
+++ b/libc/config/linux/config.json
@@ -1,13 +1,15 @@
 {
+  "scanf": {
+    "LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES": {
+      "value": "${LLVM_LIBC_OVERLAY}"
+    }
+  },
   "string": {
     "LIBC_CONF_STRING_LENGTH_IMPL": {
       "value": "clang_vector"
     },
     "LIBC_CONF_FIND_FIRST_CHARACTER_IMPL": {
       "value": "word"
-    },
-    "LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES": {
-      "value": "${LLVM_LIBC_OVERLAY}"
-    }    
+    }
   }
 }
diff --git a/libc/src/stdio/generic/fscanf.cpp b/libc/src/stdio/generic/fscanf.cpp
index 1dcf9c058af0a..f0f6c627b5054 100644
--- a/libc/src/stdio/generic/fscanf.cpp
+++ b/libc/src/stdio/generic/fscanf.cpp
@@ -35,6 +35,6 @@ LLVM_LIBC_FUNCTION(int, fscanf,
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#ifdef LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
 LLVM_LIBC_ADD_FUNCTION_C_ALIAS(fscanf, __isoc99_fscanf);
-#endif // LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
diff --git a/libc/src/stdio/generic/scanf.cpp b/libc/src/stdio/generic/scanf.cpp
index 37b7ee7d7ca36..f0607c6c8b6ab 100644
--- a/libc/src/stdio/generic/scanf.cpp
+++ b/libc/src/stdio/generic/scanf.cpp
@@ -40,3 +40,7 @@ LLVM_LIBC_FUNCTION(int, scanf, (const char *__restrict format, ...)) {
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(scanf, __isoc99_scanf);
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
diff --git a/libc/src/stdio/generic/vfscanf.cpp b/libc/src/stdio/generic/vfscanf.cpp
index 220576522d0fd..5976e61b857c5 100644
--- a/libc/src/stdio/generic/vfscanf.cpp
+++ b/libc/src/stdio/generic/vfscanf.cpp
@@ -32,3 +32,7 @@ LLVM_LIBC_FUNCTION(int, vfscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(vfscanf, __isoc99_vfscanf);
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
diff --git a/libc/src/stdio/generic/vscanf.cpp b/libc/src/stdio/generic/vscanf.cpp
index 215ba790b241c..ea82c5edb729a 100644
--- a/libc/src/stdio/generic/vscanf.cpp
+++ b/libc/src/stdio/generic/vscanf.cpp
@@ -39,3 +39,7 @@ LLVM_LIBC_FUNCTION(int, vscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(vscanf, __isoc99_vscanf);
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES

>From 37ec257dba15b6b9a76daff7760200cb948da08e Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Sat, 1 Aug 2026 16:48:10 +0000
Subject: [PATCH 9/9] Update sscanf and vsscanf.

---
 libc/src/stdio/sscanf.cpp  | 4 ++++
 libc/src/stdio/vsscanf.cpp | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libc/src/stdio/sscanf.cpp b/libc/src/stdio/sscanf.cpp
index 9fa2ede461595..85f7a3a2869f5 100644
--- a/libc/src/stdio/sscanf.cpp
+++ b/libc/src/stdio/sscanf.cpp
@@ -37,3 +37,7 @@ LLVM_LIBC_FUNCTION(int, sscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(sscanf, __isoc99_sscanf);
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
diff --git a/libc/src/stdio/vsscanf.cpp b/libc/src/stdio/vsscanf.cpp
index 7c7240a102b5a..f46754a48e97a 100644
--- a/libc/src/stdio/vsscanf.cpp
+++ b/libc/src/stdio/vsscanf.cpp
@@ -29,3 +29,7 @@ LLVM_LIBC_FUNCTION(int, vsscanf,
 }
 
 } // namespace LIBC_NAMESPACE_DECL
+
+#ifdef LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES
+LLVM_LIBC_ADD_FUNCTION_C_ALIAS(vsscanf, __isoc99_vsscanf);
+#endif // LIBC_COPT_SCANF_PROVIDE_ISOC99_ALIASES



More information about the libc-commits mailing list