stmhal: Copy changes to math.c from stm port.