I have found this little piece of C gem in the gcc torture tests suite, and more or less I understand it, except the lines marked with my comments ...
void __attribute__((noinline,noclone))
foo(int *p, float *q) { __asm__ volatile ("" : : : "memory"); } /// ??? 1
int main()
{
if (sizeof (int) == sizeof (float))
{
int i;
float f;
int *p;
/* Prevent i and f from being rewritten into SSA form. */
foo (&i, &f);
i = 0;
f = 1.0;
p = (int *)&f;
__builtin_memcpy (&i, p, 4); /// ??? 2
if (*(float *)&i != 1.0)
__builtin_abort ();
}
return 0;
}
So, question number 1:
What is this __asm__ volatile ("" : : : "memory");
? Didn't see this syntax till now ...
Question number 2:
Since __builtin_memcpy
feels to me as being a function where is this defined? The full source code compiles and runs as it is, (without any extra includes and libraries) so I'm dazed ... Is there a set of __builtin***
functions which are available via gcc, without using any library?