Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementation of __builtin_va_start(v,l)

Going down the rabbit hole of variadic macros in glibc, I’ve reached /usr/lib/gcc/x86_64-linux-gnu/4.8.2/include/stdarg.h where, for example, the va_start macro is defined as:

#define va_start(v,l) __builtin_va_start(v,l)

But I’ve been trying to look for the actual implementation of __builtin_va_start(v,l) without success. I’ve googled and grepped for it, and the furthest I’ve gotten to is Microsoft’s implementation for Visual Studio, which I suppose isn’t radically different.

Does anybody know where glibc implementation is?

TIA.

like image 644
Alf Avatar asked Mar 25 '14 17:03

Alf


2 Answers

To look in the source code of gcc, download the matching version from http://www.netgull.com/gcc/releases/ For example, the 4.8.2 version is at http://www.netgull.com/gcc/releases/gcc-4.8.2/ (82 MB).

The builtin keyword is handled at line 4169 of gcc/builtins.c

like image 172
wallyk Avatar answered Oct 23 '22 18:10

wallyk


In general, to find how gcc expands the built-in gcc function whose name is '__builtin_foo', look in the gcc source for the declaration of the function 'expand_builtin_foo'.

like image 35
Karl Zimmerman Avatar answered Oct 23 '22 19:10

Karl Zimmerman