summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2024-03-19 16:34:02 +0100
committerErik Faye-Lund <erik.faye-lund@collabora.com>2024-03-20 08:32:49 +0100
commit9c941dfc36e91f4cb0758e8b7f3b63d8290bdf95 (patch)
tree6c5c63bc584f248d6a2945d0a9cb85cd11fd8167
parentc55e22a5c35f7374e4c00e5a4fa116fbe806ad77 (diff)
properly check for libgen.h
Some users are reporting that basename is not available when building on Linux with musl libc. And since the POSIX spec[1] says that basename is defined in libgen.h, we should include that when available. So let's properly detect the header, and include it if it exists. This should hopefully make things a bit more robust. Since we're also including this from the CL program-tester, let's rearrange the includes a bit so we know that config.h has been included. Reviewed-by: David Heidelberg <david.heidelberg@collabora.com> Tested-by: David Heidelberg <david.heidelberg@collabora.com> Reviewed-by: Khem Raj <raj.khem@gmail.com> Tested-by: Khem Raj <raj.khem@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/888>
-rw-r--r--CMakeLists.txt1
-rw-r--r--tests/cl/program/program-tester.c5
-rw-r--r--tests/util/config.h.in1
-rw-r--r--tests/util/piglit-util.h4
4 files changed, 8 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd2bf6712..5563fe0e2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -492,6 +492,7 @@ check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(linux/sync_file.h HAVE_LINUX_SYNC_FILE_H)
check_include_file(endian.h HAVE_ENDIAN_H)
+check_include_file(libgen.h HAVE_LIBGEN_H)
if(DEFINED PIGLIT_INSTALL_VERSION)
set(PIGLIT_INSTALL_VERSION_SUFFIX
diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index 97fe64906..e47fb5aac 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -31,10 +31,13 @@
#include <inttypes.h>
#include <math.h>
#include <regex.h>
-#include <libgen.h>
#include "piglit-framework-cl-program.h"
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
+
/* Regexes */
/*
diff --git a/tests/util/config.h.in b/tests/util/config.h.in
index 8ed5af170..437eb9141 100644
--- a/tests/util/config.h.in
+++ b/tests/util/config.h.in
@@ -16,3 +16,4 @@
#cmakedefine HAVE_SYS_RESOURCE_H 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE_ENDIAN_H 1
+#cmakedefine HAVE_LIBGEN_H 1
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 4d3606c70..de999980b 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -52,8 +52,8 @@ extern "C" {
#include <math.h>
#include <float.h>
-#if defined(__APPLE__) || defined(__MINGW32__)
-# include "libgen.h" // for basename
+#ifdef HAVE_LIBGEN_H
+# include <libgen.h> // for basename
#elif defined(_MSC_VER)
static inline char *