]> git.sesse.net Git - vlc/commitdiff
build: create a macro to check for, and replace, possibly-inline functions.
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>
Sun, 15 Mar 2015 10:49:39 +0000 (10:49 +0000)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 16 Mar 2015 17:21:42 +0000 (19:21 +0200)
mingw (both 32 and 64) provides a number of functions that have no C
linkage, but are only available as static inline. Define a macro that can
check for the function declaration but acts like AC_REPLACE_FUNC.

Use the new macro for asprintf/vasprintf (previously implemented in
configure.ac directly).

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
configure.ac
m4/vlc.m4

index a2e71e2a0d2d4cd0e9d609e62ac7fd0f0c6258bc..2c5af8e7df1cbdef5237023849d60532b0719636 100644 (file)
@@ -562,20 +562,8 @@ AC_CHECK_FUNCS(fdatasync,,
 ])
 
 dnl mingw64 implements those as static inline, not functions with C linkage
-AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([#include <stdio.h>], [
-        char *c;
-        if (asprintf(&c, "%s %d", "string", 1) == -1)
-            c = NULL;
-    ])],[AC_DEFINE([HAVE_ASPRINTF],[1],[Define to 1 if you have asprintf function])],[AC_LIBOBJ([asprintf])])
-AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([#include <stdio.h>
-                     #include <stdarg.h>], [
-        char *c;
-        va_list ap;
-        if (vasprintf(&c, "%s %d", ap) == -1)
-            c = NULL;
-    ])],[AC_DEFINE([HAVE_VASPRINTF],[1],[Define to 1 if you have asprintf function])],[AC_LIBOBJ([vasprintf])])
+VLC_REPLACE_DECL([asprintf], [#include <stdio.h>])
+VLC_REPLACE_DECL([vasprintf], [#include <stdio.h>])
 
 dnl C11 static_assert()
 AC_MSG_CHECKING([for static_assert in assert.h])
index 1adec40b312cbe7981c54f5c169f1d81cabbf0df..753967efacefb151e76d2018cda810d3604b4355 100644 (file)
--- a/m4/vlc.m4
+++ b/m4/vlc.m4
@@ -96,3 +96,23 @@ AC_DEFUN([VLC_LIBRARY_SUFFIX], [
   AC_MSG_RESULT(${LIBEXT})
   AC_DEFINE_UNQUOTED(LIBEXT, "${LIBEXT}", [Dynamic object extension])
 ])
+
+dnl ===========================================================================
+dnl  Custom macros for checking functions with inline fallback, for mingw32/64
+
+dnl VLC_REPLACE_DECL([funcname], [include])
+AC_DEFUN([VLC_REPLACE_DECL], [
+  AS_VAR_PUSHDEF([CACHEVAR], [vlc_cv_replace_decl] AS_TR_SH([$1]))
+  AC_CACHE_VAL(CACHEVAR, [
+    AC_CHECK_DECL(
+      [$1],
+      AS_VAR_SET(CACHEVAR, [yes]),
+      AS_VAR_SET(CACHEVAR, [no]),
+      [$2]
+    )
+  ])
+  AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+    [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1], [Define to 1 if you have $1 function])],
+    [AC_LIBOBJ([$1])])
+  AS_VAR_POPDEF([CACHEVAR])
+])