Check for SYS/GL during library init. Reason is that
[AROS.git] / test / sdi / SDI_misc.h
blob5680139780577f164b993e05fd5e4671da36cfcd
1 #ifndef SDI_MISC_H
2 #define SDI_MISC_H
4 /* Includeheader
6 Name: SDI_misc.h
7 Versionstring: $VER: SDI_misc.h 1.0 (17.05.2005)
8 Author: Guido Mersmann
9 Distribution: PD
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().
14 Id: $Id$
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()
19 functions.
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:
47 ** PUTCHARPROTO
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.
55 ** Example:
57 ** struct SPrintfStream
58 ** {
59 ** char *Target;
60 ** ULONG TargetSize;
61 ** };
63 ** PUTCHARPROTO( SPrintf_DoChar, char c, struct SPrintfStream *s )
64 ** {
65 ** *(s->Target++) = c;
66 ** }
68 ** ULONG SPrintf(char *format, char *target, ULONG *args)
69 ** {
70 ** struct SPrintfStream s;
72 ** s.Target = target;
74 ** RawDoFmt( format, args, ENTRY( SPrintf_DoChar), &s);
76 ** return( s.Target - target);
77 ** }
79 ** As you can see usage within RawDoFmt() requires using the ENTRY()
80 ** macro.
84 #ifdef __MORPHOS__
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
95 UWORD Trap;
96 UWORD pad;
97 APTR Func;
100 #endif
102 #define PUTCHARPROTO(name, chr, buffer) \
103 SAVEDS ASM void name( chr, buffer); \
104 static void Trampoline_##name(void) { name(( chr) REG_D0, \
105 (buffer) REG_A3);} \
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
112 #else
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 */