summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2019-07-29 13:51:55 -0700
committerMatt Turner <mattst88@gmail.com>2019-07-30 11:49:09 -0700
commitc9b86cf52692f1d76314dce345080af8ce786792 (patch)
treeb27babe1179c7dda558b6a36439b519038a0ab3d
parent597bddad47e831474a33cde054c40bbd2cbc0600 (diff)
downloadmesa-c9b86cf52692f1d76314dce345080af8ce786792.tar.gz
meson: Test for program_invocation_name
program_invocation_name and program_invocation_short_name are both GNU extensions. I don't believe one can exist without the other, so only check for program_invocation_name. Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
-rw-r--r--meson.build7
-rw-r--r--src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c2
-rw-r--r--src/util/u_process.c8
3 files changed, 10 insertions, 7 deletions
diff --git a/meson.build b/meson.build
index 8dc431cfc5b..c9f96e7135d 100644
--- a/meson.build
+++ b/meson.build
@@ -1035,6 +1035,13 @@ foreach f : ['strtof', 'mkostemp', 'posix_memalign', 'timespec_get', 'memfd_crea
endif
endforeach
+if cc.has_header_symbol('errno.h', 'program_invocation_name',
+ args : '-D_GNU_SOURCE')
+ pre_args += '-DHAVE_PROGRAM_INVOCATION_NAME'
+elif with_tools.contains('intel')
+ error('Intel tools require the program_invocation_name variable')
+endif
+
# strtod locale support
if cc.links('''
#define _GNU_SOURCE
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
index 58005df5595..42a58a6dcc1 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c
@@ -125,7 +125,7 @@ static int virgl_vtest_send_init(struct virgl_vtest_winsys *vws)
ret = os_get_process_name(cmdline, 63);
if (ret == FALSE)
strcpy(cmdline, nstr);
-#if defined(__GLIBC__) || defined(__CYGWIN__)
+#if defined(HAVE_PROGRAM_INVOCATION_NAME)
if (!strcmp(cmdline, "shader_runner")) {
const char *name;
/* hack to get better testname */
diff --git a/src/util/u_process.c b/src/util/u_process.c
index 94c975df396..cbccf48ed01 100644
--- a/src/util/u_process.c
+++ b/src/util/u_process.c
@@ -32,11 +32,7 @@
#undef GET_PROGRAM_NAME
-#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__)
-# if !defined(__GLIBC__) || (__GLIBC__ < 2)
-/* These aren't declared in any libc5 header */
-extern char *program_invocation_name, *program_invocation_short_name;
-# endif
+#if defined(__linux__) && defined(HAVE_PROGRAM_INVOCATION_NAME)
static const char *
__getProgramName()
{
@@ -79,7 +75,7 @@ __getProgramName()
return program_invocation_name;
}
# define GET_PROGRAM_NAME() __getProgramName()
-#elif defined(__CYGWIN__)
+#elif defined(HAVE_PROGRAM_INVOCATION_NAME)
# define GET_PROGRAM_NAME() program_invocation_short_name
#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
# include <osreldate.h>