mesa/src/vulkan
Antonio Ospite ddf2aa3a4d build: avoid redefining unreachable() which is standard in C23
In the C23 standard unreachable() is now a predefined function-like
macro in <stddef.h>

See https://android.googlesource.com/platform/bionic/+/HEAD/docs/c23.md#is-now-a-predefined-function_like-macro-in

And this causes build errors when building for C23:

-----------------------------------------------------------------------
In file included from ../src/util/log.h:30,
                 from ../src/util/log.c:30:
../src/util/macros.h:123:9: warning: "unreachable" redefined
  123 | #define unreachable(str)    \
      |         ^~~~~~~~~~~
In file included from ../src/util/macros.h:31:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:456:9: note: this is the location of the previous definition
  456 | #define unreachable() (__builtin_unreachable ())
      |         ^~~~~~~~~~~
-----------------------------------------------------------------------

So don't redefine it with the same name, but use the name UNREACHABLE()
to also signify it's a macro.

Using a different name also makes sense because the behavior of the
macro was extending the one of __builtin_unreachable() anyway, and it
also had a different signature, accepting one argument, compared to the
standard unreachable() with no arguments.

This change improves the chances of building mesa with the C23 standard,
which for instance is the default in recent AOSP versions.

All the instances of the macro, including the definition, were updated
with the following command line:

  git grep -l '[^_]unreachable(' -- "src/**" | sort | uniq | \
  while read file; \
  do \
    sed -e 's/\([^_]\)unreachable(/\1UNREACHABLE(/g' -i "$file"; \
  done && \
  sed -e 's/#undef unreachable/#undef UNREACHABLE/g' -i src/intel/isl/isl_aux_info.c

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36437>
2025-07-31 17:49:42 +00:00
..
anti-lag-layer meson: include VkLayer_MESA_anti_lag in the devenv 2025-07-30 23:53:51 +00:00
device-select-layer meson: fix VkLayer_MESA_device_select in the devenv 2025-07-30 23:53:51 +00:00
overlay-layer build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
registry vulkan: update headers/xml for 1.4.318 2025-06-14 08:21:31 +00:00
runtime build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
screenshot-layer build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
util build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
vram-report-limit-layer build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
wsi build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
meson.build vulkan: implement VK_AMD_anti_lag as implicit vulkan layer 2025-07-24 09:50:07 +00:00
vulkan-android.sym android/vk: drop unnecessary symbols 2023-03-04 07:41:10 +00:00
vulkan-icd-android-symbols.txt vk: be stricter about symbols check between android and other platforms 2023-03-04 07:41:10 +00:00
vulkan-icd-symbols.txt vk: be stricter about symbols check between android and other platforms 2023-03-04 07:41:10 +00:00
vulkan.sym vk: move radv's linker symbols scripts for use in all drivers 2023-03-04 07:41:10 +00:00
vulkan_api.def.in