comparison lphobos/std/stdarg.d @ 131:5825d48b27d1 trunk

[svn r135] * Merged DMD 1.025 * * Fixed a minor linking order mishap * * Added an command line option -annotate * * Fixed some problems with running optimizations * * Added std.stdio and dependencies to lphobos (still not 100% working, but compiles and links) * * Fixed problems with passing aggregate types to variadic functions * * Added initial code towards full GC support, currently based on malloc and friends, not all the runtime calls the GC yet for memory * * Fixed problems with resolving nested function context pointers for some heavily nested cases * * Redid function argument passing + other minor code cleanups, still lots to do on this end... *
author lindquist
date Fri, 04 Jan 2008 01:38:42 +0100
parents fb265a6efea1
children eef8ac26c66c
comparison
equal deleted inserted replaced
130:a7dfa0ed966c 131:5825d48b27d1
4 * Written by Hauke Duden and Walter Bright 4 * Written by Hauke Duden and Walter Bright
5 */ 5 */
6 6
7 /* This is for use with variable argument lists with extern(D) linkage. */ 7 /* This is for use with variable argument lists with extern(D) linkage. */
8 8
9 /* Modified for LLVMDC (LLVM D Compiler) by Tomas Lindquist Olsen, 2007 */
10
9 module std.stdarg; 11 module std.stdarg;
10 12
11 alias void* va_list; 13 alias void* va_list;
12 14
13 T va_arg(T)(inout va_list vp) 15 T va_arg(T)(ref va_list vp)
14 { 16 {
15 static assert((T.sizeof & (T.sizeof -1)) == 0); 17 size_t size = T.sizeof > size_t.sizeof ? size_t.sizeof : T.sizeof;
16 va_list vptmp = cast(va_list)((cast(size_t)vp + T.sizeof - 1) & ~(T.sizeof - 1)); 18 va_list vptmp = cast(va_list)((cast(size_t)vp + size - 1) & ~(size - 1));
17 vp = vptmp + T.sizeof; 19 vp = vptmp + T.sizeof;
18 return *cast(T*)vptmp; 20 return *cast(T*)vptmp;
19 } 21 }