[libc-commits] [libc] e241964 - [libc] Fix macro definition hermeticity (#114467)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 31 14:42:54 PDT 2024
Author: Michael Jones
Date: 2024-10-31T14:42:50-07:00
New Revision: e241964b9373786f327ce24b440e2a82a3c4eeea
URL: https://github.com/llvm/llvm-project/commit/e241964b9373786f327ce24b440e2a82a3c4eeea
DIFF: https://github.com/llvm/llvm-project/commit/e241964b9373786f327ce24b440e2a82a3c4eeea.diff
LOG: [libc] Fix macro definition hermeticity (#114467)
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.
Added:
Modified:
libc/include/llvm-libc-macros/linux/fcntl-macros.h
libc/test/src/sys/mman/linux/CMakeLists.txt
libc/test/src/sys/mman/linux/shm_test.cpp
Removed:
################################################################################
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;
More information about the libc-commits
mailing list