gallium/hash_table: consolidate hash tables with FD keys
[mesa.git] / src / gallium / winsys / radeon / drm / radeon_drm_winsys.c
index 0ea43c1959b2e1256cb19e03cdec09ac3b68949b..c38d238bfcdecfae182e17351bbad6ace9102437 100644 (file)
@@ -761,28 +761,6 @@ static bool radeon_read_registers(struct radeon_winsys *rws,
     return true;
 }
 
-static unsigned hash_fd(void *key)
-{
-    int fd = pointer_to_intptr(key);
-    struct stat stat;
-    fstat(fd, &stat);
-
-    return stat.st_dev ^ stat.st_ino ^ stat.st_rdev;
-}
-
-static int compare_fd(void *key1, void *key2)
-{
-    int fd1 = pointer_to_intptr(key1);
-    int fd2 = pointer_to_intptr(key2);
-    struct stat stat1, stat2;
-    fstat(fd1, &stat1);
-    fstat(fd2, &stat2);
-
-    return stat1.st_dev != stat2.st_dev ||
-           stat1.st_ino != stat2.st_ino ||
-           stat1.st_rdev != stat2.st_rdev;
-}
-
 DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true)
 
 static bool radeon_winsys_unref(struct radeon_winsys *ws)
@@ -828,7 +806,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
 
     mtx_lock(&fd_tab_mutex);
     if (!fd_tab) {
-        fd_tab = util_hash_table_create(hash_fd, compare_fd);
+        fd_tab = util_hash_table_create_fd_keys();
     }
 
     ws = util_hash_table_get(fd_tab, intptr_to_pointer(fd));