@@ -1,17 +1,20 @@ #ifndef _VACALL_R_H /*-*- C -*-*/ #define _VACALL_R_H /* - * Copyright 1995-2004 Bruno Haible, + * Copyright 1995-2006 Bruno Haible, * * This is free software distributed under the GNU General Public Licence * described in the file COPYING. Contact the author if you don't have this * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied, * on this software. */ +#if !defined(LIBFFCALL_VERSION) +# define LIBFFCALL_VERSION 0x010B +#endif /* These definitions are adjusted by `configure' automatically. */ /* CPU */ #ifndef __i386__ @@ -42,12 +45,15 @@ #undef __hppa__ #endif #ifndef __arm__ #undef __arm__ #endif -#ifndef __rs6000__ -#undef __rs6000__ +#ifndef __powerpc__ +#undef __powerpc__ +#endif +#ifndef __powerpc64__ +#undef __powerpc64__ #endif #ifndef __s390__ #undef __s390__ #endif #ifndef __m88k__ @@ -69,14 +75,14 @@ /* Define if small structs are returned in registers */ #define __SMALL_STRUCT_RETURN__ 1 /* Define if floating-point results are returned in the integer registers */ #undef __IREG_FLOAT_RETURN__ -/* CL_LONGLONG */ -/* Define if your compiler supports the `long long' type. */ -#ifndef HAVE_LONGLONG -#undef HAVE_LONGLONG +/* AC_TYPE_LONG_LONG_INT */ +/* Define if your compiler supports the 'long long' type. */ +#ifndef HAVE_LONG_LONG_INT +#undef HAVE_LONG_LONG_INT #endif /* AC_C_CHAR_UNSIGNED */ #ifndef __CHAR_UNSIGNED__ #undef __CHAR_UNSIGNED__ @@ -89,16 +95,10 @@ */ #ifndef __VA_ALIST_WORDS #define __VA_ALIST_WORDS 256 #endif -/* The `signed' keyword. - */ -#if !defined(__STDC__) && !defined(__CHAR_UNSIGNED__) && !defined(signed) -#define signed -#endif - /* Determine the alignment of a type at compile time. */ #if defined(__GNUC__) #define __VA_alignof __alignof__ #else @@ -193,18 +193,13 @@ __VA_STRUCT_RETURN = #if defined(__sparc__) && !defined(__sparc64__) && defined(sun) && defined(__SUNPRO_C) /* SUNWspro cc */ __VA_SUNPROCC_STRUCT_RETURN, #else #if defined(__PCC_STRUCT_RETURN__) /* defined through configure, see above */ - __VA_PCC_STRUCT_RETURN | -#if defined(__sparc__) && !defined(__sparc64__) && defined(sun) && !(defined(__STDC__) || defined(__GNUC__)) /* sun cc */ - __VA_SUNCC_STRUCT_RETURN, -#else - 0, -#endif -#else -#if defined(__SMALL_STRUCT_RETURN__) || defined(__mipsn32__) || defined(__mips64__) /* defined through configure, see above */ + __VA_PCC_STRUCT_RETURN, +#else +#if defined(__SMALL_STRUCT_RETURN__) || defined(__mipsn32__) || defined(__mips64__) || defined(__ARMEL__)/* defined through configure, see above */ __VA_SMALL_STRUCT_RETURN | #endif #if defined(__GNUC__) __VA_GCC_STRUCT_RETURN | #endif @@ -249,11 +244,11 @@ /* how to pass structs */ #if defined(__mips__) || defined(__mipsn32__) || defined(__mips64__) __VA_SGICC_STRUCT_ARGS = 1<<7, #endif -#if defined(__rs6000__) +#if defined(__powerpc__) && !defined(__powerpc64__) __VA_AIXCC_STRUCT_ARGS = 1<<7, #endif /* the default way to pass floats */ /* This choice here is based on the assumption that the function you are * going to call has been compiled with the same compiler you are using to @@ -264,62 +259,27 @@ */ #ifndef __VA_STRUCT_ARGS #if (defined(__mips__) || defined(__mipsn32__) || defined(__mips64__)) && !defined(__GNUC__) /* SGI mips cc */ __VA_STRUCT_ARGS = __VA_SGICC_STRUCT_ARGS, #else -#if defined(__rs6000__) && defined(_AIX) && !defined(__GNUC__) /* AIX cc, xlc */ +#if defined(__powerpc__) && !defined(__powerpc64__) && defined(_AIX) && !defined(__GNUC__) /* AIX cc, xlc */ __VA_STRUCT_ARGS = __VA_AIXCC_STRUCT_ARGS, #else __VA_STRUCT_ARGS = 0, #endif #endif #endif /* how to pass floats */ /* ANSI C compilers and GNU gcc pass floats as floats. - * K&R C compilers pass floats as doubles. - * (Except some compilers like SGI MIPS "cc" and "cc -cckr" if a prototype is - * known for the called functions. But to compile a program with prototypes, - * "cc -ansi" is better anyway. - */ - __VA_ANSI_FLOAT_ARGS = 0, /* pass floats as floats */ - __VA_TRADITIONAL_FLOAT_ARGS = 1<<8, /* pass floats as doubles */ - /* the default way to pass floats */ - /* This choice here is based on the assumption that the function you are - * going to call has been compiled with the same compiler you are using to - * include this file. - * If you want to call functions with another float passing convention, - * just #define __VA_FLOAT_ARGS ... - * before or after #including . - */ -#ifndef __VA_FLOAT_ARGS -#if defined(__STDC__) || defined(__GNUC__) /* what about hppa "cc -Aa" ?? */ - __VA_FLOAT_ARGS = __VA_ANSI_FLOAT_ARGS, -#else - __VA_FLOAT_ARGS = __VA_TRADITIONAL_FLOAT_ARGS, -#endif -#endif + * K&R C compilers pass floats as doubles. We don't support them any more. + */ /* how to pass and return small integer arguments */ __VA_ANSI_INTEGERS = 0, /* no promotions */ __VA_TRADITIONAL_INTEGERS = 0, /* promote [u]char, [u]short to [u]int */ /* Fortunately these two methods are compatible. Our macros work with both. */ - /* the default way to pass and return small integer arguments */ - /* This choice here is based on the assumption that the function you are - * going to call has been compiled with the same compiler you are using to - * include this file. - * If you want to call functions with another float passing convention, - * just #define __VA_INTEGERS ... - * before or after #including . - */ -#ifndef __VA_INTEGERS -#if defined(__STDC__) || defined(__GNUC__) - __VA_INTEGERS = __VA_ANSI_INTEGERS, -#else - __VA_INTEGERS = __VA_TRADITIONAL_INTEGERS, -#endif -#endif /* stack cleanup policy */ __VA_CDECL_CLEANUP = 0, /* caller pops args after return */ __VA_STDCALL_CLEANUP = 1<<9, /* callee pops args before return */ /* currently only supported on __i386__ */ @@ -326,14 +286,14 @@ #ifndef __VA_CLEANUP __VA_CLEANUP = __VA_CDECL_CLEANUP, #endif /* These are for internal use only */ -#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__arm__) || defined(__rs6000__) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) || defined(__s390__) +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__arm__) || (defined(__powerpc__) && !defined(__powerpc64__)) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) || defined(__s390__) __VA_REGISTER_STRUCT_RETURN = 1<<10, #endif -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) __VA_FLOAT_1 = 1<<11, __VA_FLOAT_2 = 1<<12, #endif #if defined(__mipsn32__) || defined(__mips64__) __VA_REGISTER_FLOATSTRUCT_RETURN = 1<<13, @@ -354,11 +314,11 @@ unsigned long aptr; /* structure return pointer, return type, return type size */ void* raddr; enum __VAtype rtype; unsigned long rsize; -#if defined(__i386__) || (defined(__rs6000__) && defined(__MACH__) && defined(__APPLE__)) +#if defined(__i386__) || (defined(__powerpc__) && !defined(__powerpc64__) && defined(__MACH__) && defined(__APPLE__)) /* Filler word, needed if the numbers of words up to now in this structure */ /* is odd (because on MSVC, alignof(double) = 8, normally = 4; similarly, */ /* on MacOS X, the Apple compiler has alignof(double) = 8 whereas the */ /* standard GCC has alignof(double) = 4. */ __vaword filler1; @@ -372,11 +332,11 @@ unsigned short _ushort; int _int; unsigned int _uint; long _long; unsigned long _ulong; -#if !(defined(__mips64__) || defined(__alpha__)) && defined(HAVE_LONGLONG) +#if !(defined(__mips64__) || defined(__alpha__) || defined(__powerpc64__)) && defined(HAVE_LONG_LONG_INT) long long _longlong; unsigned long long _ulonglong; #endif float _float; double _double; @@ -393,11 +353,11 @@ long farg_offset; long darg_offset; float farg[4]; double darg[2]; #endif -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) int anum; float farg[2]; double darg[2]; #endif #if defined(__mipsn32__) || defined(__mips64__) @@ -408,11 +368,11 @@ #if defined(__sparc64__) int anum; float farg[16]; double darg[16]; #endif -#if defined(__rs6000__) +#if defined(__powerpc__) || defined(__powerpc64__) double* memfargptr; double farg[13]; #if !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) __vaword regarg[8]; unsigned long saptr; @@ -446,11 +406,11 @@ /* * Definition of the va_start_xxx macros. */ #define __VA_START_FLAGS \ - __VA_STRUCT_RETURN | __VA_FLOAT_RETURN | __VA_STRUCT_ARGS | __VA_FLOAT_ARGS | __VA_INTEGERS | __VA_CLEANUP + __VA_STRUCT_RETURN | __VA_FLOAT_RETURN | __VA_STRUCT_ARGS | __VA_CLEANUP #define __va_start(LIST,RETTYPE) \ ((LIST)->flags = __VA_START_FLAGS, \ (LIST)->rtype = (RETTYPE) \ ) #define va_start_void(LIST) __va_start(LIST,__VAvoid) @@ -509,16 +469,27 @@ * and the struct will actually be returned in registers. */ #define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) #endif -#if (defined(__i386__) && !defined(_WIN32)) || defined(__m68k__) || defined(__arm__) || defined(__rs6000__) || defined(__convex__) || defined(__s390__) +#if (defined(__i386__) && !defined(_WIN32)) || defined(__m68k__) || (defined(__arm__) && !defined(__ARMEL__)) || (defined(__powerpc__) && !defined(__powerpc64__)) || defined(__convex__) || defined(__s390__) #define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4 \ || ((TYPE_SIZE) == 8 && (TYPE_SPLITTABLE) \ && ((LIST)->flags & __VA_GCC_STRUCT_RETURN) \ ) ) +/* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set + * and the struct will actually be returned in registers. + */ +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) +#endif + +#if defined(__ARMEL__) +/* structs of size 3 also will be returned in register */ +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + ((TYPE_SIZE) <= 4) /* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set * and the struct will actually be returned in registers. */ #define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ ((LIST)->flags |= __VA_REGISTER_STRUCT_RETURN, 0) @@ -543,15 +514,15 @@ ) /* Test both __VA_OLDGCC_STRUCT_RETURN and __VA_SMALL_STRUCT_RETURN at run time. */ #define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ 0 #endif -#if defined(__mips__) && !defined(__mipsn32__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__m88k__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__m88k__) #define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ ((TYPE_SIZE) == 1 || (TYPE_SIZE) == 2 || (TYPE_SIZE) == 4) /* Test __VA_SMALL_STRUCT_RETURN instead of __VA_REGISTER_STRUCT_RETURN. */ -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) #define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ ((LIST)->anum++, \ 0 \ ) #else @@ -577,10 +548,16 @@ && ((LIST)->flags |= __VA_REGISTER_FLOATSTRUCT_RETURN), \ (TYPE_ALIGN) == sizeof(double) && (TYPE_SPLITTABLE) \ && ((TYPE_SIZE) == sizeof(double) || (TYPE_SIZE) == 2*sizeof(double)) \ && ((LIST)->flags |= __VA_REGISTER_DOUBLESTRUCT_RETURN), \ 0) +#endif +#if defined(__powerpc64__) +#define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ + 0 +#define __va_start_struct1(LIST,TYPE_SIZE,TYPE_ALIGN,TYPE_SPLITTABLE) \ + 0 #endif #if defined(__sparc64__) || defined(__ia64__) #define __va_reg_struct_return(LIST,TYPE_SIZE,TYPE_SPLITTABLE) \ ((TYPE_SIZE) <= 32) /* Turn on __VA_REGISTER_STRUCT_RETURN if __VA_SMALL_STRUCT_RETURN was set @@ -611,11 +588,11 @@ : ((LIST)->raddr = *(void* *)((LIST)->aptr), /* first arg */ \ (LIST)->aptr += sizeof(void*), \ 0 \ ) ) #endif -#if defined(__alpha__) || defined(__arm__) || defined(__rs6000__) || defined(__convex__) || defined(__s390__) +#if defined(__alpha__) || defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__) || defined(__convex__) || defined(__s390__) /* Return structure pointer is passed as first arg. */ #define __va_start_struct2(LIST) \ ((LIST)->raddr = *(void* *)((LIST)->aptr), \ (LIST)->aptr += sizeof(void*), \ 0 \ @@ -649,11 +626,11 @@ */ /* Padding of non-struct arguments. */ #define __va_argsize(TYPE_SIZE) \ (((TYPE_SIZE) + sizeof(__vaword)-1) & -(long)sizeof(__vaword)) -#if defined(__i386__) || defined(__m68k__) || defined(__mips__) && !defined(__mipsn32__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__alpha__) || defined(__arm__) || (defined(__rs6000__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__m88k__) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) +#if defined(__i386__) || defined(__m68k__) || (defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__)) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__alpha__) || defined(__arm__) || (defined(__powerpc__) && !defined(__powerpc64__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__powerpc64__) || defined(__m88k__) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) /* args grow up */ /* small structures < 1 word are adjusted depending on compiler */ #define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((LIST)->aptr += __va_argsize(TYPE_SIZE), \ (LIST)->aptr - __va_argsize(TYPE_SIZE) \ @@ -664,11 +641,11 @@ ? (TYPE_SIZE) \ : __va_argsize(TYPE_SIZE) \ ) \ ) #endif -#if defined(__rs6000__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) +#if defined(__powerpc__) && !defined(__powerpc64__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) /* args grow up */ /* small structures < 1 word are adjusted depending on compiler */ /* Also make sure we switch to the stack pointer after 8 args */ #define __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((((LIST)->onstack == 0 && (LIST)->aptr >= (long)&(LIST)->regarg[8]) \ @@ -735,24 +712,30 @@ ((LIST)->aptr = (LIST)->aptr - __va_argsize(TYPE_SIZE), \ ((TYPE_SIZE) > 4 && ((LIST)->aptr &= -8)), \ (LIST)->aptr + ((-(TYPE_SIZE)) & 3) \ ) #endif -#if defined(__i386__) || defined(__alpha__) || defined(__ia64__) +#if defined(__i386__) || defined(__alpha__) || defined(__ia64__) || defined(__ARMEL__) || ((defined(__mipsn32__) || defined(__mips64__)) && defined(_MIPSEL)) /* little endian -> small args < 1 word are adjusted to the left */ #define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) #endif -#if defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc__) || defined(__sparc64__) || defined(__hppa__) || defined(__arm__) || defined(__rs6000__) || defined(__m88k__) || defined(__convex__) || defined(__s390__) +#if defined(__m68k__) || ((defined(__mipsn32__) || defined(__mips64__)) && defined(_MIPSEB)) || defined(__sparc__) || defined(__sparc64__) || defined(__hppa__) || (defined(__arm__) && !defined(__ARMEL__)) || defined(__powerpc__) || defined(__powerpc64__) || defined(__m88k__) || defined(__convex__) || defined(__s390__) /* big endian -> small args < 1 word are adjusted to the right */ #define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) #endif -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) +#ifdef _MIPSEB /* big endian -> small args < 1 word are adjusted to the right */ #define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((LIST)->anum++, __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN)) +#else /* _MIPSEL */ +/* little endian -> small args < 1 word are adjusted to the left */ +#define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ + ((LIST)->anum++, __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN)) +#endif #endif #if defined(__x86_64__) /* the first 6 argument words are passed in registers */ #define __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((LIST)->memiargptr + ((TYPE_SIZE) + sizeof(__vaword)-1) / sizeof(__vaword) <= &(LIST)->iarg[6] \ @@ -775,27 +758,27 @@ #define va_arg_int(LIST) __va_arg(LIST,int) #define va_arg_uint(LIST) __va_arg(LIST,unsigned int) #define va_arg_long(LIST) __va_arg(LIST,long) #define va_arg_ulong(LIST) __va_arg(LIST,unsigned long) -#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__ia64__) || defined(__x86_64__) +#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) /* `long long' and `long' are identical. */ #define va_arg_longlong va_arg_long #define va_arg_ulonglong va_arg_ulong #elif defined(__mipsn32__) /* `long long' fits in __vaword. */ #define va_arg_longlong(LIST) __va_arg(LIST,long long) #define va_arg_ulonglong(LIST) __va_arg(LIST,unsigned long long) -#elif defined(__i386__) || defined(__m68k__) || defined(__mips__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__hppa__) || defined(__arm__) || defined(__rs6000__) || defined(__m88k__) || defined(__convex__) || defined(__s390__) +#elif defined(__i386__) || defined(__m68k__) || defined(__mips__) || (defined(__sparc__) && !defined(__sparc64__)) || defined(__hppa__) || defined(__arm__) || defined(__powerpc__) || defined(__m88k__) || defined(__convex__) || defined(__s390__) /* `long long's are passed embedded on the arg stack. */ #define va_arg_longlong(LIST) __va_arg_longlong(LIST,long long) #define va_arg_ulonglong(LIST) __va_arg_longlong(LIST,unsigned long long) -#if defined(__i386__) || defined(__m68k__) || defined(__arm__) || (defined(__rs6000__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__convex__) +#if defined(__i386__) || defined(__m68k__) || (defined(__arm__) && !defined(__ARMEL__)) || (defined(__powerpc__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__convex__) /* `long long's are (at most) word-aligned. */ #define __va_arg_longlong(LIST,TYPE) __va_arg(LIST,TYPE) #endif -#if defined(__mips__) || (defined(__rs6000__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__m88k__) +#if defined(__mips__) || (defined(__powerpc__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__)))) || defined(__m88k__) || defined(__ARMEL__) /* `long long's have alignment 8. */ #define __va_arg_longlong(LIST,TYPE) \ ((LIST)->aptr = (((LIST)->aptr+__VA_alignof(TYPE)-1) & -(long)__VA_alignof(TYPE)), \ __va_arg(LIST,TYPE)) #endif @@ -817,20 +800,14 @@ #endif #endif /* Floating point arguments. */ -#define va_arg_float(LIST) \ - ((LIST)->flags & __VA_TRADITIONAL_FLOAT_ARGS \ - ? (float)va_arg_double(LIST) \ - : __va_arg_float(LIST) \ - ) - -#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || defined(__arm__) || defined(__rs6000__) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) || defined(__s390__) +#if defined(__i386__) || defined(__m68k__) || defined(__mipsn32__) || defined(__mips64__) || defined(__sparc__) || defined(__sparc64__) || defined(__alpha__) || (defined(__arm__) && !defined(__ARMEL__)) || defined(__powerpc__) || defined(__powerpc64__) || defined(__convex__) || defined(__ia64__) || defined(__x86_64__) || defined(__s390__) #define __va_align_double(LIST) #endif -#if defined(__mips__) && !defined(__mipsn32__) || defined(__m88k__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) || defined(__m88k__) || defined(__ARMEL__) /* __VA_alignof(double) > sizeof(__vaword) */ #define __va_align_double(LIST) \ (LIST)->aptr = ((LIST)->aptr + sizeof(double)-1) & -(long)sizeof(double), #endif #if defined(__hppa__) @@ -853,11 +830,11 @@ #define va_arg_double(LIST) \ (((LIST)->aptr += sizeof(double)) <= (LIST)->memargptr \ ? *(double*)((LIST)->aptr - sizeof(double) - 6*sizeof(double)) \ : *(double*)((LIST)->aptr - sizeof(double)) \ ) -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ (((LIST)->aptr += sizeof(double)) <= (LIST)->memargptr \ ? /* The first 6 args have been put into memory by "stt" instructions */\ /* (see vacall-alpha.s!). Therefore load them as doubles. */ \ /* When viewed as floats, the value will be the correct one. */ \ (float)*(double*)((LIST)->aptr - sizeof(double) - 6*sizeof(double)) \ @@ -869,18 +846,18 @@ #if defined(__hppa__) /* The first 4 float registers and the first 2 double registers are stored * elsewhere. */ #if 1 /* gcc-2.5.2 passes these args in general registers! A bug, I think. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ (*(float*)((LIST)->aptr -= sizeof(float))) #define va_arg_double(LIST) \ (__va_align_double(LIST) \ *(double*)((LIST)->aptr -= sizeof(double)) \ ) #else /* this would be correct if the args were passed in float registers. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ (((LIST)->aptr -= sizeof(float)) >= (LIST)->memargptr \ ? /* The first 4 float args are stored separately. */ \ *(float*)((LIST)->aptr + (LIST)->farg_offset) \ : *(float*)((LIST)->aptr) \ ) @@ -891,15 +868,15 @@ *(double*)((LIST)->aptr + (LIST)->darg_offset) \ : *(double*)((LIST)->aptr) \ )) #endif #endif -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) /* The first 0,1,2 registers are stored elsewhere if they are floating-point * parameters. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->aptr += sizeof(float), \ (LIST)->anum++, \ ((LIST)->anum == 1 \ ? ((LIST)->flags |= __VA_FLOAT_1, (LIST)->farg[0]) \ : ((LIST)->anum == 2 && ((LIST)->flags & __VA_FLOAT_1) \ @@ -919,11 +896,11 @@ #endif #if defined(__mipsn32__) || defined(__mips64__) /* The first 0,..,8 registers are stored elsewhere if they are floating-point * parameters. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ (__va_align_double(LIST) \ (LIST)->aptr += sizeof(double), \ (++(LIST)->anum <= 8 \ ? (LIST)->farg[(LIST)->anum - 1] \ : *(float*)((LIST)->aptr - sizeof(double)) \ @@ -938,11 +915,11 @@ #endif #if defined(__sparc64__) /* The first 0,..,16 registers are stored elsewhere if they are floating-point * parameters. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ (__va_align_double(LIST) \ (LIST)->aptr += sizeof(double), \ (++(LIST)->anum <= 16 \ ? (LIST)->farg[(LIST)->anum - 1] \ : *(float*)((LIST)->aptr - sizeof(double)) \ @@ -953,13 +930,13 @@ (++(LIST)->anum <= 16 \ ? (LIST)->darg[(LIST)->anum - 1] \ : *(double*)((LIST)->aptr - sizeof(double)) \ )) #endif -#if defined(__rs6000__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) +#if defined(__powerpc__) && !defined(__powerpc64__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) /* The first 13 floating-point args have been stored elsewhere. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->aptr += sizeof(float), \ ((LIST)->memfargptr < &(LIST)->farg[13] \ ? (float) *((LIST)->memfargptr++) \ : *(float*)((LIST)->aptr - sizeof(float)) \ )) @@ -969,13 +946,13 @@ ((LIST)->memfargptr < &(LIST)->farg[13] \ ? *((LIST)->memfargptr++) \ : *(double*)((LIST)->aptr - sizeof(double)) \ )) #endif -#if defined(__rs6000__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) +#if defined(__powerpc__) && !defined(__powerpc64__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) /* The first 8 floating-point args have been stored elsewhere. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->memfargptr < &(LIST)->farg[8] \ ? (float) *((LIST)->memfargptr++) \ : ((LIST)->aptr = ((LIST)->onstack == 0 \ ? ((LIST)->onstack=1, (LIST)->saptr) \ : (LIST)->aptr \ @@ -992,14 +969,30 @@ ), \ __va_align_double(LIST) \ (LIST)->aptr += sizeof(double), \ *(double*)((LIST)->aptr - sizeof(double)) \ )) +#endif +#if defined(__powerpc64__) +/* The first 13 floating-point args have been stored elsewhere. */ +#define va_arg_float(LIST) \ + ((LIST)->aptr += sizeof(__vaword), \ + ((LIST)->memfargptr < &(LIST)->farg[13] \ + ? (float) *((LIST)->memfargptr++) \ + : *(float*)((LIST)->aptr - sizeof(float)) \ + )) +#define va_arg_double(LIST) \ + (__va_align_double(LIST) \ + (LIST)->aptr += sizeof(double), \ + ((LIST)->memfargptr < &(LIST)->farg[13] \ + ? *((LIST)->memfargptr++) \ + : *(double*)((LIST)->aptr - sizeof(double)) \ + )) #endif #if defined(__s390__) /* The first 2 floating-point args have been stored elsewhere. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->memfargptr < &(LIST)->farg[2] \ ? (LIST)->memdargptr++, (float) *((LIST)->memfargptr++) \ : ((LIST)->aptr = ((LIST)->onstack == 0 \ ? ((LIST)->onstack=1, (LIST)->saptr) \ : (LIST)->aptr \ @@ -1019,11 +1012,11 @@ *(double*)((LIST)->aptr - sizeof(double)) \ )) #endif #if defined(__ia64__) /* The first 8 floating-point args have been stored elsewhere. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->aptr += sizeof(__vaword), \ ((LIST)->memfargptr < &(LIST)->farg[8] \ ? (float) *((LIST)->memfargptr++) \ : *(float*)((LIST)->aptr - sizeof(__vaword)) \ )) @@ -1035,11 +1028,11 @@ : *(double*)((LIST)->aptr - sizeof(double)) \ )) #endif #if defined(__x86_64__) /* The first 8 floating-point args have been stored elsewhere. */ -#define __va_arg_float(LIST) \ +#define va_arg_float(LIST) \ ((LIST)->memfargptr < &(LIST)->farg[8] \ ? ((LIST)->memfargptr++, \ *(float*)((LIST)->memfargptr - 1) \ ) \ : ((LIST)->aptr += sizeof(__vaword), \ @@ -1050,12 +1043,12 @@ ? *(LIST)->memfargptr++ \ : ((LIST)->aptr += sizeof(__vaword), \ *(double*)((LIST)->aptr - sizeof(__vaword)) \ ) ) #endif -#ifndef __va_arg_float -#define __va_arg_float(LIST) __va_arg(LIST,float) +#ifndef va_arg_float +#define va_arg_float(LIST) __va_arg(LIST,float) #endif #ifndef va_arg_double #define va_arg_double(LIST) \ (__va_align_double(LIST) __va_arg(LIST,double)) #endif @@ -1084,17 +1077,17 @@ #define __va_struct_alignment(TYPE_ALIGN) \ (TYPE_ALIGN) #endif #define __va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ (LIST)->aptr = ((LIST)->aptr + __va_struct_alignment(TYPE_ALIGN)-1) & -(long)__va_struct_alignment(TYPE_ALIGN), -#if defined(__i386__) || defined(__m68k__) || defined(__alpha__) || defined(__arm__) || defined(__m88k__) || defined(__convex__) || defined(__x86_64__) +#if defined(__i386__) || defined(__m68k__) || defined(__alpha__) || defined(__arm__) || defined(__powerpc64__) || defined(__m88k__) || defined(__convex__) || defined(__x86_64__) || (defined(__ia64__) && defined(__GNUC__) && (__GNUC__ >= 3)) #define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ) #endif -#if defined(__mips__) && !defined(__mipsn32__) +#if defined(__mips__) && !defined(__mipsn32__) && !defined(__mips64__) /* small structures < 1 word are adjusted depending on compiler */ #define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((LIST)->flags & __VA_SGICC_STRUCT_ARGS \ ? /* SGI MIPS cc passes small structures left-adjusted, although big-endian! */\ @@ -1117,11 +1110,11 @@ __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ : /* SGI MIPS gcc passes small structures right-adjusted. */ \ __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ )) #endif -#if defined(__rs6000__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) +#if defined(__powerpc__) && !defined(__powerpc64__) && (defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) /* small structures < 1 word are adjusted depending on compiler */ #define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((LIST)->flags & __VA_AIXCC_STRUCT_ARGS \ ? /* AIX cc and xlc pass small structures left-adjusted, although big-endian! */\ @@ -1128,11 +1121,11 @@ __va_arg_leftadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ : /* gcc passes small structures right-adjusted. */ \ __va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ )) #endif -#if defined(__rs6000__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) +#if defined(__powerpc__) && !defined(__powerpc64__) && !(defined(_AIX) || (defined(__MACH__) && defined(__APPLE__))) /* Structures are passed as pointers to caller-made local copies. */ #define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ va_arg_ptr(LIST,void*) #endif #if defined(__sparc__) && !defined(__sparc64__) @@ -1169,11 +1162,11 @@ ? va_arg_ptr(LIST,void*) \ : /* FIXME: gcc-2.6.3 passes structures <= 4 bytes in memory left-adjusted! ?? */\ (void*)__va_arg_rightadjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ ) #endif -#if defined(__ia64__) +#if defined(__ia64__) && (!defined(__GNUC__) || (__GNUC__ < 3)) /* Types larger than a word have 2-word alignment. */ #define __va_arg_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ (__va_align_struct(LIST,TYPE_SIZE,TYPE_ALIGN) \ ((TYPE_SIZE) > sizeof(__vaword) && (((__vaword*)(LIST)->aptr - (LIST)->saptr) & 1) ? (LIST)->aptr += sizeof(__vaword) : 0), \ __va_arg_adjusted(LIST,TYPE_SIZE,TYPE_ALIGN) \ @@ -1204,11 +1197,11 @@ (__va_return(LIST,__VAuint), (LIST)->tmp._uint = (VAL)) #define va_return_long(LIST,VAL) \ (__va_return(LIST,__VAlong), (LIST)->tmp._long = (VAL)) #define va_return_ulong(LIST,VAL) \ (__va_return(LIST,__VAulong), (LIST)->tmp._ulong = (VAL)) -#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__ia64__) || defined(__x86_64__) +#if defined(__mips64__) || defined(__sparc64__) || defined(__alpha__) || defined(__powerpc64__) || defined(__ia64__) || defined(__x86_64__) #define va_return_longlong(LIST,VAL) \ (__va_return(LIST,__VAlonglong), (LIST)->tmp._long = (VAL)) #define va_return_ulonglong(LIST,VAL) \ (__va_return(LIST,__VAulonglong), (LIST)->tmp._ulong = (VAL)) #else @@ -1268,19 +1261,13 @@ #ifdef __cplusplus extern "C" void __vacall_r (); /* the return type is variable, not void! */ #else extern void __vacall_r (); /* the return type is variable, not void! */ #endif -#if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus) extern int __va_error1 (enum __VAtype, enum __VAtype); extern int __va_error2 (unsigned int); -extern void __structcpy (void* dest, void* src, unsigned long size, unsigned long alignment); -#else -extern int __va_error1 (); -extern int __va_error2 (); -extern void __structcpy (); -#endif +extern void __structcpy (void* dest, const void* src, unsigned long size, unsigned long alignment); typedef union { __vaword room[__VA_ALIST_WORDS]; double align; } __va_struct_buffer_t; extern __va_struct_buffer_t __va_struct_buffer; #endif /* _VACALL_R_H */