#include <sys/types.h>
#include <drm-uapi/drm_fourcc.h>
+#include "util/os_file.h"
+
#include "loader.h"
#include "egl_dri2.h"
#include "egl_dri2_fallbacks.h"
return EGL_FALSE;
}
- dri2_dpy->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ dri2_dpy->fd = os_dupfd_cloexec(fd);
if (dri2_dpy->fd < 0)
return EGL_FALSE;
#include <fcntl.h>
#include <unistd.h>
+#include "util/os_file.h"
+
#include "egl_dri2.h"
#include "egl_dri2_fallbacks.h"
#include "loader.h"
}
dri2_dpy->own_device = true;
} else {
- dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
+ dri2_dpy->fd = os_dupfd_cloexec(gbm_device_get_fd(gbm));
if (dri2_dpy->fd < 0) {
err = "DRI2: failed to fcntl() existing gbm device";
goto cleanup;
#include <fcntl.h>
#include "c11/threads.h"
#include "util/macros.h"
+#include "util/os_file.h"
#include "util/u_atomic.h"
#include "eglcontext.h"
* The new fd is guaranteed to be 3 or greater.
*/
if (fd != -1 && display->Options.fd == 0) {
- display->Options.fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ display->Options.fd = os_dupfd_cloexec(fd);
if (display->Options.fd == -1) {
/* Do not (really) need to teardown the display */
_eglError(EGL_BAD_ALLOC, "eglGetPlatformDisplay");
#include <libsync.h>
#include <unistd.h>
+#include "util/os_file.h"
#include "util/os_time.h"
/**
/* dup src->fd */
int fd = -1;
if (src->fd >= 0) {
- fd = fcntl(src->fd, F_DUPFD_CLOEXEC, 0);
+ fd = os_dupfd_cloexec(src->fd);
if (fd < 0) {
tu_loge("failed to dup fd %d for fence", src->fd);
sync_wait(src->fd, -1);
#include "frontend/drm_driver.h"
#include "pipe_loader_priv.h"
+#include "util/os_file.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
#include "util/u_debug.h"
bool ret;
int new_fd;
- if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0)
+ if (fd < 0 || (new_fd = os_dupfd_cloexec(fd)) < 0)
return false;
ret = pipe_loader_drm_probe_fd_nodup(dev, new_fd);
#include "pipe_loader_priv.h"
+#include "util/os_file.h"
#include "util/u_memory.h"
#include "util/u_dl.h"
#include "sw/dri/dri_sw_winsys.h"
if (!pipe_loader_sw_probe_init_common(sdev))
goto fail;
- if (fd < 0 || (sdev->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0)
+ if (fd < 0 || (sdev->fd = os_dupfd_cloexec(fd)) < 0)
goto fail;
for (i = 0; sdev->dd->winsys[i].name; i++) {
#include <fcntl.h>
#include <libsync.h>
+#include "util/os_file.h"
#include <util/u_memory.h>
#include <util/u_inlines.h>
int fd, enum pipe_fd_type type)
{
assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
- *fence = lima_fence_create(fcntl(fd, F_DUPFD_CLOEXEC, 3));
+ *fence = lima_fence_create(os_dupfd_cloexec(fd));
}
static void
lima_fence_get_fd(struct pipe_screen *pscreen,
struct pipe_fence_handle *fence)
{
- return fcntl(fence->fd, F_DUPFD_CLOEXEC, 3);
+ return os_dupfd_cloexec(fence->fd);
}
static void
#include <libsync.h>
#include <fcntl.h>
+#include "util/os_file.h"
#include "util/u_inlines.h"
#include "vc4_screen.h"
assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
*fence = vc4_fence_create(vc4->screen, vc4->last_emit_seqno,
- fcntl(fd, F_DUPFD_CLOEXEC, 3));
+ os_dupfd_cloexec(fd));
}
static void
{
struct vc4_fence *fence = vc4_fence(pfence);
- return fcntl(fence->fd, F_DUPFD_CLOEXEC, 3);
+ return os_dupfd_cloexec(fence->fd);
}
int
return NULL;
pipe_reference_init(&ws->reference, 1);
- ws->fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+ ws->fd = os_dupfd_cloexec(fd);
/* Look up the winsys from the dev table. */
simple_mtx_lock(&dev_tab_mutex);
#include <unistd.h>
#include <fcntl.h>
+#include "util/os_file.h"
+
#include "iris_drm_public.h"
extern struct pipe_screen *iris_screen_create(int fd, const struct pipe_screen_config *config);
struct pipe_screen *
iris_drm_screen_create(int fd, const struct pipe_screen_config *config)
{
- return iris_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3), config);
+ return iris_screen_create(os_dupfd_cloexec(fd), config);
}
#include <sys/stat.h>
#include "c11/threads.h"
+#include "util/os_file.h"
#include "util/u_hash_table.h"
#include "util/u_pointer.h"
#include "renderonly/renderonly.h"
if (pscreen) {
lima_screen(pscreen)->refcnt++;
} else {
- int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ int dup_fd = os_dupfd_cloexec(fd);
pscreen = lima_screen_create(dup_fd, NULL);
if (pscreen) {
struct pipe_screen *
lima_drm_screen_create_renderonly(struct renderonly *ro)
{
- return lima_screen_create(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro);
+ return lima_screen_create(os_dupfd_cloexec(ro->gpu_fd), ro);
}
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "util/format/u_format.h"
+#include "util/os_file.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_hash_table.h"
* nouveau_device_wrap does not close the fd in case of a device
* creation error.
*/
- dupfd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ dupfd = os_dupfd_cloexec(fd);
ret = nouveau_drm_new(dupfd, &drm);
if (ret)
#include <unistd.h>
#include <fcntl.h>
+#include "util/os_file.h"
+
#include "renderonly/renderonly.h"
#include "panfrost_drm_public.h"
#include "panfrost/pan_public.h"
struct pipe_screen *
panfrost_drm_screen_create(int fd)
{
- return panfrost_create_screen(fcntl(fd, F_DUPFD_CLOEXEC, 3), NULL);
+ return panfrost_create_screen(os_dupfd_cloexec(fd), NULL);
}
struct pipe_screen *
panfrost_drm_screen_create_renderonly(struct renderonly *ro)
{
- return panfrost_create_screen(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro);
+ return panfrost_create_screen(os_dupfd_cloexec(ro->gpu_fd), ro);
}
#include "radeon_drm_cs.h"
#include "radeon_drm_public.h"
+#include "util/os_file.h"
#include "util/u_cpu_detect.h"
#include "util/u_memory.h"
#include "util/u_hash_table.h"
return NULL;
}
- ws->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ ws->fd = os_dupfd_cloexec(fd);
if (!do_winsys_init(ws))
goto fail1;
#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"
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;
#include <fcntl.h>
+#include "util/os_file.h"
#include "util/u_debug.h"
#include "tegra/tegra_screen.h"
* NOTE: There are reportedly issues with reusing the file descriptor
* as-is related to Xinerama. Duplicate it to side-step any issues.
*/
- fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+ fd = os_dupfd_cloexec(fd);
if (fd < 0)
return NULL;
#include <unistd.h>
#include <fcntl.h>
+#include "util/os_file.h"
+
#include "v3d_drm_public.h"
#include "v3d/v3d_screen.h"
struct pipe_screen *
v3d_drm_screen_create(int fd, const struct pipe_screen_config *config)
{
- return v3d_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3), config, NULL);
+ return v3d_screen_create(os_dupfd_cloexec(fd), config, NULL);
}
struct pipe_screen *
#include <fcntl.h>
#include <sys/ioctl.h>
+#include "util/os_file.h"
+
#include "renderonly/renderonly.h"
#include "kmsro/drm/kmsro_drm_public.h"
#include "vc4_drm_public.h"
#endif
if (v3d_present)
- return vc4_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3), NULL);
+ return vc4_screen_create(os_dupfd_cloexec(fd), NULL);
#ifdef GALLIUM_KMSRO
return kmsro_drm_screen_create(fd, config);
#include <sys/stat.h>
#include "os/os_mman.h"
+#include "util/os_file.h"
#include "util/os_time.h"
#include "util/u_memory.h"
#include "util/format/u_format.h"
virgl_screen(pscreen)->refcnt++;
} else {
struct virgl_winsys *vws;
- int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
+ int dup_fd = os_dupfd_cloexec(fd);
vws = virgl_drm_winsys_create(dup_fd);
if (!vws) {