Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / signal / linux / signal.cpp
bloba517fa73ba8a2cec90a83b98756482a6998a4dd6
1 //===-- Linux implementation of signal ------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/signal/signal.h"
10 #include "src/signal/sigaction.h"
12 #include "src/__support/common.h"
14 #include <signal.h>
16 namespace LIBC_NAMESPACE {
18 LLVM_LIBC_FUNCTION(sighandler_t, signal, (int signum, sighandler_t handler)) {
19 struct sigaction action, old;
20 action.sa_handler = handler;
21 action.sa_flags = SA_RESTART;
22 // Errno will already be set so no need to worry about changing errno here.
23 return LIBC_NAMESPACE::sigaction(signum, &action, &old) == -1
24 ? SIG_ERR
25 : old.sa_handler;
28 } // namespace LIBC_NAMESPACE