2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Function to write module_stubs.c. Part of genmodule.
10 void writestubs(struct config
*cfg
, int is_rel
)
13 char line
[256], *type
, *name
, *banner
;
14 struct functionhead
*funclistit
;
15 struct stringlist
*aliasesit
;
16 struct functionarg
*arglistit
;
18 snprintf(line
, 255, "%s/%s_%sstubs.c", cfg
->gendir
, cfg
->modulename
, is_rel
? "rel" : "");
19 out
= fopen(line
, "w");
27 banner
= getBanner(cfg
);
33 "#undef NOLIBINLINE\n"
34 "#undef NOLIBDEFINES\n"
35 "#define NOLIBINLINE\n"
36 "#define NOLIBDEFINES\n"
37 "char *__aros_getoffsettable(void);\n"
38 "#ifndef __%s_NOLIBBASE__\n"
39 "/* Do not include the libbase */\n"
40 "#define __%s_NOLIBBASE__\n"
42 banner
, cfg
->modulenameupper
, cfg
->modulenameupper
49 "#undef NOLIBINLINE\n"
50 "#undef NOLIBDEFINES\n"
51 "#define NOLIBINLINE\n"
52 "#define NOLIBDEFINES\n"
53 "/* Be sure that the libbases are included in the stubs file */\n"
54 "#undef __NOLIBBASE__\n"
55 "#undef __%s_NOLIBBASE__\n",
56 banner
, cfg
->modulenameupper
61 if (!(cfg
->options
& OPTION_NOINCLUDES
))
64 fprintf(out
, "#define __%s_RELLIBBASE__\n", cfg
->modulenameupper
);
65 fprintf(out
, "#include <proto/%s.h>\n", cfg
->modulename
);
71 "#include <stddef.h>\n"
73 "#include <aros/cpu.h>\n"
74 "#include <aros/genmodule.h>\n"
75 "#include <aros/libcall.h>\n"
79 for (funclistit
= cfg
->funclist
;
81 funclistit
= funclistit
->next
84 if (funclistit
->lvo
>= cfg
->firstlvo
)
86 if (funclistit
->libcall
!= STACK
)
88 int nargs
= 0, nquad
= 0;
89 int isvoid
= strcmp(funclistit
->type
, "void") == 0
90 || strcmp(funclistit
->type
, "VOID") == 0;
95 funclistit
->type
, funclistit
->name
97 for (arglistit
= funclistit
->arguments
;
99 arglistit
= arglistit
->next
102 if (arglistit
!= funclistit
->arguments
)
104 fprintf(out
, "%s", arglistit
->arg
);
105 if (strchr(arglistit
->reg
, '/')) {
118 " %sAROS_LC%d%s(%s, %s,\n",
119 (isvoid
) ? "" : "return ",
120 funclistit
->argcount
, (isvoid
) ? "NR" : "",
121 funclistit
->type
, funclistit
->name
124 for (arglistit
= funclistit
->arguments
;
126 arglistit
= arglistit
->next
129 type
= getargtype(arglistit
);
130 name
= getargname(arglistit
);
131 assert(type
!= NULL
&& name
!= NULL
);
133 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
134 type
, name
, arglistit
->reg
140 else /* nquad != 0 */
144 " %sAROS_LCQUAD%d%s(%s, %s, \\\n",
145 (isvoid
) ? "" : "return ",
146 funclistit
->argcount
, (isvoid
) ? "NR" : "",
147 funclistit
->type
, funclistit
->name
153 " %sAROS_LC%dQUAD%d%s(%s, %s, \\\n",
154 (isvoid
) ? "" : "return ",
155 nargs
, nquad
, (isvoid
) ? "NR" : "",
156 funclistit
->type
, funclistit
->name
160 for (arglistit
= funclistit
->arguments
;
162 arglistit
= arglistit
->next
165 char *quad2
= strchr(arglistit
->reg
, '/');
167 type
= getargtype(arglistit
);
168 name
= getargname(arglistit
);
169 assert(type
!= NULL
&& name
!= NULL
);
174 " AROS_LCAQUAD(%s, %s, %s, %s), \\\n",
175 type
, name
, arglistit
->reg
, quad2
+1
182 " AROS_LCA(%s, %s, %s), \\\n",
183 type
, name
, arglistit
->reg
191 fprintf(out
, " %s, __aros_getbase_%s(), %u, %s);\n}\n",
192 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
195 else /* libcall==STACK */
197 fprintf(out
, "AROS_GM_%sLIBFUNCSTUB(%s, %s, %d)\n",
199 funclistit
->name
, cfg
->libbase
, funclistit
->lvo
203 for (aliasesit
= funclistit
->aliases
;
205 aliasesit
= aliasesit
->next
208 fprintf(out
, "AROS_GM_LIBFUNCALIAS(%s, %s)\n",
209 funclistit
->name
, aliasesit
->s