Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
stdarg.h
Go to the documentation of this file.
1 #ifndef _STDARG_H_
2 #define _STDARG_H_
3 
4 #include <ultra64.h>
5 
6 // When building with GCC, use the official vaarg macros to avoid warnings
7 // and possibly bad codegen.
8 #ifdef __GNUC__
9 #define va_list __builtin_va_list
10 #define va_start __builtin_va_start
11 #define va_arg __builtin_va_arg
12 #define va_end __builtin_va_end
13 #else
14 
15 typedef char *va_list;
16 #define _FP 1
17 #define _INT 0
18 #define _STRUCT 2
19 
20 #define _VA_FP_SAVE_AREA 0x10
21 #define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4))
22 #define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN)))
23 
24 #define __va_stack_arg(list, mode) \
25  ( \
26  ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \
27  _VA_ALIGN(sizeof(mode), 4)), \
28  (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode))))
29 
30 #define __va_double_arg(list, mode) \
31  ( \
32  (((long)list & 0x1) /* 1 byte aligned? */ \
33  ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \
34  : (((long)list & 0x2) /* 2 byte aligned? */ \
35  ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \
36  : __va_stack_arg(list, mode))))
37 
38 #define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \
39  __builtin_alignof(mode) == sizeof(double)) \
40  ? __va_double_arg(list, mode) \
41  : __va_stack_arg(list, mode))))[-1]
42 #define va_end(__list)
43 
44 #endif
45 #endif
char * va_list
Definition: stdarg.h:15