Reputation: 29724
In my source files of implementation of standard library I can see many methods with names prefixed with __builtin_
i.e: __builtin_memmove
. What is the meaning of this? In what sense are these methods built in?
template<bool _IsMove>
struct __copy_move<_IsMove, true, random_access_iterator_tag>
{
template<typename _Tp>
static _Tp*
__copy_m(const _Tp* __first, const _Tp* __last, _Tp* __result)
{
__builtin_memmove(__result, __first,
sizeof(_Tp) * (__last - __first));
return __result + (__last - __first);
}
};
Are these just a call to binary code? Debugger cannot step into it.
Upvotes: 1
Views: 1171
Reputation: 158529
This is just the compilers internal implementation, for gcc
we can go to their document to understand them better: Other Built-in Functions Provided by GCC and it says:
GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing of exceptions or variable-length argument lists and are not documented here because they may change from time to time; we do not recommend general use of these functions.
The remaining functions are provided for optimization purposes.
GCC includes built-in versions of many of the functions in the standard C library. The versions prefixed with _builtin are always treated as having the same meaning as the C library function even if you specify the -fno-builtin option.
and if we go to the Options Controlling C Dialect it says for -fno-builtin-function
flag (emphasis mine):
[...]GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to alloca may become single instructions which adjust the stack directly, and calls to memcpy may become inline copy loops. The resulting code is often both smaller and faster, but since the function calls no longer appear as such, you cannot set a breakpoint on those calls, nor can you change the behavior of the functions by linking with a different library.[...]
For clang
you go here.
Upvotes: 4
Reputation: 72019
It's not a keyword, it's just a naming convention that GCC and Clang follow for functions that are built-in into the compiler.
Upvotes: 1