From c9f98c9686463c26c1c7b97e1f9551908ca41dee Mon Sep 17 00:00:00 2001 From: mp Date: Thu, 18 Oct 2001 19:11:12 +0000 Subject: Add support for the gcc-2.95 stdarg implementation. --- sys/powerpc/include/ansi.h | 11 +++++++++++ sys/powerpc/include/stdarg.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'sys/powerpc') diff --git a/sys/powerpc/include/ansi.h b/sys/powerpc/include/ansi.h index 2295e4d..3fca13e 100644 --- a/sys/powerpc/include/ansi.h +++ b/sys/powerpc/include/ansi.h @@ -74,6 +74,16 @@ #if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 95) #define _BSD_VA_LIST_ __builtin_va_list /* internally known to gcc */ #else +#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ == 95) +typedef struct { + char __gpr; + char __fpr; + char __pad[2]; + char *__stack; + char *__base; +} __va_list[1]; +#define _BSD_VA_LIST_ __va_list /* va_list */ +#else typedef struct { char __gpr; char __fpr; @@ -82,6 +92,7 @@ typedef struct { char *__base; } __va_list; #define _BSD_VA_LIST_ __va_list /* va_list */ +#endif #endif /* post GCC 2.95 */ #if defined __GNUC__ typedef _BSD_VA_LIST_ __gnuc_va_list; /* compatibility w/GNU headers*/ diff --git a/sys/powerpc/include/stdarg.h b/sys/powerpc/include/stdarg.h index 4cabdaf..84d5ae4 100644 --- a/sys/powerpc/include/stdarg.h +++ b/sys/powerpc/include/stdarg.h @@ -51,12 +51,18 @@ typedef _BSD_VA_LIST_ va_list; #else +#if defined __GNUC__ && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ == 95) +#define va_start(ap, last) \ + (__builtin_next_arg(last), \ + __builtin_memcpy ((ap), __builtin_saveregs (), sizeof(__gnuc_va_list))) +#else #define va_start(ap, last) \ (__builtin_next_arg(last), \ (ap).__stack = __va_stack_args, \ (ap).__base = __va_reg_args, \ (ap).__gpr = __va_first_gpr, \ (ap).__fpr = __va_first_fpr) +#endif #define __va_first_gpr (__builtin_args_info(0)) #define __va_first_fpr (__builtin_args_info(1) - 32 - 1) @@ -83,6 +89,28 @@ typedef _BSD_VA_LIST_ va_list; #define __va_size(type) \ ((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) \ ((ap).__base + (ap).__gpr * sizeof(int) - sizeof(type)) @@ -103,6 +131,7 @@ typedef _BSD_VA_LIST_ va_list; #define __va_fpr(ap, type) \ ((ap).__fpr++, \ (ap).__fpr <= 8 ? __va_savedfpr(ap, type) : __va_stack(ap, type)) +#endif #define va_arg(ap, type) \ (*(type *)(__va_struct(type) ? (*(void **)__va_gpr(ap, void *)) : \ -- cgit v1.1