On 3/23/25 08:41, Philippe Mathieu-Daudé wrote:
On 21/3/25 18:31, Pierrick Bouvier wrote:
Adding proper functions definition instead of macros, and eliminating
ifdefs is not really boilerplate.
In another thread Richard said for these cases we should use _Generic()
more.
I was thinking about suggesting it when I first answered on this thread.
However, I realized it doesn't really help us towards our end goal to
unify variants of a compilation unit.
_Generic is just a way to have a compile time
switch(typeof(x)) {
case type_a: ...
case type_b: ...
}
This is, in some ways, what our existing macros do here, based on
TARGET_LONG_BITS. Some C compilers targetting embedded systems support
sizeof on integral types in the preprocessor to support this kind of
case before _Generic existed.
It can replace macros based on static types, but it doesn't make much
more towards eliminating target type dependency.
It could still be used here though, to avoid the need to patch all
targets using gdb register macros, that already used fixed types.
But since our list of call sites is not so huge, I would be in favor to
fix the code directly, instead of relying on _Generic. But I'm open to
that if we collectively think it's a better way.
Adding casts to loosen type system is not a win versus that.
Agreed.