]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mach/hurd/i386/intr-msg.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / mach / hurd / i386 / intr-msg.h
CommitLineData
3cf595e5 1/* Machine-dependent details of interruptible RPC messaging. i386 version.
04277e02 2 Copyright (C) 1995-2019 Free Software Foundation, Inc.
478b92f0 3 This file is part of the GNU C Library.
3cf595e5 4
478b92f0 5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
3cf595e5 9
478b92f0
UD
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
41bdb6e2 13 Lesser General Public License for more details.
3cf595e5 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
3cf595e5
RM
18
19
38e30b39
RM
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. */
5c81be53
ST
23
24/* After _hurd_intr_rpc_msg_about_to we need to make a last check of cancel, in
25 case we got interrupted right before _hurd_intr_rpc_msg_about_to. */
26#define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify, cancel_p, intr_port_p) \
3cf595e5
RM
27({ \
28 error_t err; \
5c81be53 29 asm (".globl _hurd_intr_rpc_msg_about_to\n" \
3cf595e5 30 ".globl _hurd_intr_rpc_msg_cx_sp\n" \
5c81be53
ST
31 ".globl _hurd_intr_rpc_msg_do_trap\n" \
32 ".globl _hurd_intr_rpc_msg_in_trap\n" \
3cf595e5 33 ".globl _hurd_intr_rpc_msg_sp_restored\n" \
5c81be53
ST
34 "_hurd_intr_rpc_msg_about_to: cmpl $0, %5\n" \
35 " jz _hurd_intr_rpc_msg_do\n" \
36 " movl $0, %3\n" \
37 " movl %6, %%eax\n" \
38 " jmp _hurd_intr_rpc_msg_sp_restored\n" \
39 "_hurd_intr_rpc_msg_do: movl %%esp, %%ecx\n" \
40 " leal %4, %%esp\n" \
3cf595e5
RM
41 "_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \
42 "_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \
43 "_hurd_intr_rpc_msg_in_trap: movl %%ecx, %%esp\n" \
44 "_hurd_intr_rpc_msg_sp_restored:" \
5c81be53
ST
45 : "=a" (err), "+m" (option), "+m" (timeout), "=m" (*intr_port_p) \
46 : "m" ((&msg)[-1]), "m" (*cancel_p), "i" (EINTR) \
868df0f9 47 : "ecx"); \
3cf595e5
RM
48 err; \
49})
50
51
52static void inline
53INTR_MSG_BACK_OUT (struct i386_thread_state *state)
54{
55 extern const void _hurd_intr_rpc_msg_cx_sp;
56 if (state->eip >= (natural_t) &_hurd_intr_rpc_msg_cx_sp)
57 state->uesp = state->ecx;
58 else
59 state->ecx = state->uesp;
60}
4ca84cff
RM
61\f
62#include "hurdfault.h"
63
8a0746ae
RM
64/* This cannot be an inline function because it calls setjmp. */
65#define SYSCALL_EXAMINE(state, callno) \
66({ \
67 struct { unsigned int c[2]; } *p = (void *) ((state)->eip - 7); \
68 int result; \
69 if (_hurdsig_catch_memory_fault (p)) \
70 return 0; \
71 if (result = p->c[0] == 0x0000009a && (p->c[1] & 0x00ffffff) == 0x00000700) \
72 /* The PC is just after an `lcall $7,$0' instruction. \
73 This is a system call in progress; %eax holds the call number. */ \
74 *(callno) = (state)->eax; \
75 _hurdsig_end_catch_fault (); \
76 result; \
77})
4ca84cff
RM
78
79
80struct mach_msg_trap_args
81 {
82 void *retaddr; /* Address mach_msg_trap will return to. */
83 /* This is the order of arguments to mach_msg_trap. */
84 mach_msg_header_t *msg;
85 mach_msg_option_t option;
86 mach_msg_size_t send_size;
87 mach_msg_size_t rcv_size;
88 mach_port_t rcv_name;
89 mach_msg_timeout_t timeout;
90 mach_port_t notify;
91 };
92
93
8a0746ae
RM
94/* This cannot be an inline function because it calls setjmp. */
95#define MSG_EXAMINE(state, msgid, rcvname, send_name, opt, tmout) \
96({ \
97 const struct mach_msg_trap_args *args = (const void *) (state)->uesp; \
98 mach_msg_header_t *msg; \
99 _hurdsig_catch_memory_fault (args) ? -1 : \
100 ({ \
101 msg = args->msg; \
102 *(opt) = args->option; \
103 *(tmout) = args->timeout; \
104 *(rcvname) = args->rcv_name; \
105 _hurdsig_end_catch_fault (); \
106 if (msg == 0) \
107 { \
108 *(send_name) = MACH_PORT_NULL; \
109 *(msgid) = 0; \
110 } \
111 else \
112 { \
113 if (_hurdsig_catch_memory_fault (msg)) \
114 return -1; \
115 *(send_name) = msg->msgh_remote_port; \
116 *(msgid) = msg->msgh_id; \
117 _hurdsig_end_catch_fault (); \
118 } \
119 0; \
120 }); \
121})