[libc-commits] [libc] 133492f - [libc] add proxy header for struct_sigaction (#96224)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 26 12:46:19 PDT 2024
Author: Schrodinger ZHU Yifan
Date: 2024-06-26T12:46:15-07:00
New Revision: 133492fe18260d4b5ce2d70ff9575fa9c911d090
URL: https://github.com/llvm/llvm-project/commit/133492fe18260d4b5ce2d70ff9575fa9c911d090
DIFF: https://github.com/llvm/llvm-project/commit/133492fe18260d4b5ce2d70ff9575fa9c911d090.diff
LOG: [libc] add proxy header for struct_sigaction (#96224)
Added:
libc/hdr/types/struct_sigaction.h
Modified:
libc/hdr/types/CMakeLists.txt
libc/src/signal/linux/CMakeLists.txt
libc/src/signal/linux/signal.cpp
libc/src/signal/sigaction.h
libc/test/src/signal/CMakeLists.txt
libc/test/src/signal/sigaction_test.cpp
libc/test/src/signal/sigaltstack_test.cpp
Removed:
################################################################################
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 9b3373a0ca390..1cab1d3b812cf 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -126,3 +126,12 @@ add_proxy_header_library(
libc.include.llvm-libc-types.atexithandler_t
libc.include.stdlib
)
+
+add_proxy_header_library(
+ struct_sigaction
+ HDRS
+ struct_sigaction.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.struct_sigaction
+ libc.include.signal
+)
diff --git a/libc/hdr/types/struct_sigaction.h b/libc/hdr/types/struct_sigaction.h
new file mode 100644
index 0000000000000..60f6caeb4af10
--- /dev/null
+++ b/libc/hdr/types/struct_sigaction.h
@@ -0,0 +1,21 @@
+//===-- Proxy for struct sigaction ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_SIGACTION_H
+#define LLVM_LIBC_HDR_TYPES_STRUCT_SIGACTION_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_sigaction.h"
+
+#else
+
+#include <signal.h>
+
+#endif // LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_STRUCT_SIGACTION_H
diff --git a/libc/src/signal/linux/CMakeLists.txt b/libc/src/signal/linux/CMakeLists.txt
index 7606b4b21d3dd..5a6be242ddd94 100644
--- a/libc/src/signal/linux/CMakeLists.txt
+++ b/libc/src/signal/linux/CMakeLists.txt
@@ -60,6 +60,7 @@ add_entrypoint_object(
DEPENDS
.__restore
libc.hdr.types.sigset_t
+ libc.hdr.types.struct_sigaction
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
libc.src.errno.errno
@@ -124,7 +125,7 @@ add_entrypoint_object(
../signal.h
DEPENDS
.sigaction
- libc.include.signal
+ libc.hdr.signal_macros
)
add_entrypoint_object(
diff --git a/libc/src/signal/linux/signal.cpp b/libc/src/signal/linux/signal.cpp
index a517fa73ba8a2..0d5463553eb78 100644
--- a/libc/src/signal/linux/signal.cpp
+++ b/libc/src/signal/linux/signal.cpp
@@ -7,11 +7,9 @@
//===----------------------------------------------------------------------===//
#include "src/signal/signal.h"
-#include "src/signal/sigaction.h"
-
+#include "hdr/signal_macros.h"
#include "src/__support/common.h"
-
-#include <signal.h>
+#include "src/signal/sigaction.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/signal/sigaction.h b/libc/src/signal/sigaction.h
index c36a3ec9fedfa..15b689b7dacc7 100644
--- a/libc/src/signal/sigaction.h
+++ b/libc/src/signal/sigaction.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGACTION_H
#define LLVM_LIBC_SRC_SIGNAL_SIGACTION_H
-#include <signal.h>
+#include "hdr/types/struct_sigaction.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/test/src/signal/CMakeLists.txt b/libc/test/src/signal/CMakeLists.txt
index 56ae6fd2cf617..edbd5c19edab3 100644
--- a/libc/test/src/signal/CMakeLists.txt
+++ b/libc/test/src/signal/CMakeLists.txt
@@ -32,8 +32,8 @@ add_libc_unittest(
SRCS
sigaction_test.cpp
DEPENDS
- libc.include.errno
- libc.include.signal
+ libc.hdr.errno_macros
+ libc.hdr.signal_macros
libc.src.signal.raise
libc.src.signal.sigaction
libc.test.UnitTest.ErrnoSetterMatcher
@@ -119,7 +119,7 @@ add_libc_unittest(
SRCS
sigaltstack_test.cpp
DEPENDS
- libc.include.signal
+ libc.hdr.signal_macros
libc.src.errno.errno
libc.src.signal.raise
libc.src.signal.sigaltstack
diff --git a/libc/test/src/signal/sigaction_test.cpp b/libc/test/src/signal/sigaction_test.cpp
index 262469c7600e3..a12d7989586fe 100644
--- a/libc/test/src/signal/sigaction_test.cpp
+++ b/libc/test/src/signal/sigaction_test.cpp
@@ -6,15 +6,13 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/errno_macros.h"
+#include "hdr/signal_macros.h"
#include "src/signal/raise.h"
#include "src/signal/sigaction.h"
-
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <errno.h>
-#include <signal.h>
-
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
diff --git a/libc/test/src/signal/sigaltstack_test.cpp b/libc/test/src/signal/sigaltstack_test.cpp
index 12bf2bf5e3723..cc392da8f4731 100644
--- a/libc/test/src/signal/sigaltstack_test.cpp
+++ b/libc/test/src/signal/sigaltstack_test.cpp
@@ -6,17 +6,16 @@
//
//===----------------------------------------------------------------------===//
+#include "hdr/signal_macros.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/errno/libc_errno.h"
#include "src/signal/linux/signal_utils.h"
#include "src/signal/raise.h"
#include "src/signal/sigaction.h"
#include "src/signal/sigaltstack.h"
-
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <signal.h>
#include <stdint.h>
#include <sys/syscall.h>
More information about the libc-commits
mailing list