msgportdemux.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Demux messages sent on the signal port.
  2. Copyright (C) 1991-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library 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 GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #include <hurd.h>
  16. #include <hurd/signal.h>
  17. #include <stddef.h>
  18. static boolean_t
  19. msgport_server (mach_msg_header_t *inp,
  20. mach_msg_header_t *outp)
  21. {
  22. extern boolean_t _S_msg_server (mach_msg_header_t *inp,
  23. mach_msg_header_t *outp);
  24. extern boolean_t _S_exc_server (mach_msg_header_t *inp,
  25. mach_msg_header_t *outp);
  26. return (_S_exc_server (inp, outp)
  27. || _S_msg_server (inp, outp));
  28. }
  29. /* This is the code that the signal thread runs. */
  30. void *
  31. _hurd_msgport_receive (void *arg)
  32. {
  33. /* Get our own sigstate cached so we never again have to take a lock to
  34. fetch it. There is much code in hurdsig.c that operates with some
  35. sigstate lock held, which will deadlock with _hurd_thread_sigstate.
  36. Furthermore, in the pthread case this is the convenient spot
  37. to initialize _hurd_msgport_thread (see hurdsig.c:_hurdsig_init). */
  38. _hurd_msgport_thread = _hurd_self_sigstate ()->thread;
  39. while (1)
  40. (void) __mach_msg_server (msgport_server, __vm_page_size, _hurd_msgport);
  41. }