> -----Original Message----- > From: Eric Blake <ebl...@redhat.com> > Sent: Tuesday, September 29, 2020 3:29 PM > To: Taylor Simpson <tsimp...@quicinc.com>; Philippe Mathieu-Daudé > <f4...@amsat.org>; qemu-devel@nongnu.org > Cc: a...@rev.ng; riku.voi...@iki.fi; richard.hender...@linaro.org; > laur...@vivier.eu; aleksandar.m.m...@gmail.com > Subject: Re: [RFC PATCH v4 00/29] Hexagon patch series > > On 9/29/20 3:11 PM, Taylor Simpson wrote: > > > Ouch! 4.8 is old enough that it doesn't support C11 _Generic which I am > using. That needs at least GCC 4.9. > > > > Here are a couple of examples. As you can see, _Generic is used to > dispatch to slightly different TCG generation functions depending on the > type of the operands. I will scratch my head and figure out a different way > to > do this. > > > > #define MEM_STORE1_FUNC(X) \ > > _Generic((X), int : gen_store1i, TCGv_i32 : gen_store1) > > #define MEM_STORE1(VA, DATA, SLOT) \ > > MEM_STORE1_FUNC(DATA)(cpu_env, VA, DATA, ctx, SLOT) > > See if you can use __builtin_choose_expr() instead. Look at > include/osdep/atomic.h which defines typeof_strip_qual() without > _Generic. linux-user/qemu.h __put_user_e() is also an example of what > appears to be a poor-man's replacement to _Generic.
Thanks! It's a pretty straightforward translation for my use cases #define MEM_STORE1_FUNC(X) \ __builtin_choose_expr(__builtin_types_compatible_p(typeof(X), int), \ gen_store1i, \ gen_store1) #define MEM_STORE1(VA, DATA, SLOT) \ MEM_STORE1_FUNC(DATA)(cpu_env, VA, DATA, ctx, SLOT) Taylor