Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / mach / hurd / i386 / intr-msg.h
bloba0268c1b39c333e46d2a609f650515c51aa60de7
1 /* Machine-dependent details of interruptible RPC messaging. i386 version.
2 Copyright (C) 1995-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 /* Note that we must mark OPTION and TIMEOUT as outputs of this operation,
21 to indicate that the signal thread might mutate them as part
22 of sending us to a signal handler. */
23 #define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify) \
24 ({ \
25 error_t err; \
26 asm (".globl _hurd_intr_rpc_msg_do_trap\n" \
27 ".globl _hurd_intr_rpc_msg_in_trap\n" \
28 ".globl _hurd_intr_rpc_msg_cx_sp\n" \
29 ".globl _hurd_intr_rpc_msg_sp_restored\n" \
30 " movl %%esp, %%ecx\n" \
31 " leal %3, %%esp\n" \
32 "_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \
33 "_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \
34 "_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \
35 "_hurd_intr_rpc_msg_sp_restored:" \
36 : "=a" (err), "=m" (option), "=m" (timeout) \
37 : "m" ((&msg)[-1]), "1" (option), "2" (timeout) \
38 : "%ecx"); \
39 err; \
43 static void inline
44 INTR_MSG_BACK_OUT (struct i386_thread_state *state)
46 extern const void _hurd_intr_rpc_msg_cx_sp;
47 if (state->eip >= (natural_t) &_hurd_intr_rpc_msg_cx_sp)
48 state->uesp = state->ecx;
49 else
50 state->ecx = state->uesp;
53 #include "hurdfault.h"
55 /* This cannot be an inline function because it calls setjmp. */
56 #define SYSCALL_EXAMINE(state, callno) \
57 ({ \
58 struct { unsigned int c[2]; } *p = (void *) ((state)->eip - 7); \
59 int result; \
60 if (_hurdsig_catch_memory_fault (p)) \
61 return 0; \
62 if (result = p->c[0] == 0x0000009a && (p->c[1] & 0x00ffffff) == 0x00000700) \
63 /* The PC is just after an `lcall $7,$0' instruction. \
64 This is a system call in progress; %eax holds the call number. */ \
65 *(callno) = (state)->eax; \
66 _hurdsig_end_catch_fault (); \
67 result; \
71 struct mach_msg_trap_args
73 void *retaddr; /* Address mach_msg_trap will return to. */
74 /* This is the order of arguments to mach_msg_trap. */
75 mach_msg_header_t *msg;
76 mach_msg_option_t option;
77 mach_msg_size_t send_size;
78 mach_msg_size_t rcv_size;
79 mach_port_t rcv_name;
80 mach_msg_timeout_t timeout;
81 mach_port_t notify;
85 /* This cannot be an inline function because it calls setjmp. */
86 #define MSG_EXAMINE(state, msgid, rcvname, send_name, opt, tmout) \
87 ({ \
88 const struct mach_msg_trap_args *args = (const void *) (state)->uesp; \
89 mach_msg_header_t *msg; \
90 _hurdsig_catch_memory_fault (args) ? -1 : \
91 ({ \
92 msg = args->msg; \
93 *(opt) = args->option; \
94 *(tmout) = args->timeout; \
95 *(rcvname) = args->rcv_name; \
96 _hurdsig_end_catch_fault (); \
97 if (msg == 0) \
98 { \
99 *(send_name) = MACH_PORT_NULL; \
100 *(msgid) = 0; \
102 else \
104 if (_hurdsig_catch_memory_fault (msg)) \
105 return -1; \
106 *(send_name) = msg->msgh_remote_port; \
107 *(msgid) = msg->msgh_id; \
108 _hurdsig_end_catch_fault (); \
110 0; \
111 }); \