source: trunk/third/gcc/ginclude/va-mips.h @ 8834

Revision 8834, 3.5 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
1/* ---------------------------------------- */
2/*           VARARGS  for MIPS/GNU CC       */
3/*                                          */
4/*                                          */
5/*                                          */
6/*                                          */
7/* ---------------------------------------- */
8
9
10/* These macros implement varargs for GNU C--either traditional or ANSI.  */
11
12/* Define __gnuc_va_list.  */
13
14#ifndef __GNUC_VA_LIST
15#define __GNUC_VA_LIST
16typedef char * __gnuc_va_list;
17#endif /* not __GNUC_VA_LIST */
18
19/* If this is for internal libc use, don't define anything but
20   __gnuc_va_list.  */
21#if defined (_STDARG_H) || defined (_VARARGS_H)
22
23/* In GCC version 2, we want an ellipsis at the end of the declaration
24   of the argument list.  GCC version 1 can't parse it.  */
25
26#if __GNUC__ > 1
27#define __va_ellipsis ...
28#else
29#define __va_ellipsis
30#endif
31
32#ifdef __mips64
33#define __va_rounded_size(__TYPE)  \
34  (((sizeof (__TYPE) + 8 - 1) / 8) * 8)
35#else
36#define __va_rounded_size(__TYPE)  \
37  (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
38#endif
39
40/* Get definitions for _MIPS_SIM_ABI64 etc.  */
41#ifdef _MIPS_SIM
42#include <sgidefs.h>
43#endif
44
45#ifdef _STDARG_H
46#define va_start(__AP, __LASTARG) \
47  (__AP = (__gnuc_va_list) __builtin_next_arg (__LASTARG))
48
49#else
50#define va_alist  __builtin_va_alist
51#ifdef __mips64
52/* This assumes that `long long int' is always a 64 bit type.  */
53#define va_dcl    long long int __builtin_va_alist; __va_ellipsis
54#else
55#define va_dcl    int __builtin_va_alist; __va_ellipsis
56#endif
57/* Need alternate code for _MIPS_SIM_ABI64.  */
58#if defined(_MIPS_SIM) && (_MIPS_SIM == _MIPS_SIM_ABI64)
59#define va_start(__AP)                                                  \
60  (__AP = (__gnuc_va_list) __builtin_next_arg ()                        \
61   + (__builtin_args_info (2) >= 8 ? -8 : 0))
62#else
63#define va_start(__AP)  __AP = (char *) &__builtin_va_alist
64#endif
65#endif
66
67#ifndef va_end
68void va_end (__gnuc_va_list);           /* Defined in libgcc.a */
69#endif
70#define va_end(__AP)    ((void)0)
71
72/* We cast to void * and then to TYPE * because this avoids
73   a warning about increasing the alignment requirement.  */
74/* The __mips64 cases are reversed from the 32 bit cases, because the standard
75   32 bit calling convention left-aligns all parameters smaller than a word,
76   whereas the __mips64 calling convention does not (and hence they are
77   right aligned).  */
78#ifdef __mips64
79#ifdef __MIPSEB__
80#define va_arg(__AP, __type)                                    \
81  ((__type *) (void *) (__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8) \
82                                         + __va_rounded_size (__type))))[-1]
83#else
84#define va_arg(__AP, __type)                                    \
85  ((__AP = (char *) ((((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8)    \
86                     + __va_rounded_size (__type))),            \
87   *(__type *) (void *) (__AP - __va_rounded_size (__type)))
88#endif
89
90#else /* not __mips64 */
91
92#ifdef __MIPSEB__
93/* For big-endian machines.  */
94#define va_arg(__AP, __type)                                    \
95  ((__AP = (char *) ((__alignof__ (__type) > 4                  \
96                      ? ((int)__AP + 8 - 1) & -8                \
97                      : ((int)__AP + 4 - 1) & -4)               \
98                     + __va_rounded_size (__type))),            \
99   *(__type *) (void *) (__AP - __va_rounded_size (__type)))
100#else
101/* For little-endian machines.  */
102#define va_arg(__AP, __type)                                                \
103  ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4           \
104                                          ? ((int)__AP + 8 - 1) & -8        \
105                                          : ((int)__AP + 4 - 1) & -4)       \
106                                         + __va_rounded_size(__type))))[-1]
107#endif
108#endif
109
110#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
Note: See TracBrowser for help on using the repository browser.