Cleanup of the stdarg code.

Submitted by:	ru
This commit is contained in:
Mark Peek 2001-10-19 16:15:46 +00:00
parent 0860ce5d69
commit 6b2d0a7791
2 changed files with 11 additions and 54 deletions

View File

@ -71,31 +71,20 @@
#define _BSD_OFF_T_ __int64_t /* file offset */ #define _BSD_OFF_T_ __int64_t /* file offset */
#define _BSD_PID_T_ int /* process [group] */ #define _BSD_PID_T_ int /* process [group] */
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 95) #if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 95)
#define _BSD_VA_LIST_ __builtin_va_list /* internally known to gcc */ #define _BSD_VA_LIST_ __builtin_va_list /* internally known to gcc */
#else #else
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ == 95)
typedef struct { typedef struct {
char __gpr; char __gpr;
char __fpr; char __fpr;
char __pad[2]; char __pad[2];
char *__stack; char *__stack;
char *__base; char *__base;
} __va_list[1];
#define _BSD_VA_LIST_ __va_list /* va_list */
#else
typedef struct {
char __gpr;
char __fpr;
char __pad[2];
char *__stack;
char *__base;
} __va_list; } __va_list;
#define _BSD_VA_LIST_ __va_list /* va_list */ #define _BSD_VA_LIST_ __va_list /* va_list */
#endif
#endif /* post GCC 2.95 */ #endif /* post GCC 2.95 */
#if defined __GNUC__ #ifdef __GNUC__
typedef _BSD_VA_LIST_ __gnuc_va_list; /* compatibility w/GNU headers*/ typedef _BSD_VA_LIST_ __gnuc_va_list; /* compatibility w/GNU headers*/
#endif #endif
/* /*

View File

@ -32,16 +32,6 @@
#include <machine/ansi.h> #include <machine/ansi.h>
#if 0
typedef struct {
char __gpr; /* GPR offset */
char __fpr; /* FPR offset */
/* char __pad[2]; */
char *__stack; /* args passed on stack */
char *__base; /* args passed by registers (r3-r10, f1-f8) */
} va_list;
#endif
typedef _BSD_VA_LIST_ va_list; typedef _BSD_VA_LIST_ va_list;
#ifdef __lint__ #ifdef __lint__
@ -51,10 +41,11 @@ typedef _BSD_VA_LIST_ va_list;
#else #else
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ == 95) #if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 95)
#define va_start(ap, last) \ #define va_start(ap, last) \
(__builtin_next_arg(last), \ (__builtin_next_arg(last), \
__builtin_memcpy ((ap), __builtin_saveregs (), sizeof(__gnuc_va_list))) __builtin_memcpy((void *)&(ap), __builtin_saveregs (), \
sizeof(__gnuc_va_list)))
#else #else
#define va_start(ap, last) \ #define va_start(ap, last) \
(__builtin_next_arg(last), \ (__builtin_next_arg(last), \
@ -89,28 +80,6 @@ typedef _BSD_VA_LIST_ va_list;
#define __va_size(type) \ #define __va_size(type) \
((sizeof(type) + sizeof(int) - 1) / sizeof(int) * sizeof(int)) ((sizeof(type) + sizeof(int) - 1) / sizeof(int) * sizeof(int))
#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ == 95)
#define __va_savedgpr(ap, type) \
((ap)->__base + (ap)->__gpr * sizeof(int) - sizeof(type))
#define __va_savedfpr(ap, type) \
((ap)->__base + 8 * sizeof(int) + (ap)->__fpr * sizeof(double) - \
sizeof(type))
#define __va_stack(ap, type) \
((ap)->__stack += __va_size(type) + \
(__va_longlong(type) ? (int)(ap)->__stack & 4 : 0), \
(ap)->__stack - sizeof(type))
#define __va_gpr(ap, type) \
((ap)->__gpr += __va_size(type) / sizeof(int) + \
(__va_longlong(type) ? (ap)->__gpr & 1 : 0), \
(ap)->__gpr <= 8 ? __va_savedgpr(ap, type) : __va_stack(ap, type))
#define __va_fpr(ap, type) \
((ap)->__fpr++, \
(ap)->__fpr <= 8 ? __va_savedfpr(ap, type) : __va_stack(ap, type))
#else
#define __va_savedgpr(ap, type) \ #define __va_savedgpr(ap, type) \
((ap).__base + (ap).__gpr * sizeof(int) - sizeof(type)) ((ap).__base + (ap).__gpr * sizeof(int) - sizeof(type))
@ -131,7 +100,6 @@ typedef _BSD_VA_LIST_ va_list;
#define __va_fpr(ap, type) \ #define __va_fpr(ap, type) \
((ap).__fpr++, \ ((ap).__fpr++, \
(ap).__fpr <= 8 ? __va_savedfpr(ap, type) : __va_stack(ap, type)) (ap).__fpr <= 8 ? __va_savedfpr(ap, type) : __va_stack(ap, type))
#endif
#define va_arg(ap, type) \ #define va_arg(ap, type) \
(*(type *)(__va_struct(type) ? (*(void **)__va_gpr(ap, void *)) : \ (*(type *)(__va_struct(type) ? (*(void **)__va_gpr(ap, void *)) : \