--- mstools/h/stdarg.h 2018/08/09 18:20:30 1.1.1.2 +++ mstools/h/stdarg.h 2018/08/09 18:23:03 1.1.1.3 @@ -1,7 +1,7 @@ /*** *stdarg.h - defines ANSI-style macros for variable argument functions * -* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved. +* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved. * *Purpose: * This file defines ANSI-style macros for accessing arguments @@ -19,11 +19,19 @@ extern "C" { #ifndef _VA_LIST_DEFINED +#if defined(_ALPHA_) +typedef struct { + char *a0; /* pointer to first homed integer argument */ + int offset; /* byte offset of next parameter */ +} va_list; +#else typedef char * va_list; +#endif #define _VA_LIST_DEFINED #endif -#ifdef i386 + +#ifdef _M_IX86 #define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) ) @@ -33,13 +41,7 @@ typedef char * va_list; #endif -#ifdef M_MRX000 -#define va_start(ap,v) _va_start(&(ap),0) -#define va_arg(ap,t) *((t*)(_va_arg(&(ap),sizeof(t),(t*)0,(t*)0))) -#define va_end(ap) -#else - -#ifdef MIPS +#if defined(_M_MRX000) || defined(_MIPS_) #define va_start(ap,v) ap = (va_list)&v + sizeof(v) #define va_end(list) @@ -56,8 +58,37 @@ typedef char * va_list; #endif + +#if defined (_ALPHA_) + +/* + * The Alpha compiler supports two builtin functions that are used to + * implement stdarg/varargs. The __builtin_va_start function is used + * by va_start to initialize the data structure that locates the next + * argument. The __builtin_isfloat function is used by va_arg to pick + * which part of the home area a given register argument is stored in. + * The home area is where up to six integer and/or six floating point + * register arguments are stored down (so they can also be referenced + * by a pointer like any arguments passed on the stack). + */ + +#ifdef _CFRONT +extern __builtin_va_start(va_list, ...); +#define __builtin_isfloat(a) __builtin_alignof(a) #endif +#define va_start(list, v) __builtin_va_start(list, v, 1) +#define va_end(list) +#define va_arg(list, mode) \ + ( *( ((list).offset += ((int)sizeof(mode) + 7) & -8) , \ + (mode *)((list).a0 + (list).offset - \ + ((__builtin_isfloat(mode) && (list).offset <= (6 * 8)) ? \ + (6 * 8) + 8 : ((int)sizeof(mode) + 7) & -8) \ + ) \ + ) \ + ) + +#endif /* ALPHA */ #ifdef __cplusplus