replace all F_DUPFD_CLOEXEC with os_dupfd_cloexec()
[mesa.git] / src / gallium / winsys / svga / drm / vmw_screen.c
index cecb932c4c751ccdad6510a74d5a3f33e46cdaac..e97f1621ed4dfef7bc1eb86fec60dbf5adbd780e 100644 (file)
@@ -28,6 +28,7 @@
 #include "vmw_fence.h"
 #include "vmw_context.h"
 
+#include "util/os_file.h"
 #include "util/u_memory.h"
 #include "pipe/p_compiler.h"
 #include "util/u_hash_table.h"
@@ -67,9 +68,10 @@ vmw_winsys_create( int fd )
 {
    struct vmw_winsys_screen *vws;
    struct stat stat_buf;
+   const char *getenv_val;
 
    if (dev_hash == NULL) {
-      dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare);
+      dev_hash = _mesa_hash_table_create(NULL, vmw_dev_hash, vmw_dev_compare);
       if (dev_hash == NULL)
          return NULL;
    }
@@ -89,7 +91,7 @@ vmw_winsys_create( int fd )
 
    vws->device = stat_buf.st_rdev;
    vws->open_count = 1;
-   vws->ioctl.drm_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+   vws->ioctl.drm_fd = os_dupfd_cloexec(fd);
    vws->force_coherent = FALSE;
    if (!vmw_ioctl_init(vws))
       goto out_no_ioctl;
@@ -97,6 +99,9 @@ vmw_winsys_create( int fd )
    vws->base.have_gb_dma = !vws->force_coherent;
    vws->base.need_to_rebind_resources = FALSE;
    vws->base.have_transfer_from_buffer_cmd = vws->base.have_vgpu10;
+   vws->base.have_constant_buffer_offset_cmd = FALSE;
+   getenv_val = getenv("SVGA_FORCE_KERNEL_UNMAPS");
+   vws->cache_maps = !getenv_val || strcmp(getenv_val, "0") == 0;
    vws->fence_ops = vmw_fence_ops_create(vws);
    if (!vws->fence_ops)
       goto out_no_fence_ops;
@@ -107,14 +112,12 @@ vmw_winsys_create( int fd )
    if (!vmw_winsys_screen_init_svga(vws))
       goto out_no_svga;
 
-   if (util_hash_table_set(dev_hash, &vws->device, vws) != PIPE_OK)
-      goto out_no_hash_insert;
+   _mesa_hash_table_insert(dev_hash, &vws->device, vws);
 
    cnd_init(&vws->cs_cond);
    mtx_init(&vws->cs_mutex, mtx_plain);
 
    return vws;
-out_no_hash_insert:
 out_no_svga:
    vmw_pools_cleanup(vws);
 out_no_pools:
@@ -132,7 +135,7 @@ void
 vmw_winsys_destroy(struct vmw_winsys_screen *vws)
 {
    if (--vws->open_count == 0) {
-      util_hash_table_remove(dev_hash, &vws->device);
+      _mesa_hash_table_remove_key(dev_hash, &vws->device);
       vmw_pools_cleanup(vws);
       vws->fence_ops->destroy(vws->fence_ops);
       vmw_ioctl_cleanup(vws);