[Mesa-dev] [PATCH] util: fix MSVC build issue in disk_cache.h

Brian Paul brianp at vmware.com
Tue Feb 21 22:59:16 UTC 2017


On 02/21/2017 03:57 PM, Brian Paul wrote:
> Windows doesn't have dlfcn.h.  Protect the code in question
> with #if ENABLE_SHADER_CACHE test.
> ---
>   src/util/disk_cache.h | 26 ++++++++++++++++----------
>   1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
> index 8b6fc0d..7f4da80 100644
> --- a/src/util/disk_cache.h
> +++ b/src/util/disk_cache.h
> @@ -24,7 +24,9 @@
>   #ifndef DISK_CACHE_H
>   #define DISK_CACHE_H
>
> +#ifdef ENABLE_SHADER_CACHE
>   #include <dlfcn.h>
> +#endif
>   #include <stdint.h>
>   #include <stdbool.h>
>   #include <sys/stat.h>
> @@ -43,16 +45,20 @@ 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;
> +#ifdef ENABLE_SHADER_CACHE
> +   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;
> +#else
> +   return false;
> +#endif
>   }
>
>   /* Provide inlined stub functions if the shader cache is disabled. */
>


Timothy,

Does this function really need to be inlined?  AFAICT, it's not called 
on a performance critical path.  Moving it into the .c file would seem 
to be cleaner.

-Brian



More information about the mesa-dev mailing list