List.mui: Update entries count prior to range change
[AROS.git] / arch / i386-all / include / aros / genmodule.h
blobc09522ba20ec5892df7bb84e5a938bfdf45de0bc
1 #ifndef AROS_I386_GENMODULE_H
2 #define AROS_I386_GENMODULE_H
4 /*
5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 $Id$
8 NOTE: This file must compile *without* any other header !
10 Desc: CPU-specific genmodule definitions for 32-bit x86 processors
11 Lang: english
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
26 to the asm statement
28 #define __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
29 void __ ## fname ## _ ## libbasename ## _wrapper(void) \
30 { \
31 asm volatile( \
32 ".weak " #fname "\n" \
33 #fname " :\n" \
34 "\tmovl " #libbasename ", %%eax\n" \
35 "\tjmp *%c0(%%eax)\n" \
36 : : "i" ((-lvo*LIB_VECTSIZE)) \
37 ); \
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
44 the current libbase
46 #define __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
47 void __ ## fname ## _ ## libbasename ## _relwrapper(void) \
48 { \
49 asm volatile( \
50 ".weak " #fname "\n" \
51 "\t" #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)) \
57 ); \
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
64 'functionname'
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) \
83 { \
84 asm volatile( \
85 "\t" __GM_STRINGIZE(libfuncname) " :\n" \
86 "\tpush %eax\n" \
87 "\tcall __aros_setoffsettable\n" \
88 "\tpop %eax\n" \
89 "\tjmp " #fname "\n" \
90 ); \
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
99 'functionname'
101 #define __AROS_GM_STACKALIAS(fname, alias) \
102 void alias(void); \
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 */