Skip to content

[libc] add proxy header for struct_sigaction #96224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libc/hdr/types/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need libc.include.signal?

Copy link
Contributor Author

@SchrodingerZhu SchrodingerZhu Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a convention in proxy headers to require the full build to generate the outer-level header. This is employed in all other proxy type headers. @lntue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving for now, but perhaps worth revisiting this convention. @lntue ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge this for now. if the convention is revised, we should better revisit all other files.

)
21 changes: 21 additions & 0 deletions libc/hdr/types/struct_sigaction.h
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion libc/src/signal/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -124,7 +125,7 @@ add_entrypoint_object(
../signal.h
DEPENDS
.sigaction
libc.include.signal
libc.hdr.signal_macros
)

add_entrypoint_object(
Expand Down
6 changes: 2 additions & 4 deletions libc/src/signal/linux/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion libc/src/signal/sigaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 3 additions & 3 deletions libc/test/src/signal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions libc/test/src/signal/sigaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions libc/test/src/signal/sigaltstack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Loading