You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2008/02/11 23:35:10 UTC

[jira] Commented: (STDCXX-722) [gcc] use math __builtins

    [ https://issues.apache.org/jira/browse/STDCXX-722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567853#action_12567853 ] 

Martin Sebor commented on STDCXX-722:
-------------------------------------

The naive solution here is to simply replace calls to the libc math functions (such as {{atan2}}) with those to the corresponding builtin. The script below shows the names of these functions currently used.

A (likely) more efficient but more involved solution is to make use of gcc's built-ins for the C99 complex functions such as {{ccoshf}}, {{ccosh}}, and {{ccoshl}} etc.

{noformat}
$   svn cat http://svn.apache.org/repos/asf/stdcxx/trunk/include/complex \
            http://svn.apache.org/repos/asf/stdcxx/trunk/include/complex.cc \
  | sed -n "s/.*_RWSTD_C::\([a-z][a-z0-9]*\).*/\1/gp" | sort | uniq
atan2
cos
cosh
exp
log
pow
sin
sinh
sqrt
{noformat}

> [gcc] use math __builtins
> -------------------------
>
>                 Key: STDCXX-722
>                 URL: https://issues.apache.org/jira/browse/STDCXX-722
>             Project: C++ Standard Library
>          Issue Type: Sub-task
>          Components: 26. Numerics
>    Affects Versions: 4.2.0
>         Environment: gcc 4
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>            Priority: Minor
>             Fix For: 4.2.1
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> For better efficiency and to reduce namespace pollution we can replace all the math functions used in [<complex>|http://svn.apache.org/repos/asf/stdcxx/trunk/include/complex] with gcc's built-in  equivalents.
> Quoting from section [5.46 Other built-in functions provided by GCC|http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Other-Builtins.html#Other-Builtins] of the gcc online manual:
> {quote}
> The ISO C99 functions {{_Exit}}, {{acoshf}}, {{acoshl}}, {{acosh}}, {{asinhf}}, {{asinhl}}, {{asinh}}, {{atanhf}}, {{atanhl}}, {{atanh}}, {{cabsf}}, {{cabsl}}, {{cabs}}, {{cacosf}}, {{cacoshf}}, {{cacoshl}}, {{cacosh}}, {{cacosl}}, {{cacos}}, {{cargf}}, {{cargl}}, {{carg}}, {{casinf}}, {{casinhf}}, {{casinhl}}, {{casinh}}, {{casinl}}, {{casin}}, {{catanf}}, {{catanhf}}, {{catanhl}}, {{catanh}}, {{catanl}}, {{catan}}, {{cbrtf}}, {{cbrtl}}, {{cbrt}}, {{ccosf}}, {{ccoshf}}, {{ccoshl}}, {{ccosh}}, {{ccosl}}, {{ccos}}, {{cexpf}}, {{cexpl}}, {{cexp}}, {{cimagf}}, {{cimagl}}, {{cimag}}, {{clogf}}, {{clogl}}, {{clog}}, {{conjf}}, {{conjl}}, {{conj}}, {{copysignf}}, {{copysignl}}, {{copysign}}, {{cpowf}}, {{cpowl}}, {{cpow}}, {{cprojf}}, {{cprojl}}, {{cproj}}, {{crealf}}, {{creall}}, {{creal}}, {{csinf}}, {{csinhf}}, {{csinhl}}, {{csinh}}, {{csinl}}, {{csin}}, {{csqrtf}}, {{csqrtl}}, {{csqrt}}, {{ctanf}}, {{ctanhf}}, {{ctanhl}}, {{ctanh}}, {{ctanl}}, {{ctan}}, {{erfcf}}, {{erfcl}}, {{erfc}}, {{erff}}, {{erfl}}, {{erf}}, {{exp2f}}, {{exp2l}}, {{exp2}}, {{expm1f}}, {{expm1l}}, {{expm1}}, {{fdimf}}, {{fdiml}}, {{fdim}}, {{fmaf}}, {{fmal}}, {{fmaxf}}, {{fmaxl}}, {{fmax}}, {{fma}}, {{fminf}}, {{fminl}}, {{fmin}}, {{hypotf}}, {{hypotl}}, {{hypot}}, {{ilogbf}}, {{ilogbl}}, {{ilogb}}, {{imaxabs}}, {{isblank}}, {{iswblank}}, {{lgammaf}}, {{lgammal}}, {{lgamma}}, {{llabs}}, {{llrintf}}, {{llrintl}}, {{llrint}}, {{llroundf}}, {{llroundl}}, {{llround}}, {{log1pf}}, {{log1pl}}, {{log1p}}, {{log2f}}, {{log2l}}, {{log2}}, {{logbf}}, {{logbl}}, {{logb}}, {{lrintf}}, {{lrintl}}, {{lrint}}, {{lroundf}}, {{lroundl}}, {{lround}}, {{nearbyintf}}, {{nearbyintl}}, {{nearbyint}}, {{nextafterf}}, {{nextafterl}}, {{nextafter}}, {{nexttowardf}}, {{nexttowardl}}, {{nexttoward}}, {{remainderf}}, {{remainderl}}, {{remainder}}, {{remquof}}, {{remquol}}, {{remquo}}, {{rintf}}, {{rintl}}, {{rint}}, {{roundf}}, {{roundl}}, {{round}}, {{scalblnf}}, {{scalblnl}}, {{scalbln}}, {{scalbnf}}, {{scalbnl}}, {{scalbn}}, {{snprintf}}, {{tgammaf}}, {{tgammal}}, {{tgamma}}, {{truncf}}, {{truncl}}, {{trunc}}, {{vfscanf}}, {{vscanf}}, {{vsnprintf}} and {{vsscanf}} are handled as built-in functions except in strict ISO C90 mode ({{-ansi}} or {{-std=c89}}).
> There are also built-in versions of the ISO C99 functions {{acosf}}, {{acosl}}, {{asinf}}, {{asinl}}, {{atan2f}}, {{atan2l}}, {{atanf}}, {{atanl}}, {{ceilf}}, {{ceill}}, {{cosf}}, {{coshf}}, {{coshl}}, {{cosl}}, {{expf}}, {{expl}}, {{fabsf}}, {{fabsl}}, {{floorf}}, {{floorl}}, {{fmodf}}, {{fmodl}}, {{frexpf}}, {{frexpl}}, {{ldexpf}}, {{ldexpl}}, {{log10f}}, {{log10l}}, {{logf}}, {{logl}}, {{modfl}}, {{modf}}, {{powf}}, {{powl}}, {{sinf}}, {{sinhf}}, {{sinhl}}, {{sinl}}, {{sqrtf}}, {{sqrtl}}, {{tanf}}, {{tanhf}}, {{tanhl}} and {{tanl}} that are recognized in any mode since ISO C90 reserves these names for the purpose to which ISO C99 puts them. All these functions have corresponding versions prefixed with {{__builtin_}}.
> {quote}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.