[Cfp-interest 1525] Re: request for input
Joseph Myers
joseph at codesourcery.com
Tue Mar 3 14:32:27 PST 2020
On Tue, 3 Mar 2020, Jim Thomas wrote:
> > I think the same principle still applies to them - if e.g. libffi gets
> > support for these types, then if you have normal functions any language
> > runtime can bind to the functions, just like other C functions, without
> > needing special C code, but if you only have type-generic macros then
> > other-language bindings are more complicated.
>
> Is it significantly more complicated?
>
> T1 T1addT2(T2 x, T2 y) { return T1add(x, y); }
It's the difference between language bindings need to have C code for each
function, versus language bindings that might be implemented entirely in
that language using its generic FFI support.
> > The tricky thing - the reason why the tgmath.h rules need to specify
> > exactly how the underlying function is determined rather than just saying
> > any function with wide-enough parameters is used - is integer types, which
> > may get narrowed even when floating arguments don't (e.g. an
> > implementation where binary64 is the widest floating-point format can't
> > avoid narrowing long long arguments to these functions).
>
> Do you see a problem if the tgmath rules specify that any wide enough
> function is used (provided one exists), where integer arguments are
> regarded (as they are in the TS) as having a certain floating type
> (double, _Float64, or _Decimal64) depending on the prefix type?
At present, integer arguments being regarded as having a certain type just
means that type is the one that goes into the usual arithmetic conversions
when used to determine the argument type of the function to be called -
the integer arguments don't get converted to double, _Float64 or
_Decimal64 if the argument type chosen is a wider one.
If none of the arguments have an integer type, it is effectively as if any
wide-enough function were allowed (in the case of these narrowing macros),
because any wide-enough function will produce the same result in the
absence of narrowing of arguments when converted to the function parameter
type, and the tgmath.h rules mean that only integer arguments can ever be
narrowed.
If arguments have integer types, the choice among multiple possible
wide-enough functions might affect whether those integer arguments get
narrowed.
--
Joseph S. Myers
joseph at codesourcery.com
More information about the Cfp-interest
mailing list