aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common.h1
-rw-r--r--libglitter_redistribute_energy_double.c25
2 files changed, 24 insertions, 2 deletions
diff --git a/common.h b/common.h
index 3a70c71..33b54dc 100644
--- a/common.h
+++ b/common.h
@@ -55,6 +55,7 @@ struct libglitter_render_context {
# pragma GCC diagnostic ignored "-Wdouble-promotion"
#elif defined(__clang__)
# pragma clang diagnostic ignored "-Wfloat-equal"
+# pragma clang diagnostic ignored "-Wfloat-conversion"
# pragma clang diagnostic ignored "-Wdouble-promotion"
# pragma clang diagnostic ignored "-Wimplicit-float-conversion"
#endif
diff --git a/libglitter_redistribute_energy_double.c b/libglitter_redistribute_energy_double.c
index 6b57c0e..24d6c4a 100644
--- a/libglitter_redistribute_energy_double.c
+++ b/libglitter_redistribute_energy_double.c
@@ -3,12 +3,33 @@
#ifndef TEST
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wfloat-equal"
+#elif defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wfloat-equal"
+#endif
+
+static int
+exactly(double a, double b)
+{
+ return a == b;
+}
+
+#if defined(__GNUC__) && !defined(__clang__)
+# pragma GCC diagnostic pop
+#elif defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
+
static void
vconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height, size_t kernelsize, const double *kernel)
{
size_t y, x, i;
- if (kernelsize == 3 && kernel[0] == kernel[1] && kernel[1] == kernel[2]) {
+ if (kernelsize == 3 && exactly(kernel[0], kernel[1]) && exactly(kernel[1], kernel[2])) {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
raster[x] += raster[x + 1 * rowsize];
@@ -50,7 +71,7 @@ hconvolute(double *restrict raster, size_t rowsize, size_t width, size_t height,
{
size_t y, x, i;
- if (kernelsize == 3 && kernel[0] == kernel[1] && kernel[1] == kernel[2]) {
+ if (kernelsize == 3 && exactly(kernel[0], kernel[1]) && exactly(kernel[1], kernel[2])) {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
raster[x + 1] += raster[x + 2];