1 /** 2 * Copy of core.stdc.stdarg; 3 * 4 * Copyright: Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved 5 * Authors: Walter Bright, http://www.digitalmars.com 6 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/speller.d, root/_speller.d) 8 * Documentation: https://dlang.org/phobos/dmd_root_speller.html 9 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/speller.d 10 */ 11 12 module dmd.root.stdarg; 13 14 public import core.stdc.stdarg; 15 16 @system: 17 //@nogc: // Not yet, need to make TypeInfo's member functions @nogc first 18 nothrow: 19 pure: 20 21 void va_end(va_list ap) 22 { 23 } 24 25 version (X86) 26 { 27 28 void va_copy(out va_list dest, va_list src) 29 { 30 dest = src; 31 } 32 } 33 else version (Windows) 34 { 35 /// 36 void va_copy(out va_list dest, va_list src) 37 { 38 dest = src; 39 } 40 } 41 else version (X86_64) 42 { 43 import core.stdc.stdlib : alloca; 44 45 /// 46 void va_copy(out va_list dest, va_list src, void* storage = alloca(__va_list_tag.sizeof)) 47 { 48 // Instead of copying the pointers, and aliasing the source va_list, 49 // the default argument alloca will allocate storage in the caller's 50 // stack frame. This is still not correct (it should be allocated in 51 // the place where the va_list variable is declared) but most of the 52 // time the caller's stack frame _is_ the place where the va_list is 53 // allocated, so in most cases this will now work. 54 dest = cast(va_list)storage; 55 *dest = *src; 56 } 57 } 58 else 59 static assert(false, "Unsupported platform");