@halton @pozdnyakov 
I cannot use functions to replace these. If I _must_ change this, the only option is to explode the code (I guess 'goto' is even more forbidden than macros). Remember, this is dealing with C code, not C++ code...
On a side note, Effective C++ recommends using functions instead macros in C++ code (but we deal with C code). Also, it doesn't say macros should not be used. Like here, they are very useful in making the code much more readable.
Here is my challenge: if you can replace these macros with <50 lines functions, I give you 100 euros :)
Anyhow, please advise which way forward: should I explode the code, or continue using these macros.