#include <sys/stat.h>
#include <unistd.h>
+#include "util/os_file.h"
+
#include "freedreno_drmif.h"
#include "freedreno_priv.h"
*/
struct fd_device * fd_device_new_dup(int fd)
{
- int dup_fd = dup(fd);
+ int dup_fd = os_dupfd_cloexec(fd);
struct fd_device *dev = fd_device_new(dup_fd);
if (dev)
dev->closefd = 1;
#include "drm-uapi/drm_fourcc.h"
+#include "util/os_file.h"
+
static int
tu_hal_open(const struct hw_module_t *mod,
const char *id,
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
.pNext = &ded_alloc,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT,
- .fd = dup(dma_buf),
+ .fd = os_dupfd_cloexec(dma_buf),
};
result =
if (semaphore != VK_NULL_HANDLE) {
int semaphore_fd =
- nativeFenceFd >= 0 ? dup(nativeFenceFd) : nativeFenceFd;
+ nativeFenceFd >= 0 ? os_dupfd_cloexec(nativeFenceFd) : nativeFenceFd;
semaphore_result = tu_ImportSemaphoreFdKHR(
device, &(VkImportSemaphoreFdInfoKHR) {
.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
}
if (fence != VK_NULL_HANDLE) {
- int fence_fd = nativeFenceFd >= 0 ? dup(nativeFenceFd) : nativeFenceFd;
+ int fence_fd = nativeFenceFd >= 0 ? os_dupfd_cloexec(nativeFenceFd) : nativeFenceFd;
fence_result = tu_ImportFenceFdKHR(
device, &(VkImportFenceFdInfoKHR) {
.sType = VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR,
#include <libsync.h>
+#include "util/os_file.h"
#include "util/u_inlines.h"
#include "freedreno_fence.h"
enum pipe_fd_type type)
{
assert(type == PIPE_FD_TYPE_NATIVE_SYNC);
- *pfence = fence_create(fd_context(pctx), NULL, 0, dup(fd));
+ *pfence = fence_create(fd_context(pctx), NULL, 0, os_dupfd_cloexec(fd));
}
void fd_fence_server_sync(struct pipe_context *pctx,
struct pipe_fence_handle *fence)
{
fence_flush(fence);
- return dup(fence->fence_fd);
+ return os_dupfd_cloexec(fence->fence_fd);
}
struct pipe_fence_handle * fd_fence_create(struct fd_batch *batch)