Copied and adopted from musl implementation. * converted all 'long double' to 'double' * removed %m support