Skip to contentSkip to conversation

Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

PATCH Superseded Joachim Schmitz 2 participants 5 messages Jun 15, 2016 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

---
 Makefile            | 18 ++++++++++++++----
 compat/win32/poll.c |  8 ++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)
Makefile +7 -4
index 6b0c961..2af4db3 100644
@@ -152,6 +152,11 @@ all::
 #
 # Define NO_MMAP if you want to avoid mmap.
 #
+# Define NO_SYS_POLL_H if you don't have sys/poll.h.
+#
+# Define NO_POLL if you do not have or do not want to use poll.
+# This also implies NO_SYS_POLL_H.
+#
 # Define NO_PTHREADS if you do not have or do not want to use Pthreads.
 #
 # Define NO_PREAD if you have a problem with pread() system call (e.g.
@@ -1216,7 +1221,7 @@ ifeq ($(uname_S),Windows)
        NO_PREAD = YesPlease
        NEEDS_CRYPTO_WITH_SSL = YesPlease
        NO_LIBGEN_H = YesPlease
-       NO_SYS_POLL_H = YesPlease
+       NO_POLL = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NO_IPV6 = YesPlease
        NO_UNIX_SOCKETS = YesPlease
@@ -1257,7 +1262,7 @@ ifeq ($(uname_S),Windows)
        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild
-Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
        COMPAT_OBJS = compat/msvc.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/poll.o compat/win32/dirent.o
+               compat/win32/dirent.o
        COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H

-DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
-NODEFAULTLIB:MSVCRT.lib
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib
@@ -1312,7 +1317,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_PREAD = YesPlease
NEEDS_CRYPTO_WITH_SSL = YesPlease
NO_LIBGEN_H = YesPlease
- NO_SYS_POLL_H = YesPlease
+ NO_POLL = YesPlease
NO_SYMLINK_HEAD = YesPlease
NO_UNIX_SOCKETS = YesPlease
NO_SETENV = YesPlease
@@ -1347,7 +1352,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))

        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \

- compat/win32/poll.o compat/win32/dirent.o
+ compat/win32/dirent.o
EXTLIBS += -lws2_32
PTHREAD_LIBS =
X = .exe
@@ -1601,6 +1606,11 @@ ifdef NO_GETTEXT
BASIC_CFLAGS += -DNO_GETTEXT
USE_GETTEXT_SCHEME ?= fallthrough
endif
+ifdef NO_POLL

+       NO_SYS_POLL_H = YesPlease
+       COMPAT_CFLAGS += -DNO_POLL -Icompat/win32 # so it find poll.h
+       COMPAT_OBJS += compat/win32/poll.c
+endif
 ifdef NO_STRCASESTR
        COMPAT_CFLAGS += -DNO_STRCASESTR
        COMPAT_OBJS += compat/strcasestr.o
compat/win32/poll.c +6 -2
index 403eaa7..49541f1 100644
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif
 
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
 

--
1.7.12

HP NonStop is using this, patch to add this is to follow.

Bye, Jojo

#1 lore raw
Quoted 11 lines · Joachim Schmitz
---
 Makefile            | 18 ++++++++++++++----
 compat/win32/poll.c |  8 ++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)
Makefile +0 -0
index 6b0c961..2af4db3 100644

Makefile all:: · line 158

Quoted 7 lines
Makefile +4 -0
@@ -152,6 +152,11 @@ all::
 #
 # Define NO_MMAP if you want to avoid mmap.
 #
+# Define NO_SYS_POLL_H if you don't have sys/poll.h.
+#
+# Define NO_POLL if you do not have or do not want to use poll.
+# This also implies NO_SYS_POLL_H.

Do you really need to have both? I suspect "If you do not have a usable sys/poll.h, set NO_SYS_POLL_H" may be a simpler alternative, but there must be a reason why you had to add a new one instead of going that route. It would be a good idea to describe that reason in the log message above, in the space before your Sign-off.

Quoted 19 lines
Makefile +2 -4
@@ -1257,7 +1262,7 @@ ifeq ($(uname_S),Windows)
        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild
-Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
        COMPAT_OBJS = compat/msvc.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/poll.o compat/win32/dirent.o
+               compat/win32/dirent.o
        COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H
...
@@ -1347,7 +1352,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/poll.o compat/win32/dirent.o
+               compat/win32/dirent.o
        EXTLIBS += -lws2_32
...

Makefile ifdef NO_GETTEXT

Quoted 6 lines
Makefile +5 -0
@@ -1601,6 +1606,11 @@ ifdef NO_GETTEXT
...
+ifdef NO_POLL
+       NO_SYS_POLL_H = YesPlease
+       COMPAT_CFLAGS += -DNO_POLL -Icompat/win32 # so it find poll.h
+       COMPAT_OBJS += compat/win32/poll.c
+endif

In general, I think this is a good direction to go. If the existing emulation in win32/poll.c turns out to be usable across platforms and not windows specific, sharing it would be a good idea.

But if the emulation is no longer windows specific, shouldn't you also move it outside compat/win32/ and somewhere more generic?

compat/win32/poll.c line 29

Quoted 12 lines
compat/win32/poll.c +3 -1
index 403eaa7..49541f1 100644
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif

Hrm, are the Windows folks OK with this? MINGW and MSVC are affected; Cygwin should be OK, I think.

Quoted 12 lines
compat/win32/poll.c +3 -1
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
#2 lore raw
Quoted 15 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Wednesday, August 22, 2012 7:13 PM
To: Joachim Schmitz
Cc: [email protected]; Erik Faye-Lund; Johannes Sixt; Marius Storm-Olsen
Subject: Re: [PATCH] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 6 lines · Joachim Schmitz
---
 Makefile            | 18 ++++++++++++++----
 compat/win32/poll.c |  8 ++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)
Quoted 15 lines

Makefile all:: · line 158

Quoted 12 lines
Makefile +4 -0
index 6b0c961..2af4db3 100644
@@ -152,6 +152,11 @@ all::
 #
 # Define NO_MMAP if you want to avoid mmap.
 #
+# Define NO_SYS_POLL_H if you don't have sys/poll.h.
+#
+# Define NO_POLL if you do not have or do not want to use poll.
+# This also implies NO_SYS_POLL_H.

Do you really need to have both? I suspect "If you do not have a usable sys/poll.h, set NO_SYS_POLL_H" may be a simpler alternative, but there

must

Hmm, Not having <sys/poll.h> and not having poll() are different thinks, aren't they?

Using NO_SYS_POL_H so far only affects BASIC_CFLAGS:
ifdef NO_SYS_POLL_H

        BASIC_CFLAGS += -DNO_SYS_POLL_H

endif

It does not add compat/win32/poll.c to COMPAT_OBJS, NO_POLL does that.

Quoted 1 line

be a reason why you had to add a new one instead of going that route. It

would

Quoted 1 line

be a good idea to describe that reason in the log message above, in the

space

Quoted 12 lines

before your Sign-off.

Makefile ifeq ($(uname_S),Windows) · line 1266

Quoted 9 lines
Makefile +1 -3
@@ -1257,7 +1262,7 @@ ifeq ($(uname_S),Windows)
        BASIC_CFLAGS = -nologo -I. -I../zlib -Icompat/vcbuild
-Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
        COMPAT_OBJS = compat/msvc.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/poll.o compat/win32/dirent.o
+               compat/win32/dirent.o
        COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -

DHAVE_STRING_H

Quoted 16 lines
Quoted 10 lines

...

Makefile +1 -1
@@ -1347,7 +1352,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
        COMPAT_OBJS += compat/mingw.o compat/winansi.o \
                compat/win32/pthread.o compat/win32/syslog.o \
-               compat/win32/poll.o compat/win32/dirent.o
+               compat/win32/dirent.o
        EXTLIBS += -lws2_32
...

Makefile ifdef NO_GETTEXT ... · line 1609

Quoted 4 lines
Makefile +4 -0
@@ -1601,6 +1606,11 @@ ifdef NO_GETTEXT ...
+ifdef NO_POLL
+       NO_SYS_POLL_H = YesPlease
+       COMPAT_CFLAGS += -DNO_POLL -Icompat/win32 # so it find poll.h
+       COMPAT_OBJS += compat/win32/poll.c endif

In general, I think this is a good direction to go. If the existing

emulation in

Quoted 1 line

win32/poll.c turns out to be usable across platforms and not windows

specific,

Quoted 3 lines

sharing it would be a good idea.

But if the emulation is no longer windows specific, shouldn't you also

move it

Quoted 1 line

outside compat/win32/ and somewhere more generic?

Should be possible. Esp. as with the current setup make issues a warning:

Makefile:2329: target `compat/win32/poll.c' doesn't match the target pattern

Haven't yet been able to spot where that comes from.

Quoted 8 lines
Quoted 8 lines
compat/win32/poll.c index renamed from compat/win32/poll.c +0 -0

403eaa7..49541f1 100644

compat/win32/poll.c +0 -0
@@ -24,7 +24,9 @@
 # pragma GCC diagnostic ignored "-Wtype-limits"
 #endif
 
Quoted 7 lines

compat/win32/poll.c line 29

Quoted 4 lines
compat/win32/poll.c +3 -1
-#include <malloc.h>
+#if defined(WIN32)
+# include <malloc.h>
+#endif

Hrm, are the Windows folks OK with this? MINGW and MSVC are affected; Cygwin should be OK, I think.

I stole that define from another place in git (compat/nedmalloc/nedmalloc.c" line 36), there too it was used to hide <malloc.h>, so I assumed it to be the proper method?

Quoted 12 lines
Quoted 12 lines
compat/win32/poll.c +3 -1
 #include <sys/types.h>
 
@@ -48,7 +50,9 @@
 #else
 # include <sys/time.h>
 # include <sys/socket.h>
-# include <sys/select.h>
+# ifndef NO_SYS_SELECT_H
+#  include <sys/select.h>
+# endif
 # include <unistd.h>
 #endif
#3 lore raw
Quoted 6 lines · Joachim Schmitz
Quoted 2 lines

Do you really need to have both? I suspect "If you do not have a usable sys/poll.h, set NO_SYS_POLL_H" may be a simpler alternative, but there

must

Hmm, Not having <sys/poll.h> and not having poll() are different thinks, aren't they?

Ahh, OK, I forgot the other combination: working poll() but inclusion of sys/poll.h is unnecessary. OK.

#4 lore raw
In reply to Junio C Hamano
Quoted 4 lines

From: Joachim Schmitz [mailto:[email protected]]
Sent: Wednesday, August 22, 2012 7:44 PM
To: 'Junio C Hamano'
Cc: '[email protected]'; 'Erik Faye-Lund'; 'Johannes Sixt'; 'Marius

Storm-

Quoted 21 lines

Olsen'
Subject: RE: [PATCH] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 17 lines

From: Junio C Hamano [mailto:[email protected]]
Sent: Wednesday, August 22, 2012 7:13 PM
To: Joachim Schmitz
Cc: [email protected]; Erik Faye-Lund; Johannes Sixt; Marius Storm-Olsen
Subject: Re: [PATCH] Support non-WIN32 system lacking poll() while keeping the WIN32 part intact

Quoted 7 lines · Joachim Schmitz
---
 Makefile            | 18 ++++++++++++++----
 compat/win32/poll.c |  8 ++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)
Makefile +0 -0

...

Quoted 5 lines
Quoted 5 lines

Makefile ifdef NO_GETTEXT ... · line 1609

Quoted 5 lines
Makefile +4 -0
@@ -1601,6 +1606,11 @@ ifdef NO_GETTEXT ...
+ifdef NO_POLL
+       NO_SYS_POLL_H = YesPlease
+       COMPAT_CFLAGS += -DNO_POLL -Icompat/win32 # so it find poll.h
+       COMPAT_OBJS += compat/win32/poll.c

This is of course wrong! Needs to be poll.o, not poll.c

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

endif

In general, I think this is a good direction to go. If the existing emulation in win32/poll.c turns out to be usable across platforms and not windows specific, sharing it would be a good idea.

Quoted 6 lines
Quoted 2 lines

But if the emulation is no longer windows specific, shouldn't you also move it outside compat/win32/ and somewhere more generic?

Should be possible. Esp. as with the current setup make issues a warning:

Makefile:2329: target `compat/win32/poll.c' doesn't match the target

pattern

Quoted 2 lines

Haven't yet been able to spot where that comes from.

See above.