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 " return AROS_LC%d%s(%s, %s,\n",
93 funclistit
->argcount
, (isvoid
) ? "NR" : "",
94 funclistit
->type
, funclistit
->name
97 for (arglistit
= funclistit
->arguments
;
99 arglistit
= arglistit
->next
102 type
= getargtype(arglistit
);
103 name
= getargname(arglistit
);
104 assert(type
!= NULL
&& name
!= NULL
);
106 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
107 type
, name
, arglistit
->reg
113 } else { /* nquad != 0 */
118 " return AROS_LCQUAD%d%s(%s, %s, \\\n",
119 funclistit
->argcount
, (isvoid
) ? "NR" : "",
120 funclistit
->type
, funclistit
->name
126 " return AROS_LC%dQUAD%d%s(%s, %s, \\\n",
127 nargs
, nquad
, (isvoid
) ? "NR" : "",
128 funclistit
->type
, funclistit
->name
132 for (arglistit
= funclistit
->arguments
;
134 arglistit
= arglistit
->next
137 char *quad2
= strchr(arglistit
->reg
, '/');
139 type
= getargtype(arglistit
);
140 name
= getargname(arglistit
);
141 assert(type
!= NULL
&& name
!= NULL
);
146 " AROS_LCAQUAD(%s, %s, %s, %s), \\\n",
147 type
, name
, arglistit
->reg
, quad2
+1
152 " AROS_LCA(%s, %s, %s), \\\n",
153 type
, name
, arglistit
->reg
156 arglistit
->reg
[2] = '/';
162 fprintf(out
, " %s, %s, %u, %s);\n}\n",
163 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
166 else /* libcall==STACK */
168 fprintf(out
, "AROS_LIBFUNCSTUB(%s, %s, %d)\n",
169 funclistit
->name
, cfg
->libbase
, funclistit
->lvo
173 for (aliasesit
= funclistit
->aliases
;
175 aliasesit
= aliasesit
->next
178 fprintf(out
, "AROS_FUNCALIAS(%s, %s)\n",
179 funclistit
->name
, aliasesit
->s