Resurrected native codesetslib from r27301
[cake.git] / workbench / libs / codesetslib / include / SDI_stdarg.h
bloba7243e6ce0c66031fa488ab1edf2cb23da99935f
1 #ifndef SDI_STDARG_H
2 #define SDI_STDARG_H
4 /* Includeheader
6 Name: SDI_stdarg.h
7 Versionstring: $VER: SDI_stdarg.h 1.0 (05.07.2004)
8 Author: Jens Langner
9 Distribution: PD
10 Project page: http://www.sf.net/projects/sditools/
11 Description: defines to hide OS specific variable arguments
12 function definitions
14 1.0 05.07.04 : initial version
19 ** This is PD (Public Domain). This means you can do with it whatever you want
20 ** without any restrictions. I only ask you to tell me improvements, so I may
21 ** fix the main line of this files as well.
23 ** To keep confusion level low: When changing this file, please note it in
24 ** above history list and indicate that the change was not made by myself
25 ** (e.g. add your name or nick name).
27 ** Find the latest version of this file at:
28 ** http://cvs.sourceforge.net/viewcvs.py/sditools/sditools/headers/
30 ** Jens Langner <Jens.Langner@light-speed.de> and
31 ** Dirk Stöcker <soft@dstoecker.de>
34 #include "SDI_compiler.h"
37 ** Variable arguments function macros to allow specification of the
38 ** variable arguments typical functions like va_list/va_start/va_end in
39 ** an operating system independent fashion.
41 ** With help of the following macro definition a developer might define
42 ** variable arguments functions for different types of operating
43 ** system implementations without having to clutter the sources with
44 ** multiple "#ifdef" defines just because all of these operating systems
45 ** come with different varable arguments support functions.
47 ** Example:
49 ** Instead of using the standard va_list, va_start and va_end functions
50 ** of <stdarg.h>, a developer might specify the following sprintf()
51 ** function to make it automatically compatible with AmigaOS3, AmigaOS4
52 ** and also MorphOS.
54 ** int VARARGS68K sprintf(char *buf, char *fmt, ...)
55 ** {
56 ** VA_LIST args;
58 ** VA_START(args, fmt);
59 ** RawDoFmt(fmt, VA_ARG(args, void *), NULL, buf);
60 ** VA_END(args);
62 ** return(strlen(buf));
63 ** }
65 ** Please note the uppercase letters of the macros in contrast to the
66 ** official varargs functions specified in <stdarg.h>.
68 ** By using this schema a developer might ensure full source code backward
69 ** compatibility to AmigaOS3 without having to introduce dozens of #ifdef
70 ** statements in his code.
73 #include <stdarg.h>
75 #ifdef VA_LIST
76 #undef VA_LIST
77 #endif
78 #ifdef VA_START
79 #undef VA_START
80 #endif
81 #ifdef VA_ARG
82 #undef VA_ARG
83 #endif
84 #ifdef VA_END
85 #undef VA_END
86 #endif
88 #if defined(__amigaos4__)
89 #define VA_LIST va_list
90 #define VA_START(va, start) va_startlinear((va), (start))
91 #define VA_ARG(va, type) va_getlinearva((va), type)
92 #define VA_END(va) va_end((va))
93 #elif defined(__MORPHOS__)
94 #define VA_LIST va_list
95 #define VA_START(va, start) va_start((va), (start))
96 #define VA_ARG(va, type) (va)->overflow_arg_area
97 #define VA_END(va) va_end((va))
98 #else
99 #define VA_LIST va_list
100 #define VA_START(va, start) va_start((va), (start))
101 #define VA_ARG(va, type) (va)
102 #define VA_END(va) va_end((va))
103 #endif
105 #endif /* SDI_STDARG_H */