forkfd: Fix compilation with older glibc

glibc 2.9 is required for pipe2 and version 2.7 for eventfd.

Bionic added them to Android version 2.3.1, but I can't find a version
macro.

uclibc masquerades as glibc version 2.2, so this function won't be
thread-safe with uclibc.

Change-Id: Iee8cbc07c4434ce9b560ffff13cd3c3b63dd7e83
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Thiago Macieira 2015-03-20 23:48:02 +09:00 committed by Olivier Goffart (Woboq GmbH)
parent 06671a3cbd
commit f25d6ad2aa
1 changed files with 7 additions and 3 deletions

View File

@ -41,9 +41,13 @@
#include <unistd.h>
#ifdef __linux__
# define HAVE_PIPE2 1
# define HAVE_EVENTFD 1
# include <sys/eventfd.h>
# if (defined(__GLIBC__) && (__GLIBC__ << 16) + __GLIBC_MINOR__ >= 0x207) || defined(__BIONIC__)
# include <sys/eventfd.h>
# define HAVE_EVENTFD 1
# endif
# if (defined(__GLIBC__) && (__GLIBC__ << 16) + __GLIBC_MINOR__ >= 0x209) || defined(__BIONIC__)
# define HAVE_PIPE2 1
# endif
#endif
#if _POSIX_VERSION-0 >= 200809L || _XOPEN_VERSION-0 >= 500