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
)
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_stubs.c", cfg
->gendir
, cfg
->modulename
);
18 out
= fopen(line
, "w");
26 banner
= getBanner(cfg
);
31 "#define NOLIBDEFINES\n"
32 "#define NOLIBINLINE\n"
33 "/* Be sure that the libbases are included in the stubs file */\n"
34 "#undef __NOLIBBASE__\n"
35 "#undef __%s_NOLIBBASE__\n",
36 banner
, cfg
->modulenameupper
40 if (cfg
->modtype
!= MCC
&& cfg
->modtype
!= MUI
&& cfg
->modtype
!= MCP
)
42 fprintf(out
, "#include <proto/%s.h>\n", cfg
->modulename
);
48 "#include <exec/types.h>\n"
49 "#include <aros/cpu.h>\n"
50 "#include <aros/libcall.h>\n"
54 for (funclistit
= cfg
->funclist
;
56 funclistit
= funclistit
->next
59 if (funclistit
->lvo
>= cfg
->firstlvo
)
61 if (funclistit
->libcall
!= STACK
)
63 int nargs
= 0, nquad
= 0;
64 int isvoid
= strcmp(funclistit
->type
, "void") == 0
65 || strcmp(funclistit
->type
, "VOID") == 0;
70 funclistit
->type
, funclistit
->name
72 for (arglistit
= funclistit
->arguments
;
74 arglistit
= arglistit
->next
77 if (arglistit
!= funclistit
->arguments
)
79 fprintf(out
, "%s", arglistit
->arg
);
80 if (strchr(arglistit
->reg
, '/')) {
92 " %sAROS_LC%d%s(%s, %s,\n",
93 (isvoid
) ? "" : "return ",
94 funclistit
->argcount
, (isvoid
) ? "NR" : "",
95 funclistit
->type
, funclistit
->name
98 for (arglistit
= funclistit
->arguments
;
100 arglistit
= arglistit
->next
103 type
= getargtype(arglistit
);
104 name
= getargname(arglistit
);
105 assert(type
!= NULL
&& name
!= NULL
);
107 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
108 type
, name
, arglistit
->reg
114 else /* nquad != 0 */
120 " %sAROS_LCQUAD%d%s(%s, %s, \\\n",
121 (isvoid
) ? "" : "return ",
122 funclistit
->argcount
, (isvoid
) ? "NR" : "",
123 funclistit
->type
, funclistit
->name
131 " %sAROS_LC%dQUAD%d%s(%s, %s, \\\n",
132 (isvoid
) ? "" : "return ",
133 nargs
, nquad
, (isvoid
) ? "NR" : "",
134 funclistit
->type
, funclistit
->name
138 for (arglistit
= funclistit
->arguments
;
140 arglistit
= arglistit
->next
143 char *quad2
= strchr(arglistit
->reg
, '/');
145 type
= getargtype(arglistit
);
146 name
= getargname(arglistit
);
147 assert(type
!= NULL
&& name
!= NULL
);
152 " AROS_LCAQUAD(%s, %s, %s, %s), \\\n",
153 type
, name
, arglistit
->reg
, quad2
+1
160 " AROS_LCA(%s, %s, %s), \\\n",
161 type
, name
, arglistit
->reg
169 fprintf(out
, " %s, %s, %u, %s);\n}\n",
170 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
173 else /* libcall==STACK */
175 fprintf(out
, "AROS_LIBFUNCSTUB(%s, %s, %d)\n",
176 funclistit
->name
, cfg
->libbase
, funclistit
->lvo
180 for (aliasesit
= funclistit
->aliases
;
182 aliasesit
= aliasesit
->next
185 fprintf(out
, "AROS_FUNCALIAS(%s, %s)\n",
186 funclistit
->name
, aliasesit
->s