You copied the Doc URL to your clipboard.

GNU built-in functions

These functions provide compatibility with GNU library header files. The functions are described in the GNU documentation.

See GCC, the GNU Compiler Collection for more information.

Nonstandard functions

  • __builtin_alloca()
  • __builtin_bcmp()
  • __builtin_exit()
  • __builtin_gamma()
  • __builtin_gammaf()
  • __builtin_gammal()
  • __builtin_index()
  • __builtin__memcpy_chk()
  • __builtin__memmove_chk()
  • __builtin_mempcpy()
  • __builtin__mempcpy_chk()
  • __builtin__memset_chk()
  • __builtin_object_size()
  • __builtin_rindex()
  • __builtin__snprintf_chk()
  • __builtin__sprintf_chk()
  • __builtin_stpcpy()
  • __builtin__stpcpy_chk()
  • __builtin_strcat_chk()
  • __builtin__strcpy_chk()
  • __builtin_strcasecmp()
  • __builtin_strncasecmp()
  • __builtin__strncat_chk()
  • __builtin__strncpy_chk()
  • __builtin__vsnprintf_chk()
  • __builtin__vsprintf_chk()

C99 functions

  • __builtin_exit()
  • __builtin_acoshf()
  • __builtin_acoshl()
  • __builtin_acosh()
  • __builtin_asinhf(
  • __builtin_asinhl()
  • __builtin_asinh()
  • __builtin_atanhf()
  • __builtin_atanhl()
  • __builtin_atanh()
  • __builtin_cabsf()
  • __builtin_cabsl()
  • __builtin_cabs()
  • __builtin_cacosf()
  • __builtin_cacoshf()
  • __builtin_cacoshl()
  • __builtin_cacosh()
  • __builtin_cacosl()
  • __builtin_cacos()
  • __builtin_cargf()
  • __builtin_cargl()
  • __builtin_carg()
  • __builtin_casinf()
  • __builtin_casinhf()
  • __builtin_casinhl()
  • __builtin_casinh()
  • __builtin_casinl()
  • __builtin_casin()
  • __builtin_catanf()
  • __builtin_catanhf()
  • __builtin_catanhl()
  • __builtin_catanh()
  • __builtin_catanl()
  • __builtin_catan()
  • __builtin_cbrtf()
  • __builtin_cbrtl()
  • __builtin_cbrt()
  • __builtin_ccosf()
  • __builtin_ccoshf()
  • __builtin_ccoshl()
  • __builtin_ccosh()
  • __builtin_ccosl()
  • __builtin_ccos()
  • __builtin_cexpf()
  • __builtin_cexpl()
  • __builtin_cexp()
  • __builtin_cimagf()
  • __builtin_cimagl()
  • __builtin_cimag()
  • __builtin_clogf()
  • __builtin_clogl()
  • __builtin_clog()
  • __builtin_conjf()
  • __builtin_conjl()
  • __builtin_conj()
  • __builtin_copysignf()
  • __builtin_copysignl()
  • __builtin_copysign()
  • __builtin_cpowf()
  • __builtin_cpowl()
  • __builtin_cpow()
  • __builtin_cprojf()
  • __builtin_cprojl()
  • __builtin_cproj()
  • __builtin_crealf()
  • __builtin_creall()
  • __builtin_creal()
  • __builtin_csinf()
  • __builtin_csinhf()
  • __builtin_csinhl()
  • __builtin_csinh()
  • __builtin_csinl()
  • __builtin_csin()
  • __builtin_csqrtf()
  • __builtin_csqrtl()
  • __builtin_csqrt()
  • __builtin_ctanf()
  • __builtin_ctanhf()
  • __builtin_ctanhl()
  • __builtin_ctanh()
  • __builtin_ctanl()
  • __builtin_ctan()
  • __builtin_erfcf()
  • __builtin_erfcl()
  • __builtin_erfc()
  • __builtin_erff()
  • __builtin_erfl()
  • __builtin_erf()
  • __builtin_exp2f()
  • __builtin_exp2l()
  • __builtin_exp2()
  • __builtin_expm1f()
  • __builtin_expm1l()
  • __builtin_expm1()
  • __builtin_fdimf()
  • __builtin_fdiml()
  • __builtin_fdim()
  • __builtin_fmaf()
  • __builtin_fmal()
  • __builtin_fmaxf()
  • __builtin_fmaxl()
  • __builtin_fmax()
  • __builtin_fma()
  • __builtin_fminf()
  • __builtin_fminl()
  • __builtin_fmin()
  • __builtin_hypotf()
  • __builtin_hypotl()
  • __builtin_hypot()
  • __builtin_ilogbf()
  • __builtin_ilogbl()
  • __builtin_ilogb()
  • __builtin_imaxabs()
  • __builtin_isblank()
  • __builtin_isfinite()
  • __builtin_isinf()
  • __builtin_isnan()
  • __builtin_isnanf()
  • __builtin_isnanl()
  • __builtin_isnormal()
  • __builtin_iswblank()
  • __builtin_lgammaf()
  • __builtin_lgammal()
  • __builtin_lgamma()
  • __builtin_llabs()
  • __builtin_llrintf()
  • __builtin_llrintl()
  • __builtin_llrint()
  • __builtin_llroundf()
  • __builtin_llroundl()
  • __builtin_llround()
  • __builtin_log1pf()
  • __builtin_log1pl()
  • __builtin_log1p()
  • __builtin_log2f()
  • __builtin_log2l()
  • __builtin_log2()
  • __builtin_logbf()
  • __builtin_logbl()
  • __builtin_logb()
  • __builtin_lrintf()
  • __builtin_lrintl()
  • __builtin_lrint()
  • __builtin_lroundf()
  • __builtin_lroundl()
  • __builtin_lround()
  • __builtin_nearbyintf()
  • __builtin_nearbyintl()
  • __builtin_nearbyint()
  • __builtin_nextafterf()
  • __builtin_nextafterl()
  • __builtin_nextafter()
  • __builtin_nexttowardf()
  • __builtin_nexttowardl()
  • __builtin_nexttoward()
  • __builtin_remainderf()
  • __builtin_remainderl()
  • __builtin_remainder()
  • __builtin_remquof()
  • __builtin_remquol()
  • __builtin_remquo()
  • __builtin_rintf()
  • __builtin_rintl()
  • __builtin_rint()
  • __builtin_roundf()
  • __builtin_roundl()
  • __builtin_round()
  • __builtin_scalblnf()
  • __builtin_scalblnl()
  • __builtin_scalbln()
  • __builtin_scalbnf()
  • __builtin_calbnl()
  • __builtin_scalbn()
  • __builtin_signbit()
  • __builtin_signbitf()
  • __builtin_signbitl()
  • __builtin_snprintf()
  • __builtin_tgammaf()
  • __builtin_tgammal()
  • __builtin_tgamma()
  • __builtin_truncf()
  • __builtin_truncl()
  • __builtin_trunc()
  • __builtin_vfscanf()
  • __builtin_vscanf()
  • __builtin_vsnprintf()
  • __builtin_vsscanf()

C99 functions in the C90 reserved namespace

  • __builtin_acosf()
  • __builtin_acosl()
  • __builtin_asinf()
  • __builtin_asinl()
  • __builtin_atan2f()
  • __builtin_atan2l()
  • __builtin_atanf()
  • __builtin_atanl()
  • __builtin_ceilf()
  • __builtin_ceill()
  • __builtin_cosf()
  • __builtin_coshf()
  • __builtin_coshl()
  • __builtin_cosl()
  • __builtin_expf()
  • __builtin_expl()
  • __builtin_fabsf()
  • __builtin_fabsl()
  • __builtin_floorf()
  • __builtin_floorl()
  • __builtin_fmodf()
  • __builtin_fmodl()
  • __builtin_frexpf()
  • __builtin_frexpl()
  • __builtin_ldexpf()
  • __builtin_ldexpl()
  • __builtin_log10f()
  • __builtin_log10l()
  • __builtin_logf()
  • __builtin_logl()
  • __builtin_modfl()
  • __builtin_modf()
  • __builtin_powf()
  • __builtin_powl()
  • __builtin_sinf()
  • __builtin_sinhf()
  • __builtin_sinhl()
  • __builtin_sinl()
  • __builtin_sqrtf()
  • __builtin_sqrtl()
  • __builtin_tanf()
  • __builtin_tanhf()
  • __builtin_tanhl()
  • __builtin_tanl()

C94 functions

  • __builtin_swalnum()
  • __builtin_iswalpha()
  • __builtin_iswcntrl()
  • __builtin_iswdigit()
  • __builtin_iswgraph()
  • __builtin_iswlower()
  • __builtin_iswprint()
  • __builtin_iswpunct()
  • __builtin_iswspace()
  • __builtin_iswupper()
  • __builtin_iswxdigit()
  • __builtin_towlower()
  • __builtin_towupper()

C90 functions

  • __builtin_abort()
  • __builtin_abs()
  • __builtin_acos()
  • __builtin_asin()
  • __builtin_atan2()
  • __builtin_atan()
  • __builtin_calloc()
  • __builtin_cosh()
  • __builtin_cos()
  • __builtin_exit()
  • __builtin_exp()
  • __builtin_fabs()
  • __builtin_floor()
  • __builtin_fmod()
  • __builtin_fprintf()
  • __builtin_fputc()
  • __builtin_fputs()
  • __builtin_frexp()
  • __builtin_fscanf()
  • __builtin_isalnum()
  • __builtin_isalpha()
  • __builtin_iscntrl()
  • __builtin_isdigit()
  • __builtin_isgraph()
  • __builtin_islower()
  • __builtin_isprint()
  • __builtin_ispunct()
  • __builtin_isspace()
  • __builtin_isupper()
  • __builtin_isxdigit()
  • __builtin_tolower()
  • __builtin_toupper()
  • __builtin_labs()
  • __builtin_ldexp()
  • __builtin_log10()
  • __builtin_log()
  • __builtin_malloc()
  • __builtin_memchr()
  • __builtin_memcmp()
  • __builtin_memcpy()
  • __builtin_memset()
  • __builtin_modf()
  • __builtin_pow()
  • __builtin_printf()
  • __builtin_putchar()
  • __builtin_puts()
  • __builtin_scanf()
  • __builtin_sinh()
  • __builtin_sin()
  • __builtin_snprintf()
  • __builtin_sprintf()
  • __builtin_sqrt()
  • __builtin_sscanf()
  • __builtin_strcat()
  • __builtin_strchr()
  • __builtin_strcmp()
  • __builtin_strcpy()
  • __builtin_strcspn()
  • __builtin_strlen()
  • __builtin_strncat()
  • __builtin_strncmp()
  • __builtin_strncpy()
  • __builtin_strpbrk()
  • __builtin_strrchr()
  • __builtin_strspn()
  • __builtin_strstr()
  • __builtin_tanh()
  • __builtin_tan()
  • __builtin_va_copy()
  • __builtin_va_end()
  • __builtin_va_start()
  • __builtin_vfprintf()
  • __builtin_vprintf()
  • __builtin_vsprintf()

The __builtin_va_list type is also supported. It is equivalent to the va_list type declared in stdarg.h.

C99 floating-point functions

  • __builtin_huge_val()
  • __builtin_huge_valf()
  • __builtin_huge_vall()
  • __builtin_inf()
  • __builtin_nan()
  • __builtin_nanf()
  • __builtin_nanl()
  • __builtin_nans()
  • __builtin_nansf()
  • __builtin_nansl()

GNU atomic memory access functions

  • __sync_fetch_and_add()
  • __sync_fetch_and_sub()
  • __sync_fetch_and_or()
  • __sync_fetch_and_and()
  • __sync_fetch_and_xor()
  • __sync_fetch_and_nand()
  • __sync_add_and_fetch()
  • __sync_sub_and_fetch()
  • __sync_or_and_fetch()
  • __sync_and_and_fetch()
  • __sync_xor_and_fetch()
  • __sync_nand_and_fetch()
  • __sync_bool_compare_and_swap()
  • __sync_val_compare_and_swap()
  • __sync_lock_test_and_set()
  • __sync_lock_release()
  • __sync_synchronize()
Note

Some architectures, such as ARMv6-M, do not provide the exclusive load and store instructions required by these intrinsics. Because different users will have different requirements for how these operations should be performed, the GNU atomic intrinsics are defined for these targets but require you to implement the __user_cmpxchg_1, __user_cmpxchg_2 and __user_cmpxchg_4 functions.

These functions are defined as follows:

//Compare and exchange word
int __user_cmpxchg_4(unsigned int *ptr, unsigned int old, unsigned int new)

//Compare and exchange half word
short __user_cmpxchg_2(unsigned short *ptr, unsigned short old, unsigned short new)
      
//Compare and exchange byte
char __user_cmpxchg_1(unsigned char *ptr, unsigned char old, unsigned char new)

The following is a sample implementation of the __user_cmpxchg_4() function. Note that in a real implementation, both accesses to *ptr should be atomic, so that no intervening access can change the value stored in memory.

int __user_cmpxchg_4(unsigned int *ptr, unsigned int old, unsigned int new) {
  if (*ptr == old) {
    *ptr = new;
    return 0;
  } else {
    return 1;
  }
}

Other built-in functions

  • __builtin_choose_expr()
  • __builtin_clz()
  • __builtin_types_compatible_p()
  • __builtin_constant_p()
  • __builtin_ctz()
  • __builtin_ctzl()
  • __builtin_ctzll()
  • __builtin_expect()
    Note __builtin_expect() acts as a hint to the compiler. armcc may use this information differently to other compilers that support __builtin_expect().
  • __builtin_ffs()
  • __builtin_ffsl()
  • __builtin_ffsll()
  • __builtin_frame_address()
  • __builtin_offsetof()
  • __builtin_prefetch()
  • __builtin_return_address()
  • __builtin_popcount()
  • __builtin_signbit()
Was this page helpful? Yes No