quakeforge/tools/qfcc/test/vecaddr.r
Bill Currie d18ee8dd86 [qfcc] Make vecaddr work in both v6p and Ruamoko
It's full of evil hacks, but has always been an evil hack relying on
undefined behavior. The weird shenanigans with local variables are
because Ruamoko doesn't copy the parameters like v6p does and thus v and
z are NOT adjacent as parameters. Worse, the padding is uninitialized
and thus should not be relied upon to be any particular value. Still
does a nice job of testing dot products, though.
2022-01-30 14:22:05 +09:00

33 lines
482 B
R

void printf (string fmt, ...) = #0;
#if __RUAMOKO__ > 1
#define dot @dot
#define X .y
#else
#define dot *
#define X
#endif
void forcelive (float z)
{
}
float foo (vector _v, float _z)
{
vector v = _v;
float z = _z;
_v = nil;
_z = _z - _z;
forcelive (z);
return (v dot *(vector*)(&v.y))X;
}
int
main (int argc, string *argv)
{
vector v = [1, 2, 3];
vector w = [2, 3, 4];
float f;
printf ("%v %g %g %g\n", v, v dot v, v dot w, f=foo (v, 4));
return f != (v dot w)X;
}