revert between 56095 -> 55830 in arch
[AROS.git] / tools / genmodule / writegetlibbase.c
blob348acefd902636fba7bf9f21069e037ac0867b7b
1 /*
2 Copyright © 2012-2017, The AROS Development Team. All rights reserved.
3 $Id$
5 Function to write module_getlibbase.c. Part of genmodule.
6 */
8 #include "genmodule.h"
10 void writegetlibbase(struct config *cfg, int is_rel)
12 FILE *out;
13 char line[256], *banner;
15 snprintf(line, 255, "%s/%s_%sgetlibbase.c",
16 cfg->libgendir, cfg->modulename, is_rel ? "rel" : ""
18 out = fopen(line, "w");
20 if (out==NULL)
22 perror(line);
23 exit(20);
26 banner = getBanner(cfg);
27 fprintf(out, "%s\n", banner);
28 freeBanner(banner);
30 if (!is_rel)
32 fprintf(out,
33 "extern %s%s;\n"
34 "\n"
35 "%s__aros_getbase_%s(void)\n"
36 "{\n"
37 " return %s;\n"
38 "}\n",
39 cfg->libbasetypeptrextern, cfg->libbase,
40 cfg->libbasetypeptrextern, cfg->libbase,
41 cfg->libbase
44 else /* is_rel */
46 fprintf(out,
47 "#include <exec/types.h>\n"
48 "char *__aros_getoffsettable(void);\n"
49 "extern IPTR __aros_rellib_offset_%s;\n"
50 "\n"
51 "%s__aros_getbase_%s(void)\n"
52 "{\n"
53 " return *((%s*)(__aros_getoffsettable()+__aros_rellib_offset_%s));\n"
54 "}\n",
55 cfg->libbase,
56 cfg->libbasetypeptrextern, cfg->libbase,
57 cfg->libbasetypeptrextern, cfg->libbase
60 fclose(out);