Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / include / SDI_misc.h
blob77fe744eab0c2386df7aa1421a98a495f56cfd90
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://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()
17 functions.
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:
45 ** PUTCHARPROTO
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.
53 ** Example:
55 ** struct SPrintfStream
56 ** {
57 ** char *Target;
58 ** ULONG TargetSize;
59 ** };
61 ** PUTCHARPROTO( SPrintf_DoChar, char c, struct SPrintfStream *s )
62 ** {
63 ** *(s->Target++) = c;
64 ** }
66 ** ULONG SPrintf(char *format, char *target, ULONG *args)
67 ** {
68 ** struct SPrintfStream s;
70 ** s.Target = target;
72 ** RawDoFmt( format, args, ENTRY( SPrintf_DoChar), &s);
74 ** return( s.Target - target);
75 ** }
77 ** As you can see usage within RawDoFmt() requires using the ENTRY()
78 ** macro.
82 #ifdef __MORPHOS__
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
93 UWORD Trap;
94 UWORD pad;
95 APTR Func;
98 #endif
100 #define PUTCHARPROTO(name, chr, buffer) \
101 SAVEDS ASM void name( chr, buffer); \
102 static void Trampoline_##name(void) { name(( chr) REG_D0, \
103 (buffer) REG_A3);} \
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
110 #else
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 */