I'm using VS2012 Ultimate for some embedded development in C. I compile the code with a platform abstraction and simulate it on my PC. Another person in the company uses CodeWarrior with a PPC abstraction layer and runs the thing on an MPC565 chip. The tasks on the embedded chip occasionally overrun the CPU or time boundaries.
There is quite a bit of trigonometry in the code. I know that the trig execution on the embedded chip is slow. How can I exaggerate the time spent in trig code on my PC? I'm thinking something like this:
#define cos(x) ({ while(asiTimeMsec64() % 10 != 0); cos(x);})
#define sin(x) ({ while(asiTimeMsec64() % 10 != 0); sin(x);})
#define tan(x) ({ while(asiTimeMsec64() % 10 != 0); tan(x);})
However, that code doesn't quite work. I get compiler errors about my cos
calls not returning a number. I would like some kind of spin-lock -- something that doesn't allow other threads to run.
How do I override the math.h trig functions to make them artificially slow?