summaryrefslogtreecommitdiff
path: root/libc/src/signal
AgeCommit message (Collapse)Author
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187) This is the first step in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-02-07[libc][signal] clean up usage of sighandler_t (#125745)Nick Desaulniers
`man 3 signal`'s declaration has a face _only a mother could love_. sighandler_t and __sighandler_t are not defined in the C standard, or POSIX. They are helpful typedefs provided by glibc and the Linux kernel UAPI headers respectively since working with function pointers' syntax can be painful. But we should not rely on them; in C++ we have `auto*` and `using` statements. Remove the proxy header, and only include a typedef for sighandler_t when targeting Linux, for compatibility with glibc. Fixes: #125598
2024-11-26[libc] suppress more clang-cl warnings (#117718)Schrodinger ZHU Yifan
- migrate more `-O3` to `${libc_opt_high_flag}` - workaround a issue with `LLP64` in test. The overflow testing is guarded by a constexpr but the literal overflow itself will still trigger warnings. Notice that for math smoke test, for some reasons, the `${libc_opt_high_flag}` will be passed into `lld-link` which confuses the linker so there are still some warnings leftover there. I can investigate more when I have time.
2024-09-07[libc] Add proxy header for the stack_t type (#107559)wldfngrs
added proxy header for the stack_t type and modified the corresponding CMakeLists.txt files
2024-09-06[libc] Fix signal's dependency on the proxy header sighandler_t. (#107605)lntue
2024-09-05[libc] Add proxy header for __sighandler_t type (#107354)wldfngrs
Added proxy headers for __sighandler_t type, modified the corresponding CMakeLists.txt files and test files
2024-07-12[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)Petr Hosek
This is a part of #97655.
2024-07-12Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace ↵Mehdi Amini
declaration" (#98593) Reverts llvm/llvm-project#98075 bots are broken
2024-07-11[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)Petr Hosek
This is a part of #97655.
2024-06-26[libc] add proxy header for struct_sigaction (#96224)Schrodinger ZHU Yifan
2024-04-11[libc] Codify header inclusion policy (#87017)Nick Desaulniers
When supporting "overlay" vs "fullbuild" modes, "what ABI are you using?" becomes a fundamental question to have concrete answers for. Overlay mode MUST match the ABI of the system being overlayed onto; fullbuild more flexible (the only system ABI relevant is the OS kernel). When implementing llvm-libc we generally prefer the include-what-you use style of avoiding transitive dependencies (since that makes refactoring headers more painful, and slows down build times). So what header do you include for any given type or function declaration? For any given userspace program, the answer is straightforward. But for llvm-libc which is trying to support multiple ABIs (at least one per configuration), the answer is perhaps less clear. This proposal seeks to add one layer of indirection relative to what's being done today. It then converts users of sigset_t and struct epoll_event and the epoll implemenations over to this convention as an example.
2024-01-19[libc] remove extra -Werror (#78761)Nick Desaulniers
-Werror is now a global default as of commit c52b467875e2 ("Reapply "[libc] build with -Werror (#73966)" (#74506)")
2024-01-03[libc] fix -Wcast-function-type via union rather than reinterpret_cast (#76875)Nick Desaulniers
The GCC build is producing the following diagnostic: llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction& __llvm_libc_18_0_0_git::KernelSigaction::operator=(const sigaction&)’: llvm-project/libc/src/signal/linux/signal_utils.h:38:20: warning: cast between incompatible function types from ‘void (*)(int, siginfo_t*, void*)’ to ‘void (*)(int)’ [-Wcast-function-type] 38 | sa_handler = reinterpret_cast<HandlerType *>(sa.sa_sigaction); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction::operator sigaction() const’: llvm-project/libc/src/signal/linux/signal_utils.h:51:25: warning: cast between incompatible function types from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t*, void*)’ [-Wcast-function-type] 51 | sa.sa_sigaction = reinterpret_cast<SiginfoHandlerType *>(sa_handler); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Two issues here: 1. Clang supports -Wcast-function-type, but not as part of the -Wextra group. 2. The existing implementation tried to work around the oddity that is the kernel's struct sigaction != POSIX via reinterpret_cast in a way that's not compatible with -Wcast-function-type. Just use a union which is well defined (and two function pointers are the same size.) Link: https://github.com/llvm/llvm-project/issues/76872 Fixes: https://github.com/llvm/llvm-project/issues/74617
2023-09-26[libc] Mass replace enclosing namespace (#67032)Guillaume Chatelet
This is step 4 of https://discourse.llvm.org/t/rfc-customizable-namespace-to-allow-testing-the-libc-when-the-system-libc-is-also-llvms-libc/73079
2023-09-21[libc][clang-tidy] Add llvm-header-guard to get consistant naming and ↵Guillaume Chatelet
prevent file copy/paste issues. (#66477)
2023-08-29[libc] Fix the remaining old style includesPetr Hosek
These were omitted from previous cleanup changes. Differential Revision: https://reviews.llvm.org/D159066
2023-08-07[libc][cleanup] Fix most conversion warningsMichael Jones
This patch is large, but is almost entirely just adding casts to calls to syscall_impl. Much of the work was done programatically, with human checking when the syntax or types got confusing. Reviewed By: mcgrathr Differential Revision: https://reviews.llvm.org/D156950
2023-07-05[libc] Use the new style includesPetr Hosek
We should be using the standard includes. Differential Revision: https://reviews.llvm.org/D154529
2023-03-05[libc] Switch signal and termios to libc_errno.Siva Chandra Reddy
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D145274
2023-01-24[libc][NFC] Another round of replacement of static inline with LIBC_INLINE.Siva Chandra Reddy
Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D142398
2022-10-18[libc] Add implementation of sigaltstack for linux.Siva Chandra Reddy
Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D135949
2022-10-06[libc] add killMichael Jones
Add the kill syscall wrapper and tests. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D135406
2022-09-30[libc] add syscall functionMichael Jones
Add the syscall wrapper function and tests. It's implemented using a macro to guarantee the minimum number of arguments. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D134919
2022-09-30[libc] Re-enable functions from signal.h and re-enable abort.Siva Chandra Reddy
They were disabled because we were including linux/signal.h from our signal.h. Linux's signal.h is not designed to be included from user programs as it causes a lot of non-standard name pollution. Also, it is not self-contained. This change defines types and macros relevant for signal related syscalls within libc's headers and removes inclusion of Linux headers. This patch enables the funtions only for x86_64. They will be enabled for aarch64 also in a follow up patch after testing. Reviewed By: abrachet, lntue Differential Revision: https://reviews.llvm.org/D134567
2022-09-02[libc][NFC] Use no_sanitize("all")Alex Brachet
This function cannot have any instrumentation because it's assembly must match exactly what the debugger is expecting. Previously it was just a list of what sanitizers we expect libc would be sanitized with but this is untenable.
2022-03-04[libc] Make the errno macro resolve to the thread local variable directly.Siva Chandra Reddy
With modern architectures having a thread pointer and language supporting thread locals, there is no reason to use a function intermediary to access the thread local errno value. The entrypoint corresponding to errno has been replaced with an object library as there is no formal entrypoint for errno anymore. Reviewed By: jeffbailey, michaelrj Differential Revision: https://reviews.llvm.org/D120920
2021-12-22[libc] Move the x86_64 syscall functions to OSUtil.Siva Chandra Reddy
Reviewed By: michaelrj, lntue Differential Revision: https://reviews.llvm.org/D116177
2021-12-07[libc] apply new lint rulesMichael Jones
This patch applies the lint rules described in the previous patch. There was also a significant amount of effort put into manually fixing things, since all of the templated functions, or structs defined in /spec, were not updated and had to be handled manually. Reviewed By: sivachandra, lntue Differential Revision: https://reviews.llvm.org/D114302
2021-01-08[libc] Switch to use a macro which does not insert a section for every libc ↵Michael Jones
function. Summary: The new macro also inserts the C alias for the C++ implementations without needing an objcopy based post processing step. The CMake rules have been updated to reflect this. More CMake cleanup can be taken up in future rounds and appropriate TODOs have been added for them. Reviewers: mcgrathr, sivachandra Subscribers:
2020-04-21[libc][NFC] Cleanup dependencies in src/signal and test/src/signal.Siva Chandra Reddy
Reviewers: abrachet Differential Revision: https://reviews.llvm.org/D78585
2020-04-21[libc][Take 2] Propagate entrypoint deps to downstream targets.Siva Chandra Reddy
This reverts commit a8086ba4ac85152d8407630e56e9ee5c8b46a214. Setting couple of target properties to an empty string was missed in the previous commit.
2020-04-21[libc] Revert "Propagate entrypoint deps to downstream targets."Siva Chandra Reddy
This reverts commit 20cb440ea210597bf223505604bb5f2220a067c6 as the target llvmlibc seems to be failing on the bots.
2020-04-21[libc] Propagate entrypoint deps to downstream targets.Siva Chandra Reddy
Deps are recrusively evaluated at the place they are needed. With this change, one does not have to list recursive deps of entrypoints when listing test targets. One will still have to explicitly list all entrypoint objects when setting up an "add_entrypoint_library" target. Reviewers: abrachet Differential Revision: https://reviews.llvm.org/D78537
2020-04-10[libc] Add fully-qualified target names.Siva Chandra Reddy
Only targets setup by the special LLVM libc rules now have fully qualified names. The naming style is similar to fully qualified names in Python. Reviewers: abrachet, PaulkaToast, phosek Differential Revision: https://reviews.llvm.org/D77340
2020-04-08[libc][NFC] Make all top of file comments consistent.Paula Toth
Summary: Made all header files consistent based of this documentation: https://llvm.org/docs/CodingStandards.html#file-headers. And did the same for all source files top of file comments. Reviewers: sivachandra, abrachet Reviewed By: sivachandra, abrachet Subscribers: MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D77533
2020-04-06[libc] NFC: Fix trivial typo in comments, documents, and messagesKazuaki Ishizaki
Differential Revision: https://reviews.llvm.org/D77462
2020-04-01[libc] Add sigfillset and sigdelsetAlex Brachet
Summary: Add's `sigfillset` and `sigdelset` which will be used in D76676. Reviewers: sivachandra, PaulkaToast Reviewed By: sivachandra Subscribers: mgorny, MaskRay, tschuett, libc-commits Differential Revision: https://reviews.llvm.org/D76936
2020-03-28[libc] Extend add_object rule to handle helper object libraries.Siva Chandra Reddy
The rule is now called add_object_library. Reviewers: abrachet Differential Revision: https://reviews.llvm.org/D76826
2020-03-28[libc][NFC] Ensure internal implementation is in __llvm_libc namespaceAlex Brachet
Summary: In preparation for D76818. Reviewers: PaulkaToast, sivachandra, gchatelet Reviewed By: PaulkaToast, sivachandra Subscribers: MaskRay, tschuett, libc-commits Differential Revision: https://reviews.llvm.org/D76967
2020-03-22[libc] Add signalAlex Brachet
Summary: This patch adds a Linux implementation for `signal` It also fixes `ASSERT|EXPECT_THAT` macros Reviewers: sivachandra, PaulkaToast, MaskRay Reviewed By: sivachandra Subscribers: mgorny, tschuett, libc-commits Differential Revision: https://reviews.llvm.org/D76536
2020-03-18[libc] Add sigactionAlex Brachet
Summary: This patch adds `sigaction` and the `sa_restorer` signal trampoline function `__restore_rt` Reviewers: sivachandra, MaskRay, PaulkaToast Reviewed By: sivachandra Subscribers: gchatelet, mgorny, tschuett, libc-commits Differential Revision: https://reviews.llvm.org/D75802
2020-03-02[libc] Add `errno_h` as a dependency to `sigaddset` and `sigemptyset`.Siva Chandra Reddy
Summary: The bots are catching this missing dependency. Reviewers: PaulkaToast, abrachet Subscribers: mgorny, MaskRay, tschuett, libc-commits Tags: #libc-project Differential Revision: https://reviews.llvm.org/D75502
2020-03-02[libc] Add sigprocmaskAlex Brachet
Summary: This patch adds `sigprocmask`, `sigemptyset` and `sigaddset` Reviewers: sivachandra, MaskRay, gchatelet Reviewed By: sivachandra Subscribers: mgorny, tschuett, libc-commits Differential Revision: https://reviews.llvm.org/D75026
2020-02-21Remove unused variableAlex Brachet
2020-02-20[libc] Add Initial Support for SignalsAlex Brachet
Summary: This patch adds signal support on Linux. The current implementation gets the SIG* macros and types like `sigset_t` from <linux/signals.h> This patch also adds raise(3), and internal routines `block_all_signals` and `restore_signals` Reviewers: sivachandra, MaskRay, gchatelet Reviewed By: sivachandra Subscribers: libc-commits, mgorny, tschuett Differential Revision: https://reviews.llvm.org/D74528