start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / test / sdi / SDI_stdarg.h
blob12871689ee68d79d988641bf2228ea403fadd129
1 #ifndef SDI_STDARG_H
2 #define SDI_STDARG_H
4 /* Includeheader
6 Name: SDI_stdarg.h
7 Versionstring: $VER: SDI_stdarg.h 1.1 (06.06.2014)
8 Author: Jens Maus
9 Distribution: PD
10 Project page: http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
11 Description: defines to hide OS specific variable arguments
12 function definitions
13 Id: $Id$
14 URL: $URL: svn://svn.code.sf.net/p/adtools/code/trunk/sdi/SDI_stdarg.h $
16 1.0 05.07.2004 : initial version
17 1.1 06.06.2014 : added a type cast to VA_ARG() result
22 ** This is PD (Public Domain). This means you can do with it whatever you want
23 ** without any restrictions. I only ask you to tell me improvements, so I may
24 ** fix the main line of this files as well.
26 ** To keep confusion level low: When changing this file, please note it in
27 ** above history list and indicate that the change was not made by myself
28 ** (e.g. add your name or nick name).
30 ** Find the latest version of this file at:
31 ** http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
33 ** Jens Maus <mail@jens-maus.de>
34 ** Dirk Stöcker <soft@dstoecker.de>
37 #include "SDI_compiler.h"
40 ** Variable arguments function macros to allow specification of the
41 ** variable arguments typical functions like va_list/va_start/va_end in
42 ** an operating system independent fashion.
44 ** With help of the following macro definition a developer might define
45 ** variable arguments functions for different types of operating
46 ** system implementations without having to clutter the sources with
47 ** multiple "#ifdef" defines just because all of these operating systems
48 ** come with different varable arguments support functions.
50 ** Example:
52 ** Instead of using the standard va_list, va_start and va_end functions
53 ** of <stdarg.h>, a developer might specify the following sprintf()
54 ** function to make it automatically compatible with AmigaOS3, AmigaOS4
55 ** and also MorphOS.
57 ** int VARARGS68K sprintf(char *buf, char *fmt, ...)
58 ** {
59 ** VA_LIST args;
61 ** VA_START(args, fmt);
62 ** RawDoFmt(fmt, VA_ARG(args, void *), NULL, buf);
63 ** VA_END(args);
65 ** return(strlen(buf));
66 ** }
68 ** Please note the uppercase letters of the macros in contrast to the
69 ** official varargs functions specified in <stdarg.h>.
71 ** By using this schema a developer might ensure full source code backward
72 ** compatibility to AmigaOS3 without having to introduce dozens of #ifdef
73 ** statements in his code.
76 #include <stdarg.h>
78 #ifdef VA_LIST
79 #undef VA_LIST
80 #endif
81 #ifdef VA_START
82 #undef VA_START
83 #endif
84 #ifdef VA_ARG
85 #undef VA_ARG
86 #endif
87 #ifdef VA_END
88 #undef VA_END
89 #endif
91 #if defined(__amigaos4__)
92 #define VA_LIST va_list
93 #define VA_START(va, start) va_startlinear((va), (start))
94 #define VA_ARG(va, type) va_getlinearva((va), type)
95 #define VA_END(va) va_end((va))
96 #elif defined(__MORPHOS__)
97 #define VA_LIST va_list
98 #define VA_START(va, start) va_start((va), (start))
99 #define VA_ARG(va, type) (type)((va)->overflow_arg_area)
100 #define VA_END(va) va_end((va))
101 #else
102 #define VA_LIST va_list
103 #define VA_START(va, start) va_start((va), (start))
104 #define VA_ARG(va, type) (type)(va)
105 #define VA_END(va) va_end((va))
106 #endif
108 #endif /* SDI_STDARG_H */