[libc-commits] [libc] 9523e53 - [libc] Add file constants (#230230)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 8 12:48:20 PDT 2026
Author: Michael Jones
Date: 2026-10-08T12:48:13-07:00
New Revision: 9523e53e43ee4f0a87e15893194f07ac455b6a29
URL: https://github.com/llvm/llvm-project/commit/9523e53e43ee4f0a87e15893194f07ac455b6a29
DIFF: https://github.com/llvm/llvm-project/commit/9523e53e43ee4f0a87e15893194f07ac455b6a29.diff
LOG: [libc] Add file constants (#230230)
POSIX defines FILENAME_MAX and FOPEN_MAX, this PR adds values for them.
See:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdio.h.html
Added:
Modified:
libc/include/llvm-libc-macros/stdio-macros.h
libc/include/stdio.yaml
Removed:
################################################################################
diff --git a/libc/include/llvm-libc-macros/stdio-macros.h b/libc/include/llvm-libc-macros/stdio-macros.h
index 192c161b8ec8d9..e419a6aed5bc51 100644
--- a/libc/include/llvm-libc-macros/stdio-macros.h
+++ b/libc/include/llvm-libc-macros/stdio-macros.h
@@ -73,4 +73,15 @@ extern FILE *stderr;
#define TMP_MAX 1000000
#endif
+// match linux/limits.h PATH_MAX
+#ifndef FILENAME_MAX
+#define FILENAME_MAX 4096
+#endif
+
+// Actually a lower bound on how many files we guarantee can be open at once.
+// POSIX says "at least eight", which seems like a fine number to me.
+#ifndef FOPEN_MAX
+#define FOPEN_MAX 8
+#endif
+
#endif // LLVM_LIBC_MACROS_STDIO_MACROS_H
diff --git a/libc/include/stdio.yaml b/libc/include/stdio.yaml
index 1b3aaa2ccea162..1ac0422866fb8c 100644
--- a/libc/include/stdio.yaml
+++ b/libc/include/stdio.yaml
@@ -30,6 +30,10 @@ macros:
macro_header: stdio-macros.h
- macro_name: TMP_MAX
macro_header: stdio-macros.h
+ - macro_name: FILENAME_MAX
+ macro_header: stdio-macros.h
+ - macro_name: FOPEN_MAX
+ macro_header: stdio-macros.h
types:
- type_name: rsize_t
- type_name: size_t
More information about the libc-commits
mailing list