util/fossilize_db: fix macOS inotify build error
authorJuston Li <justonli@google.com>
Tue, 17 Jan 2023 20:57:48 +0000 (12:57 -0800)
committerMarge Bot <emma+marge@anholt.net>
Mon, 23 Jan 2023 18:31:48 +0000 (18:31 +0000)
require <sys/inotify.h> for fossilize_db

Fixes: 3b69b67545b ("util/fossilize_db: add runtime RO foz db loading via FOZ_DBS_DYNAMIC_LIST")

Signed-off-by: Juston Li <justonli@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20755>

meson.build
src/util/fossilize_db.c
src/util/fossilize_db.h

index 8a26ebc..1766957 100644 (file)
@@ -1252,7 +1252,7 @@ if not ['linux'].contains(host_machine.system())
 endif
 
 foreach h : ['xlocale.h', 'linux/futex.h', 'endian.h', 'dlfcn.h', 'sys/shm.h',
-             'cet.h', 'pthread_np.h', 'renderdoc_app.h']
+             'cet.h', 'pthread_np.h', 'renderdoc_app.h', 'sys/inotify.h']
   if cc.check_header(h)
     pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
   endif
index 25f4dec..16daec4 100644 (file)
@@ -325,6 +325,7 @@ load_foz_dbs_ro(struct foz_db *foz_db, char *foz_dbs_ro)
    }
 }
 
+#ifdef FOZ_DB_UTIL_DYNAMIC_LIST
 static bool
 check_file_already_loaded(struct foz_db *foz_db,
                           FILE *db_file,
@@ -483,6 +484,7 @@ foz_dbs_list_updater_init(struct foz_db *foz_db, char *list_filename)
 
    return true;
 }
+#endif
 
 /* Here we open mesa cache foz dbs files. If the files exist we load the index
  * db into a hash table. The index db contains the offsets needed to later
@@ -525,10 +527,12 @@ foz_prepare(struct foz_db *foz_db, char *cache_path)
    if (foz_dbs_ro)
       load_foz_dbs_ro(foz_db, foz_dbs_ro);
 
+#ifdef FOZ_DB_UTIL_DYNAMIC_LIST
    char *foz_dbs_list =
       getenv("MESA_DISK_CACHE_READ_ONLY_FOZ_DBS_DYNAMIC_LIST");
    if (foz_dbs_list)
       foz_dbs_list_updater_init(foz_db, foz_dbs_list);
+#endif
 
    return true;
 
@@ -541,6 +545,7 @@ fail:
 void
 foz_destroy(struct foz_db *foz_db)
 {
+#ifdef FOZ_DB_UTIL_DYNAMIC_LIST
    struct foz_dbs_list_updater *updater = &foz_db->updater;
    if (updater->thrd) {
       inotify_rm_watch(updater->inotify_fd, updater->inotify_wd);
@@ -550,6 +555,7 @@ foz_destroy(struct foz_db *foz_db)
       thrd_join(updater->thrd, NULL);
       close(updater->inotify_fd);
    }
+#endif
 
    if (foz_db->db_idx)
       fclose(foz_db->db_idx);
index 90ebe52..4e24e3f 100644 (file)
 #define FOZ_DB_UTIL 1
 #endif
 
+#ifdef HAVE_SYS_INOTIFY_H
+#define FOZ_DB_UTIL_DYNAMIC_LIST 1
+#endif
+
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>