2001-11-11 10:54:21 +08:00
|
|
|
#ifndef _STDARG_H
|
|
|
|
#define _STDARG_H
|
|
|
|
|
2008-12-02 02:19:25 +08:00
|
|
|
#ifdef __x86_64__
|
2009-07-19 04:06:37 +08:00
|
|
|
#ifndef _WIN64
|
2008-12-02 02:19:25 +08:00
|
|
|
|
2010-12-28 18:32:40 +08:00
|
|
|
typedef void *va_list;
|
2008-12-02 02:19:25 +08:00
|
|
|
|
2010-12-28 18:32:40 +08:00
|
|
|
va_list __va_start(void *fp);
|
2013-04-26 23:42:12 +08:00
|
|
|
void *__va_arg(va_list ap, int arg_type, int size, int align);
|
2010-12-28 18:32:40 +08:00
|
|
|
va_list __va_copy(va_list src);
|
|
|
|
void __va_end(va_list ap);
|
2008-12-02 02:19:25 +08:00
|
|
|
|
2010-12-28 18:32:40 +08:00
|
|
|
#define va_start(ap, last) ((ap) = __va_start(__builtin_frame_address(0)))
|
|
|
|
#define va_arg(ap, type) \
|
2013-04-26 23:42:12 +08:00
|
|
|
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type))))
|
2010-12-28 18:32:40 +08:00
|
|
|
#define va_copy(dest, src) ((dest) = __va_copy(src))
|
|
|
|
#define va_end(ap) __va_end(ap)
|
2008-12-02 02:19:25 +08:00
|
|
|
|
2009-07-19 04:06:37 +08:00
|
|
|
#else /* _WIN64 */
|
2001-11-11 10:54:21 +08:00
|
|
|
typedef char *va_list;
|
2013-04-24 09:19:15 +08:00
|
|
|
#define va_start(ap,last) __builtin_va_start(ap,last)
|
|
|
|
#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap)
|
|
|
|
#define va_copy(dest, src) ((dest) = (src))
|
2009-07-19 04:06:37 +08:00
|
|
|
#define va_end(ap)
|
|
|
|
#endif
|
2001-11-11 10:54:21 +08:00
|
|
|
|
2009-07-19 04:06:37 +08:00
|
|
|
#else /* __i386__ */
|
|
|
|
typedef char *va_list;
|
2001-11-11 10:54:21 +08:00
|
|
|
/* only correct for i386 */
|
2002-08-31 20:43:53 +08:00
|
|
|
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
|
|
|
|
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
|
2006-10-29 03:45:50 +08:00
|
|
|
#define va_copy(dest, src) (dest) = (src)
|
2001-11-11 10:54:21 +08:00
|
|
|
#define va_end(ap)
|
2008-12-02 02:19:25 +08:00
|
|
|
#endif
|
|
|
|
|
2001-11-12 02:01:29 +08:00
|
|
|
/* fix a buggy dependency on GCC in libio.h */
|
|
|
|
typedef va_list __gnuc_va_list;
|
2003-01-07 04:22:23 +08:00
|
|
|
#define _VA_LIST_DEFINED
|
2001-11-12 02:01:29 +08:00
|
|
|
|
2008-12-02 02:19:25 +08:00
|
|
|
#endif /* _STDARG_H */
|