测试机信息如下:
$ uname -a
Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
-------------------------------
首先,参考下面一段代码:boost/asio/detai/config.hpp (boost_1_77_0)
// Linux: epoll, eventfd and timerfd.
#if defined(__linux__)
# include <linux/version.h>
# if !defined(BOOST_ASIO_HAS_EPOLL)
# if !defined(BOOST_ASIO_DISABLE_EPOLL)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# define BOOST_ASIO_HAS_EPOLL 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45)
# endif // !defined(BOOST_ASIO_DISABLE_EPOLL)
# endif // !defined(BOOST_ASIO_HAS_EPOLL)
# if !defined(BOOST_ASIO_HAS_EVENTFD)
# if !defined(BOOST_ASIO_DISABLE_EVENTFD)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# define BOOST_ASIO_HAS_EVENTFD 1
# endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# endif // !defined(BOOST_ASIO_DISABLE_EVENTFD)
# endif // !defined(BOOST_ASIO_HAS_EVENTFD)
# if !defined(BOOST_ASIO_HAS_TIMERFD)
# if defined(BOOST_ASIO_HAS_EPOLL)
# if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# define BOOST_ASIO_HAS_TIMERFD 1
# endif // (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
# endif // defined(BOOST_ASIO_HAS_EPOLL)
# endif // !defined(BOOST_ASIO_HAS_TIMERFD)
#endif // defined(__linux__)
通过以上代码得知,只要linux内核版本大于2.5.45就使用了epoll。
LINUX_VERSION_CODE为linux系统定义的宏,位于/usr/include/linux/version.h
#define LINUX_VERSION_CODE 199168
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#define RHEL_MAJOR 7
#define RHEL_MINOR 9
#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))
#define RHEL_RELEASE_CODE 1801
#define RHEL_RELEASE "1160.25.1"
#define KERNEL_HEADERS_CHECKSUM "9539ce96a60186245118a6d053a557e9dc951163"
通过上面的宏定义计算 LINUX_VERSION_CODE(199168) > KERNEL_VESION(2,5,45)
因此推断,boost使用了epoll