Don't know what to say here, but this doesn't look good. But the solution should be probably getting away from underlying libc and using own printf impl for any port.