X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tools%2Fmkbridge.c;h=29bdd9a55a708547c58d269fb284e68ac8fef7d8;hb=ee554c95296119b6b8d82856fbb09ffb8c9dc419;hp=a5dd2b8487629f0ce9a39d8f482af1cd2f78165d;hpb=1f84f6b3a3aa6ddbdcd8428b311e6049aeec4385;p=ia32rtools.git diff --git a/tools/mkbridge.c b/tools/mkbridge.c index a5dd2b8..29bdd9a 100644 --- a/tools/mkbridge.c +++ b/tools/mkbridge.c @@ -1,12 +1,18 @@ +/* + * ia32rtools + * (C) notaz, 2013,2014 + * + * This work is licensed under the terms of 3-clause BSD license. + * See COPYING file in the top-level directory. + */ + #include #include #include #include "my_assert.h" #include "my_str.h" - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#define IS(w, y) !strcmp(w, y) +#include "common.h" #include "protoparse.h" @@ -177,7 +183,21 @@ static void out_fromasm_x86(FILE *f, const char *sym, pp->is_fastcall ? "__fastcall" : (pp->is_stdcall ? "__stdcall" : "__cdecl")); if (ret64) - fprintf(f, " ret64"); + fprintf(f, " ret64"); + if (!pp->is_fastcall && pp->argc_reg != 0) + fprintf(f, " +reg"); + + if (pp->is_stdcall && !pp->is_fastcall && pp->argc_reg != 0 + && !IS_START(sym, "sub_") && !IS_START(sym, "f_")) + { + // alias for possible .def export + char sym2[256]; + + snprintf(sym2, sizeof(sym2), "_%s@%d", + sym, pp->argc * 4); + fprintf(f, "\n.global %s # for .def\n", sym2); + fprintf(f, "%s:", sym2); + } fprintf(f, "\n.global %s\n", sym); fprintf(f, "%s:\n", sym); @@ -310,7 +330,7 @@ int main(int argc, char *argv[]) my_assert_not(fout, NULL); fprintf(fout, ".text\n\n"); - fprintf(fout, "# to asm\n\n"); + fprintf(fout, "# C -> asm\n\n"); while (fgets(line, sizeof(line), fsyms_to)) { @@ -331,7 +351,7 @@ int main(int argc, char *argv[]) out_toasm_x86(fout, sym_noat, pp); } - fprintf(fout, "# from asm\n\n"); + fprintf(fout, "# asm -> C\n\n"); while (fgets(line, sizeof(line), fsyms_from)) {