[Piglit] [PATCH] cmake: Check for asprintf.
Ian Romanick
idr at freedesktop.org
Mon Dec 23 12:34:08 PST 2013
On 12/21/2013 01:32 PM, Vinson Lee wrote:
> Newer versions of MinGW provide asprintf in stdio.h. Do not define
> asprintf if it already exists.
>
> This patch fixes the Fedora 20 MinGW build.
>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
This is the method I was going to suggest after seeing the initial patch.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> CMakeLists.txt | 1 +
> tests/util/config.h.in | 1 +
> tests/util/piglit-util.c | 4 ++--
> tests/util/piglit-util.h | 4 ++--
> 4 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index e952e24..6092f99 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -324,6 +324,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${piglit_BINARY_DIR}/bin)
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${piglit_BINARY_DIR}/bin)
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${piglit_BINARY_DIR}/bin)
>
> +check_function_exists(asprintf HAVE_ASPRINTF)
> check_function_exists(strchrnul HAVE_STRCHRNUL)
> check_function_exists(strndup HAVE_STRNDUP)
> check_function_exists(fopen_s HAVE_FOPEN_S)
> diff --git a/tests/util/config.h.in b/tests/util/config.h.in
> index 2e8262a..691a249 100644
> --- a/tests/util/config.h.in
> +++ b/tests/util/config.h.in
> @@ -1,3 +1,4 @@
> +#cmakedefine HAVE_ASPRINTF
> #cmakedefine HAVE_STRCHRNUL
> #cmakedefine HAVE_FOPEN_S
> #cmakedefine HAVE_SETRLIMIT
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index 1c7f118..fe49fed 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -56,7 +56,7 @@
> #include "piglit-util.h"
>
>
> -#if defined(_WIN32)
> +#ifndef HAVE_ASPRINTF
>
> /* Some versions of MinGW are missing _vscprintf's declaration, although they
> * still provide the symbol in the import library.
> @@ -103,7 +103,7 @@ int asprintf(char **strp, const char *fmt, ...)
> return length;
> }
>
> -#endif /* _WIN32 */
> +#endif /* HAVE_ASPRINTF */
>
> /**
> * \brief Split \a string into an array of strings.
> diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
> index 4535fad..db880c7 100644
> --- a/tests/util/piglit-util.h
> +++ b/tests/util/piglit-util.h
> @@ -84,9 +84,9 @@ lround(double x) {
> #define PRINTFLIKE(f, a)
> #endif
>
> -#ifdef _WIN32
> +#ifndef HAVE_ASPRINTF
> int asprintf(char **strp, const char *fmt, ...) PRINTFLIKE(2, 3);
> -#endif /* _WIN32 */
> +#endif /* HAVE_ASPRINTF */
>
> // Trick from http://tdistler.com/2011/03/24/how-to-define-nan-not-a-number-on-windows
> #ifndef INFINITY
>
More information about the Piglit
mailing list