[libc-commits] [libc] [libc] Add a few missing fcntl.h macro. (PR #226810)

via libc-commits libc-commits at lists.llvm.org
Sun Sep 27 10:06:42 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

<details>
<summary>Changes</summary>

* Add a few POSIX-specified symbolic constants to `<fcntl.h>`: `O_RSYNC`,
  `AT_SYMLINK_FOLLOW`, and `F_DUPFD_CLOEXEC`.
* Don't add `_CLOFORK` variants, since those are not supported by Linux.
* List the constants in the `fcntl.yaml` file for posterity.

---
Full diff: https://github.com/llvm/llvm-project/pull/226810.diff


2 Files Affected:

- (modified) libc/include/fcntl.yaml (+76-2) 
- (modified) libc/include/llvm-libc-macros/linux/fcntl-macros.h (+6) 


``````````diff
diff --git a/libc/include/fcntl.yaml b/libc/include/fcntl.yaml
index 849c6247d5786..160e25a304aca 100644
--- a/libc/include/fcntl.yaml
+++ b/libc/include/fcntl.yaml
@@ -2,13 +2,87 @@ header: fcntl.h
 standards:
   - posix
 macros:
+  - macro_name: O_CLOEXEC
+    macro_header: fcntl-macros.h
+  - macro_name: O_CREAT
+    macro_header: fcntl-macros.h
+  - macro_name: O_DIRECTORY
+    macro_header: fcntl-macros.h
+  - macro_name: O_EXCL
+    macro_header: fcntl-macros.h
+  - macro_name: O_NOCTTY
+    macro_header: fcntl-macros.h
+  - macro_name: O_NOFOLLOW
+    macro_header: fcntl-macros.h
+  - macro_name: O_TRUNC
+    macro_header: fcntl-macros.h
+  - macro_name: O_APPEND
+    macro_header: fcntl-macros.h
+  - macro_name: O_DSYNC
+    macro_header: fcntl-macros.h
+  - macro_name: O_NONBLOCK
+    macro_header: fcntl-macros.h
+  - macro_name: O_RSYNC
+    macro_header: fcntl-macros.h
+  - macro_name: O_SYNC
+    macro_header: fcntl-macros.h
+  - macro_name: O_ACCMODE
+    macro_header: fcntl-macros.h
+  - macro_name: O_RDONLY
+    macro_header: fcntl-macros.h
+  - macro_name: O_RDWR
+    macro_header: fcntl-macros.h
+  - macro_name: O_WRONLY
+    macro_header: fcntl-macros.h
   - macro_name: AT_FDCWD
     macro_header: fcntl-macros.h
-  - macro_name: AT_REMOVEDIR
+  - macro_name: AT_EACCESS
     macro_header: fcntl-macros.h
   - macro_name: AT_SYMLINK_NOFOLLOW
     macro_header: fcntl-macros.h
-  - macro_name: AT_EACCESS
+  - macro_name: AT_SYMLINK_FOLLOW
+    macro_header: fcntl-macros.h
+  - macro_name: AT_REMOVEDIR
+    macro_header: fcntl-macros.h
+  - macro_name: F_DUPFD
+    macro_header: fcntl-macros.h
+  - macro_name: F_DUPFD_CLOEXEC
+    macro_header: fcntl-macros.h
+  - macro_name: F_GETFD
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETFD
+    macro_header: fcntl-macros.h
+  - macro_name: F_GETFL
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETFL
+    macro_header: fcntl-macros.h
+  - macro_name: F_GETLK
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETLK
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETLKW
+    macro_header: fcntl-macros.h
+  - macro_name: F_OFD_GETLK
+    macro_header: fcntl-macros.h
+  - macro_name: F_OFD_SETLK
+    macro_header: fcntl-macros.h
+  - macro_name: F_OFD_SETLKW
+    macro_header: fcntl-macros.h
+  - macro_name: F_GETOWN
+    macro_header: fcntl-macros.h
+  - macro_name: F_GETOWN_EX
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETOWN
+    macro_header: fcntl-macros.h
+  - macro_name: F_SETOWN_EX
+    macro_header: fcntl-macros.h
+  - macro_name: FD_CLOEXEC
+    macro_header: fcntl-macros.h
+  - macro_name: F_RDLCK
+    macro_header: fcntl-macros.h
+  - macro_name: F_UNLCK
+    macro_header: fcntl-macros.h
+  - macro_name: F_WRLCK
     macro_header: fcntl-macros.h
   - macro_name: POSIX_FADV_NORMAL
     macro_header: fcntl-macros.h
diff --git a/libc/include/llvm-libc-macros/linux/fcntl-macros.h b/libc/include/llvm-libc-macros/linux/fcntl-macros.h
index 648c4a9ec00da..f21339abfaad7 100644
--- a/libc/include/llvm-libc-macros/linux/fcntl-macros.h
+++ b/libc/include/llvm-libc-macros/linux/fcntl-macros.h
@@ -22,6 +22,7 @@
 #define O_NDELAY O_NONBLOCK
 #define O_PATH 010000000
 #define O_SYNC 004010000
+#define O_RSYNC O_SYNC
 #define O_TRUNC 000001000
 
 #ifdef __aarch64__
@@ -58,6 +59,10 @@
 // should not be followed.
 #define AT_SYMLINK_NOFOLLOW 0x100
 
+// Special flag for functions like linkat to convey that symlinks
+// should be followed.
+#define AT_SYMLINK_FOLLOW 0x400
+
 // Allow empty relative pathname.
 #define AT_EMPTY_PATH 0x1000
 
@@ -82,6 +87,7 @@
 #define F_SETLKW64 14
 #define F_SETOWN_EX 15
 #define F_GETOWN_EX 16
+#define F_DUPFD_CLOEXEC 1030
 
 // Open File Description Locks.
 #define F_OFD_GETLK 36

``````````

</details>


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


More information about the libc-commits mailing list