[libc-commits] [libc] [libc] Fix macro definition hermeticity (PR #114467)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Oct 31 14:25:14 PDT 2024
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/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.
>From 88ce25df6a672298b0ba0a3e93db7b81db57878a Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Thu, 31 Oct 2024 14:23:12 -0700
Subject: [PATCH] [libc] Fix macro definition hermeticity
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.
---
libc/include/llvm-libc-macros/linux/fcntl-macros.h | 3 +++
libc/test/src/sys/mman/linux/CMakeLists.txt | 1 +
libc/test/src/sys/mman/linux/shm_test.cpp | 2 +-
3 files changed, 5 insertions(+), 1 deletion(-)
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