Commit 59d52763 by Charles Hannum

entered into RCS

From-SVN: r1293
parent 45528dbf
/* GNU C varargs support for the Intel 80960. */ /* GNU C varargs support for the Intel 80960. */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
/* The first element is the address of the first argument.
The second element is the number of bytes skipped past so far. */
typedef unsigned __gnuc_va_list[2];
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
/* In GCC version 2, we want an ellipsis at the end of the declaration /* In GCC version 2, we want an ellipsis at the end of the declaration
of the argument list. GCC version 1 can't parse it. */ of the argument list. GCC version 1 can't parse it. */
...@@ -9,10 +22,6 @@ ...@@ -9,10 +22,6 @@
#define __va_ellipsis #define __va_ellipsis
#endif #endif
/* The first element is the address of the first argument.
The second element is the number of bytes skipped past so far. */
typedef unsigned va_list[2];
/* The stack size of the type t. */ /* The stack size of the type t. */
#define __vsiz(T) (((sizeof (T) + 3) / 4) * 4) #define __vsiz(T) (((sizeof (T) + 3) / 4) * 4)
/* The stack alignment of the type t. */ /* The stack alignment of the type t. */
...@@ -42,4 +51,8 @@ typedef unsigned va_list[2]; ...@@ -42,4 +51,8 @@ typedef unsigned va_list[2];
*((T *) ((char *) *(AP) + (AP)[1] - __vsiz (T))) \ *((T *) ((char *) *(AP) + (AP)[1] - __vsiz (T))) \
) )
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(AP) #define va_end(AP)
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
...@@ -7,8 +7,18 @@ ...@@ -7,8 +7,18 @@
/* ---------------------------------------- */ /* ---------------------------------------- */
/* These macros implement traditional (non-ANSI) varargs /* These macros implement varargs for GNU C--either traditional or ANSU. */
for GNU C. */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef char * __gnuc_va_list;
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
/* In GCC version 2, we want an ellipsis at the end of the declaration /* In GCC version 2, we want an ellipsis at the end of the declaration
of the argument list. GCC version 1 can't parse it. */ of the argument list. GCC version 1 can't parse it. */
...@@ -19,13 +29,6 @@ ...@@ -19,13 +29,6 @@
#define __va_ellipsis #define __va_ellipsis
#endif #endif
#ifndef _VA_LIST_
#define _VA_LIST_
/* Make this a macro rather than a typedef, so we can undef any other defn. */
#define va_list __va___list
typedef char * __va___list;
#endif
#define __va_rounded_size(TYPE) \ #define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
...@@ -38,6 +41,7 @@ typedef char * __va___list; ...@@ -38,6 +41,7 @@ typedef char * __va___list;
#define va_start(AP) AP = (char *) &__builtin_va_alist #define va_start(AP) AP = (char *) &__builtin_va_alist
#endif #endif
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(AP) #define va_end(AP)
#ifdef lint /* complains about constant in conditional context */ #ifdef lint /* complains about constant in conditional context */
...@@ -50,3 +54,4 @@ typedef char * __va___list; ...@@ -50,3 +54,4 @@ typedef char * __va___list;
: ((int)AP + 2*4 - 1) & -4)))[-1] : ((int)AP + 2*4 - 1) & -4)))[-1]
#endif /* lint */ #endif /* lint */
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
#if __GNUC__ > 1
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef struct
{
char *__va_stack_start; /* Real start of stack args. */
char *__va_int; /* Pointer to the general register */
/* args and stack. */
char *__va_float; /* Pointer to the fp register args. */
char *__va_double;
} __gnuc_va_list;
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
#ifdef _STDARG_H
#define va_start(AP,LASTARG) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
#else
#define va_alist __builtin_va_alist
/* The ... causes current_function_varargs to be set in cc1. */
#define va_dcl int __builtin_va_alist; ...
#define va_start(AP) ((AP) = *(__gnuc_va_list *)__builtin_saveregs())
#endif /* _STDARG_H */
/* Handle pass by invisible reference and voids left by aligned */
/* doubles. */
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define va_arg(AP, TYPE) \
(((__va_rounded_size(TYPE) <= 8) \
? ((AP).__va_int -= __va_rounded_size (TYPE), \
(AP).__va_float -= __va_rounded_size (TYPE), \
(AP).__va_double -= __va_rounded_size (TYPE), \
(__alignof__ (TYPE) > 4 ? ((int)(AP).__va_int &= ~(0x7), \
(int)(AP).__va_float &= ~(0x7), \
(int)(AP).__va_double &= ~(0x7)) : 0))\
: (int)((AP).__va_int -= sizeof (TYPE *), \
(AP).__va_float -= sizeof (TYPE *), \
(AP).__va_double -= sizeof (TYPE *))), \
(((AP).__va_int < (AP).__va_stack_start \
|| __builtin_classify_type (* (TYPE *) 0) != 8) \
? ((__va_rounded_size(TYPE) <= 8) ? *(TYPE *)(AP).__va_int \
: **(TYPE **)(AP).__va_int) \
: ((__va_rounded_size(TYPE) <= 4) ? *(TYPE *)(AP).__va_float \
: ((__va_rounded_size(TYPE) <= 8) ? *(TYPE *)(AP).__va_double \
: **(TYPE **)(AP).__va_int))))
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(AP)
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
#else /* not __GNUCC_ > 1 */
typedef char *va_list;
/* __builtin_saveregs () tickles a bug in the pa-risc gcc 1.39 port, */
/* so don't use it for varargs. Obviously the stdarg stuff doesn't */
/* work very well. */
#ifdef _STDARG_H
#define va_start(AP,LASTARG) \
(__builtin_saveregs(), (AP) = __builtin_next_arg ())
/* gcc1 doesn't implement pass by invisible reference */
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
#define va_arg(AP,TYPE) \
((AP) -= __va_rounded_size (TYPE), (__alignof__ (TYPE) > 4 ? \
(int)AP &= ~(0x7) : 0), \
*(TYPE *)(AP))
void va_end (va_list); /* Defined in libgcc.a */
#define va_end(AP)
#else /* _STDARG_H */
#define va_alist __va_a__, __va_b__, __va_c__, __va_d__
#define va_dcl int __va_a__, __va_b__, __va_c__, __va_d__;
#define va_start(list) list = (char *) &__va_a__, &__va_b__, &__va_c__, \
&__va_d__
# define va_arg(list,mode) *(mode *) ((int) (list = (char *) \
(((int) list + sizeof(int /*__va_a__*/) - sizeof(mode)) & ~(sizeof(mode)-1)) \
- sizeof(int /*__va_a__*/)) + sizeof(int /*__va_a__*/))
#define va_end(list)
#endif /* _STDARG_H */
#endif /* not __GNUCC__ > 1 */
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
* # of calls to va_arg (debugging) at __va_buf[15] * # of calls to va_arg (debugging) at __va_buf[15]
*/ */
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef void *__voidptr; typedef void *__voidptr;
#if 1 #if 1
...@@ -63,6 +68,14 @@ typedef __voidptr(*__va_buf); ...@@ -63,6 +68,14 @@ typedef __voidptr(*__va_buf);
#endif #endif
typedef __va_buf __gnuc_va_list;
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
/* In GCC version 2, we want an ellipsis at the end of the declaration /* In GCC version 2, we want an ellipsis at the end of the declaration
of the argument list. GCC version 1 can't parse it. */ of the argument list. GCC version 1 can't parse it. */
...@@ -79,8 +92,6 @@ typedef __voidptr(*__va_buf); ...@@ -79,8 +92,6 @@ typedef __voidptr(*__va_buf);
/* The ... causes current_function_varargs to be set in cc1. */ /* The ... causes current_function_varargs to be set in cc1. */
#define va_dcl __voidptr va_alist; __va_ellipsis #define va_dcl __voidptr va_alist; __va_ellipsis
typedef __va_buf va_list;
/* __asm ("rcsp %0" : "=r" ( _AP [0]));*/ /* __asm ("rcsp %0" : "=r" ( _AP [0]));*/
...@@ -111,4 +122,7 @@ __extension__ \ ...@@ -111,4 +122,7 @@ __extension__ \
*(( _MODE *)__param_addr); \ *(( _MODE *)__param_addr); \
}) })
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(_X) #define va_end(_X)
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
/* This is just like the default gvarargs.h /* This is just like the default gvarargs.h
except for differences described below. */ except for differences described below. */
/* Make this a macro rather than a typedef, so we can undef any other defn. */ /* Define __gnuc_va_list. */
#define va_list __va___list
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
#ifndef __svr4__ #ifndef __svr4__
/* This has to be a char * to be compatible with Sun. /* This has to be a char * to be compatible with Sun.
i.e., we have to pass a `va_list' to vsprintf. */ i.e., we have to pass a `va_list' to vsprintf. */
typedef char * __va___list; typedef char * __gnuc_va_list;
#else #else
/* This has to be a void * to be compatible with Sun svr4. /* This has to be a void * to be compatible with Sun svr4.
i.e., we have to pass a `va_list' to vsprintf. */ i.e., we have to pass a `va_list' to vsprintf. */
typedef void * __va___list; typedef void * __gnuc_va_list;
#endif #endif
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
/* In GCC version 2, we want an ellipsis at the end of the declaration /* In GCC version 2, we want an ellipsis at the end of the declaration
of the argument list. GCC version 1 can't parse it. */ of the argument list. GCC version 1 can't parse it. */
...@@ -34,6 +42,7 @@ typedef void * __va___list; ...@@ -34,6 +42,7 @@ typedef void * __va___list;
(__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist)) (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
#endif #endif
void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#define va_end(pvar) #define va_end(pvar)
#define __va_rounded_size(TYPE) \ #define __va_rounded_size(TYPE) \
...@@ -64,3 +73,6 @@ __extension__ \ ...@@ -64,3 +73,6 @@ __extension__ \
*(TYPE *)__u.__d; }) \ *(TYPE *)__u.__d; }) \
: ((pvar) += __va_rounded_size (TYPE), \ : ((pvar) += __va_rounded_size (TYPE), \
*((TYPE *) ((pvar) - __va_rounded_size (TYPE)))));}) *((TYPE *) ((pvar) - __va_rounded_size (TYPE)))));})
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment