[PATCH] Fixed compilation with Visual Studio by including poll.h

Subsystems: the rest

DORMANTno replies

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

[PATCH] Fixed compilation with Visual Studio by including poll.h

From: Sven Strickroth <hidden>
Date: 2016-06-15 22:53:38

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.

Signed-off-by: Sven Strickroth <redacted>
---
 builtin/upload-archive.c |    1 +
 upload-pack.c            |    1 +
 2 files changed, 2 insertions(+)
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index b928beb..6226bbb 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2006 Franck Bui-Huu
  */
+#include "poll.h"
 #include "cache.h"
 #include "builtin.h"
 #include "archive.h"
diff --git a/upload-pack.c b/upload-pack.c
index bb08e2e..79f9f8f 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,3 +1,4 @@
+#include "poll.h"
 #include "cache.h"
 #include "refs.h"
 #include "pkt-line.h"
-- 
Best regards,
 Sven Strickroth
 ClamAV, a GPL anti-virus toolkit   http://www.clamav.net
 PGP key id F5A9D4C4 @ any key-server

Re: [PATCH] Fixed compilation with Visual Studio by including poll.h

From: Jeff King <hidden>
Date: 2016-06-15 22:53:38

On Fri, Apr 20, 2012 at 10:37:19PM +0200, Sven Strickroth wrote:
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.
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

Re: [PATCH] Fixed compilation with Visual Studio by including poll.h

From: Sven Strickroth <hidden>
Date: 2016-06-15 22:53:38

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).
diff --git a/git-compat-util.h b/git-compat-util.h
index ed11ad8..a96849c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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>
-- 
Best regards,
 Sven Strickroth
 ClamAV, a GPL anti-virus toolkit   http://www.clamav.net
 PGP key id F5A9D4C4 @ any key-server

Re: [PATCH] Fixed compilation with Visual Studio by including poll.h

From: Erik Faye-Lund <hidden>
Date: 2016-06-15 22:53:38

On Fri, Apr 20, 2012 at 11:26 PM, Sven Strickroth
[off-list ref] wrote:
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).
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?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help