2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 Function to write module_stubs.c. Part of genmodule.
9 void writestubs(struct config
*cfg
, int is_rel
)
12 char line
[256], *type
, *name
, *banner
;
13 struct functionhead
*funclistit
;
14 struct stringlist
*aliasesit
;
15 struct functionarg
*arglistit
;
17 snprintf(line
, 255, "%s/%s_%sstubs.c", cfg
->gendir
, cfg
->modulename
, is_rel
? "rel" : "");
18 out
= fopen(line
, "w");
26 banner
= getBanner(cfg
);
32 "#define NOLIBINLINE\n"
33 "#define NOLIBDEFINES\n"
34 "#ifndef __%s_NOLIBBASE__\n"
35 "/* Do not include the libbase */\n"
36 "#define __%s_NOLIBBASE__\n"
38 banner
, cfg
->modulenameupper
, cfg
->modulenameupper
45 "#define NOLIBINLINE\n"
46 "#define NOLIBDEFINES\n"
47 "/* Be sure that the libbases are included in the stubs file */\n"
48 "#undef __NOLIBBASE__\n"
49 "#undef __%s_NOLIBBASE__\n",
50 banner
, cfg
->modulenameupper
55 if (cfg
->modtype
!= MCC
&& cfg
->modtype
!= MUI
&& cfg
->modtype
!= MCP
)
57 fprintf(out
, "#include <proto/%s.h>\n", cfg
->modulename
);
59 fprintf(out
, "extern IPTR %s_offset;\n", cfg
->libbase
);
65 "#include <exec/types.h>\n"
66 "#include <aros/cpu.h>\n"
67 "#include <aros/libcall.h>\n"
71 for (funclistit
= cfg
->funclist
;
73 funclistit
= funclistit
->next
76 if (funclistit
->lvo
>= cfg
->firstlvo
)
78 if (funclistit
->libcall
!= STACK
)
80 int nargs
= 0, nquad
= 0;
81 int isvoid
= strcmp(funclistit
->type
, "void") == 0
82 || strcmp(funclistit
->type
, "VOID") == 0;
87 funclistit
->type
, funclistit
->name
89 for (arglistit
= funclistit
->arguments
;
91 arglistit
= arglistit
->next
94 if (arglistit
!= funclistit
->arguments
)
96 fprintf(out
, "%s", arglistit
->arg
);
97 if (strchr(arglistit
->reg
, '/')) {
110 " %s %s = AROS_GET_RELBASE + %s_offset;\n",
111 cfg
->libbasetypeptrextern
, cfg
->libbase
,
117 " %sAROS_LC%d%s(%s, %s,\n",
118 (isvoid
) ? "" : "return ",
119 funclistit
->argcount
, (isvoid
) ? "NR" : "",
120 funclistit
->type
, funclistit
->name
123 for (arglistit
= funclistit
->arguments
;
125 arglistit
= arglistit
->next
128 type
= getargtype(arglistit
);
129 name
= getargname(arglistit
);
130 assert(type
!= NULL
&& name
!= NULL
);
132 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
133 type
, name
, arglistit
->reg
139 else /* nquad != 0 */
143 " %sAROS_LCQUAD%d%s(%s, %s, \\\n",
144 (isvoid
) ? "" : "return ",
145 funclistit
->argcount
, (isvoid
) ? "NR" : "",
146 funclistit
->type
, funclistit
->name
152 " %sAROS_LC%dQUAD%d%s(%s, %s, \\\n",
153 (isvoid
) ? "" : "return ",
154 nargs
, nquad
, (isvoid
) ? "NR" : "",
155 funclistit
->type
, funclistit
->name
159 for (arglistit
= funclistit
->arguments
;
161 arglistit
= arglistit
->next
164 char *quad2
= strchr(arglistit
->reg
, '/');
166 type
= getargtype(arglistit
);
167 name
= getargname(arglistit
);
168 assert(type
!= NULL
&& name
!= NULL
);
173 " AROS_LCAQUAD(%s, %s, %s, %s), \\\n",
174 type
, name
, arglistit
->reg
, quad2
+1
181 " AROS_LCA(%s, %s, %s), \\\n",
182 type
, name
, arglistit
->reg
190 fprintf(out
, " %s, %s, %u, %s);\n}\n",
191 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
194 else /* libcall==STACK */
196 fprintf(out
, "AROS_%sLIBFUNCSTUB(%s, %s, %d)\n",
198 funclistit
->name
, cfg
->libbase
, funclistit
->lvo
202 for (aliasesit
= funclistit
->aliases
;
204 aliasesit
= aliasesit
->next
207 fprintf(out
, "AROS_FUNCALIAS(%s, %s)\n",
208 funclistit
->name
, aliasesit
->s