about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-07-14 20:08:49 +0000
committerEric Wong <e@80x24.org>2015-07-14 20:09:58 +0000
commit8177ec7a32ef7f4c12756d8b272d15a9239a154d (patch)
tree184797ee0af63cedd16e3e1e97ecac3dd76f5a6b
parent8eb264580731e4304808428db5c7a33fe1926a52 (diff)
downloadraindrops-8177ec7a32ef7f4c12756d8b272d15a9239a154d.tar.gz
The linux/tcp.h header may not exist on alternative libc
implementations such as musl.

Noticed-by: Doug Forster <doug.forster@gmail.com>
-rw-r--r--ext/raindrops/extconf.rb1
-rw-r--r--ext/raindrops/linux_tcp_info.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/raindrops/extconf.rb b/ext/raindrops/extconf.rb
index f012808..74ed8f9 100644
--- a/ext/raindrops/extconf.rb
+++ b/ext/raindrops/extconf.rb
@@ -6,6 +6,7 @@ have_func('munmap', 'sys/mman.h') or abort 'munmap() not found'
 
 $CPPFLAGS += " -D_GNU_SOURCE "
 have_func('mremap', 'sys/mman.h')
+have_header('linux/tcp.h')
 
 $CPPFLAGS += " -D_BSD_SOURCE "
 have_func("getpagesize", "unistd.h")
diff --git a/ext/raindrops/linux_tcp_info.c b/ext/raindrops/linux_tcp_info.c
index dcdb153..5e25d4d 100644
--- a/ext/raindrops/linux_tcp_info.c
+++ b/ext/raindrops/linux_tcp_info.c
@@ -1,4 +1,4 @@
-#ifdef __linux__
+#if defined(__linux__) && defined(HAVE_LINUX_TCP_H)
 #include <ruby.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -170,4 +170,4 @@ void Init_raindrops_linux_tcp_info(void)
         TCPI_DEFINE_METHOD(total_retrans);
 }
 #endif /* TCP_INFO */
-#endif /* __linux__ */
+#endif /* defined(__linux__) && defined(HAVE_LINUX_TCP_H) */