async-event.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Async events for the GDB event loop.
  2. Copyright (C) 1999-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef ASYNC_EVENT_H
  15. #define ASYNC_EVENT_H
  16. #include "gdbsupport/event-loop.h"
  17. struct async_signal_handler;
  18. struct async_event_handler;
  19. typedef void (sig_handler_func) (gdb_client_data);
  20. /* Type of async event handler callbacks.
  21. DATA is the client data originally passed to create_async_event_handler.
  22. The callback is called when the async event handler is marked. The callback
  23. is responsible for clearing the async event handler if it no longer needs
  24. to be called. */
  25. typedef void (async_event_handler_func) (gdb_client_data);
  26. extern struct async_signal_handler *
  27. create_async_signal_handler (sig_handler_func *proc,
  28. gdb_client_data client_data,
  29. const char *name);
  30. extern void delete_async_signal_handler (struct async_signal_handler **);
  31. /* Call the handler from HANDLER the next time through the event
  32. loop. */
  33. extern void mark_async_signal_handler (struct async_signal_handler *handler);
  34. /* Returns true if HANDLER is marked ready. */
  35. extern int
  36. async_signal_handler_is_marked (struct async_signal_handler *handler);
  37. /* Mark HANDLER as NOT ready. */
  38. extern void clear_async_signal_handler (struct async_signal_handler *handler);
  39. /* Create and register an asynchronous event source in the event loop,
  40. and set PROC as its callback. CLIENT_DATA is passed as argument to
  41. PROC upon its invocation. Returns a pointer to an opaque structure
  42. used to mark as ready and to later delete this event source from
  43. the event loop.
  44. NAME is a user-friendly name for the handler, used in debug statements. The
  45. name is not copied: its lifetime should be at least as long as that of the
  46. handler. */
  47. extern struct async_event_handler *
  48. create_async_event_handler (async_event_handler_func *proc,
  49. gdb_client_data client_data,
  50. const char *name);
  51. /* Remove the event source pointed by HANDLER_PTR created by
  52. CREATE_ASYNC_EVENT_HANDLER from the event loop, and release it. */
  53. extern void
  54. delete_async_event_handler (struct async_event_handler **handler_ptr);
  55. /* Call the handler from HANDLER the next time through the event
  56. loop. */
  57. extern void mark_async_event_handler (struct async_event_handler *handler);
  58. /* Return true if HANDLER is marked. */
  59. extern bool async_event_handler_marked (async_event_handler *handler);
  60. /* Mark the handler (ASYNC_HANDLER_PTR) as NOT ready. */
  61. extern void clear_async_event_handler (struct async_event_handler *handler);
  62. extern void initialize_async_signal_handlers (void);
  63. #endif /* ASYNC_EVENT_H */