comparison druntime/src/compiler/ldc/ldc/vararg.d @ 759:d3eb054172f9

Added copy of druntime from DMD 2.020 modified for LDC.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:52:37 +0100
parents
children
comparison
equal deleted inserted replaced
758:f04dde6e882c 759:d3eb054172f9
1 /*
2 * This module holds the implementation of special vararg templates for D style var args.
3 *
4 * Provides the functions tango.core.Vararg expects to be present!
5 */
6
7 module ldc.Vararg;
8
9 // Check for the right compiler
10 version(LDC)
11 {
12 // OK
13 }
14 else
15 {
16 static assert(false, "This module is only valid for LDC");
17 }
18
19 alias void* va_list;
20
21 void va_start(T) ( out va_list ap, inout T parmn )
22 {
23 // not needed !
24 }
25
26 T va_arg(T)(ref va_list vp)
27 {
28 T* arg = cast(T*) vp;
29 // ldc always aligns to size_t.sizeof in vararg lists
30 vp = cast(va_list) ( cast(void*) vp + ( ( T.sizeof + size_t.sizeof - 1 ) & ~( size_t.sizeof - 1 ) ) );
31 return *arg;
32 }
33
34 void va_end( va_list ap )
35 {
36 // not needed !
37 }
38
39 void va_copy( out va_list dst, va_list src )
40 {
41 // seems pretty useless !
42 dst = src;
43 }