mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
util/radv: move *_get_function_timestamp() to utils
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
parent
ed6b47f435
commit
207e3a6e4b
2 changed files with 20 additions and 19 deletions
|
|
@ -25,14 +25,13 @@
|
||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "radv_private.h"
|
#include "radv_private.h"
|
||||||
#include "radv_cs.h"
|
#include "radv_cs.h"
|
||||||
|
#include "util/disk_cache.h"
|
||||||
#include "util/strtod.h"
|
#include "util/strtod.h"
|
||||||
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
|
|
@ -45,29 +44,14 @@
|
||||||
#include "sid.h"
|
#include "sid.h"
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
||||||
static int
|
|
||||||
radv_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
|
||||||
{
|
|
||||||
Dl_info info;
|
|
||||||
struct stat st;
|
|
||||||
if (!dladdr(ptr, &info) || !info.dli_fname) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (stat(info.dli_fname, &st)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
*timestamp = st.st_mtim.tv_sec;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
|
radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
|
||||||
{
|
{
|
||||||
uint32_t mesa_timestamp, llvm_timestamp;
|
uint32_t mesa_timestamp, llvm_timestamp;
|
||||||
uint16_t f = family;
|
uint16_t f = family;
|
||||||
memset(uuid, 0, VK_UUID_SIZE);
|
memset(uuid, 0, VK_UUID_SIZE);
|
||||||
if (radv_get_function_timestamp(radv_device_get_cache_uuid, &mesa_timestamp) ||
|
if (!disk_cache_get_function_timestamp(radv_device_get_cache_uuid, &mesa_timestamp) ||
|
||||||
radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp))
|
!disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memcpy(uuid, &mesa_timestamp, 4);
|
memcpy(uuid, &mesa_timestamp, 4);
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,10 @@
|
||||||
#ifndef DISK_CACHE_H
|
#ifndef DISK_CACHE_H
|
||||||
#define DISK_CACHE_H
|
#define DISK_CACHE_H
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -38,6 +40,21 @@ typedef uint8_t cache_key[CACHE_KEY_SIZE];
|
||||||
|
|
||||||
struct disk_cache;
|
struct disk_cache;
|
||||||
|
|
||||||
|
static inline bool
|
||||||
|
disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
|
||||||
|
{
|
||||||
|
Dl_info info;
|
||||||
|
struct stat st;
|
||||||
|
if (!dladdr(ptr, &info) || !info.dli_fname) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (stat(info.dli_fname, &st)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*timestamp = st.st_mtim.tv_sec;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Provide inlined stub functions if the shader cache is disabled. */
|
/* Provide inlined stub functions if the shader cache is disabled. */
|
||||||
|
|
||||||
#ifdef ENABLE_SHADER_CACHE
|
#ifdef ENABLE_SHADER_CACHE
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue