mirror of
https://github.com/intel/llvm.git
synced 2026-01-30 22:53:05 +08:00
[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
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
|
||||
24
libc/hdr/types/sighandler_t.h
Normal file
24
libc/hdr/types/sighandler_t.h
Normal file
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user