I am trying to understand how the std::pow function works in GCC. I was looking at the source code for the cmath library here https://code.woboq.org/gcc/libstdc++-v3/include/c_global/cmath.html#_ZSt3powff.
On line 388 of that file, they give the definition of pow when float types are passed as the argument as shown here
#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
inline _GLIBCXX_CONSTEXPR float
pow(float __x, float __y)
{ return __builtin_powf(__x, __y); }
This pow function calls another function __builtin_powf.
What I want to know is, where is __builtin_powf defined? I read that it is a built in function, but that still does not help me understand where its implementation lives. I can not seem to find __builtin_powf anywhere else in the GCC source code. Also, how is it translated to assembly?
float
(f
),double
(w
)int
,long
(l
) and other variants of several mathematical functions automatically. Seef95-lang.c
../configure
script that must be executed before the building of the compiler from source) so the versions of gcc, when built for a specified target system (hardware and OS), makes use of known libraries or machine instructions on that target system.__builtin_XXX
syntax is for things that can't be implemented as ordinary functions, but instead need to trigger some special handling at compile time. In this case it's merely constant folding where possible, but many of the other builtins do stuff that isn't remotely like anything a real function could do. Asking for their source code is like asking for the source code of thesizeof
function - there isn't a single function written down that it could be.