7 Versionstring: $VER: SDI_misc.h 1.0 (17.05.2005)
10 Project page: http://www.sf.net/projects/sditools/
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 1.0 17.05.05 : inspired by the SDI_#?.h files made by Jens Langner
16 and Dirk Stöcker I created this file to handle rawdofmt()
21 ** This is PD (Public Domain). This means you can do with it whatever you want
22 ** without any restrictions. I only ask you to tell me improvements, so I may
23 ** fix the main line of this files as well.
25 ** To keep confusion level low: When changing this file, please note it in
26 ** above history list and indicate that the change was not made by myself
27 ** (e.g. add your name or nick name).
29 ** Find the latest version of this file at:
30 ** http://cvs.sourceforge.net/viewcvs.py/sditools/sditools/headers/
32 ** Guido Mersmann <geit@gmx.de>
36 #include "SDI_compiler.h"
39 ** Function macros to handle the creation of functions for different
40 ** Operating System versions.
41 ** Currently AmigaOS and MorphOS is supported.
43 ** Currently the following macros are available:
47 ** When using RawDoFmt() from exec.library you need this function to
48 ** store the output created by the function.
50 ** For more information about RawDoFmt() take a look into the
51 ** relevant descriptions in exec.library autodocs.
55 ** struct SPrintfStream
61 ** PUTCHARPROTO( SPrintf_DoChar, char c, struct SPrintfStream *s )
63 ** *(s->Target++) = c;
66 ** ULONG SPrintf(char *format, char *target, ULONG *args)
68 ** struct SPrintfStream s;
72 ** RawDoFmt( format, args, ENTRY( SPrintf_DoChar), &s);
74 ** return( s.Target - target);
77 ** As you can see usage within RawDoFmt() requires using the ENTRY()
84 #ifndef SDI_TRAP_LIB /* avoid defining this twice */
86 #include <proto/alib.h>
87 #include <emul/emulregs.h>
89 #define SDI_TRAP_LIB 0xFF00 /* SDI prefix to reduce conflicts */
91 struct SDI_EmulLibEntry
100 #define PUTCHARPROTO(name, chr, buffer) \
101 SAVEDS ASM void name( chr, buffer); \
102 static void Trampoline_##name(void) { name(( chr) REG_D0, \
104 static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
105 (APTR) Trampoline_##name}; \
106 SAVEDS ASM void name( chr, buffer)
108 #define ENTRY(func) (APTR)&Gate_##func
112 #define PUTCHARPROTO(name, chr, buffer) \
113 SAVEDS ASM void name(REG(d0, chr), REG(a3, buffer))
115 #define ENTRY(func) (APTR)func
117 #endif /* __MORPHOS__ */
119 #endif /* SDI_MISC_H */