-printf "Checking if epoll exists... ";
-$has_epoll = 0;
-$fail = 0;
-open(EPOLL, "</usr/include/sys/epoll.h") or $fail = 1;
-if (!$fail) {
- $has_epoll = 1;
- close(EPOLL);
-}
-if ($has_epoll) {
- my $kernel = `uname -r`;
- chomp($kernel);
- if (($kernel =~ /^2\.0\./) || ($kernel =~ /^2\.2\./) || ($kernel =~ /^2\.4\./)) {
- $has_epoll = 0;
- }
- else
- {
- # Suggestion from nenolod, weed out odd systems which have glibc built
- # against 2.4 kernels (ick)
- my $kernel_arch = `uname -p`;
- chomp($kernel_arch);
- my $libcv = 0.0;
- my $kernelv = 0.0;
- if ($kernel_arch =~ /x86_64/) {
- open (FH,"/lib64/libc.so.6|") or $has_epoll = 0;
- }
- else {
- open (FH,"/lib/libc.so.6|") or $has_epoll = 0;
- }
- if ($has_epoll)
- {
- while (defined(my $line = <FH>))
- {
- chomp($line);
- if ($line =~ /GNU C Library .* version (.*?) /)
- {
- $libcv = $1;
- $libcv =~ /(\d+\.\d+)/;
- $libcv = $1;
- }
- elsif ($line =~ /Compiled on a Linux (.*?\..*?)\.* system/)
- {
- $kernelv = $1;
- # Fix for some retarded libc builds, strip off >> and << etc.
- $kernelv =~ /(\d+\.\d+)/;
- $kernelv = $1;
- }
- }
- close FH;
- if ($libcv < 2.3)
- {
- $has_epoll = 0;
- printf "libc too old: $libcv... ";
- }
- if ($kernelv < 2.6)
- {
- $has_epoll = 0;
- printf "libc built against older kernel $kernelv... ";
- }
- }
- }
-}
-print "yes\n" if $has_epoll == 1;
-print "no\n" if $has_epoll == 0;
+printf "Checking for epoll support... ";
+$has_epoll = test_compile('epoll');
+print $has_epoll ? "yes\n" : "no\n";
+
+printf "Checking for eventfd support... ";
+$config{HAS_EVENTFD} = test_compile('eventfd') ? 'true' : 'false';
+print $config{HAS_EVENTFD} eq 'true' ? "yes\n" : "no\n";