Fix: ld testsuite: non-PIC shared tests fail on powerpc-linux-musl
[binutils-gdb.git] / gdbsupport / event-pipe.h
blob999dd4b91517a08f1a9e7084d8b0cc1f43249267
1 /* Event pipe for GDB, the GNU debugger.
3 Copyright (C) 2021-2023 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef COMMON_EVENT_PIPE_H
21 #define COMMON_EVENT_PIPE_H
23 /* An event pipe used as a waitable file in the event loop in place of
24 some other event associated with a signal. The handler for the
25 signal marks the event pipe to force a wakeup in the event loop.
26 This uses the well-known self-pipe trick. */
28 class event_pipe
30 public:
31 event_pipe() = default;
32 ~event_pipe();
34 DISABLE_COPY_AND_ASSIGN (event_pipe);
36 /* Create a new pipe. */
37 bool open_pipe ();
39 /* Close the pipe. */
40 void close_pipe ();
42 /* True if the event pipe has been opened. */
43 bool is_open () const
44 { return m_fds[0] != -1; }
46 /* The file descriptor of the waitable file to use in the event
47 loop. */
48 int event_fd () const
49 { return m_fds[0]; }
51 /* Flush the event pipe. */
52 void flush ();
54 /* Put something in the pipe, so the event loop wakes up. */
55 void mark ();
56 private:
57 int m_fds[2] = { -1, -1 };
60 #endif /* COMMON_EVENT_PIPE_H */