ORCA-C/ORCACDefs/stdarg.h
Stephen Heumann 438942692a Make va_arg(ap,double) work correctly.
This was not working because floating-point arguments are really passed in the extended format, but based on the wording in the C standard a type of "double" should still work for arguments passed with that type.

This fixes #29. (The bug report was valid only with respect to double, not float or long double.)
2021-09-03 21:25:20 -05:00

37 lines
916 B
C

/****************************************************************
*
* stdarg.h - variable length parameter list handling
*
* February 1989
* Mike Westerfield
*
* Copyright 1989
* Byte Works, Inc.
*
*****************************************************************
*
* Modified July 1994
*
* Thanks to Doug Gwyn for the new va_start & va_arg declarations.
*
****************************************************************/
#ifndef __stdarg__
#define __stdarg__
#ifndef __va_list__
#define __va_list__
typedef char *__va_list[2];
#endif
typedef __va_list va_list;
#define va_end(a) __va_end(a)
#define va_start(ap,LastFixedParm) ((void) ((ap)[0] = (ap)[1] = (char *) (&LastFixedParm + 1)))
#define va_arg(ap,type) _Generic(*(type *)0, \
double: (type)((long double *)((ap)[0] += sizeof(long double)))[-1], \
default: ((type *)((ap)[0] += sizeof(type)))[-1])
void __va_end(va_list);
#endif