From d973ebcca85078aeb8d6f790795b75c8a8b863b8 Mon Sep 17 00:00:00 2001 From: everHannes Date: Mon, 24 Aug 2015 20:36:08 +0200 Subject: [PATCH] moved back windows compat headers and fixed catta headers to stop clutter dependent projects with wincompat.h redefines also fixed WINVER to be a project property set in src/Makefile.am instead of undef/define override in wincompat.h --- configure.ac | 2 +- include/Makefile.am | 12 +----------- include/catta/simple-watch.h | 1 - include/catta/thread-watch.h | 1 - include/catta/timeval.h | 6 ++++-- include/catta/watch.h | 8 +++++--- src/Makefile.am | 10 +++++++--- .../compat/windows/include}/arpa/inet.h | 0 .../windows => src/compat/windows/include}/net/if.h | 0 .../compat/windows/include}/netinet/in.h | 0 .../compat/windows/include}/sys/ioctl.h | 0 .../compat/windows/include}/sys/poll.h | 0 .../compat/windows/include}/sys/select.h | 0 .../compat/windows/include}/sys/socket.h | 0 .../windows => src/compat/windows/include}/sys/uio.h | 0 .../compat/windows/include}/sys/utsname.h | 0 src/compat/windows/wincompat.c | 2 +- .../catta/compat => src/compat/windows}/wincompat.h | 0 src/iface-windows.c | 2 ++ 19 files changed, 21 insertions(+), 23 deletions(-) rename {include/catta/compat/windows => src/compat/windows/include}/arpa/inet.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/net/if.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/netinet/in.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/ioctl.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/poll.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/select.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/socket.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/uio.h (100%) rename {include/catta/compat/windows => src/compat/windows/include}/sys/utsname.h (100%) rename {include/catta/compat => src/compat/windows}/wincompat.h (100%) diff --git a/configure.ac b/configure.ac index c5314af..d760f34 100644 --- a/configure.ac +++ b/configure.ac @@ -59,7 +59,7 @@ fi AC_CHECK_DECL(_WIN32) AM_CONDITIONAL([WINDOWS], [ test "x$ac_cv_have_decl__WIN32" = "xyes" ]) if test "x$ac_cv_have_decl__WIN32" = "xyes" ; then - CPPFLAGS="$CPPFLAGS -I`pwd`/include/compat/windows" + CPPFLAGS="$CPPFLAGS -I`pwd`/src/compat/windows/include" fi AC_CHECK_MEMBER([struct in_pktinfo.ipi_spec_dst], AC_DEFINE([HAVE_IPI_SPEC_DST], [], [struct in_pktinfo has ipi_spec_dst member]), diff --git a/include/Makefile.am b/include/Makefile.am index fae04ca..7951320 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -35,14 +35,4 @@ nobase_include_HEADERS = \ catta/log.h \ catta/rr.h \ catta/publish.h \ - catta/lookup.h \ - catta/compat/wincompat.h \ - catta/compat/windows/arpa/inet.h \ - catta/compat/windows/net/if.h \ - catta/compat/windows/netinet/in.h \ - catta/compat/windows/sys/ioctl.h \ - catta/compat/windows/sys/poll.h \ - catta/compat/windows/sys/select.h \ - catta/compat/windows/sys/socket.h \ - catta/compat/windows/sys/uio.h \ - catta/compat/windows/sys/utsname.h + catta/lookup.h diff --git a/include/catta/simple-watch.h b/include/catta/simple-watch.h index ce91d1f..fb126ad 100644 --- a/include/catta/simple-watch.h +++ b/include/catta/simple-watch.h @@ -22,7 +22,6 @@ /** \file simple-watch.h Simple poll() based main loop implementation */ -#include #include #include diff --git a/include/catta/thread-watch.h b/include/catta/thread-watch.h index 3ecb1e4..7057dff 100644 --- a/include/catta/thread-watch.h +++ b/include/catta/thread-watch.h @@ -22,7 +22,6 @@ /** \file thread-watch.h Threaded poll() based main loop implementation */ -#include #include #include diff --git a/include/catta/timeval.h b/include/catta/timeval.h index d78d229..0c52eaa 100644 --- a/include/catta/timeval.h +++ b/include/catta/timeval.h @@ -23,8 +23,10 @@ /** \file timeval.h Functions to facilitate timeval handling */ #include -#ifndef _MSC_VER -#include +#ifdef _WIN32 + #include // timeval +#else + #include #endif #include diff --git a/include/catta/watch.h b/include/catta/watch.h index 7824724..a0c6389 100644 --- a/include/catta/watch.h +++ b/include/catta/watch.h @@ -22,9 +22,11 @@ /** \file watch.h Simplistic main loop abstraction */ -#include -#ifndef _MSC_VER -#include +#ifdef _WIN32 + #include // POLLIN +#else + #include + #include #endif #include diff --git a/src/Makefile.am b/src/Makefile.am index b78e013..9471992 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -85,15 +85,19 @@ endif endif endif +if WINDOWS +# require Windows Vista or above (for winsock2) +AM_CFLAGS+=-DWINVER=0x0600 -D_WIN32_WINNT=0x0600 +endif + libcatta_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) libcatta_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) libcatta_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBCATTA_VERSION_INFO) if WINDOWS -libcatta_la_CFLAGS += -I$(top_srcdir)/include/catta/compat/windows libcatta_la_SOURCES += \ - compat/windows/wincompat.c + compat/windows/wincompat.c \ + compat/windows/wincompat.h libcatta_la_LIBADD += -lws2_32 -liphlpapi libcatta_la_LDFLAGS += -no-undefined -Wl,--kill-at,--output-def=.libs/libcatta-0.def endif - diff --git a/include/catta/compat/windows/arpa/inet.h b/src/compat/windows/include/arpa/inet.h similarity index 100% rename from include/catta/compat/windows/arpa/inet.h rename to src/compat/windows/include/arpa/inet.h diff --git a/include/catta/compat/windows/net/if.h b/src/compat/windows/include/net/if.h similarity index 100% rename from include/catta/compat/windows/net/if.h rename to src/compat/windows/include/net/if.h diff --git a/include/catta/compat/windows/netinet/in.h b/src/compat/windows/include/netinet/in.h similarity index 100% rename from include/catta/compat/windows/netinet/in.h rename to src/compat/windows/include/netinet/in.h diff --git a/include/catta/compat/windows/sys/ioctl.h b/src/compat/windows/include/sys/ioctl.h similarity index 100% rename from include/catta/compat/windows/sys/ioctl.h rename to src/compat/windows/include/sys/ioctl.h diff --git a/include/catta/compat/windows/sys/poll.h b/src/compat/windows/include/sys/poll.h similarity index 100% rename from include/catta/compat/windows/sys/poll.h rename to src/compat/windows/include/sys/poll.h diff --git a/include/catta/compat/windows/sys/select.h b/src/compat/windows/include/sys/select.h similarity index 100% rename from include/catta/compat/windows/sys/select.h rename to src/compat/windows/include/sys/select.h diff --git a/include/catta/compat/windows/sys/socket.h b/src/compat/windows/include/sys/socket.h similarity index 100% rename from include/catta/compat/windows/sys/socket.h rename to src/compat/windows/include/sys/socket.h diff --git a/include/catta/compat/windows/sys/uio.h b/src/compat/windows/include/sys/uio.h similarity index 100% rename from include/catta/compat/windows/sys/uio.h rename to src/compat/windows/include/sys/uio.h diff --git a/include/catta/compat/windows/sys/utsname.h b/src/compat/windows/include/sys/utsname.h similarity index 100% rename from include/catta/compat/windows/sys/utsname.h rename to src/compat/windows/include/sys/utsname.h diff --git a/src/compat/windows/wincompat.c b/src/compat/windows/wincompat.c index b60eb8f..93a557e 100644 --- a/src/compat/windows/wincompat.c +++ b/src/compat/windows/wincompat.c @@ -1,4 +1,4 @@ -#include "catta/compat/wincompat.h" +#include "wincompat.h" #include #include #include diff --git a/include/catta/compat/wincompat.h b/src/compat/windows/wincompat.h similarity index 100% rename from include/catta/compat/wincompat.h rename to src/compat/windows/wincompat.h diff --git a/src/iface-windows.c b/src/iface-windows.c index 1d8d0f3..7be73f0 100644 --- a/src/iface-windows.c +++ b/src/iface-windows.c @@ -23,8 +23,10 @@ #include // wcstombs #include #include +#include #include #include +#include "compat/windows/wincompat.h" #include "hashmap.h" #include "util.h" // catta_format_mac_address #include "fdutil.h" // catta_set_nonblock -- 2.39.5