1/* stdarg/vararg support for the Hitachi h8/300 and h8/300h */
2
3/* Define __gnuc_va_list. */
4
5#ifndef __GNUC_VA_LIST
6#define __GNUC_VA_LIST
7typedef void *__gnuc_va_list;
8#endif
9
10/* If this is for internal libc use, don't define anything but
11   __gnuc_va_list.  */
12#if defined (_STDARG_H) || defined (_VARARGS_H)
13
14/* In GCC version 2, we want an ellipsis at the end of the declaration
15   of the argument list.  GCC version 1 can't parse it.  */
16
17#if __GNUC__ > 1
18#define __va_ellipsis ...
19#else
20#define __va_ellipsis
21#endif
22
23#ifdef __H8300__
24#define __va_rounded_size(TYPE)  \
25  (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
26#else
27#define __va_rounded_size(TYPE)  \
28  (((sizeof (TYPE) + sizeof (long) - 1) / sizeof (long)) * sizeof (long))
29#endif
30
31#ifdef _STDARG_H
32
33#define va_start(AP,LASTARG) \
34  (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
35
36#else /* _VARARGS_H */
37
38#define va_alist  __builtin_va_alist
39/* The ... causes current_function_varargs to be set in cc1.  */
40#define va_dcl    int __builtin_va_alist; __va_ellipsis
41#define va_start(AP)  AP = (void *) &__builtin_va_alist
42
43#endif /* _VARARGS_H */
44
45#define va_arg(AP, TYPE)						\
46 (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),	\
47  *((TYPE *) (void *) ((char *) (AP)					\
48		       - ((sizeof (TYPE) < __va_rounded_size (int)	\
49			  ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
50
51#define va_end(AP)	((void) 0)
52
53/* Copy __gnuc_va_list into another variable of this type.  */
54#define __va_copy(dest, src) (dest) = (src)
55
56#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
57