gfxstream: Using DETECT_OS_FUCHSIA from util instead of __Fushsia__

The DETECT_OS_FUCHSIA constant defined in util/detect_os.h allows
replacing the ocurrences of defined(__Fushsia__) and __Fuschsia__. They
are equivalent in functionality but the util's one is easier to read and
write. Also it does not require the define() syntax.

The change involve replacing every ocurrence of defined(__Fuchsia__) with
DETECT_OS_FUCHSIA. Then replacing every ocurrence of #ifdef __Fuchsia__
with #if DETECT_OS_FUCHSIA.

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32286>
This commit is contained in:
Manuel Dun 2024-11-20 14:50:09 -04:00 committed by Marge Bot
parent 870aa88a5f
commit 5cf2d8efa3
5 changed files with 17 additions and 14 deletions

View file

@ -7,8 +7,9 @@
#include <inttypes.h>
#include <stddef.h>
#include "util/detect_os.h"
#if defined(__Fuchsia__)
#if DETECT_OS_FUCHSIA
typedef void* address_space_handle_t;
#else
typedef int address_space_handle_t;

View file

@ -8,8 +8,9 @@
#include <inttypes.h>
#include <stddef.h>
#include "util/detect_os.h"
#ifdef __Fuchsia__
#if DETECT_OS_FUCHSIA
#include <fidl/fuchsia.hardware.goldfish/cpp/wire.h>
#endif
@ -34,14 +35,14 @@ private:
address_space_handle_t release();
static void closeHandle(address_space_handle_t handle);
#ifdef __Fuchsia__
#if DETECT_OS_FUCHSIA
::fidl::WireSyncClient<fuchsia_hardware_goldfish::AddressSpaceDevice>
m_device;
::fidl::WireSyncClient<fuchsia_hardware_goldfish::AddressSpaceChildDriver>
m_child_driver;
#else // __Fuchsia__
#else // DETECT_OS_FUCHSIA
address_space_handle_t m_handle;
#endif // !__Fuchsia__
#endif // !DETECT_OS_FUCHSIA
friend class GoldfishAddressSpaceBlock;
friend class GoldfishAddressSpaceHostMemoryAllocator;
@ -69,13 +70,13 @@ private:
void destroy();
GoldfishAddressSpaceBlock &operator=(const GoldfishAddressSpaceBlock &);
#ifdef __Fuchsia__
#if DETECT_OS_FUCHSIA
::fidl::WireSyncClient<fuchsia_hardware_goldfish::AddressSpaceChildDriver>*
m_driver;
uint32_t m_vmo;
#else // __Fuchsia__
#else // DETECT_OS_FUCHSIA
address_space_handle_t m_handle;
#endif // !__Fuchsia__
#endif // !DETECT_OS_FUCHSIA
void *m_mmaped_ptr;
uint64_t m_phys_addr;

View file

@ -19,6 +19,7 @@
#include "vk_device.h"
#include "vk_instance.h"
#include "vk_sync_dummy.h"
#include "util/detect_os.h"
uint32_t gSeqno = 0;
uint32_t gNoRenderControlEnc = 0;
@ -202,7 +203,7 @@ static VkResult gfxstream_vk_physical_device_init(
memset(&dispatch_table, 0, sizeof(struct vk_physical_device_dispatch_table));
vk_physical_device_dispatch_table_from_entrypoints(
&dispatch_table, &gfxstream_vk_physical_device_entrypoints, false);
#if !defined(__Fuchsia__)
#if !DETECT_OS_FUCHSIA
vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
&wsi_physical_device_entrypoints, false);
#endif
@ -364,7 +365,7 @@ VkResult gfxstream_vk_CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
memset(&dispatch_table, 0, sizeof(struct vk_instance_dispatch_table));
vk_instance_dispatch_table_from_entrypoints(&dispatch_table, &gfxstream_vk_instance_entrypoints,
false);
#if !defined(__Fuchsia__)
#if !DETECT_OS_FUCHSIA
vk_instance_dispatch_table_from_entrypoints(&dispatch_table, &wsi_instance_entrypoints, false);
#endif
@ -516,7 +517,7 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
memset(&dispatch_table, 0, sizeof(struct vk_device_dispatch_table));
vk_device_dispatch_table_from_entrypoints(&dispatch_table, &gfxstream_vk_device_entrypoints,
false);
#if !defined(__Fuchsia__)
#if !DETECT_OS_FUCHSIA
vk_device_dispatch_table_from_entrypoints(&dispatch_table, &wsi_device_entrypoints, false);
#endif

View file

@ -21,7 +21,7 @@
extern "C" {
#if DETECT_OS_ANDROID || defined(__Fuchsia__)
#if DETECT_OS_ANDROID || DETECT_OS_FUCHSIA
#define SET_HWVULKAN_DISPATCH_MAGIC res->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
#elif defined(__linux__)
#define SET_HWVULKAN_DISPATCH_MAGIC res->loaderData.loaderMagic = ICD_LOADER_MAGIC;

View file

@ -5,7 +5,7 @@
#pragma once
#include "util/detect_os.h"
#if DETECT_OS_ANDROID || defined(__Fuchsia__)
#if DETECT_OS_ANDROID || DETECT_OS_FUCHSIA
#include <hardware/hwvulkan.h>
#elif defined(__linux__)
#include <vulkan/vk_icd.h>
@ -39,7 +39,7 @@ struct goldfish_vk_object_list {
struct goldfish_vk_object_list* next;
};
#if DETECT_OS_ANDROID || defined(__Fuchsia__)
#if DETECT_OS_ANDROID || DETECT_OS_FUCHSIA
#define DECLARE_HWVULKAN_DISPATCH hwvulkan_dispatch_t dispatch;
#elif defined(__linux__)
#define DECLARE_HWVULKAN_DISPATCH VK_LOADER_DATA loaderData;