[vlc-devel] [PATCH] configure: check socklen_t as int first

KO Myung-Hun komh78 at gmail.com
Mon Feb 17 09:19:53 CET 2020


OS/2 socket APIs use int not unsigned int in place of socklen_t. As
a result, compilation is stopped at function call requiring socklen_t *
because of type mismatch between int * and unsigned int *.
---
 configure.ac | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7741ddca55..16eee78456 100644
--- a/configure.ac
+++ b/configure.ac
@@ -759,8 +759,22 @@ ac_cv_type_socklen_t,
 #endif]], [[socklen_t len; len = 0;]])],
 ac_cv_type_socklen_t=yes,
 ac_cv_type_socklen_t=no)])
-AS_IF([test "$ac_cv_type_socklen_t" = no],
- [AC_DEFINE(socklen_t, unsigned int)])
+AS_IF([test "$ac_cv_type_socklen_t" = no], [
+  VLC_SAVE_FLAGS
+  CFLAGS="-Wpointer-sign -Werror"
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([[
+#include <sys/types.h>
+#ifdef _WIN32
+# include <winsock2.h>
+# include <ws2tcpip.h>
+#else
+# include <sys/socket.h>
+#endif
+]], [[getpeername(0, 0, (int *)0);]])],
+    AC_DEFINE(socklen_t, int), AC_DEFINE(socklen_t, unsigned int))
+  VLC_RESTORE_FLAGS
+])
 
 dnl Check for struct sockaddr_storage
 AH_TEMPLATE(sockaddr_storage, [Define to `sockaddr' if <sys/socket.h> does not define.]) dnl ` (fix VIM syntax highlight
-- 
2.22.0



More information about the vlc-devel mailing list