#ifndef MDK_ARM_CPP_FI_H
#define MDK_ARM_CPP_FI_H

/* intrinsics */
extern "C" {
void *__builtin_alloca(unsigned int);
int __builtin_popcountll(unsigned long long);
int __is_constrange(int, int, int);
void __promise(int);

#define __NO_EMBEDDED_ASM

/* Taken from
 * http://www.keil.com/support/man/docs/armcc/armcc_chr1435075770601.htm
 */
void __breakpoint(int val);
void __cdp(unsigned int coproc, unsigned int ops, unsigned int regs);
void __clrex(void);
unsigned char __clz(unsigned int val);
unsigned int __current_pc(void);
unsigned int __current_sp(void);
int __disable_fiq(void); /* Note there is also void __disable_fiq(void) */
int __disable_irq(void); /* void __disable_irq(void) */
void __dmb(unsigned int val);
void __dsb(unsigned int val);
void __enable_fiq(void);
void __enable_irq(void);
double __fabs(double val);
float __fabsf(float val);
void __force_loads(void);
void __force_stores(void);
void __isb(unsigned int val);
unsigned int __ldrex(volatile void *ptr); /* deprecated */
unsigned long long __ldrexd(volatile void *ptr); /* deprecated */
unsigned int __ldrt(const volatile void *ptr);
void __memory_changed(void);
void __nop(void);
void __pld(...);
void __pli(...);
int __qadd(int val1, int val2);
int __qdbl(int val);
int __qsub(int val1, int val2);
unsigned int __rbit(unsigned int val);
unsigned int __rev(unsigned int val);
unsigned int __return_address(void);
unsigned int __ror(unsigned int val, unsigned int shift);
void __schedule_barrier(void);
int __semihost(int val, const void *ptr);
void __sev(void);
double __sqrt(double val);
float __sqrtf(float val);
int __ssat(int val, unsigned int sat);
int __strex(unsigned int val, volatile void *ptr); /* deprecated */
int __strexd(unsigned long long val, volatile void *ptr); /* deprecated */
void __strt(unsigned int val, volatile void *ptr);
unsigned int __swp(unsigned int val, volatile void *ptr); /* deprecated from ARMv6 */
int __usat(unsigned int val, unsigned int sat);
void __wfe(void);
void __wfi(void);
void __yield(void);
unsigned int __vfp_status(unsigned int mask, unsigned int flags);
}

#if __QACPP_MAJOR__ < 44
// C '1x
#define _Pragma _ignore_paren
#endif

#if __QACPP_MAJOR__ < 42
#define __ALIGNOF__(x) (sizeof(char))
#else
#define __ALIGNOF__ alignof
#endif

#else
#error "Multiple include"
#endif  /* ifndef MDK_ARM_CPP_FI_H */

