[clang][bytecode] Ignore Namespace{Using,Alias}Decls (#125387)
[llvm-project.git] / libc / src / signal / linux / signal.cpp
blob1da0ef8c97a206df11be17fe1f2a14d82c674c1f
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 "hdr/signal_macros.h"
11 #include "hdr/types/sighandler_t.h"
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
14 #include "src/signal/sigaction.h"
16 namespace LIBC_NAMESPACE_DECL {
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_DECL