[vlc-commits] use the proper check for sys/socket.h availability

Steve Lhomme git at videolan.org
Thu Apr 12 13:19:44 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Apr 12 13:00:54 2018 +0200| [333ed248b9d40fd9a0d14c10d46e64f5b6c8ccf4] | committer: Steve Lhomme

use the proper check for sys/socket.h availability

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=333ed248b9d40fd9a0d14c10d46e64f5b6c8ccf4
---

 compat/inet_pton.c                | 4 ++--
 compat/recvmsg.c                  | 2 ++
 compat/sendmsg.c                  | 2 ++
 include/vlc_fixups.h              | 4 ++--
 include/vlc_interrupt.h           | 4 ++--
 include/vlc_network.h             | 4 +++-
 modules/access/http/h1conn_test.c | 2 ++
 modules/access/http/h2conn_test.c | 2 ++
 modules/access/http/tunnel_test.c | 2 ++
 modules/access_output/udp.c       | 2 +-
 src/misc/interrupt.c              | 4 +++-
 src/network/httpd.c               | 2 +-
 src/network/rootbind.c            | 2 ++
 src/os2/filesystem.c              | 2 ++
 src/os2/thread.c                  | 2 ++
 src/posix/filesystem.c            | 2 ++
 test/modules/misc/tls.c           | 2 ++
 17 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/compat/inet_pton.c b/compat/inet_pton.c
index 7052a1a7a5..38c2281d2e 100644
--- a/compat/inet_pton.c
+++ b/compat/inet_pton.c
@@ -26,9 +26,9 @@
 #include <errno.h>
 
 #include <sys/types.h>
-#ifndef _WIN32
+#ifdef HAVE_SYS_SOCKET_H
 # include <sys/socket.h>
-#else
+#elif defined(_WIN32)
 # include <winsock2.h>
 # include <ws2tcpip.h>
 # undef EAFNOSUPPORT
diff --git a/compat/recvmsg.c b/compat/recvmsg.c
index c037ab9888..6b95deff5f 100644
--- a/compat/recvmsg.c
+++ b/compat/recvmsg.c
@@ -88,7 +88,9 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #include <sys/uio.h>
 
 ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
diff --git a/compat/sendmsg.c b/compat/sendmsg.c
index 0f42e782f8..28d2eb098b 100644
--- a/compat/sendmsg.c
+++ b/compat/sendmsg.c
@@ -78,7 +78,9 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #include <sys/uio.h>
 
 ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 037f67da31..0d9abed520 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -370,9 +370,9 @@ void swab (const void *, void *, ssize_t);
 
 /* Socket stuff */
 #ifndef HAVE_INET_PTON
-# ifndef _WIN32
+# ifdef HAVE_SYS_SOCKET_H
 #  include <sys/socket.h>
-#else
+# elif defined(_WIN32)
 typedef int socklen_t;
 # endif
 int inet_pton(int, const char *, void *);
diff --git a/include/vlc_interrupt.h b/include/vlc_interrupt.h
index a6fb303200..1195c19d33 100644
--- a/include/vlc_interrupt.h
+++ b/include/vlc_interrupt.h
@@ -21,9 +21,9 @@
 #ifndef VLC_INTERRUPT_H
 # define VLC_INTERRUPT_H 1
 # include <vlc_threads.h>
-# ifndef _WIN32
+# ifdef HAVE_SYS_SOCKET_H
 #  include <sys/socket.h> /* socklen_t */
-# else
+# elif defined(_WIN32)
 #  include <ws2tcpip.h>
 # endif
 
diff --git a/include/vlc_network.h b/include/vlc_network.h
index 184c23acae..1a80759dd5 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -50,7 +50,9 @@
 #       define IPV6_V6ONLY 27
 #   endif
 #else
-#   include <sys/socket.h>
+#   ifdef HAVE_SYS_SOCKET_H
+#       include <sys/socket.h>
+#   endif
 #   include <netinet/in.h>
 #   include <netdb.h>
 #   define net_errno errno
diff --git a/modules/access/http/h1conn_test.c b/modules/access/http/h1conn_test.c
index 2817b45e2d..0e792274c1 100644
--- a/modules/access/http/h1conn_test.c
+++ b/modules/access/http/h1conn_test.c
@@ -29,7 +29,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 
 #include <vlc_common.h>
 #include <vlc_block.h>
diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c
index 109e6c0cf0..1fb9a15d61 100644
--- a/modules/access/http/h2conn_test.c
+++ b/modules/access/http/h2conn_test.c
@@ -29,7 +29,9 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 
 #include <vlc_common.h>
 #include <vlc_block.h>
diff --git a/modules/access/http/tunnel_test.c b/modules/access/http/tunnel_test.c
index 3afee3c617..90bc7efd01 100644
--- a/modules/access/http/tunnel_test.c
+++ b/modules/access/http/tunnel_test.c
@@ -31,7 +31,9 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #ifndef SOCK_CLOEXEC
 # define SOCK_CLOEXEC 0
 # define accept4(a,b,c,d) accept(a,b,c)
diff --git a/modules/access_output/udp.c b/modules/access_output/udp.c
index 1204eab750..472fd8c4a2 100644
--- a/modules/access_output/udp.c
+++ b/modules/access_output/udp.c
@@ -43,7 +43,7 @@
 #ifdef _WIN32
 #   include <winsock2.h>
 #   include <ws2tcpip.h>
-#else
+#elif defined (HAVE_SYS_SOCKET_H)
 #   include <sys/socket.h>
 #endif
 
diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c
index 7004ed2c3a..2c3d359943 100644
--- a/src/misc/interrupt.c
+++ b/src/misc/interrupt.c
@@ -399,7 +399,9 @@ int vlc_poll_i11e(struct pollfd *fds, unsigned nfds, int timeout)
 
 # include <fcntl.h>
 # include <sys/uio.h>
-# include <sys/socket.h>
+# ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+# endif
 
 
 /* There are currently no ways to atomically force a non-blocking read or write
diff --git a/src/network/httpd.c b/src/network/httpd.c
index d9237ebb9c..a22d9208cc 100644
--- a/src/network/httpd.c
+++ b/src/network/httpd.c
@@ -55,7 +55,7 @@
 
 #if defined(_WIN32)
 #   include <winsock2.h>
-#else
+#elif defined(HAVE_SYS_SOCKET_H)
 #   include <sys/socket.h>
 #endif
 
diff --git a/src/network/rootbind.c b/src/network/rootbind.c
index d1a8ce1e07..f10c219559 100644
--- a/src/network/rootbind.c
+++ b/src/network/rootbind.c
@@ -41,7 +41,9 @@ int rootwrap_bind (int, int, int, const struct sockaddr *, size_t);
 
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #include <sys/uio.h>
 #include <sys/un.h>
 #include <netinet/in.h>
diff --git a/src/os2/filesystem.c b/src/os2/filesystem.c
index bbb4ab346b..651f73d486 100644
--- a/src/os2/filesystem.c
+++ b/src/os2/filesystem.c
@@ -38,7 +38,9 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #include <signal.h>
 
 #include <vlc_common.h>
diff --git a/src/os2/thread.c b/src/os2/thread.c
index 8f7b335ea4..364fb78307 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -40,7 +40,9 @@
 #include <time.h>
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 
 #include <sys/time.h>
 #include <sys/select.h>
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 6c56013233..715ca4cfbf 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -38,7 +38,9 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 
 #include <vlc_common.h>
 #include <vlc_fs.h>
diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c
index f44f26f04f..2860f5ba03 100644
--- a/test/modules/misc/tls.c
+++ b/test/modules/misc/tls.c
@@ -29,7 +29,9 @@
 #include <string.h>
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
 #include <poll.h>
 
 #include <vlc_common.h>



More information about the vlc-commits mailing list