]> git.ipfire.org Git - thirdparty/glibc.git/blob - hurd/msgportdemux.c
Update to 2.1.x development version
[thirdparty/glibc.git] / hurd / msgportdemux.c
1 /* Demux messages sent on the signal port.
2 Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
19
20 #include <hurd.h>
21 #include <hurd/signal.h>
22 #include <stddef.h>
23
24 struct demux
25 {
26 struct demux *next;
27 boolean_t (*demux) (mach_msg_header_t *inp,
28 mach_msg_header_t *outp);
29 };
30
31 struct demux *_hurd_msgport_demuxers = NULL;
32
33 extern boolean_t __msg_server (mach_msg_header_t *inp,
34 mach_msg_header_t *outp);
35
36 static boolean_t
37 msgport_server (mach_msg_header_t *inp,
38 mach_msg_header_t *outp)
39 {
40 extern boolean_t _S_msg_server (mach_msg_header_t *inp,
41 mach_msg_header_t *outp);
42 extern boolean_t _S_exc_server (mach_msg_header_t *inp,
43 mach_msg_header_t *outp);
44 struct demux *d;
45
46 for (d = _hurd_msgport_demuxers; d != NULL; d = d->next)
47 if ((*d->demux) (inp, outp))
48 return 1;
49
50 return (_S_exc_server (inp, outp) ||
51 _S_msg_server (inp, outp));
52 }
53
54 /* This is the code that the signal thread runs. */
55 void
56 _hurd_msgport_receive (void)
57 {
58 /* Get our own sigstate cached so we never again have to take a lock to
59 fetch it. There is much code in hurdsig.c that operates with some
60 sigstate lock held, which will deadlock with _hurd_thread_sigstate. */
61 (void) _hurd_self_sigstate ();
62
63 while (1)
64 (void) __mach_msg_server (msgport_server, __vm_page_size, _hurd_msgport);
65 }