[Spice-devel] [PATCH spice-server 02/33] windows: Do not include headers not available on Windows

Frediano Ziglio fziglio at redhat.com
Fri Dec 21 12:02:50 UTC 2018


This is a preparatory patch for next portability patches

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/dispatcher.c              |  2 ++
 server/net-utils.c               |  2 ++
 server/red-channel-client.c      |  6 ++++--
 server/red-qxl.c                 |  1 -
 server/red-stream.c              |  6 ++++--
 server/reds.c                    | 12 ++++++++----
 server/reds.h                    |  1 -
 server/sound.c                   |  2 ++
 server/spice-core.h              |  6 ++++++
 server/tests/replay.c            |  2 ++
 server/tests/test-display-base.c |  2 ++
 server/tests/test-playback.c     |  1 -
 12 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 48dc915a..3e27f2c2 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -24,7 +24,9 @@
 #include <string.h>
 #include <pthread.h>
 #include <fcntl.h>
+#ifndef _WIN32
 #include <poll.h>
+#endif
 
 #include "dispatcher.h"
 
diff --git a/server/net-utils.c b/server/net-utils.c
index ca8a4e7f..802509a4 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -24,11 +24,13 @@
 #include <stdbool.h>
 #include <string.h>
 #include <sys/types.h>
+#ifndef _WIN32
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <sys/socket.h>
+#endif
 
 #include <common/log.h>
 
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index b3a6ec12..375a60b3 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -22,12 +22,14 @@
 #include <glib.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#ifndef _WIN32
+#include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <sys/ioctl.h>
+#endif
 #ifdef HAVE_LINUX_SOCKIOS_H
 #include <linux/sockios.h> /* SIOCOUTQ */
 #endif
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 97940611..cec3eefb 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -24,7 +24,6 @@
 #include <errno.h>
 #include <string.h>
 #include <pthread.h>
-#include <sys/socket.h>
 #include <inttypes.h>
 
 #include <spice/qxl_dev.h>
diff --git a/server/red-stream.c b/server/red-stream.c
index fd5b8cd1..57034a64 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -20,11 +20,13 @@
 #endif
 
 #include <errno.h>
-#include <netdb.h>
 #include <unistd.h>
-#include <sys/socket.h>
 #include <fcntl.h>
+#ifndef _WIN32
+#include <netdb.h>
+#include <sys/socket.h>
 #include <netinet/tcp.h>
+#endif
 
 #include <glib.h>
 
diff --git a/server/reds.c b/server/reds.c
index 98a3435d..aa3f8ca7 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -22,16 +22,21 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <limits.h>
+#include <pthread.h>
+#include <ctype.h>
+#ifndef _WIN32
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <limits.h>
-#include <pthread.h>
 #include <sys/mman.h>
-#include <ctype.h>
+#include <sys/un.h>
+#else
+#include <ws2tcpip.h>
+#endif
 
 #include <openssl/err.h>
 
@@ -40,7 +45,6 @@
 #endif
 
 #include <glib.h>
-#include <sys/un.h>
 
 #include <spice/protocol.h>
 #include <spice/vd_agent.h>
diff --git a/server/reds.h b/server/reds.h
index 9f17a5ec..106310eb 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -19,7 +19,6 @@
 #define REDS_H_
 
 #include <stdint.h>
-#include <sys/uio.h>
 #include <spice/vd_agent.h>
 #include <common/marshaller.h>
 #include <common/messages.h>
diff --git a/server/sound.c b/server/sound.c
index 8cdb7d71..44b27dec 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -23,10 +23,12 @@
 #include <errno.h>
 #include <limits.h>
 #include <sys/types.h>
+#ifndef _WIN32
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#endif
 
 #include <common/generated_server_marshallers.h>
 #include <common/snd_codec.h>
diff --git a/server/spice-core.h b/server/spice-core.h
index 3d5c83bf..d77c4f9e 100644
--- a/server/spice-core.h
+++ b/server/spice-core.h
@@ -23,7 +23,13 @@
 #endif
 
 #include <stdint.h>
+#ifndef _WIN32
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#include <windows.h>
+typedef int socklen_t;
+#endif
 #include <spice/qxl_dev.h>
 #include <spice/vd_agent.h>
 #include <spice/macros.h>
diff --git a/server/tests/replay.c b/server/tests/replay.c
index bd9420b8..b689044a 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -30,7 +30,9 @@
 #include <signal.h>
 #include <unistd.h>
 #include <pthread.h>
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <fcntl.h>
 #include <glib.h>
 #include <pthread.h>
diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c
index 3ca85f3a..868521bc 100644
--- a/server/tests/test-display-base.c
+++ b/server/tests/test-display-base.c
@@ -22,8 +22,10 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <signal.h>
+#ifndef _WIN32
 #include <sys/wait.h>
 #include <sys/select.h>
+#endif
 #include <sys/types.h>
 #include <getopt.h>
 #include <pthread.h>
diff --git a/server/tests/test-playback.c b/server/tests/test-playback.c
index 9b2dcc10..cbefb9b0 100644
--- a/server/tests/test-playback.c
+++ b/server/tests/test-playback.c
@@ -17,7 +17,6 @@
 */
 #include <config.h>
 #include <stdio.h>
-#include <sys/select.h>
 #include <sys/time.h>
 #include <math.h>
 
-- 
2.17.2



More information about the Spice-devel mailing list