1 #ifndef AROS_I386_GENMODULE_H
2 #define AROS_I386_GENMODULE_H
5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
8 NOTE: This file must compile *without* any other header !
10 Desc: CPU-specific genmodule definitions for 32-bit x86 processors
14 #include <exec/execbase.h>
16 /* Macros for generating library stub functions and aliases for stack libcalls. */
18 /* Macro: AROS_GM_LIBFUNCSTUB(functionname, libbasename, lvo)
19 This macro will generate code for a stub function for
20 the function 'functionname' of lirary with libbase
21 'libbasename' and 'lvo' number of the function in the
22 vector table. lvo has to be a constant value (not a variable)
24 Internals: a dummy function is used that will generate some
25 unused junk code but otherwise we can't pass input arguments
28 #define __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
29 void __ ## fname ## _ ## libbasename ## _wrapper(void) \
32 ".weak " #fname "\n" \
34 "\tmovl " #libbasename ", %%eax\n" \
35 "\tjmp *%c0(%%eax)\n" \
36 : : "i" ((-lvo*LIB_VECTSIZE)) \
39 #define AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
40 __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo)
42 /* Macro: AROS_GM_RELLIBFUNCSTUB(functionname, libbasename, lvo)
43 Same as AROS_GM_LIBFUNCSTUB but finds libbase at an offset in
46 #define __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
47 void __ ## fname ## _ ## libbasename ## _relwrapper(void) \
50 ".weak " #fname "\n" \
52 "\tcall __aros_getoffsettable\n" \
53 "\taddl __aros_rellib_offset_" #libbasename ", %%eax\n" \
54 "\tmovl (%%eax), %%eax\n" \
55 "\tjmp *%c0(%%eax)\n" \
56 : : "i" ((-lvo*LIB_VECTSIZE)) \
59 #define AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
60 __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo)
62 /* Macro: AROS_GM_LIBFUNCALIAS(functionname, alias)
63 This macro will generate an alias 'alias' for function
66 #define __AROS_GM_LIBFUNCALIAS(fname, alias) \
67 asm(".weak " #alias "\n" \
68 "\t.set " #alias "," #fname \
70 #define AROS_GM_LIBFUNCALIAS(fname, alias) \
71 __AROS_GM_LIBFUNCALIAS(fname, alias)
74 /* Wrapper for stack calls - saves the current base
75 * in the baseslot for this library
77 * Only needed for peropener libraries
79 #define __GM_STRINGIZE(x) #x
80 #define __AROS_GM_STACKCALL(fname, libbasename, libfuncname) \
81 void libfuncname(void); \
82 void __ ## fname ## _stackcall(void) \
85 "\t" __GM_STRINGIZE(libfuncname) " :\n" \
87 "\tcall __aros_setoffsettable\n" \
89 "\tjmp " #fname "\n" \
93 #define AROS_GM_STACKCALL(fname, libbasename, lvo) \
94 __AROS_GM_STACKCALL(fname, libbasename, AROS_SLIB_ENTRY(fname, libbasename, lvo))
97 /* Macro: AROS_GM_STACKALIAS(functionname, libbasename, lvo)
98 This macro will generate an alias 'alias' for function
101 #define __AROS_GM_STACKALIAS(fname, alias) \
103 asm(".weak " __GM_STRINGIZE(alias) "\n" \
104 "\t.set " __GM_STRINGIZE(alias) "," #fname \
106 #define AROS_GM_STACKALIAS(fname, libbasename, lvo) \
107 __AROS_GM_STACKALIAS(fname, AROS_SLIB_ENTRY(fname, libbasename, lvo))
109 #endif /* AROS_I386_GENMODULE_H */