slkern/cc_stdarg.h

38 lines
1.1 KiB
C
Raw Normal View History

// This is NEW CODE for auditing purposes, but should actually be replaced with libc/include/stdarg.h
#ifndef _FAKELIBC_STDARG_H
#define _FAKELIBC_STDARG_H
// TODO: This will basically not work except for the simplest printf-like cases
struct va_list_struct {long long** ptr;};
typedef struct va_list_struct va_list;
//typedef int va_list;
#define _VA_CHECK() \
if (__builtin_func_callconv != 101) {\
printf("ERROR: Unpacking varargs currently only works with __classic_call (#101). Function %s uses convention %d instead.\n", __func__, __builtin_func_callconv);\
}
#define va_start(list,lastarg) \
do {\
_VA_CHECK();\
list.ptr = &lastarg;\
list.ptr++;\
} while(0)
#define va_arg(list,T) \
(T)(*list.ptr++)
#define va_end(list) \
do {list.ptr = (void*)0;} while(0)
/*
#define va_start(...) printf("WARNING: Unimplemented: va_start in %s\n", __func__)
#define va_arg(...) printf("WARNING: Unimplemented: va_start in %s\n", __func__)
#define va_end(...) printf("WARNING: Unimplemented: va_end in %s\n", __func__)
*/
/* From ifndef at top of file: */
#endif