{"thread":{"id":"30298","subject":"[PATCH] Fixed compilation with Visual Studio by including poll.h","startedAt":"2012-04-20T20:37:19Z","lastAt":"2012-04-20T23:23:19Z","messageCount":6,"participants":["Sven Strickroth","Jeff King","Junio C Hamano","Erik Faye-Lund"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"189780","messageId":"4F91C8FF.7070402@tu-clausthal.de","threadId":"30298","inReplyTo":null,"subject":"[PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Sven Strickroth","fromEmail":"sven.strickroth@tu-clausthal.de","sentAt":"2012-04-20T20:37:19Z","receivedAt":"2012-04-20T20:37:19Z","isPatch":true,"sender":{"key":"sven.strickroth@tu-clausthal.de","avatar":null},"body":"upload-archive.c and upload-pack.c use pollfd struct and POLLIN constant\nwhich are defined in poll.h. However, poll.h is not included.\n\nSigned-off-by: Sven Strickroth <email@cs-ware.de>\n---\n builtin/upload-archive.c |    1 +\n upload-pack.c            |    1 +\n 2 files changed, 2 insertions(+)\n\ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex b928beb..6226bbb 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -1,6 +1,7 @@\n /*\n  * Copyright (c) 2006 Franck Bui-Huu\n  */\n+#include \"poll.h\"\n #include \"cache.h\"\n #include \"builtin.h\"\n #include \"archive.h\"\ndiff --git a/upload-pack.c b/upload-pack.c\nindex bb08e2e..79f9f8f 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -1,3 +1,4 @@\n+#include \"poll.h\"\n #include \"cache.h\"\n #include \"refs.h\"\n #include \"pkt-line.h\"\n-- \nBest regards,\n Sven Strickroth\n ClamAV, a GPL anti-virus toolkit   http://www.clamav.net\n PGP key id F5A9D4C4 @ any key-server\n"},{"id":"189781","messageId":"20120420204722.GD13103@sigill.intra.peff.net","threadId":"30298","inReplyTo":"4F91C8FF.7070402@tu-clausthal.de","subject":"Re: [PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-04-20T20:47:23Z","receivedAt":"2012-04-20T20:47:23Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 20, 2012 at 10:37:19PM +0200, Sven Strickroth wrote:\n\n> upload-archive.c and upload-pack.c use pollfd struct and POLLIN constant\n> which are defined in poll.h. However, poll.h is not included.\n\nThis should already be included by git-compat-util.h:\n\n  $ grep -C1 poll.h git-compat-util.h\n  #ifndef NO_SYS_POLL_H\n  #include <sys/poll.h>\n  #else\n  #include <poll.h>\n  #endif\n\nIt looks like we will prefer sys/poll.h if it exists. The official XSI\nlocation is \"poll.h\", but I guess in practice they are equivalent on\nmost systems if you have both (certainly on Linux, poll.h just includes\nsys/poll.h).\n\nDoes your environments have a sys/poll.h that exists isn't sufficient to\nuse poll? Maybe we need to tweak git-compat-util to include both if they\nboth exist.\n\n-Peff\n"},{"id":"189783","messageId":"4F91D489.8050402@tu-clausthal.de","threadId":"30298","inReplyTo":"20120420204722.GD13103@sigill.intra.peff.net","subject":"Re: [PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Sven Strickroth","fromEmail":"sven.strickroth@tu-clausthal.de","sentAt":"2012-04-20T21:26:33Z","receivedAt":"2012-04-20T21:26:33Z","isPatch":true,"sender":{"key":"sven.strickroth@tu-clausthal.de","avatar":null},"body":"Windows does not have sys/poll.h. I have to use the one from compat/win32.\n\nThe problem is that\n    NO_SYS_POLL_H\nis defined in compat/msvc.h in my environment.\nAnd in git-compat-util.h\n    #ifndef NO_SYS_POLL_H\n    #include <sys/poll.h>\n    #else\n    #include <poll.h>\n    #endif\nis before\n    #elif defined(_MSC_VER)\n    #include \"compat/msvc.h\"\n. Moving it down, solves the issue for me. (Suppose this is a fix for my\nscenario only).\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex ed11ad8..a96849c 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -111,11 +111,6 @@\n #include <regex.h>\n #include <utime.h>\n #include <syslog.h>\n-#ifndef NO_SYS_POLL_H\n-#include <sys/poll.h>\n-#else\n-#include <poll.h>\n-#endif\n #if defined(__MINGW32__)\n /* pull in Windows compatibility stuff */\n #include \"compat/mingw.h\"\n@@ -152,6 +147,11 @@\n #define _ALL_SOURCE 1\n #endif\n #endif\n+#ifndef NO_SYS_POLL_H\n+#include <sys/poll.h>\n+#else\n+#include <poll.h>\n+#endif\n\n #ifndef NO_LIBGEN_H\n #include <libgen.h>\n-- \nBest regards,\n Sven Strickroth\n ClamAV, a GPL anti-virus toolkit   http://www.clamav.net\n PGP key id F5A9D4C4 @ any key-server\n"},{"id":"189786","messageId":"xmqqty0ekr5t.fsf@junio.mtv.corp.google.com","threadId":"30298","inReplyTo":"20120420204722.GD13103@sigill.intra.peff.net","subject":"Re: [PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-20T21:51:58Z","receivedAt":"2012-04-20T21:51:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, Apr 20, 2012 at 10:37:19PM +0200, Sven Strickroth wrote:\n>\n>> upload-archive.c and upload-pack.c use pollfd struct and POLLIN constant\n>> which are defined in poll.h. However, poll.h is not included.\n>\n> This should already be included by git-compat-util.h:\n\nThanks for a bit of sanity.\n\n>   $ grep -C1 poll.h git-compat-util.h\n>   #ifndef NO_SYS_POLL_H\n>   #include <sys/poll.h>\n>   #else\n>   #include <poll.h>\n>   #endif\n>\n> It looks like we will prefer sys/poll.h if it exists. The official XSI\n> location is \"poll.h\", but I guess in practice they are equivalent on\n> most systems if you have both (certainly on Linux, poll.h just includes\n> sys/poll.h).\n\nThere actually is no preference between the two from _our_ side. It is\nup to the builder to know and define necessary make variables.\n\n> Does your environments have a sys/poll.h that exists isn't sufficient to\n> use poll? Maybe we need to tweak git-compat-util to include both if they\n> both exist.\n\nBoth?  I guess, but I suspect that on most sane systems one would\ninclude the other if there are both provided (iow, just so that you can\ncomplile sources written both for XSI and for systems in the field).\n"},{"id":"189787","messageId":"CABPQNSb7NeHOnOy-zmNMA3Jp143oCYqsGjK=+uatsS9bYaN5hA@mail.gmail.com","threadId":"30298","inReplyTo":"4F91D489.8050402@tu-clausthal.de","subject":"Re: [PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@gmail.com","sentAt":"2012-04-20T21:58:30Z","receivedAt":"2012-04-20T21:58:30Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Fri, Apr 20, 2012 at 11:26 PM, Sven Strickroth\n<sven.strickroth@tu-clausthal.de> wrote:\n> Windows does not have sys/poll.h. I have to use the one from compat/win32.\n>\n> The problem is that\n>    NO_SYS_POLL_H\n> is defined in compat/msvc.h in my environment.\n> And in git-compat-util.h\n>    #ifndef NO_SYS_POLL_H\n>    #include <sys/poll.h>\n>    #else\n>    #include <poll.h>\n>    #endif\n> is before\n>    #elif defined(_MSC_VER)\n>    #include \"compat/msvc.h\"\n> . Moving it down, solves the issue for me. (Suppose this is a fix for my\n> scenario only).\n>\n\nNO_SYS_POLL_H shouldn't be defined in compat/msvc.h, it should be\ndefined by the build-system. Our Makefile already does this inside the\n\"ifeq ($(uname_S),Windows)\"-block.\n\nHow are you building Git?\n"},{"id":"189788","messageId":"20120420232319.GA14109@sigill.intra.peff.net","threadId":"30298","inReplyTo":"xmqqty0ekr5t.fsf@junio.mtv.corp.google.com","subject":"Re: [PATCH] Fixed compilation with Visual Studio by including poll.h","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-04-20T23:23:19Z","receivedAt":"2012-04-20T23:23:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Apr 20, 2012 at 02:51:58PM -0700, Junio C Hamano wrote:\n\n> > It looks like we will prefer sys/poll.h if it exists. The official XSI\n> > location is \"poll.h\", but I guess in practice they are equivalent on\n> > most systems if you have both (certainly on Linux, poll.h just includes\n> > sys/poll.h).\n> \n> There actually is no preference between the two from _our_ side. It is\n> up to the builder to know and define necessary make variables.\n\nI say \"prefer\" only because if you set nothing, you get \"sys/poll.h\". So\nit is up to the builder to say \"no, I do not have that non-standard\nlocation. Use the standard one instead\". Which seems a little backwards.\n\nOf course \"standard\" here is just what POSIX says; sys/poll.h may be\nmuch more standard in the real world (I don't know).\n\n> > Does your environments have a sys/poll.h that exists isn't sufficient to\n> > use poll? Maybe we need to tweak git-compat-util to include both if they\n> > both exist.\n> \n> Both?  I guess, but I suspect that on most sane systems one would\n> include the other if there are both provided (iow, just so that you can\n> complile sources written both for XSI and for systems in the field).\n\nI would think one or the other would be fine. But the fact that Sven's\npatch works makes me think that he has sys/poll.h, but it is not\nsufficient. Hopefully including \"poll.h\" would be enough, but it's not\nclear to me.\n\n-Peff\n"}]}