Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler Features Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR Compiler Command-line Options Language Extensions Compiler-specific Features Keywords and operators __align __ALIGNOF__ __alignof__ __asm __forceinline __global_reg __inline __int64 __INTADDR__ __irq __packed __pure __smc __softfp __svc __svc_indirect __svc_indirect_r7 __value_in_regs __weak __writeonly __declspec attributes __declspec(noinline) __declspec(noreturn) __declspec(nothrow) __declspec(notshared) __declspec(thread) Function attributes __attribute__((alias)) function attribute __attribute__((always_inline)) function attribute __attribute__((const)) function attribute __attribute__((deprecated)) function attribute __attribute__((destructor[(priority)])) function a __attribute__((format)) function attribute __attribute__((format_arg(string-index))) function __attribute__((malloc)) function attribute __attribute__((noinline)) function attribute __attribute__((no_instrument_function)) function a __attribute__((nomerge)) function attribute __attribute__((nonnull)) function attribute __attribute__((noreturn)) function attribute __attribute__((notailcall)) function attribute __attribute__((nothrow)) function attribute __attribute__((pcs("calling_convention"))) functio __attribute__((pure)) function attribute __attribute__((section("name"))) function attribut __attribute__((sentinel)) function attribute __attribute__((unused)) function attribute __attribute__((used)) function attribute __attribute__((visibility("visibility_type"))) fun __attribute__((warn_unused_result)) __attribute__((weak)) function attribute __attribute__((weakref("target"))) function attrib Type attributes __attribute__((bitband)) type attribute __attribute__((aligned)) type attribute __attribute__((packed)) type attribute Variable attributes __attribute__((alias)) variable attribute __attribute__((at(address))) variable attribute __attribute__((aligned)) variable attribute __attribute__((deprecated)) variable attribute __attribute__((noinline)) constant variable attrib __attribute__((packed)) variable attribute __attribute__((section("name"))) variable attribut __attribute__((unused)) variable attribute __attribute__((used)) variable attribute __attribute__((visibility("visibility_type"))) var __attribute__((weak)) variable attribute __attribute__((weakref("target"))) variable attrib __attribute__((zero_init)) variable attribute Pragmas #pragma anon_unions, #pragma no_anon_unions #pragma arm #pragma arm section [section_type_list] #pragma diag_default tag[,tag,...] #pragma diag_error tag[,tag,...] #pragma diag_remark tag[,tag,...] #pragma diag_suppress tag[,tag,...] #pragma diag_warning tag[, tag, ...] #pragma exceptions_unwind, #pragma no_exceptions_u #pragma GCC system_header #pragma hdrstop #pragma import symbol_name #pragma import(__use_full_stdio) #pragma import(__use_smaller_memcpy) #pragma inline, #pragma no_inline #pragma no_pch #pragma Onum #pragma once #pragma Ospace #pragma Otime #pragma pack(n) #pragma pop #pragma push #pragma softfp_linkage, #pragma no_softfp_linkage #pragma thumb #pragma unroll [(n)] #pragma unroll_completely #pragma weak symbol, #pragma weak symbol1 = symbol Instruction intrinsics __breakpoint intrinsic __cdp intrinsic __clrex intrinsic __clz intrinsic __current_pc intrinsic __current_sp intrinsic __disable_fiq intrinsic __disable_irq intrinsic __dmb intrinsic __dsb intrinsic __enable_fiq intrinsic __enable_irq intrinsic __fabs intrinsic __fabsf intrinsic __force_loads intrinsic __force_stores intrinsic __isb intrinsic __ldrex intrinsic __ldrexd intrinsic __ldrt intrinsic __memory_changed intrinsic __nop intrinsic __pld intrinsic __pli intrinsic __qadd intrinsic __qdbl intrinsic __qsub intrinsic __rbit intrinsic __rev intrinsic __return_address intrinsic __ror intrinsic __schedule_barrier intrinsic __semihost intrinsic __sev intrinsic __sqrt intrinsic __sqrtf intrinsic __ssat intrinsic __strex intrinsic __strexd intrinsic __strt intrinsic __swp intrinsic __usat intrinsic __wfe intrinsic __wfi intrinsic __yield intrinsic ARMv6 SIMD intrinsics ETSI basic operations C55x intrinsics VFP status intrinsic __vfp_status intrinsic Fused Multiply Add (FMA) intrinsics Named register variables GNU built-in functions Predefined macros Built-in function name variables C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

GNU built-in functions

9.154 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()
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.