mesa/src/gallium/winsys
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
..
amdgpu/drm build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
asahi/drm asahi: Add scaffolding for supporting driconf options 2023-09-05 18:50:34 +00:00
crocus/drm format: Generate endian-independent format aliases 2024-07-19 13:50:42 +00:00
d3d12/wgl winsys/d3d12: Support no-alpha formats through the DXGI swapchain path 2025-05-30 01:24:10 +00:00
etnaviv/drm build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
freedreno/drm freedreno: use unicode © instead of DOS-like (C) copyright sign 2024-08-28 08:54:00 +00:00
i915/drm i915g: fix count of buffers at i915_drm_batchbuffer_validate_buffers 2024-08-18 20:19:44 +00:00
iris/drm format: Generate endian-independent format aliases 2024-07-19 13:50:42 +00:00
kmsro/drm kmsro: look for graphics capable screen as renderonly device 2025-03-05 10:48:28 +00:00
lima/drm lima: add driconf infrastructure 2025-06-10 15:32:42 +00:00
nouveau/drm build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
panfrost/drm build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
radeon amd: replace most u_bit_consecutive* with BITFIELD_MASK/RANGE 2025-06-04 17:46:38 +00:00
rocket/drm rocket: Initial commit of a driver for Rockchip's NPU 2025-07-28 08:06:38 +02:00
svga/drm svga: assorted code clean-ups in svga drm code 2025-06-23 17:33:18 +00:00
sw egl,gallium,gbm,mesa: replace get_param with pipe_caps access 2025-01-17 04:39:46 +00:00
tegra/drm build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
v3d/drm build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
vc4/drm build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
virgl virgl: Free resource memory on creation failure 2025-06-27 13:56:23 +00:00