Other built-in functions provided by GCC

Previous GNU C Language Extensions Next

GCC provides a large number of built-in functions. Some of these are for internal use in the processing of exceptions or variable-length argument lists and will not be 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_ will always be treated as having the same meaning as the C library function even if you specify the '-fno-builtin' option (see C Dialect Options). Many of these functions are only optimized in certain cases; if they are not optimized in a particular case, a call to the library function will be emitted (but this does not make sense in TIGCC, as the standard C library is not provided with it).

The functions abort, exit, _Exit and _exit are recognized and presumed not to return, but otherwise are not built in (TIGCC defines them as macros anyway). _exit is not recognized in strict ISO C mode ('-ansi', '-std=c89' or '-std=c99'). _Exit is not recognized in strict C89 mode ('-ansi' or '-std=c89'). All these functions have corresponding versions prefixed with __builtin_, which may be used even in strict C89 mode.

Outside strict ISO C mode, the functions alloca, bcmp, bzero, index, rindex, ffs, fputs_unlocked, printf_unlocked and fprintf_unlocked may be handled as built-in functions. All these functions have corresponding versions prefixed with __builtin_, which may be used even in strict C89 mode (in TIGCC, alloca is built-in; other than that only __builtin_bzero might be useful).

The ISO C99 functions conj, conjf, conjl, creal, crealf, creall, cimag, cimagf, cimagl, imaxabs, llabs, snprintf, vscanf, vsnprintf and vsscanf are handled as built-in functions except in strict ISO C90 mode. There are also built-in versions of the ISO C99 functions cosf, cosl, expf, expl, fabsf, fabsl, logf, logl, sinf, sinl, sqrtf, and sqrtl, 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_ (again, none of these are implemented in TIGCC).

The ISO C90 functions abs, cos, exp, fabs, fprintf, fputs, labs, log, memcmp, memcpy, memset, printf, putchar, puts, scanf, sin, snprintf, sprintf, sqrt, sscanf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, vprintf and vsprintf are all recognized as built-in functions unless '-fno-builtin' is specified (or '-fno-builtin-function' is specified for an individual function). All of these functions have corresponding versions prefixed with __builtin_ (but most of these are defined as macros in TIGCC).

GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have the same names as the standard macros (isgreater, isgreaterequal, isless, islessequal, islessgreater, and isunordered), with __builtin_ prefixed. The GNU team intends for a library implementor to be able to simply #define each standard macro to its built-in equivalent.