util: fix MSVC build issue in disk_cache.h
authorBrian Paul <brianp@vmware.com>
Tue, 21 Feb 2017 22:52:40 +0000 (15:52 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 22 Feb 2017 03:54:46 +0000 (20:54 -0700)
Windows doesn't have dlfcn.h.  Protect the code in question
with #if ENABLE_SHADER_CACHE test.  And fix indentation.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/util/disk_cache.h

index 8b6fc0ddcbf0b5d29c6aee584c64bf3c3b33d193..7f4da809ccb445764e53b38d42f69472fc4be84c 100644 (file)
@@ -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. */