git-compat-util: prefer poll.h to sys/poll.h
POSIX specifies that <poll.h> is the correct header for poll(2) whereas <sys/poll.h> is only needed for some old libc. Let's follow the POSIX way by default. This effectively eliminates musl's warning: warning redirecting incorrect #include <sys/poll.h> to <poll.h> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Đoàn Trần Công Danh committed
Nov 14, 2018 at 08:10 UTC
2648ccc231b38206e2dafe9a6cc1ca0978bcef5e
3 files changed
+17
-2
Makefile
+7
-1
@@ -207,10 +207,12 @@ all::
207
# Define MMAP_PREVENTS_DELETE if a file that is currently mmapped cannot be
208
# deleted or cannot be replaced using rename().
209
#
210
+# Define NO_POLL_H if you don't have poll.h.
211
+#
212
# Define NO_SYS_POLL_H if you don't have sys/poll.h.
213
#
214
# Define NO_POLL if you do not have or don't want to use poll().
213
-# This also implies NO_SYS_POLL_H.
215
+# This also implies NO_POLL_H and NO_SYS_POLL_H.
216
#
217
# Define NEEDS_SYS_PARAM_H if you need to include sys/param.h to compile,
218
# *PLEASE* REPORT to git@vger.kernel.org if your platform needs this;
@@ -1460,6 +1462,7 @@ ifdef NO_GETTEXT
1462
USE_GETTEXT_SCHEME ?= fallthrough
1463
endif
1464
ifdef NO_POLL
1465
+ NO_POLL_H = YesPlease
1466
NO_SYS_POLL_H = YesPlease
1467
COMPAT_CFLAGS += -DNO_POLL -Icompat/poll
1468
COMPAT_OBJS += compat/poll/poll.o
@@ -1498,6 +1501,9 @@ endif
1501
ifdef NO_SYS_SELECT_H
1502
BASIC_CFLAGS += -DNO_SYS_SELECT_H
1503
endif
1504
+ifdef NO_POLL_H
1505
+ BASIC_CFLAGS += -DNO_POLL_H
1506
+endif
1507
ifdef NO_SYS_POLL_H
1508
BASIC_CFLAGS += -DNO_SYS_POLL_H
1509
endif
configure.ac
+6
@@ -792,6 +792,12 @@ AC_CHECK_HEADER([sys/select.h],
792
[NO_SYS_SELECT_H=UnfortunatelyYes])
793
GIT_CONF_SUBST([NO_SYS_SELECT_H])
794
#
795
+# Define NO_POLL_H if you don't have poll.h
796
+AC_CHECK_HEADER([poll.h],
797
+[NO_POLL_H=],
798
+[NO_POLL_H=UnfortunatelyYes])
799
+GIT_CONF_SUBST([NO_POLL_H])
800
+#
801
# Define NO_SYS_POLL_H if you don't have sys/poll.h
802
AC_CHECK_HEADER([sys/poll.h],
803
[NO_SYS_POLL_H=],
git-compat-util.h
+4
-1
@@ -180,9 +180,12 @@
180
#include <regex.h>
181
#include <utime.h>
182
#include <syslog.h>
183
-#ifndef NO_SYS_POLL_H
183
+#if !defined(NO_POLL_H)
184
+#include <poll.h>
185
+#elif !defined(NO_SYS_POLL_H)
186
#include <sys/poll.h>
187
#else
188
+/* Pull the compat stuff */
189
#include <poll.h>
190
#endif
191
#ifdef HAVE_BSD_SYSCTL