3 * Copyright (C) 2007 Daniel Drake <dsd@gentoo.org>
5 * Based on glibc header
6 * Copyright (C) 2007 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __LIBUSB_SIGNALFD_H__
24 #define __LIBUSB_SIGNALFD_H__
26 /* FIXME: in future, remove this and unconditionally use glibc directly when
27 * glibc-2.8 is widespread */
33 #define __NR_signalfd 321
34 #elif defined(__x86_64__)
35 #define __NR_signalfd 282
37 #error "signalfd unsupported on this architecture"
40 /* signalfd() implementation was added as of glibc-2.7 */
41 #if __GLIBC_PREREQ(2, 7)
42 int signalfd(int fd, const sigset_t *mask, int flags);
44 #include <sys/syscall.h>
46 #define SIZEOF_SIG (_NSIG / 8)
47 #define SIZEOF_SIGSET (SIZEOF_SIG > sizeof(sigset_t) ? sizeof(sigset_t): SIZEOF_SIG)
49 static inline int signalfd(int fd, const sigset_t *mask, int flags)
51 return syscall(__NR_signalfd, fd, mask, SIZEOF_SIGSET);
55 struct signalfd_siginfo {