2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Function to write module_stubs.c. Part of genmodule.
11 void writestubs(struct config
*cfg
)
14 char line
[256], *type
, *name
;
15 struct functionhead
*funclistit
;
16 struct stringlist
*aliasesit
;
17 struct functionarg
*arglistit
;
19 snprintf(line
, 255, "%s/%s_stubs.c", cfg
->gendir
, cfg
->modulename
);
20 out
= fopen(line
, "w");
32 "#define NOLIBDEFINES\n"
33 "/* Be sure that the libbases are included in the stubs file */\n"
34 "#undef __NOLIBBASE__\n"
35 "#undef __%s_NOLIBBASE__\n",
36 getBanner(cfg
), cfg
->modulenameupper
39 if (cfg
->intcfg
& CFG_GENASTUBS
)
41 snprintf(line
, 255, "%s/%s_astubs.S", cfg
->gendir
, cfg
->modulename
);
42 outasm
= fopen(line
, "w");
45 fprintf(stderr
, "Could not write %s\n", line
);
48 fprintf(outasm
, "%s", getBanner(cfg
));
49 fprintf(outasm
, STUBCODE_INIT
);
52 if (cfg
->modtype
!= MCC
&& cfg
->modtype
!= MUI
&& cfg
->modtype
!= MCP
)
54 fprintf(out
, "#include <proto/%s.h>\n", cfg
->modulename
);
60 "#include <exec/types.h>\n"
61 "#include <aros/libcall.h>\n"
65 for (funclistit
= cfg
->funclist
;
67 funclistit
= funclistit
->next
70 if (funclistit
->lvo
>= cfg
->firstlvo
)
72 if (funclistit
->libcall
!= STACK
)
74 int isvoid
= strcmp(funclistit
->type
, "void") == 0
75 || strcmp(funclistit
->type
, "VOID") == 0;
80 funclistit
->type
, funclistit
->name
82 for (arglistit
= funclistit
->arguments
;
84 arglistit
= arglistit
->next
87 if (arglistit
!= funclistit
->arguments
)
89 fprintf(out
, "%s", arglistit
->arg
);
95 " return AROS_LC%d%s(%s, %s,\n",
96 funclistit
->argcount
, (isvoid
) ? "NR" : "",
97 funclistit
->type
, funclistit
->name
100 for (arglistit
= funclistit
->arguments
;
102 arglistit
= arglistit
->next
105 type
= getargtype(arglistit
);
106 name
= getargname(arglistit
);
107 assert(type
!= NULL
&& name
!= NULL
);
109 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
110 type
, name
, arglistit
->reg
116 fprintf(out
, " %s, %s, %u, %s);\n}\n",
117 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
120 else /* libcall==STACK */
122 assert(cfg
->intcfg
& CFG_GENASTUBS
);
128 &(__AROS_GETJUMPVEC(NULL
, funclistit
->lvo
)->vec
)
132 for (aliasesit
= funclistit
->aliases
;
134 aliasesit
= aliasesit
->next
137 assert(cfg
->intcfg
& CFG_GENASTUBS
);
139 fprintf(outasm
, ALIASCODE
, funclistit
->name
, aliasesit
->s
);
144 if (cfg
->intcfg
& CFG_GENASTUBS
)