]> granicus.if.org Git - graphviz/commitdiff
Revert "more sqrt"
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 15 Feb 2022 08:08:30 +0000 (19:08 +1100)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 16 Feb 2022 10:06:30 +0000 (21:06 +1100)
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 <digulla@hepe.com>

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.

lib/neatogen/matrix_ops.c

index 2cb9314d4ae52b417719e643824083118b89ea79..420858a1e7113cd9263373d4eb17c96a903bfb24 100644 (file)
@@ -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);
     }
 }