1 /**
2  * The vararg module is intended to facilitate vararg manipulation in D.
3  * It should be interface compatible with the C module "stdarg," and the
4  * two modules may share a common implementation if possible (as is done
5  * here).
6  *
7  * Copyright: Public Domain
8  * License:   Public Domain
9  * Authors:   Hauke Duden, Walter Bright
10  */
11 module tango.core.Vararg;
12 
13 public import core.vararg;
14 
15 /**
16 
17   Gdc
18 
19 
20 **/
21 
22 
23 version( GNU )
24 {
25     // GDC doesn't need va_start/va_end
26     // If the va_arg template version is used,
27 
28     public import std.stdarg;
29 
30     version( X86_64 )
31     {
32         alias va_list __va_argsave_t;
33          //__va_argsave_t __va_argsave;
34     }
35 
36     // va_start and va_end is not needed for gdc, stubs only exist for eased
37     // cross-compiler programming
38     void va_start(T)( va_list ap, T parmn)   {   }
39     void va_end(va_list ap)    {    }
40 }
41 else version( LDC )
42 {
43     public import core.stdc.stdarg;
44 }
45 else
46 {
47     version (DigitalMars) version (X86_64) version = DigitalMarsX64;
48     version (X86)
49     {
50         alias void* va_list;
51 
52         template va_arg(T)
53         {
54             T va_arg(ref va_list _argptr)
55             {
56                 T arg = *cast(T*)_argptr;
57                 _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1));
58                 return arg;
59             }
60         }
61     }
62     else
63     {
64         public import tango.stdc.stdarg;
65     }
66 }