7 Versionstring: $VER: SDI_misc.h 1.0 (17.05.2005)
10 Project page: http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
11 Description: defines to hide compiler specific function stuff.
12 This header is ment to keep all minor functions
13 like PutChProc() used by RawDoFMT().
15 URL: $URL: svn://svn.code.sf.net/p/adtools/code/trunk/sdi/SDI_misc.h $
17 1.0 17.05.05 : inspired by the SDI_#?.h files made by Jens Langner
18 and Dirk Stöcker I created this file to handle rawdofmt()
23 ** This is PD (Public Domain). This means you can do with it whatever you want
24 ** without any restrictions. I only ask you to tell me improvements, so I may
25 ** fix the main line of this files as well.
27 ** To keep confusion level low: When changing this file, please note it in
28 ** above history list and indicate that the change was not made by myself
29 ** (e.g. add your name or nick name).
31 ** Find the latest version of this file at:
32 ** http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
34 ** Guido Mersmann <geit@gmx.de>
38 #include "SDI_compiler.h"
41 ** Function macros to handle the creation of functions for different
42 ** Operating System versions.
43 ** Currently AmigaOS and MorphOS is supported.
45 ** Currently the following macros are available:
49 ** When using RawDoFmt() from exec.library you need this function to
50 ** store the output created by the function.
52 ** For more information about RawDoFmt() take a look into the
53 ** relevant descriptions in exec.library autodocs.
57 ** struct SPrintfStream
63 ** PUTCHARPROTO( SPrintf_DoChar, char c, struct SPrintfStream *s )
65 ** *(s->Target++) = c;
68 ** ULONG SPrintf(char *format, char *target, ULONG *args)
70 ** struct SPrintfStream s;
74 ** RawDoFmt( format, args, ENTRY( SPrintf_DoChar), &s);
76 ** return( s.Target - target);
79 ** As you can see usage within RawDoFmt() requires using the ENTRY()
86 #ifndef SDI_TRAP_LIB /* avoid defining this twice */
88 #include <proto/alib.h>
89 #include <emul/emulregs.h>
91 #define SDI_TRAP_LIB 0xFF00 /* SDI prefix to reduce conflicts */
93 struct SDI_EmulLibEntry
102 #define PUTCHARPROTO(name, chr, buffer) \
103 SAVEDS ASM void name( chr, buffer); \
104 static void Trampoline_##name(void) { name(( chr) REG_D0, \
106 static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
107 (APTR) Trampoline_##name}; \
108 SAVEDS ASM void name( chr, buffer)
110 #define ENTRY(func) (APTR)&Gate_##func
114 #define PUTCHARPROTO(name, chr, buffer) \
115 SAVEDS ASM void name(REG(d0, chr), REG(a3, buffer))
117 #define ENTRY(func) (APTR)func
119 #endif /* __MORPHOS__ */
121 #endif /* SDI_MISC_H */