]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/aio_misc.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / aio_misc.h
CommitLineData
dff8da6b 1/* Copyright (C) 2004-2024 Free Software Foundation, Inc.
ffdd5e50 2 This file is part of the GNU C Library.
ffdd5e50
UD
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; see the file COPYING.LIB. If
5a82c748 16 not, see <https://www.gnu.org/licenses/>. */
ffdd5e50
UD
17
18#ifndef _AIO_MISC_H
19# include_next <aio_misc.h>
88bce79e
UD
20# include <limits.h>
21# include <pthread.h>
ffdd5e50
UD
22# include <signal.h>
23# include <sysdep.h>
ffdd5e50
UD
24
25# define aio_start_notify_thread __aio_start_notify_thread
26# define aio_create_helper_thread __aio_create_helper_thread
27
28extern inline void
29__aio_start_notify_thread (void)
30{
31 sigset_t ss;
32 sigemptyset (&ss);
f26d456b
AZ
33 INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &ss, NULL,
34 __NSIG_BYTES);
ffdd5e50
UD
35}
36
37extern inline int
88bce79e
UD
38__aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
39 void *arg)
ffdd5e50
UD
40{
41 pthread_attr_t attr;
42
43 /* Make sure the thread is created detached. */
d12506b2
FW
44 __pthread_attr_init (&attr);
45 __pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
ffdd5e50
UD
46
47 /* The helper thread needs only very little resources. */
d12506b2 48 __pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr));
ffdd5e50
UD
49
50 /* Block all signals in the helper thread. To do this thoroughly we
51 temporarily have to block all signals here. */
52 sigset_t ss;
53 sigset_t oss;
54 sigfillset (&ss);
f26d456b
AZ
55 INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &ss, &oss,
56 __NSIG_BYTES);
ffdd5e50 57
d12506b2 58 int ret = __pthread_create (threadp, &attr, tf, arg);
ffdd5e50
UD
59
60 /* Restore the signal mask. */
f26d456b
AZ
61 INTERNAL_SYSCALL_CALL (rt_sigprocmask, SIG_SETMASK, &oss, NULL,
62 __NSIG_BYTES);
ffdd5e50 63
d12506b2 64 __pthread_attr_destroy (&attr);
ffdd5e50 65 return ret;
88bce79e 66}
ffdd5e50 67#endif