gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / glibc-hurd-signal-sa-siginfo.patch
1 This patch is needed to build e2fsprogs, util-linux.
2
3 Taken from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/tg-hurdsig-SA_SIGINFO.diff
4
5 From: Jeremie Koenig <jk@jk.fr.eu.org>
6 Subject: [PATCH] implement SA_SIGINFO signal handlers.
7
8 52baaca Hurd signals: Copy bits/sigaction.h
9 4232c66 Hurd signals: SA_SIGINFO support
10 1831cfe Hurd signals: Use POSIX sigcodes
11
12 ---
13 hurd/hurd/signal.h | 5 +
14 hurd/hurdfault.c | 2
15 hurd/hurdinit.c | 2
16 hurd/hurdsig.c | 6 -
17 sysdeps/mach/hurd/bits/sigaction.h | 86 +++++++++++++++++++++
18 sysdeps/mach/hurd/i386/bits/sigcontext.h | 4
19 sysdeps/mach/hurd/i386/exc2signal.c | 123 +++++++++++++++++++-----------
20 sysdeps/mach/hurd/i386/trampoline.c | 125 ++++++++++++++++++++++++++++---
21 sysdeps/mach/hurd/kill.c | 2
22 sysdeps/mach/hurd/setitimer.c | 2
23 10 files changed, 293 insertions(+), 64 deletions(-)
24
25 Index: glibc-2.31/hurd/hurd/signal.h
26 ===================================================================
27 --- glibc-2.31.orig/hurd/hurd/signal.h
28 +++ glibc-2.31/hurd/hurd/signal.h
29 @@ -290,6 +290,11 @@ extern int _hurd_raise_signal (struct hu
30 extern void _hurd_exception2signal (struct hurd_signal_detail *detail,
31 int *signo);
32
33 +/* Translate a Mach exception into a signal with a legacy sigcode. */
34 +
35 +extern void _hurd_exception2signal_legacy (struct hurd_signal_detail *detail,
36 + int *signo);
37 +
38
39 /* Make the thread described by SS take the signal described by SIGNO and
40 DETAIL. If the process is traced, this will in fact stop with a SIGNO
41 Index: glibc-2.31/hurd/hurdfault.c
42 ===================================================================
43 --- glibc-2.31.orig/hurd/hurdfault.c
44 +++ glibc-2.31/hurd/hurdfault.c
45 @@ -70,7 +70,7 @@ _hurdsig_fault_catch_exception_raise (ma
46 codes into a signal number and subcode. */
47 _hurd_exception2signal (&d, &signo);
48
49 - return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.code)
50 + return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preemptor, signo, d.exc_subcode)
51 ? 0 : EGREGIOUS;
52 }
53
54 Index: glibc-2.31/hurd/hurdinit.c
55 ===================================================================
56 --- glibc-2.31.orig/hurd/hurdinit.c
57 +++ glibc-2.31/hurd/hurdinit.c
58 @@ -177,7 +177,7 @@ _hurd_new_proc_init (char **argv,
59 /* This process is "traced", meaning it should stop on signals or exec.
60 We are all set up now to handle signals. Stop ourselves, to inform
61 our parent (presumably a debugger) that the exec has completed. */
62 - __msg_sig_post (_hurd_msgport, SIGTRAP, 0, __mach_task_self ());
63 + __msg_sig_post (_hurd_msgport, SIGTRAP, TRAP_TRACE, __mach_task_self ());
64 }
65
66 #include <shlib-compat.h>
67 Index: glibc-2.31/hurd/hurdsig.c
68 ===================================================================
69 --- glibc-2.31.orig/hurd/hurdsig.c
70 +++ glibc-2.31/hurd/hurdsig.c
71 @@ -730,7 +730,7 @@ post_signal (struct hurd_sigstate *ss,
72 { /* PE cannot be null. */
73 do
74 {
75 - if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->code))
76 + if (HURD_PREEMPT_SIGNAL_P (pe, signo, detail->exc_subcode))
77 {
78 if (pe->preemptor)
79 {
80 @@ -1374,7 +1374,7 @@ _S_msg_sig_post (mach_port_t me,
81 if (err = signal_allowed (signo, refport))
82 return err;
83
84 - d.code = sigcode;
85 + d.code = d.exc_subcode = sigcode;
86 d.exc = 0;
87
88 /* Post the signal to a global receiver thread (or mark it pending in
89 @@ -1403,7 +1403,7 @@ _S_msg_sig_post_untraced (mach_port_t me
90 if (err = signal_allowed (signo, refport))
91 return err;
92
93 - d.code = sigcode;
94 + d.code = d.exc_subcode = sigcode;
95 d.exc = 0;
96
97 /* Post the signal to the designated signal-receiving thread. This will
98 Index: glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
99 ===================================================================
100 --- /dev/null
101 +++ glibc-2.31/sysdeps/mach/hurd/bits/sigaction.h
102 @@ -0,0 +1,86 @@
103 +/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
104 + This file is part of the GNU C Library.
105 +
106 + The GNU C Library is free software; you can redistribute it and/or
107 + modify it under the terms of the GNU Lesser General Public
108 + License as published by the Free Software Foundation; either
109 + version 2.1 of the License, or (at your option) any later version.
110 +
111 + The GNU C Library is distributed in the hope that it will be useful,
112 + but WITHOUT ANY WARRANTY; without even the implied warranty of
113 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
114 + Lesser General Public License for more details.
115 +
116 + You should have received a copy of the GNU Lesser General Public
117 + License along with the GNU C Library; if not, write to the Free
118 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
119 + 02111-1307 USA. */
120 +
121 +#ifndef _BITS_SIGACTION_H
122 +#define _BITS_SIGACTION_H 1
123 +
124 +#ifndef _SIGNAL_H
125 +# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
126 +#endif
127 +
128 +/* These definitions match those used by the 4.4 BSD kernel.
129 + If the operating system has a `sigaction' system call that correctly
130 + implements the POSIX.1 behavior, there should be a system-dependent
131 + version of this file that defines `struct sigaction' and the `SA_*'
132 + constants appropriately. */
133 +
134 +/* Structure describing the action to be taken when a signal arrives. */
135 +struct sigaction
136 + {
137 + /* Signal handler. */
138 +#if defined __USE_POSIX199309 || defined __USE_XOPEN_EXTENDED
139 + union
140 + {
141 + /* Used if SA_SIGINFO is not set. */
142 + __sighandler_t sa_handler;
143 + /* Used if SA_SIGINFO is set. */
144 + void (*sa_sigaction) (int, siginfo_t *, void *);
145 + }
146 + __sigaction_handler;
147 +# define sa_handler __sigaction_handler.sa_handler
148 +# define sa_sigaction __sigaction_handler.sa_sigaction
149 +#else
150 + __sighandler_t sa_handler;
151 +#endif
152 +
153 + /* Additional set of signals to be blocked. */
154 + __sigset_t sa_mask;
155 +
156 + /* Special flags. */
157 + int sa_flags;
158 + };
159 +
160 +/* Bits in `sa_flags'. */
161 +#if defined __USE_XOPEN_EXTENDED || defined __USE_MISC
162 +# define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
163 +#endif
164 +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
165 +# define SA_RESTART 0x0002 /* Restart syscall on signal return. */
166 +# define SA_NODEFER 0x0010 /* Don't automatically block the signal when
167 + its handler is being executed. */
168 +# define SA_RESETHAND 0x0004 /* Reset to SIG_DFL on entry to handler. */
169 +#endif
170 +#define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */
171 +#define SA_SIGINFO 0x0040 /* Signal handler with SA_SIGINFO args */
172 +
173 +#ifdef __USE_MISC
174 +# define SA_INTERRUPT 0 /* Historical no-op ("not SA_RESTART"). */
175 +
176 +/* Some aliases for the SA_ constants. */
177 +# define SA_NOMASK SA_NODEFER
178 +# define SA_ONESHOT SA_RESETHAND
179 +# define SA_STACK SA_ONSTACK
180 +#endif
181 +
182 +
183 +/* Values for the HOW argument to `sigprocmask'. */
184 +#define SIG_BLOCK 1 /* Block signals. */
185 +#define SIG_UNBLOCK 2 /* Unblock signals. */
186 +#define SIG_SETMASK 3 /* Set the set of blocked signals. */
187 +
188 +#endif
189 Index: glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
190 ===================================================================
191 --- glibc-2.31.orig/sysdeps/mach/hurd/i386/bits/sigcontext.h
192 +++ glibc-2.31/sysdeps/mach/hurd/i386/bits/sigcontext.h
193 @@ -97,6 +97,10 @@ struct sigcontext
194 #define sc_ps sc_efl
195
196
197 +/* The deprecated sigcode values below are passed as an extra, non-portable
198 + argument to regular signal handlers. You should use SA_SIGINFO handlers
199 + instead, which use the standard POSIX signal codes. */
200 +
201 /* Codes for SIGFPE. */
202 #define FPE_INTOVF_TRAP 0x1 /* integer overflow */
203 #define FPE_INTDIV_FAULT 0x2 /* integer divide by zero */
204 Index: glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
205 ===================================================================
206 --- glibc-2.31.orig/sysdeps/mach/hurd/i386/exc2signal.c
207 +++ glibc-2.31/sysdeps/mach/hurd/i386/exc2signal.c
208 @@ -23,8 +23,8 @@
209 /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
210 into a signal number and signal subcode. */
211
212 -void
213 -_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
214 +static void
215 +exception2signal (struct hurd_signal_detail *detail, int *signo, int posix)
216 {
217 detail->error = 0;
218
219 @@ -36,44 +36,62 @@ _hurd_exception2signal (struct hurd_sign
220 break;
221
222 case EXC_BAD_ACCESS:
223 - if (detail->exc_code == KERN_INVALID_ADDRESS
224 - || detail->exc_code == KERN_PROTECTION_FAILURE
225 - || detail->exc_code == KERN_WRITE_PROTECTION_FAILURE)
226 - *signo = SIGSEGV;
227 - else
228 - *signo = SIGBUS;
229 - detail->code = detail->exc_subcode;
230 + switch (detail->exc_code)
231 + {
232 + case KERN_INVALID_ADDRESS:
233 + case KERN_MEMORY_FAILURE:
234 + *signo = SIGSEGV;
235 + detail->code = posix ? SEGV_MAPERR : detail->exc_subcode;
236 + break;
237 +
238 + case KERN_PROTECTION_FAILURE:
239 + case KERN_WRITE_PROTECTION_FAILURE:
240 + *signo = SIGSEGV;
241 + detail->code = posix ? SEGV_ACCERR : detail->exc_subcode;
242 + break;
243 +
244 + default:
245 + *signo = SIGBUS;
246 + detail->code = posix ? BUS_ADRERR : detail->exc_subcode;
247 + break;
248 + }
249 detail->error = detail->exc_code;
250 break;
251
252 case EXC_BAD_INSTRUCTION:
253 *signo = SIGILL;
254 - if (detail->exc_code == EXC_I386_INVOP)
255 - detail->code = ILL_INVOPR_FAULT;
256 - else if (detail->exc_code == EXC_I386_STKFLT)
257 - detail->code = ILL_STACK_FAULT;
258 - else
259 - detail->code = 0;
260 + switch (detail->exc_code)
261 + {
262 + case EXC_I386_INVOP:
263 + detail->code = posix ? ILL_ILLOPC : ILL_INVOPR_FAULT;
264 + break;
265 +
266 + case EXC_I386_STKFLT:
267 + detail->code = posix ? ILL_BADSTK : ILL_STACK_FAULT;
268 + break;
269 +
270 + default:
271 + detail->code = 0;
272 + break;
273 + }
274 break;
275
276 case EXC_ARITHMETIC:
277 + *signo = SIGFPE;
278 switch (detail->exc_code)
279 {
280 case EXC_I386_DIV: /* integer divide by zero */
281 - *signo = SIGFPE;
282 - detail->code = FPE_INTDIV_FAULT;
283 + detail->code = posix ? FPE_INTDIV : FPE_INTDIV_FAULT;
284 break;
285
286 case EXC_I386_INTO: /* integer overflow */
287 - *signo = SIGFPE;
288 - detail->code = FPE_INTOVF_TRAP;
289 + detail->code = posix ? FPE_INTOVF : FPE_INTOVF_TRAP;
290 break;
291
292 /* These aren't anywhere documented or used in Mach 3.0. */
293 case EXC_I386_NOEXT:
294 case EXC_I386_EXTOVR:
295 default:
296 - *signo = SIGFPE;
297 detail->code = 0;
298 break;
299
300 @@ -82,51 +100,43 @@ _hurd_exception2signal (struct hurd_sign
301 Give an error code corresponding to the first bit set. */
302 if (detail->exc_subcode & FPS_IE)
303 {
304 - *signo = SIGILL;
305 - detail->code = ILL_FPEOPR_FAULT;
306 + /* NB: We used to send SIGILL here but we can't distinguish
307 + POSIX vs. legacy with respect to what signal we send. */
308 + detail->code = posix ? FPE_FLTINV : 0 /*ILL_FPEOPR_FAULT*/;
309 }
310 else if (detail->exc_subcode & FPS_DE)
311 {
312 - *signo = SIGFPE;
313 - detail->code = FPE_FLTDNR_FAULT;
314 + detail->code = posix ? FPE_FLTUND : FPE_FLTDNR_FAULT;
315 }
316 else if (detail->exc_subcode & FPS_ZE)
317 {
318 - *signo = SIGFPE;
319 - detail->code = FPE_FLTDIV_FAULT;
320 + detail->code = posix ? FPE_FLTDIV : FPE_FLTDIV_FAULT;
321 }
322 else if (detail->exc_subcode & FPS_OE)
323 {
324 - *signo = SIGFPE;
325 - detail->code = FPE_FLTOVF_FAULT;
326 + detail->code = posix ? FPE_FLTOVF : FPE_FLTOVF_FAULT;
327 }
328 else if (detail->exc_subcode & FPS_UE)
329 {
330 - *signo = SIGFPE;
331 - detail->code = FPE_FLTUND_FAULT;
332 + detail->code = posix ? FPE_FLTUND : FPE_FLTUND_FAULT;
333 }
334 else if (detail->exc_subcode & FPS_PE)
335 {
336 - *signo = SIGFPE;
337 - detail->code = FPE_FLTINX_FAULT;
338 + detail->code = posix ? FPE_FLTRES : FPE_FLTINX_FAULT;
339 }
340 else
341 {
342 - *signo = SIGFPE;
343 detail->code = 0;
344 }
345 break;
346
347 /* These two can only be arithmetic exceptions if we
348 - are in V86 mode, which sounds like emulation to me.
349 - (See Mach 3.0 i386/trap.c.) */
350 + are in V86 mode. (See Mach 3.0 i386/trap.c.) */
351 case EXC_I386_EMERR:
352 - *signo = SIGFPE;
353 - detail->code = FPE_EMERR_FAULT;
354 + detail->code = posix ? 0 : FPE_EMERR_FAULT;
355 break;
356 case EXC_I386_BOUND:
357 - *signo = SIGFPE;
358 - detail->code = FPE_EMBND_FAULT;
359 + detail->code = posix ? FPE_FLTSUB : FPE_EMBND_FAULT;
360 break;
361 }
362 break;
363 @@ -143,7 +153,7 @@ _hurd_exception2signal (struct hurd_sign
364 if (detail->exc_code == EXC_I386_BOUND)
365 {
366 *signo = SIGFPE;
367 - detail->code = FPE_SUBRNG_FAULT;
368 + detail->code = posix ? FPE_FLTSUB : FPE_SUBRNG_FAULT;
369 }
370 else
371 {
372 @@ -154,13 +164,34 @@ _hurd_exception2signal (struct hurd_sign
373
374 case EXC_BREAKPOINT:
375 *signo = SIGTRAP;
376 - if (detail->exc_code == EXC_I386_SGL)
377 - detail->code = DBG_SINGLE_TRAP;
378 - else if (detail->exc_code == EXC_I386_BPT)
379 - detail->code = DBG_BRKPNT_FAULT;
380 - else
381 - detail->code = 0;
382 + switch (detail->exc_code)
383 + {
384 + case EXC_I386_SGL:
385 + detail->code = posix ? TRAP_BRKPT : DBG_SINGLE_TRAP;
386 + break;
387 +
388 + case EXC_I386_BPT:
389 + detail->code = posix ? TRAP_BRKPT : DBG_BRKPNT_FAULT;
390 + break;
391 +
392 + default:
393 + detail->code = 0;
394 + break;
395 + }
396 break;
397 }
398 }
399 libc_hidden_def (_hurd_exception2signal)
400 +
401 +void
402 +_hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
403 +{
404 + exception2signal (detail, signo, 1);
405 +}
406 +
407 +void
408 +_hurd_exception2signal_legacy (struct hurd_signal_detail *detail, int *signo)
409 +{
410 + exception2signal (detail, signo, 0);
411 +}
412 +
413 Index: glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
414 ===================================================================
415 --- glibc-2.31.orig/sysdeps/mach/hurd/i386/trampoline.c
416 +++ glibc-2.31/sysdeps/mach/hurd/i386/trampoline.c
417 @@ -19,13 +19,66 @@
418 #include <hurd/signal.h>
419 #include <hurd/userlink.h>
420 #include <thread_state.h>
421 +#include <mach/exception.h>
422 #include <mach/machine/eflags.h>
423 #include <assert.h>
424 #include <errno.h>
425 #include "hurdfault.h"
426 #include <intr-msg.h>
427 +#include <sys/ucontext.h>
428
429
430 +/* Fill in a siginfo_t structure for SA_SIGINFO-enabled handlers. */
431 +static void fill_siginfo (siginfo_t *si, int signo,
432 + const struct hurd_signal_detail *detail,
433 + const struct machine_thread_all_state *state)
434 +{
435 + si->si_signo = signo;
436 + si->si_errno = detail->error;
437 + si->si_code = detail->code;
438 +
439 + /* XXX We would need a protocol change for sig_post to include
440 + * this information. */
441 + si->si_pid = -1;
442 + si->si_uid = -1;
443 +
444 + /* Address of the faulting instruction or memory access. */
445 + if (detail->exc == EXC_BAD_ACCESS)
446 + si->si_addr = (void *) detail->exc_subcode;
447 + else
448 + si->si_addr = (void *) state->basic.eip;
449 +
450 + /* XXX On SIGCHLD, this should be the exit status of the child
451 + * process. We would need a protocol change for the proc server
452 + * to send this information along with the signal. */
453 + si->si_status = 0;
454 +
455 + si->si_band = 0; /* SIGPOLL is not supported yet. */
456 + si->si_value.sival_int = 0; /* sigqueue() is not supported yet. */
457 +}
458 +
459 +/* Fill in a ucontext_t structure SA_SIGINFO-enabled handlers. */
460 +static void fill_ucontext (ucontext_t *uc, const struct sigcontext *sc)
461 +{
462 + uc->uc_flags = 0;
463 + uc->uc_link = NULL;
464 + uc->uc_sigmask = sc->sc_mask;
465 + uc->uc_stack.ss_sp = (__ptr_t) sc->sc_esp;
466 + uc->uc_stack.ss_size = 0;
467 + uc->uc_stack.ss_flags = 0;
468 +
469 + /* Registers. */
470 + memcpy (&uc->uc_mcontext.gregs[REG_GS], &sc->sc_gs,
471 + (REG_TRAPNO - REG_GS) * sizeof (int));
472 + uc->uc_mcontext.gregs[REG_TRAPNO] = 0;
473 + uc->uc_mcontext.gregs[REG_ERR] = 0;
474 + memcpy (&uc->uc_mcontext.gregs[REG_EIP], &sc->sc_eip,
475 + (NGREG - REG_EIP) * sizeof (int));
476 +
477 + /* XXX FPU state. */
478 + memset (&uc->uc_mcontext.fpregs, 0, sizeof (fpregset_t));
479 +}
480 +
481 struct sigcontext *
482 _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
483 int signo, struct hurd_signal_detail *detail,
484 @@ -43,15 +96,38 @@ _hurd_setup_sighandler (struct hurd_sigs
485 struct
486 {
487 int signo;
488 - long int sigcode;
489 - struct sigcontext *scp; /* Points to ctx, below. */
490 + union
491 + {
492 + /* Extra arguments for traditional signal handlers */
493 + struct
494 + {
495 + long int sigcode;
496 + struct sigcontext *scp; /* Points to ctx, below. */
497 + } legacy;
498 +
499 + /* Extra arguments for SA_SIGINFO handlers */
500 + struct
501 + {
502 + siginfo_t *siginfop; /* Points to siginfo, below. */
503 + ucontext_t *uctxp; /* Points to uctx, below. */
504 + } posix;
505 + };
506 void *sigreturn_addr;
507 void *sigreturn_returns_here;
508 struct sigcontext *return_scp; /* Same; arg to sigreturn. */
509 +
510 + /* NB: sigreturn assumes link is next to ctx. */
511 struct sigcontext ctx;
512 struct hurd_userlink link;
513 + ucontext_t ucontext;
514 + siginfo_t siginfo;
515 } *stackframe;
516
517 + /* sigaction for preemptors */
518 + static const struct sigaction legacy_sigaction = {
519 + .sa_flags = SA_RESTART
520 + };
521 +
522 if (ss->context)
523 {
524 /* We have a previous sigcontext that sigreturn was about
525 @@ -94,9 +170,13 @@ _hurd_setup_sighandler (struct hurd_sigs
526 the SP on sigreturn. */
527 state->basic.uesp = state->basic.ecx;
528
529 - /* XXX what if handler != action->handler (for instance, if a signal
530 - * preemptor took over) ? */
531 action = & _hurd_sigstate_actions (ss) [signo];
532 + if ( (action->sa_flags & SA_SIGINFO)
533 + && handler != (__sighandler_t) action->sa_sigaction
534 + || !(action->sa_flags & SA_SIGINFO)
535 + && handler != action->sa_handler)
536 + /* A signal preemptor took over, use legacy semantic. */
537 + action = &legacy_sigaction;
538
539 if ((action->sa_flags & SA_ONSTACK)
540 && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK)))
541 @@ -140,15 +220,9 @@ _hurd_setup_sighandler (struct hurd_sigs
542 = &stackframe->link.thread.next;
543 ss->active_resources = &stackframe->link;
544
545 - /* Set up the arguments for the signal handler. */
546 - stackframe->signo = signo;
547 - stackframe->sigcode = detail->code;
548 - stackframe->scp = stackframe->return_scp = scp = &stackframe->ctx;
549 - stackframe->sigreturn_addr = &__sigreturn;
550 - stackframe->sigreturn_returns_here = firewall; /* Crash on return. */
551 -
552 /* Set up the sigcontext from the current state of the thread. */
553
554 + scp = &stackframe->ctx;
555 scp->sc_onstack = ss->sigaltstack.ss_flags & SS_ONSTACK ? 1 : 0;
556
557 /* struct sigcontext is laid out so that starting at sc_gs mimics a
558 @@ -162,6 +236,35 @@ _hurd_setup_sighandler (struct hurd_sigs
559 &state->fpu, &scp->sc_i386_float_state,
560 sizeof (state->fpu));
561
562 + /* Set up the arguments for the signal handler. */
563 + stackframe->signo = signo;
564 + if (action->sa_flags & SA_SIGINFO)
565 + {
566 + stackframe->posix.siginfop = &stackframe->siginfo;
567 + stackframe->posix.uctxp = &stackframe->ucontext;
568 + fill_siginfo (&stackframe->siginfo, signo, detail, state);
569 + fill_ucontext (&stackframe->ucontext, scp);
570 + }
571 + else
572 + {
573 + if (detail->exc)
574 + {
575 + int nsigno;
576 + _hurd_exception2signal_legacy (detail, &nsigno);
577 + assert (nsigno == signo);
578 + }
579 + else
580 + detail->code = 0;
581 +
582 + stackframe->legacy.sigcode = detail->code;
583 + stackframe->legacy.scp = &stackframe->ctx;
584 + }
585 +
586 + /* Set up the bottom of the stack. */
587 + stackframe->sigreturn_addr = &__sigreturn;
588 + stackframe->sigreturn_returns_here = firewall; /* Crash on return. */
589 + stackframe->return_scp = &stackframe->ctx;
590 +
591 _hurdsig_end_catch_fault ();
592
593 if (! ok)
594 Index: glibc-2.31/sysdeps/mach/hurd/kill.c
595 ===================================================================
596 --- glibc-2.31.orig/sysdeps/mach/hurd/kill.c
597 +++ glibc-2.31/sysdeps/mach/hurd/kill.c
598 @@ -64,7 +64,7 @@ __kill (pid_t pid, int sig)
599 {
600 if (msgport != MACH_PORT_NULL)
601 /* Send a signal message to his message port. */
602 - return __msg_sig_post (msgport, sig, 0, refport);
603 + return __msg_sig_post (msgport, sig, SI_USER, refport);
604
605 /* The process has no message port. Perhaps try direct
606 frobnication of the task. */
607 Index: glibc-2.31/sysdeps/mach/hurd/setitimer.c
608 ===================================================================
609 --- glibc-2.31.orig/sysdeps/mach/hurd/setitimer.c
610 +++ glibc-2.31/sysdeps/mach/hurd/setitimer.c
611 @@ -105,7 +105,7 @@ timer_thread (void)
612 __msg_sig_post_request (_hurd_msgport,
613 _hurd_itimer_port,
614 MACH_MSG_TYPE_MAKE_SEND_ONCE,
615 - SIGALRM, 0, __mach_task_self ());
616 + SIGALRM, SI_TIMER, __mach_task_self ());
617 break;
618
619 case MACH_RCV_INTERRUPTED:
620 Index: glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
621 ===================================================================
622 --- glibc-2.31.orig/sysdeps/mach/hurd/i386/sigcontextinfo.h
623 +++ glibc-2.31/sysdeps/mach/hurd/i386/sigcontextinfo.h
624 @@ -18,11 +18,10 @@
625 #ifndef _SIGCONTEXTINFO_H
626 #define _SIGCONTEXTINFO_H
627
628 -#define SIGCONTEXT struct sigcontext
629 static inline uintptr_t
630 -sigcontext_get_pc (struct sigcontext ctx)
631 +sigcontext_get_pc (struct ucontext_t *ctx)
632 {
633 - return ctx.sc_eip;
634 + return ctx->uc_mcontext.gregs[REG_EIP];
635 }
636
637 #endif