mesa/src/panfrost/compiler/valhall
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
..
test panfrost/va: use 'lane' modifier for MKVEC.v2i8 2025-04-10 10:15:46 -07:00
asm.py panfrost: refactor valhall ISA parser 2024-08-20 12:18:19 +00:00
disasm.py panfrost: refactor valhall ISA parser 2024-08-20 12:18:19 +00:00
disassemble.h pan/va: Ensure no clash with other defs in disassembler 2024-06-17 07:31:50 +00:00
ISA.xml bi/va: Add instructions required for KHR_shader_atomic_int64 2025-07-11 12:42:30 +00:00
meson.build build: pass licensing information in SPDX form 2024-06-29 12:42:49 -07:00
test-assembly.py
va_compiler.h pan/bi: Add support for IDVS2 on Avalon 2025-03-10 09:12:19 +01:00
va_insert_flow.c pan/va: Support relaxed waits on read-only render targets 2025-04-10 13:17:53 +00:00
va_lower_constants.c panfrost/va: use 'lane' modifier for MKVEC.v2i8 2025-04-10 10:15:46 -07:00
va_lower_isel.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
va_lower_split_64bit.c
va_mark_last.c
va_merge_flow.c pan/va: Support relaxed waits on read-only render targets 2025-04-10 13:17:53 +00:00
va_optimize.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
va_pack.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
va_perf.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
va_validate.c pan/va: allow using both FAU and small constants in the same instruction 2025-05-28 22:21:46 +00:00
valhall.c.py bi/va: Add instructions required for KHR_shader_atomic_int64 2025-07-11 12:42:30 +00:00
valhall.h pan/bi: Use shader_output intrinsic for IDVS 2025-03-10 09:03:35 +01:00
valhall.py panfrost: split pseudo instructions from Bifrost and Valhall 2024-08-20 12:18:19 +00:00
valhall_enums.h.py panfrost: refactor valhall ISA parser 2024-08-20 12:18:19 +00:00