]> git.ipfire.org Git - thirdparty/glibc.git/blame - hurd/hurd/sigpreempt.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / hurd / hurd / sigpreempt.h
CommitLineData
71733723 1/* Preemption of Hurd signals before POSIX.1 semantics take over.
f7a9f785 2 Copyright (C) 1996-2016 Free Software Foundation, Inc.
10dc2a90 3 This file is part of the GNU C Library.
71733723 4
10dc2a90 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.
71733723 9
10dc2a90
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.
71733723 14
41bdb6e2 15 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
71733723
RM
18
19#ifndef _HURD_SIGPREEMPT_H
20
21#define _HURD_SIGPREEMPT_H 1
22#include <errno.h>
23#include <signal.h> /* For sigset_t, sighandler_t, SIG_ERR. */
24struct hurd_sigstate; /* <hurd/signal.h> */
93a470c7 25struct hurd_signal_detail; /* <hurd/signal.h> */
71733723 26
10dc2a90 27struct hurd_signal_preemptor
71733723
RM
28 {
29 /* These members select which signals this structure will apply to.
30 The rest of the structure is only consulted if these match. */
31 sigset_t signals; /* Signals preempted. */
32 unsigned long int first, last; /* Range of sigcode values preempted. */
33
34 /* This function will be called (with SS->lock held) to decide what to
35 do with the signal described. It may modify the codes of the signal
10dc2a90 36 passed. If the return value is SIG_ERR, the next matching preemptor
71733723 37 is tried, or the normal handling is done for the signal (which may
10dc2a90 38 have been changed by the preemptor function). Otherwise, the signal
71733723 39 is processed as if the return value were its handler setting. */
10dc2a90 40 sighandler_t (*preemptor) (struct hurd_signal_preemptor *preemptor,
71733723 41 struct hurd_sigstate *ss,
93a470c7 42 int *signo, struct hurd_signal_detail *detail);
10dc2a90 43 /* If PREEMPTOR is null, act as if it returned HANDLER. */
71733723
RM
44 sighandler_t handler;
45
10dc2a90 46 struct hurd_signal_preemptor *next; /* List structure. */
71733723
RM
47 };
48
10dc2a90
UD
49#define HURD_PREEMPT_SIGNAL_P(preemptor, signo, sigcode) \
50 (((preemptor)->signals & sigmask (signo)) && \
51 (sigcode) >= (preemptor)->first && (sigcode) <= (preemptor)->last)
71733723
RM
52
53
10dc2a90
UD
54/* Signal preemptors applying to all threads; locked by _hurd_siglock. */
55extern struct hurd_signal_preemptor *_hurdsig_preemptors;
71733723
RM
56extern sigset_t _hurdsig_preempted_set;
57
58
10dc2a90
UD
59/* The caller must initialize all members of *PREEMPTOR except `next'.
60 The preemptor is registered on the global list. */
61void hurd_preempt_signals (struct hurd_signal_preemptor *preemptor);
71733723 62
10dc2a90
UD
63/* Remove a preemptor registered with hurd_preempt_signals. */
64void hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor);
71733723
RM
65
66
67/* Call *OPERATE and return its value. If a signal in SIGSET with a sigcode
68 in the range [FIRST,LAST] arrives during the call, catch it. If HANDLER
69 is a function, it handles the signal in the normal way (i.e. it should
70 longjmp unless it can restart the insn on return). If it is SIG_ERR,
71 hurd_catch_signal returns the sc_error value from the signal (or
72 EGRATUITOUS if that is zero).
73
10dc2a90 74 The preemptor structure is passed to *OPERATE, which may modify its
71733723
RM
75 sigcode range or functions at any time during which it is guaranteed no
76 signal in SIGSET will arrive. */
77
78error_t hurd_catch_signal (sigset_t sigset,
79 unsigned long int first, unsigned long int last,
10dc2a90 80 error_t (*operate) (struct hurd_signal_preemptor *),
71733723
RM
81 sighandler_t handler);
82
83
84/* Convenience functions using `hurd_catch_signal'. */
85
c3d3967c
RM
86
87/* Like `memset', but catch faults in DEST. */
71733723
RM
88error_t hurd_safe_memset (void *dest, int byte, size_t nbytes);
89
c3d3967c
RM
90/* Like `memcpy', but catch faults in SRC. */
91error_t hurd_safe_copyin (void *dest, const void *src, size_t nbytes);
92
93/* Like `memcpy', but catch faults in DEST. */
94error_t hurd_safe_copyout (void *dest, const void *src, size_t nbytes);
95
96/* Like `memmove', but catch faults in SRC or DEST.
97 If only one region is expected to fault, it is more efficient
98 to use `hurd_safe_copyin' or `hurd_safe_copyout' as appropriate. */
99error_t hurd_safe_memmove (void *dest, const void *src, size_t nbytes);
100
71733723
RM
101
102#endif /* hurd/sigpreempt.h */