[Cfp-interest] updated draft

Joel C. Salomon joelcsalomon at gmail.com
Thu Mar 15 10:01:33 PDT 2012


Fred J. Tydeman wrote:
> Jim Thomas wrote:
>>> Do we need to list <tgmath.h> along with <math.h> for table 2?
>>
>> What do you think is missing or unclear? <tgmath.h> includes
>> <math.h> and just adds macro definitions. Footnote 313 is
>> explicit about the affect of rounding control pragmas on
>> <tgmath.h> functions.
>
> I expect the macros in <math.h> to be different from the macros
> in <tgmath.h>.  So, it is unclear to me if using a <tgmath.h>
> macro gets static rounding direction.
>
> C11's footnote 313 says suppressing a <tgmath.h> macro gets
> the corresponding function.  That means no static rounding
> direction.
>
> I expect some users would like to use just <tgmath.h> and would
> like static rounding applied to math functions.

There's a slight difference; the <tgmath.h> macros are of the sort
    #define sin(x) _Generic(…)(x)
while the form the <math.h> macros has not been defined.

I'd suggest something like (using the hidden
    double (*__sin_arr[])(double) = {
        [FE_DYNAMIC] = sin,
        [FE_DOWNWARD] = __sin_down, …};
    #define __sin __sin_arr[fegetround()]
    #define sin __sin
This can be wrapped in <tgmath.h>.

—Joel



More information about the Cfp-interest mailing list