Skip to content

Commit 2648ccc

Browse files
sgngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d166e6a commit 2648ccc

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,12 @@ all::
207207
# Define MMAP_PREVENTS_DELETE if a file that is currently mmapped cannot be
208208
# deleted or cannot be replaced using rename().
209209
#
210+
# Define NO_POLL_H if you don't have poll.h.
211+
#
210212
# Define NO_SYS_POLL_H if you don't have sys/poll.h.
211213
#
212214
# 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.
214216
#
215217
# Define NEEDS_SYS_PARAM_H if you need to include sys/param.h to compile,
216218
# *PLEASE* REPORT to [email protected] if your platform needs this;
@@ -1460,6 +1462,7 @@ ifdef NO_GETTEXT
14601462
USE_GETTEXT_SCHEME ?= fallthrough
14611463
endif
14621464
ifdef NO_POLL
1465+
NO_POLL_H = YesPlease
14631466
NO_SYS_POLL_H = YesPlease
14641467
COMPAT_CFLAGS += -DNO_POLL -Icompat/poll
14651468
COMPAT_OBJS += compat/poll/poll.o
@@ -1498,6 +1501,9 @@ endif
14981501
ifdef NO_SYS_SELECT_H
14991502
BASIC_CFLAGS += -DNO_SYS_SELECT_H
15001503
endif
1504+
ifdef NO_POLL_H
1505+
BASIC_CFLAGS += -DNO_POLL_H
1506+
endif
15011507
ifdef NO_SYS_POLL_H
15021508
BASIC_CFLAGS += -DNO_SYS_POLL_H
15031509
endif

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,12 @@ AC_CHECK_HEADER([sys/select.h],
792792
[NO_SYS_SELECT_H=UnfortunatelyYes])
793793
GIT_CONF_SUBST([NO_SYS_SELECT_H])
794794
#
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+
#
795801
# Define NO_SYS_POLL_H if you don't have sys/poll.h
796802
AC_CHECK_HEADER([sys/poll.h],
797803
[NO_SYS_POLL_H=],

git-compat-util.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,12 @@
180180
#include <regex.h>
181181
#include <utime.h>
182182
#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)
184186
#include <sys/poll.h>
185187
#else
188+
/* Pull the compat stuff */
186189
#include <poll.h>
187190
#endif
188191
#ifdef HAVE_BSD_SYSCTL

0 commit comments

Comments
 (0)