[libc-commits] [libc] [libc] Fix macro definition hermeticity (PR #114467)

via libc-commits libc-commits at lists.llvm.org
Thu Oct 31 14:25:52 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

<details>
<summary>Changes</summary>

Previously shm_test was including <asm-generic/fcntl.h> for the macro
FD_CLOEXEC. This patch adds that macro to the list we have defined, and
redirects the test to use the correct proxy header.


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


3 Files Affected:

- (modified) libc/include/llvm-libc-macros/linux/fcntl-macros.h (+3) 
- (modified) libc/test/src/sys/mman/linux/CMakeLists.txt (+1) 
- (modified) libc/test/src/sys/mman/linux/shm_test.cpp (+1-1) 


``````````diff
diff --git a/libc/include/llvm-libc-macros/linux/fcntl-macros.h b/libc/include/llvm-libc-macros/linux/fcntl-macros.h
index 8ee95863728e15..aec8a0d2da0b52 100644
--- a/libc/include/llvm-libc-macros/linux/fcntl-macros.h
+++ b/libc/include/llvm-libc-macros/linux/fcntl-macros.h
@@ -88,6 +88,9 @@
 // Close on succesful
 #define F_CLOEXEC 1
 
+// Close on execute for fcntl.
+#define FD_CLOEXEC 1
+
 #define F_RDLCK 0
 #define F_WRLCK 1
 #define F_UNLCK 2
diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt
index a432d88ffb90c9..69263986cc574c 100644
--- a/libc/test/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/test/src/sys/mman/linux/CMakeLists.txt
@@ -163,5 +163,6 @@ add_libc_unittest(
     libc.src.unistd.ftruncate
     libc.src.unistd.close
     libc.src.__support.OSUtil.osutil
+    libc.hdr.fcntl_macros
     libc.test.UnitTest.ErrnoSetterMatcher
 )
diff --git a/libc/test/src/sys/mman/linux/shm_test.cpp b/libc/test/src/sys/mman/linux/shm_test.cpp
index 4b8971f670581c..97de705c4c2b06 100644
--- a/libc/test/src/sys/mman/linux/shm_test.cpp
+++ b/libc/test/src/sys/mman/linux/shm_test.cpp
@@ -6,6 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "hdr/fcntl_macros.h"
 #include "src/__support/OSUtil/syscall.h"
 #include "src/fcntl/fcntl.h"
 #include "src/sys/mman/mmap.h"
@@ -16,7 +17,6 @@
 #include "src/unistd/ftruncate.h"
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/LibcTest.h"
-#include <asm-generic/fcntl.h>
 #include <sys/syscall.h>
 
 using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;

``````````

</details>


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


More information about the libc-commits mailing list