mesa/src/egl/main
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
..
50_mesa.json egl/meson: allow passing a full path to the glvnd json file 2025-06-20 22:18:22 +00:00
egl.def.in
eglapi.c egl/wayland: Move bind_wayland_display to legacy build option 2025-07-10 14:51:20 +00:00
eglarray.c
eglarray.h
eglconfig.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
eglconfig.h egl: Implement EGL_EXT_config_select_group 2024-05-11 19:43:47 +00:00
eglconfigdebug.c egl: cast printf argument to the expected type 2025-07-04 15:26:39 +00:00
eglconfigdebug.h
eglcontext.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
eglcontext.h
eglcurrent.c
eglcurrent.h egl: refactor to use DETECT_OS_ANDROID instead of ANDROID 2024-02-01 19:29:49 +00:00
egldefines.h
egldevice.c egl: Add EGL_EXT_device_query_name and EGL_EXT_device_persistent_id 2025-06-20 15:35:44 +00:00
egldevice.h egl: Add EGL_EXT_device_query_name and EGL_EXT_device_persistent_id 2025-06-20 15:35:44 +00:00
egldispatchstubs.c
egldispatchstubs.h
egldisplay.c egl/surfaceless: Fix EGL_DEVICE_EXT implementation 2023-12-13 23:15:17 +00:00
egldisplay.h egl: Remove EGL_MESA_drm_image 2025-07-09 17:49:58 +00:00
egldriver.h egl/wayland: Move bind_wayland_display to legacy build option 2025-07-10 14:51:20 +00:00
eglentrypoint.h egl/wayland: Move bind_wayland_display to legacy build option 2025-07-10 14:51:20 +00:00
eglglobals.c
eglglobals.h
eglglvnd.c
eglimage.c egl/wayland: Move bind_wayland_display to legacy build option 2025-07-10 14:51:20 +00:00
eglimage.h egl: Remove EGL_MESA_drm_image 2025-07-09 17:49:58 +00:00
egllog.c egl: use os_get_option() to allow android to set EGL_LOG_LEVEL 2024-06-21 07:44:36 +00:00
egllog.h
eglsurface.c build: avoid redefining unreachable() which is standard in C23 2025-07-31 17:49:42 +00:00
eglsurface.h egl: Retire NV_post_sub_buffer support. 2025-02-21 02:50:56 +00:00
eglsync.c
eglsync.h
egltypedefs.h