Skip to content

Commit

Permalink
Cleanup macro usage
Browse files Browse the repository at this point in the history
* Replace #ifdef <> with #if defined(<>)
* Replace #ifndef <> with #if !defined(<>)
* Add #elif defined(__linux__) || defined(__APPLE__) instead of just having a
naked #else block.
* Add warnings to the new block to indicate that it should be changed when
a new platform is being added. Several places before had the #if WIN32 #else
which inherently assumes that everything in the #else block is supported, when
in reality it was for unix
* Add COMMON_UNIX_PLATFORMS macro define for convenience
* Fix a few auto-gen places where None was printed by mistake
  • Loading branch information
charles-lunarg committed Apr 18, 2023
1 parent 4599ce2 commit f035e57
Show file tree
Hide file tree
Showing 41 changed files with 725 additions and 689 deletions.
6 changes: 5 additions & 1 deletion loader/asm_offset.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ static const uint32_t PHYS_DEV_OFFSET_PHYS_DEV_TERM = offsetof(struct loader_phy
static const uint32_t INSTANCE_OFFSET_ICD_TERM = offsetof(struct loader_icd_term, this_instance);
static const uint32_t DISPATCH_OFFSET_ICD_TERM = offsetof(struct loader_icd_term, phys_dev_ext);
static const uint32_t EXT_OFFSET_DEVICE_DISPATCH = offsetof(struct loader_dev_dispatch_table, ext_dispatch);
#else
#warning asm_offset.c variable declarations need to be defined for this platform
#endif

#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
#define SIZE_T_FMT "%-8zu"
#else
#elif defined(__GNUC__) || defined(__clang__)
#define SIZE_T_FMT "%-8lu"
#else
#warning asm_offset.c SIZE_T_FMT must be defined for this platform
#endif

struct ValueInfo {
Expand Down
4 changes: 2 additions & 2 deletions loader/cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "loader_common.h"

#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif

Expand Down Expand Up @@ -154,6 +154,6 @@ void cJSON_Minify(char *json);
#define cJSON_SetIntValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val))
#define cJSON_SetNumberValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val))

#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
3 changes: 1 addition & 2 deletions loader/debug_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef WIN32
#if !defined(WIN32)
#include <signal.h>
#else
#endif

#include "vulkan/vk_layer.h"
Expand Down
4 changes: 2 additions & 2 deletions loader/dirent_on_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "allocation.h"

#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif

Expand Down Expand Up @@ -108,7 +108,7 @@ void rewinddir(DIR *dir) {
}
}

#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions loader/dirent_on_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <vulkan/vulkan.h>

#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif

Expand Down Expand Up @@ -46,6 +46,6 @@ void rewinddir(DIR *);
*/

#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
4 changes: 2 additions & 2 deletions loader/extension_manual.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice phy

// ---- VK_EXT_acquire_xlib_display extension trampoline/terminators

#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT)
VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) {
const VkLayerInstanceDispatchTable *disp;
VkPhysicalDevice unwrapped_phys_dev = loader_unwrap_physical_device(physicalDevice);
Expand Down Expand Up @@ -247,7 +247,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDev

#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT

#ifdef VK_USE_PLATFORM_WIN32_KHR
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModes2EXT(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
uint32_t *pPresentModeCount,
Expand Down
4 changes: 2 additions & 2 deletions loader/extension_manual.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice

VKAPI_ATTR VkResult VKAPI_CALL terminator_ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display);

#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
#if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT)
VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);

VKAPI_ATTR VkResult VKAPI_CALL terminator_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display* dpy,
Expand All @@ -62,7 +62,7 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_GetRandROutputDisplayEXT(VkPhysicalDev
VkDisplayKHR* pDisplay);
#endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT

#ifdef VK_USE_PLATFORM_WIN32_KHR
#if defined(VK_USE_PLATFORM_WIN32_KHR)
VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModes2EXT(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
uint32_t* pPresentModeCount,
Expand Down
Loading

0 comments on commit f035e57

Please sign in to comment.