[vlc-devel] [PATCH] build: create a macro to check for, and replace, possibly-inline functions.

Rémi Denis-Courmont remi at remlab.net
Tue Mar 10 13:17:09 CET 2015


Leaving aside the contentious issue of whose bug is it...

Le 2015-03-09 23:30, Diego Elio Pettenò a écrit :
>  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_FUNC_INLINE([gmtime_r], [
> +    #define _POSIX_C_SOURCE 200809L

Forcing a build environment only for a test is not a good idea IMNSHO.

> +    #include <time.h>
> +  ], [
> +    time_t t; struct tm r;
> +    gmtime_r(&t, &r);
> +  ])

AC_CHECK_DECL(S) and AC_LIBOBJ would be much simpler. We already do 
that for nanosleep().

> +
> +VLC_REPLACE_FUNC_INLINE([asprintf], [
> +    #include <stdio.h>
> +  ], [
> +    char *c;
> +    if (asprintf(&c, "%s %d", "string", 1) == -1)
> +        c = NULL;
> +  ])
> +
> +VLC_REPLACE_FUNC_INLINE([vasprintf], [
> +    #include <stdio.h>
> +    #include <stdarg.h>
> +  ], [
> +    char *c;
> +    va_list ap;
> +    if (vasprintf(&c, "%s %d", ap) == -1)
> +        c = NULL;
> +  ])

Revectoring the v/asprintf checks is a good idea (though personally I 
would have left the original AC_REPLACE_FUNCS), but belongs in a 
separate patch. Also same comments as above.

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list