2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
5 Function to write module_stubs.c. Part of genmodule.
7 #include "archspecific.h"
10 void writestubs(struct config
*cfg
)
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_stubs.c", cfg
->gendir
, cfg
->modulename
);
19 out
= fopen(line
, "w");
27 banner
= getBanner(cfg
);
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 banner
, 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", banner
);
49 fprintf(outasm
, STUBCODE_INIT
);
53 if (cfg
->modtype
!= MCC
&& cfg
->modtype
!= MUI
&& cfg
->modtype
!= MCP
)
55 fprintf(out
, "#include <proto/%s.h>\n", cfg
->modulename
);
61 "#include <exec/types.h>\n"
62 "#include <aros/libcall.h>\n"
66 for (funclistit
= cfg
->funclist
;
68 funclistit
= funclistit
->next
71 if (funclistit
->lvo
>= cfg
->firstlvo
)
73 if (funclistit
->libcall
!= STACK
)
75 int isvoid
= strcmp(funclistit
->type
, "void") == 0
76 || strcmp(funclistit
->type
, "VOID") == 0;
81 funclistit
->type
, funclistit
->name
83 for (arglistit
= funclistit
->arguments
;
85 arglistit
= arglistit
->next
88 if (arglistit
!= funclistit
->arguments
)
90 fprintf(out
, "%s", arglistit
->arg
);
96 " return AROS_LC%d%s(%s, %s,\n",
97 funclistit
->argcount
, (isvoid
) ? "NR" : "",
98 funclistit
->type
, funclistit
->name
101 for (arglistit
= funclistit
->arguments
;
103 arglistit
= arglistit
->next
106 type
= getargtype(arglistit
);
107 name
= getargname(arglistit
);
108 assert(type
!= NULL
&& name
!= NULL
);
110 fprintf(out
, " AROS_LCA(%s,%s,%s),\n",
111 type
, name
, arglistit
->reg
117 fprintf(out
, " %s, %s, %u, %s);\n}\n",
118 cfg
->libbasetypeptrextern
, cfg
->libbase
, funclistit
->lvo
, cfg
->basename
121 else /* libcall==STACK */
123 assert(cfg
->intcfg
& CFG_GENASTUBS
);
129 -funclistit
->lvo
*LIB_VECTSIZE
133 for (aliasesit
= funclistit
->aliases
;
135 aliasesit
= aliasesit
->next
138 assert(cfg
->intcfg
& CFG_GENASTUBS
);
140 fprintf(outasm
, ALIASCODE
, funclistit
->name
, aliasesit
->s
);
145 if (cfg
->intcfg
& CFG_GENASTUBS
)