mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-11 11:40:28 +01:00
gfxstream: Avoid repeated functionality
Removed a function that creates anonymous file descriptors when called. Additionally replaced a call of said function with the one from the "util" directory. The intention is to avoid repeated functionality util: Allow code to be compatible in c++ compilers Added an extern "C" statement and preprocessor directives to make the “os_create_anonymous_file” function compatible with c++ compilers Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32096>
This commit is contained in:
parent
f1724b44d0
commit
217c17e8a2
2 changed files with 11 additions and 17 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include "gfxstream_vk_private.h"
|
||||
#include "goldfish_address_space.h"
|
||||
#include "goldfish_vk_private_defs.h"
|
||||
#include "util/anon_file.h"
|
||||
#include "util/macros.h"
|
||||
#include "virtgpu_gfxstream_protocol.h"
|
||||
#include "vulkan/vulkan_core.h"
|
||||
|
|
@ -37,22 +38,6 @@
|
|||
#include <drm_fourcc.h>
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__) || defined(__linux__) || defined(__APPLE__)
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
static inline int inline_memfd_create(const char* name, unsigned int flags) {
|
||||
#if defined(__ANDROID__)
|
||||
return syscall(SYS_memfd_create, name, flags);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define memfd_create inline_memfd_create
|
||||
#endif
|
||||
|
||||
#ifndef VK_USE_PLATFORM_FUCHSIA
|
||||
void zx_handle_close(zx_handle_t) {}
|
||||
void zx_event_create(int, zx_handle_t*) {}
|
||||
|
|
@ -5760,11 +5745,12 @@ VkResult ResourceTracker::on_vkGetSemaphoreFdKHR(void* context, VkResult, VkDevi
|
|||
} else {
|
||||
// opaque fd
|
||||
int hostFd = 0;
|
||||
int32_t size = 0;
|
||||
VkResult result = enc->vkGetSemaphoreFdKHR(device, pGetFdInfo, &hostFd, true /* do lock */);
|
||||
if (result != VK_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
*pFd = memfd_create("vk_opaque_fd", 0);
|
||||
*pFd = os_create_anonymous_file(size, "vk_opaque_fd");
|
||||
write(*pFd, &hostFd, sizeof(hostFd));
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,15 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
/* On win32, off_t is only 32 bit, so always using 64 bit size */
|
||||
int os_create_anonymous_file(int64_t size, const char *debug_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue