[libc-commits] [libc] 73514f6 - [libc] Add proxy header for __sighandler_t type (#107354)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 5 15:04:38 PDT 2024
Author: wldfngrs
Date: 2024-09-05T18:04:35-04:00
New Revision: 73514f6831cfcea49f33fb9e31db0141b05532f2
URL: https://github.com/llvm/llvm-project/commit/73514f6831cfcea49f33fb9e31db0141b05532f2
DIFF: https://github.com/llvm/llvm-project/commit/73514f6831cfcea49f33fb9e31db0141b05532f2.diff
LOG: [libc] Add proxy header for __sighandler_t type (#107354)
Added proxy headers for __sighandler_t type, modified the corresponding
CMakeLists.txt files and test files
Added:
libc/hdr/types/sighandler_t.h
Modified:
libc/hdr/types/CMakeLists.txt
libc/src/signal/linux/signal.cpp
libc/src/signal/signal.h
libc/test/src/signal/CMakeLists.txt
libc/test/src/signal/signal_test.cpp
Removed:
################################################################################
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index f41576c07d99be..ea7bbccffbb819 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -171,3 +171,13 @@ add_proxy_header_library(
libc.include.llvm-libc-types.locale_t
libc.include.locale
)
+
+add_proxy_header_library(
+ __sighandler_t
+ HDRS
+ sighandler_t.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.__sighandler_t
+ libc.include.signal
+)
+
diff --git a/libc/hdr/types/sighandler_t.h b/libc/hdr/types/sighandler_t.h
new file mode 100644
index 00000000000000..b18f8e856c5b6c
--- /dev/null
+++ b/libc/hdr/types/sighandler_t.h
@@ -0,0 +1,24 @@
+//===-- Definition of macros from __sighandler_t.h ------------------------===//
+//
+// 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_SIGHANDLER_T_H
+#define LLVM_LIBC_HDR_SIGHANDLER_T_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/__sighandler_t.h"
+
+using sighandler_t = __sighandler_t;
+
+#else // overlay mode
+
+#include <signal.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_SIGHANDLER_T_H
diff --git a/libc/src/signal/linux/signal.cpp b/libc/src/signal/linux/signal.cpp
index 241258faf2e81d..1da0ef8c97a206 100644
--- a/libc/src/signal/linux/signal.cpp
+++ b/libc/src/signal/linux/signal.cpp
@@ -8,6 +8,7 @@
#include "src/signal/signal.h"
#include "hdr/signal_macros.h"
+#include "hdr/types/sighandler_t.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/signal/sigaction.h"
diff --git a/libc/src/signal/signal.h b/libc/src/signal/signal.h
index 2037305f8c11e5..06e77e11bf0bd3 100644
--- a/libc/src/signal/signal.h
+++ b/libc/src/signal/signal.h
@@ -9,13 +9,11 @@
#ifndef LLVM_LIBC_SRC_SIGNAL_SIGNAL_H
#define LLVM_LIBC_SRC_SIGNAL_SIGNAL_H
+#include "hdr/types/sighandler_t.h"
#include "src/__support/macros/config.h"
-#include <signal.h>
namespace LIBC_NAMESPACE_DECL {
-using sighandler_t = __sighandler_t;
-
sighandler_t signal(int signum, sighandler_t handler);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/signal/CMakeLists.txt b/libc/test/src/signal/CMakeLists.txt
index edbd5c19edab38..f7923204eaf499 100644
--- a/libc/test/src/signal/CMakeLists.txt
+++ b/libc/test/src/signal/CMakeLists.txt
@@ -74,7 +74,7 @@ add_libc_unittest(
SRCS
signal_test.cpp
DEPENDS
- libc.include.signal
+ libc.hdr.types.sighandler_t
libc.src.errno.errno
libc.src.signal.raise
libc.src.signal.signal
diff --git a/libc/test/src/signal/signal_test.cpp b/libc/test/src/signal/signal_test.cpp
index 70e95a8c159a8b..4b57311eee2d86 100644
--- a/libc/test/src/signal/signal_test.cpp
+++ b/libc/test/src/signal/signal_test.cpp
@@ -13,14 +13,14 @@
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <signal.h>
+#include "hdr/types/sighandler_t.h"
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
TEST(LlvmLibcSignal, Invalid) {
LIBC_NAMESPACE::libc_errno = 0;
- LIBC_NAMESPACE::sighandler_t valid = +[](int) {};
+ sighandler_t valid = +[](int) {};
EXPECT_THAT((void *)LIBC_NAMESPACE::signal(0, valid),
Fails(EINVAL, (void *)SIG_ERR));
EXPECT_THAT((void *)LIBC_NAMESPACE::signal(65, valid),
More information about the libc-commits
mailing list