From: Matthew Fernandez Date: Tue, 15 Feb 2022 08:08:30 +0000 (+1100) Subject: Revert "more sqrt" X-Git-Tag: 3.0.0~26^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47dd9598091b8fca57820e34ab5077f73cca4165;p=graphviz Revert "more sqrt" This reverts commit ef77679d9fd51ac7a1a69e5a2635c2280856cd85. This commit was working around a GCC bug. Quoting its predecessor 0dfd6ab3449455907a5a684fb54cb8b54c5befd5 that gives context: work around a bug in GCC: It generates a call to "sqrtf" for "(float)sqrt(d)" but sqrtf doesn't exist in libm.a. reported by: Aaron Digulla As of fe3f9411d2c59b463ab1b64eecfd19f2db55d2fc, Graphviz requires a C99 compiler. C99 guarantees `sqrtf` so even if this “bug” still exists, generating a `sqrtf` call is fine on a C99 toolchain. --- diff --git a/lib/neatogen/matrix_ops.c b/lib/neatogen/matrix_ops.c index 2cb9314d4..420858a1e 100644 --- a/lib/neatogen/matrix_ops.c +++ b/lib/neatogen/matrix_ops.c @@ -622,27 +622,19 @@ void sqrt_vec(int n, float *vec) void sqrt_vecf(int n, float *source, float *target) { int i; - double d; float v; for (i = 0; i < n; i++) { - if ((v = source[i]) >= 0.0) { - /* do this in two steps to avoid a bug in gcc-4.00 on AIX */ - d = sqrt(v); - target[i] = (float) d; - } + if ((v = source[i]) >= 0.0) + target[i] = (float) sqrt(v); } } void invert_sqrt_vec(int n, float *vec) { int i; - double d; float v; for (i = 0; i < n; i++) { - if ((v = vec[i]) > 0.0) { - /* do this in two steps to avoid a bug in gcc-4.00 on AIX */ - d = 1. / sqrt(v); - vec[i] = (float) d; - } + if ((v = vec[i]) > 0.0) + vec[i] = 1.0f / (float) sqrt(v); } }