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>
This commit is contained in:
committed by
Marge Bot
parent
b4c7d3a08e
commit
ddf2aa3a4d
@@ -61,7 +61,7 @@ brw_math_function(enum opcode op)
|
||||
case SHADER_OPCODE_INT_REMAINDER:
|
||||
return BRW_MATH_FUNCTION_INT_DIV_REMAINDER;
|
||||
default:
|
||||
unreachable("not reached: unknown math function");
|
||||
UNREACHABLE("not reached: unknown math function");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ normalize_brw_reg_for_encoding(brw_reg *reg)
|
||||
case VGRF:
|
||||
case ATTR:
|
||||
case UNIFORM:
|
||||
unreachable("not reached");
|
||||
UNREACHABLE("not reached");
|
||||
}
|
||||
|
||||
return brw_reg;
|
||||
@@ -1209,7 +1209,7 @@ brw_generator::generate_code(const cfg_t *cfg, int dispatch_width,
|
||||
case SHADER_OPCODE_FIND_LIVE_CHANNEL:
|
||||
case SHADER_OPCODE_FIND_LAST_LIVE_CHANNEL:
|
||||
case SHADER_OPCODE_LOAD_LIVE_CHANNELS:
|
||||
unreachable("Should be lowered by lower_find_live_channel()");
|
||||
UNREACHABLE("Should be lowered by lower_find_live_channel()");
|
||||
break;
|
||||
|
||||
case FS_OPCODE_LOAD_LIVE_CHANNELS: {
|
||||
@@ -1337,10 +1337,10 @@ brw_generator::generate_code(const cfg_t *cfg, int dispatch_width,
|
||||
break;
|
||||
|
||||
default:
|
||||
unreachable("Unsupported opcode");
|
||||
UNREACHABLE("Unsupported opcode");
|
||||
|
||||
case SHADER_OPCODE_LOAD_PAYLOAD:
|
||||
unreachable("Should be lowered by lower_load_payload()");
|
||||
UNREACHABLE("Should be lowered by lower_load_payload()");
|
||||
}
|
||||
prev_inst = inst;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user