Fixed compilation with Visual Studio by including poll.h
PATCH 1/1 Fixed compilation with Visual Studio by including poll.h
upload-archive.c and upload-pack.c use pollfd struct and POLLIN constant which are defined in poll.h. However, poll.h is not included.
--- builtin/upload-archive.c | 1 + upload-pack.c | 1 + 2 files changed, 2 insertions(+)
builtin/upload-archive.c +1 -0
@@ -1,6 +1,7 @@/* * Copyright (c) 2006 Franck Bui-Huu */ +#include "poll.h" #include "cache.h" #include "builtin.h" #include "archive.h"
upload-pack.c +1 -0
@@ -1,3 +1,4 @@ +#include "poll.h" #include "cache.h" #include "refs.h" #include "pkt-line.h"
Signature · 4 lines
Best regards, Sven Strickroth ClamAV, a GPL anti-virus toolkit http://www.clamav.net PGP key id F5A9D4C4 @ any key-server
Quoted 2 lines · Sven Strickroth
upload-archive.candupload-pack.cuse pollfd struct and POLLIN constant which are defined inpoll.h. However,poll.his not included.
This should already be included by git-compat-util.h:
$ grep -C1 poll.h git-compat-util.h #ifndef NO_SYS_POLL_H #include <sys/poll.h> #else #include <poll.h> #endif
It looks like we will prefer sys/poll.h if it exists. The official XSI location is "poll.h", but I guess in practice they are equivalent on most systems if you have both (certainly on Linux, poll.h just includes sys/poll.h).
Does your environments have a sys/poll.h that exists isn't sufficient to use poll? Maybe we need to tweak git-compat-util to include both if they both exist.
-Peff
Windows does not have sys/poll.h. I have to use the one from compat/win32.
The problem is that
NO_SYS_POLL_H
is defined in compat/msvc.h in my environment.
And in git-compat-util.h
#ifndef NO_SYS_POLL_H
#include <sys/poll.h>
#else
#include <poll.h>
#endif
is before
#elif defined(_MSC_VER)
#include "compat/msvc.h". Moving it down, solves the issue for me. (Suppose this is a fix for my scenario only).
git-compat-util.h +5 -5
@@ -111,11 +111,6 @@#include <regex.h> #include <utime.h> #include <syslog.h> -#ifndef NO_SYS_POLL_H -#include <sys/poll.h> -#else -#include <poll.h> -#endif #if defined(__MINGW32__)/* pull in Windows compatibility stuff */ #include "compat/mingw.h"
@@ -152,6 +147,11 @@#define _ALL_SOURCE 1#endif #endif +#ifndef NO_SYS_POLL_H +#include <sys/poll.h> +#else +#include <poll.h> +#endif #ifndef NO_LIBGEN_H #include <libgen.h>
Signature · 4 lines
Best regards, Sven Strickroth ClamAV, a GPL anti-virus toolkit http://www.clamav.net PGP key id F5A9D4C4 @ any key-server
Quoted 17 lines · Sven Strickroth
Windows does not have
sys/poll.h. I have to use the one from compat/win32.The problem is that
NO_SYS_POLL_H
is defined incompat/msvc.hin my environment.
And ingit-compat-util.h
#ifndefNO_SYS_POLL_H
#include <sys/poll.h>
#else
#include <poll.h>
#endif
is before
#elifdefined(_MSC_VER)
#include "compat/msvc.h"
. Moving it down, solves the issue for me. (Suppose this is a fix for my scenario only).
NO_SYS_POLL_H shouldn't be defined in compat/msvc.h, it should be defined by the build-system. Our Makefile already does this inside the "ifeq ($(uname_S),Windows)"-block.
How are you building Git?
Quoted 6 lines · Jeff King
Quoted 2 lines · Sven Strickroth
upload-archive.candupload-pack.cuse pollfd struct and POLLIN constant which are defined inpoll.h. However,poll.his not included.This should already be included by
git-compat-util.h:
Thanks for a bit of sanity.
Quoted 11 lines
$ grep -C1 poll.h git-compat-util.h #ifndef NO_SYS_POLL_H #include <sys/poll.h> #else #include <poll.h> #endifIt looks like we will prefer
sys/poll.hif it exists. The official XSI location is "poll.h", but I guess in practice they are equivalent on most systems if you have both (certainly on Linux,poll.hjust includessys/poll.h).
There actually is no preference between the two from _our_ side. It is up to the builder to know and define necessary make variables.
Quoted 3 lines
Does your environments have a
sys/poll.hthat exists isn't sufficient to use poll? Maybe we need to tweak git-compat-util to include both if they both exist.
Both? I guess, but I suspect that on most sane systems one would include the other if there are both provided (iow, just so that you can complile sources written both for XSI and for systems in the field).
Quoted 7 lines · Junio C Hamano
Quoted 4 lines
It looks like we will prefer
sys/poll.hif it exists. The official XSI location is "poll.h", but I guess in practice they are equivalent on most systems if you have both (certainly on Linux,poll.hjust includessys/poll.h).There actually is no preference between the two from _our_ side. It is up to the builder to know and define necessary make variables.
I say "prefer" only because if you set nothing, you get "sys/poll.h". So it is up to the builder to say "no, I do not have that non-standard location. Use the standard one instead". Which seems a little backwards.
Of course "standard" here is just what POSIX says; sys/poll.h may be much more standard in the real world (I don't know).
Quoted 7 lines
Quoted 3 lines
Does your environments have a
sys/poll.hthat exists isn't sufficient to use poll? Maybe we need to tweak git-compat-util to include both if they both exist.Both? I guess, but I suspect that on most sane systems one would include the other if there are both provided (iow, just so that you can complile sources written both for XSI and for systems in the field).
I would think one or the other would be fine. But the fact that Sven's patch works makes me think that he has sys/poll.h, but it is not sufficient. Hopefully including "poll.h" would be enough, but it's not clear to me.
-Peff