util/disk_cache: Fix disk_cache_get_function_timestamp with disabled cache.
radv always needs it, so just check the header instead. Also
do not declare the function if the variable is not set, so we
get a nice compile error instead of failing to open a device
at runtime.
Fixes: b87ef9e606
"util: fix MSVC build issue in disk_cache.h"
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
@@ -872,6 +872,7 @@ AC_HEADER_MAJOR
|
|||||||
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
|
AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
|
||||||
AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
|
AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
|
||||||
AC_CHECK_HEADERS([endian.h])
|
AC_CHECK_HEADERS([endian.h])
|
||||||
|
AC_CHECK_HEADER([dlfcn.h], [DEFINES="$DEFINES -DHAVE_DLFCN_H"])
|
||||||
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
|
AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
|
||||||
AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
|
AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
|
||||||
AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
|
AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
|
||||||
|
@@ -960,7 +960,7 @@ elif cc.has_header_symbol('sys/mkdev.h', 'major')
|
|||||||
pre_args += '-DMAJOR_IN_MKDEV'
|
pre_args += '-DMAJOR_IN_MKDEV'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h']
|
foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h']
|
||||||
if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h))
|
if cc.compiles('#include <@0@>'.format(h), name : '@0@'.format(h))
|
||||||
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
|
pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
|
||||||
endif
|
endif
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
#ifndef DISK_CACHE_H
|
#ifndef DISK_CACHE_H
|
||||||
#define DISK_CACHE_H
|
#define DISK_CACHE_H
|
||||||
|
|
||||||
#ifdef ENABLE_SHADER_CACHE
|
#ifdef HAVE_DLFCN_H
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -88,10 +88,10 @@ disk_cache_format_hex_id(char *buf, const uint8_t *hex_id, unsigned size)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DLFCN_H
|
||||||
static inline bool
|
static inline bool
|
||||||
disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_SHADER_CACHE
|
|
||||||
Dl_info info;
|
Dl_info info;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (!dladdr(ptr, &info) || !info.dli_fname) {
|
if (!dladdr(ptr, &info) || !info.dli_fname) {
|
||||||
@@ -102,10 +102,8 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
|||||||
}
|
}
|
||||||
*timestamp = st.st_mtime;
|
*timestamp = st.st_mtime;
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Provide inlined stub functions if the shader cache is disabled. */
|
/* Provide inlined stub functions if the shader cache is disabled. */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user