define signalfd patch

If sys/signalfd.h does not exist, assume that it does not exist
in glibc, rather than that it exists without a corresponding
header file.  Note that this version of the signalfd() wrapper
function (unlike the version in glibc) falls back dynamically to
the old signalfd system call if the signalfd4 system call is not
implemented in the currently-running kernel; the version in glibc
chooses the version of the signalfd system call to make via static
build-time configuration.

Signed-off-by: Michael K Johnson <johnsonm@rpath.com>
Signed-off-by: Daniel Lezcnao <dlezcano@fr.ibm.com>
This commit is contained in:
Michael K. Johnson 2009-03-08 17:24:26 +01:00 committed by Daniel Lezcano
parent 216061bffa
commit 8ca61733b9

View File

@ -43,9 +43,35 @@
#include <sys/poll.h>
#ifdef HAVE_SYS_SIGNALFD_H
#include <sys/signalfd.h>
# include <sys/signalfd.h>
#else
extern int signalfd (int fd, const sigset_t *mask, int flags);
# ifndef __NR_signalfd4
/* assume kernel headers are too old */
# if __i386__
# define __NR_signalfd4 327
# elif __x86_64__
# define __NR_signalfd4 289
# endif
#endif
# ifndef __NR_signalfd
/* assume kernel headers are too old */
# if __i386__
# define __NR_signalfd 321
# elif __x86_64__
# define __NR_signalfd 282
# endif
#endif
int signalfd(int fd, const sigset_t *mask, int flags)
{
int retval;
retval = syscall (__NR_signalfd4, fd, mask, _NSIG / 8, flags);
if (errno == ENOSYS && flags == 0)
retval = syscall (__NR_signalfd, fd, mask, _NSIG / 8);
return retval;
}
#endif
#if !HAVE_DECL_PR_CAPBSET_DROP