[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: goo 0_153 now available
I've got goo 0_153 working under Windows and will release the binaries
shortly. I've managed to work around the lack of VARARG macros in
VC. It's ugly but works.
In grt.h add an #else to the block that defines the XCALLN, etc
macros:
--------------8<----------------
#if !defined(_MSC_VER)
#define CALLN(...) _CALLN(regs, __VA_ARGS__)
#define XCALL0(...) _CALL0(REGSCREF(), __VA_ARGS__)
#define XCALL1(...) _CALL1(REGSCREF(), __VA_ARGS__)
#define XCALL2(...) _CALL2(REGSCREF(), __VA_ARGS__)
#define XCALL3(...) _CALL3(REGSCREF(), __VA_ARGS__)
#define XCALL4(...) _CALL4(REGSCREF(), __VA_ARGS__)
#define XCALL5(...) _CALL5(REGSCREF(), __VA_ARGS__)
#define XCALLN(...) _CALLN(REGSCREF(), __VA_ARGS__)
#define XXCALL0(...) _CALL0(REGSREF(), __VA_ARGS__)
#define XXCALL1(...) _CALL1(REGSREF(), __VA_ARGS__)
#define XXCALL2(...) _CALL2(REGSREF(), __VA_ARGS__)
#define XXCALL3(...) _CALL3(REGSREF(), __VA_ARGS__)
#define XXCALL4(...) _CALL4(REGSREF(), __VA_ARGS__)
#define XXCALL5(...) _CALL5(REGSREF(), __VA_ARGS__)
#define XXCALLN(...) _CALLN(REGSREF(), __VA_ARGS__)
#else
IMPORTEXPORT EXTTVAR(msc_calln_regs);
IMPORTEXPORT extern P _MSC_CALLN (int check, P fun, int n, ...);
#define CALLN (TSET(msc_calln_regs, regs),_MSC_CALLN)
#define XCALL0(check, fun) _CALL0(REGSCREF(), check, fun)
#define XCALL1(check, fun, a1) _CALL1(REGSCREF(), check, fun, a1)
#define XCALL2(check, fun, a1, a2) _CALL2(REGSCREF(), check, fun, a1, a2)
#define XCALL3(check, fun, a1, a2, a3) _CALL3(REGSCREF(), check, fun, a1, a2, a3)
#define XCALL4(check, fun, a1, a2, a3, a4) _CALL4(REGSCREF(), check, fun, a1, a2, a3, a4)
#define XCALL5(check, fun, a1, a2, a3, a4, a5) _CALL5(REGSCREF(), check, fun, a1, a2, a3, a4, a5)
#define XCALLN (TSET(msc_calln_regs, REGSCREF()),_MSC_CALLN)
#define XXCALL0(check, fun) _CALL0(REGSREF(), check, fun)
#define XXCALL1(check, fun, a1) _CALL1(REGSREF(), check, fun, a1)
#define XXCALL2(check, fun, a1, a2) _CALL2(REGSREF(), check, fun, a1, a2)
#define XXCALL3(check, fun, a1, a2, a3) _CALL3(REGSREF(), check, fun, a1, a2, a3)
#define XXCALL4(check, fun, a1, a2, a3, a4) _CALL4(REGSREF(), check, fun, a1, a2, a3, a4)
#define XXCALL5(check, fun, a1, a2, a3, a4, a5) _CALL5(REGSREF(), check, fun, a1, a2, a3, a4, a5)
#define XXCALLN (TSET(msc_calln_regs,REGSREF()),_MSC_CALLN)
#endif
--------------8<----------------
Note that addition of a thread local variable, msc_calln_regs, and the
change to the macros. The CALLN style macros now set msc_calln_regs to
the required 'regs' value before calling the _MSC_CALLN function. This
is done using the sequence seperator in (the ',').
In grt.c I added:
--------------8<----------------
#if defined(_MSC_VER)
DEFTVAR(msc_calln_regs);
P _MSC_CALLN (int check, P fun, int n, ...) {
REGS regs = (REGS)TREF(msc_calln_regs);
int i;
P res;
va_list ap; va_start(ap, n);
INC_STACK(n);
for (i = 0; i < n; i++)
REG(sp)[- i - 1] = va_arg(ap, P);
va_end(ap);
PUSH((P)(PINT)n);
PUSH(fun);
if(check)
YPcheck_call_types();
res = FUNCALL(fun);
DEC_STACK(n+2);
return res;
}
#endif
--------------8<----------------
This adds the definition of the msc_calln_regs variable and the
function to extract the value from it.
Like I said, it's ugly, but it allows compiling Goo 0_153 under MSVC with
no other source code changes. Previously I used to have to modify
g2c.goo to generate the expanded macros and rebuild g2c before
compiling under MSVC.
Chris.
--
http://radio.weblogs.com/0102385