Subject: Re: `-ffreestanding'
To: None <>
From: Richard Earnshaw <>
List: tech-kern
Date: 07/16/2001 17:01:27 said:
>  > #define memcpy(x,y,z) __builtin_memcpy(x,y,z)
> So, how does this work in GCC?  If you expressly use a __builtin_*()
> version of a function, will it still emit a call to e.g. memcpy() if
> it can't emit an inline optimized block move? 

Yes... at least for some builtins.

On the ARM I get:

/* Size unknown, alignment unknown */
foo(char *a, char *b, int c)
  __builtin_memcpy(a, b, c);

/* Size known, alignment known  */
bar(int *a, int *b)
  __builtin_memcpy(a, b, 16);

        mov     ip, sp
        stmfd   sp!, {r4, fp, ip, lr, pc}
        sub     fp, ip, #4
        bl      memcpy
        mov     r0, r4
        ldmea   fp, {r4, fp, sp, pc}

        str     lr, [sp, #-4]!
        mov     ip, r0
        ldmia   r1, {r0, r1, r2, r3}
        stmia   ip, {r0, r1, r2, r3}
        mov     r0, lr
        ldr     pc, [sp], #4