Blame sysdeps/unix/sysv/linux/aio_misc.h

Packit Service 82fcde
/* Copyright (C) 2004-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public License as
Packit Service 82fcde
   published by the Free Software Foundation; either version 2.1 of the
Packit Service 82fcde
   License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; see the file COPYING.LIB.  If
Packit Service 82fcde
   not, see <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#ifndef _AIO_MISC_H
Packit Service 82fcde
# include_next <aio_misc.h>
Packit Service 82fcde
# include <limits.h>
Packit Service 82fcde
# include <pthread.h>
Packit Service 82fcde
# include <signal.h>
Packit Service 82fcde
# include <sysdep.h>
Packit Service 82fcde
Packit Service 82fcde
# define aio_start_notify_thread __aio_start_notify_thread
Packit Service 82fcde
# define aio_create_helper_thread __aio_create_helper_thread
Packit Service 82fcde
Packit Service 82fcde
extern inline void
Packit Service 82fcde
__aio_start_notify_thread (void)
Packit Service 82fcde
{
Packit Service 82fcde
  sigset_t ss;
Packit Service 82fcde
  sigemptyset (&ss);
Packit Service 82fcde
  INTERNAL_SYSCALL_DECL (err);
Packit Service 82fcde
  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
extern inline int
Packit Service 82fcde
__aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
Packit Service 82fcde
			    void *arg)
Packit Service 82fcde
{
Packit Service 82fcde
  pthread_attr_t attr;
Packit Service 82fcde
Packit Service 82fcde
  /* Make sure the thread is created detached.  */
Packit Service 82fcde
  pthread_attr_init (&attr);
Packit Service 82fcde
  pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
Packit Service 82fcde
Packit Service 82fcde
  /* The helper thread needs only very little resources.  */
Packit Service 82fcde
  (void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr));
Packit Service 82fcde
Packit Service 82fcde
  /* Block all signals in the helper thread.  To do this thoroughly we
Packit Service 82fcde
     temporarily have to block all signals here.  */
Packit Service 82fcde
  sigset_t ss;
Packit Service 82fcde
  sigset_t oss;
Packit Service 82fcde
  sigfillset (&ss);
Packit Service 82fcde
  INTERNAL_SYSCALL_DECL (err);
Packit Service 82fcde
  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
Packit Service 82fcde
Packit Service 82fcde
  int ret = pthread_create (threadp, &attr, tf, arg);
Packit Service 82fcde
Packit Service 82fcde
  /* Restore the signal mask.  */
Packit Service 82fcde
  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
Packit Service 82fcde
		    _NSIG / 8);
Packit Service 82fcde
Packit Service 82fcde
  (void) pthread_attr_destroy (&attr);
Packit Service 82fcde
  return ret;
Packit Service 82fcde
}
Packit Service 82fcde
#endif