Welcome to mirror list, hosted at ThFree Co, Russian Federation.

varargs.h « include « mingw « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f81c864bc790a18a0ff21c141072d81248e0a626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * varargs.h
 *
 * Old, non-ANSI facilities for stepping through a list of function
 * arguments of an unknown number and type.
 * TODO: Has not been tested. Essentially it copies the GCC version.
 *
 * NOTE: I believe GCC supplies a version of this header as well (in
 *       addition to stdarg.h and others). The GCC version is more
 *       complex, to deal with many alternate systems, but it is
 *       probably more trustworthy overall. It would probably be
 *       better to use the GCC version.
 *
 * NOTE: These are incompatible with the versions in stdarg.h and should
 *       NOT be mixed! All new code should use the ANSI compatible versions.
 *
 * This file is part of the Mingw32 package.
 *
 * Contributors:
 *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
 *
 *  THIS SOFTWARE IS NOT COPYRIGHTED
 *
 *  This source code is offered for use in the public domain. You may
 *  use, modify or distribute it freely.
 *
 *  This code is distributed in the hope that it will be useful but
 *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 *  DISCLAIMED. This includes but is not limited to warranties of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * $Revision$
 * $Author$
 * $Date$
 *
 */

#ifndef	__STRICT_ANSI__

#ifndef _VARARGS_H_
#define _VARARGS_H_

/* All the headers include this file. */
#include <_mingw.h>

/* 
 * I was told that Win NT likes this.
 */
#ifndef _VA_LIST_DEFINED
#define _VA_LIST_DEFINED
#endif

#ifndef RC_INVOKED

#ifndef	_VA_LIST
#define _VA_LIST
#if defined __GNUC__ && __GNUC__ >= 3
typedef __builtin_va_list va_list;
#else
typedef char* va_list;
#endif
#endif

/*
 * Amount of space required in an argument list (ie. the stack) for an
 * argument of type t.
 */
#define __va_argsiz(t)	\
	(((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))

#define	va_alist	__builtin_va_alist

/*
 * Used in old style argument lists IIRC. The ellipsis forces the compiler
 * to realize this is a vararg function.
 */
#define va_dcl		int __builtin_va_alist; ...

#define va_start(ap)	\
	((ap) = ((va_list) &__builtin_va_alist))
#define va_end(ap)	((void)0)


/*
 * Increment ap to the next argument in the list while returing a
 * pointer to what ap pointed to first, which is of type t.
 *
 * We cast to void* and then to t* because this avoids a warning about
 * increasing the alignment requirement.
 */

#define va_arg(ap, t)					\
	 (((ap) = (ap) + __va_argsiz(t)),		\
	  *((t*) (void*) ((ap) - __va_argsiz(t))))


#endif	/* Not RC_INVOKED */

#endif	/* Not _VARARGS_H_ */

#endif	/* Not __STRICT_ANSI__ */