ref: 2e48ce132e011e83517a9fc4905edcc8f9a5ef58
parent: 4fcc1ea6012dbb25aeb94397d81f364fab81a58d
author: Ben Harris <bjh21@bjh21.me.uk>
date: Tue Apr 4 17:43:25 EDT 2023
Replace <math.h> with <tgmath.h> throughout C89 provided only double-precision mathematical functions (sin() etc), and so despite using single-precision elsewhere, those are what Puzzles has traditionally used. C99 introduced single-precision equivalents (sinf() etc), and I hope it's been long enough that we can safely use them. Maybe they'll even be faster. Rather than directly use the single-precision functions, though, we use the magic macros from <tgmath.h> that automatically choose the precision of mathematical functions based on their arguments. This has the advantage that we only need to change which header we include, and thus that we can switch back again if some platform has trouble with the new header.
--- a/auxiliary/hat-test.c
+++ b/auxiliary/hat-test.c
@@ -5,7 +5,7 @@
*/
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
--- a/auxiliary/hatgen.c
+++ b/auxiliary/hatgen.c
@@ -16,7 +16,7 @@
*/
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
--- a/blackbox.c
+++ b/blackbox.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/bridges.c
+++ b/bridges.c
@@ -73,7 +73,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/cmake/testbuild.c
+++ b/cmake/testbuild.c
@@ -5,7 +5,7 @@
#include <stdarg.h>
#include <string.h>
#include <errno.h>
-#include <math.h>
+#include <tgmath.h>
#include <sys/time.h>
#include <sys/resource.h>
--- a/cube.c
+++ b/cube.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/dominosa.c
+++ b/dominosa.c
@@ -48,7 +48,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/drawing.c
+++ b/drawing.c
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/fifteen.c
+++ b/fifteen.c
@@ -8,7 +8,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/filling.c
+++ b/filling.c
@@ -58,7 +58,7 @@
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
--- a/flip.c
+++ b/flip.c
@@ -9,7 +9,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/flood.c
+++ b/flood.c
@@ -32,7 +32,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/galaxies.c
+++ b/galaxies.c
@@ -80,7 +80,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/grid.c
+++ b/grid.c
@@ -13,7 +13,7 @@
#include <ctype.h>
#include <float.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/gtk.c
+++ b/gtk.c
@@ -13,7 +13,7 @@
#include <stdarg.h>
#include <string.h>
#include <errno.h>
-#include <math.h>
+#include <tgmath.h>
#include <unistd.h>
#include <sys/time.h>
--- a/guess.c
+++ b/guess.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/hat.c
+++ b/hat.c
@@ -12,7 +12,7 @@
*/
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
--- a/inertia.c
+++ b/inertia.c
@@ -12,7 +12,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/keen.c
+++ b/keen.c
@@ -8,7 +8,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "latin.h"
--- a/lightup.c
+++ b/lightup.c
@@ -48,7 +48,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/loopgen.c
+++ b/loopgen.c
@@ -8,7 +8,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/loopy.c
+++ b/loopy.c
@@ -77,7 +77,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/magnets.c
+++ b/magnets.c
@@ -37,7 +37,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/map.c
+++ b/map.c
@@ -15,7 +15,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/mines.c
+++ b/mines.c
@@ -13,7 +13,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "tree234.h"
#include "puzzles.h"
--- a/misc.c
+++ b/misc.c
@@ -3,7 +3,7 @@
*/
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
--- a/mosaic.c
+++ b/mosaic.c
@@ -14,7 +14,7 @@
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--- a/net.c
+++ b/net.c
@@ -8,7 +8,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/netslide.c
+++ b/netslide.c
@@ -9,7 +9,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/nullgame.c
+++ b/nullgame.c
@@ -16,7 +16,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/pattern.c
+++ b/pattern.c
@@ -8,7 +8,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/pearl.c
+++ b/pearl.c
@@ -36,7 +36,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "grid.h"
--- a/pegs.c
+++ b/pegs.c
@@ -8,7 +8,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/penrose.c
+++ b/penrose.c
@@ -9,7 +9,7 @@
#include <assert.h>
#include <string.h>
-#include <math.h>
+#include <tgmath.h>
#include <stdio.h>
#include "puzzles.h" /* for malloc routines, and PI */
--- a/range.c
+++ b/range.c
@@ -58,7 +58,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/rect.c
+++ b/rect.c
@@ -26,7 +26,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/samegame.c
+++ b/samegame.c
@@ -68,7 +68,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/signpost.c
+++ b/signpost.c
@@ -8,7 +8,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/singles.c
+++ b/singles.c
@@ -58,7 +58,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "latin.h"
--- a/sixteen.c
+++ b/sixteen.c
@@ -10,7 +10,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/slant.c
+++ b/slant.c
@@ -28,7 +28,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/solo.c
+++ b/solo.c
@@ -87,7 +87,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#ifdef STANDALONE_SOLVER
#include <stdarg.h>
--- a/tents.c
+++ b/tents.c
@@ -33,7 +33,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "matching.h"
--- a/towers.c
+++ b/towers.c
@@ -23,7 +23,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "latin.h"
--- a/tracks.c
+++ b/tracks.c
@@ -21,7 +21,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/twiddle.c
+++ b/twiddle.c
@@ -11,7 +11,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/undead.c
+++ b/undead.c
@@ -35,7 +35,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/unequal.c
+++ b/unequal.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "latin.h" /* contains typedef for digit */
--- a/unfinished/group.c
+++ b/unfinished/group.c
@@ -31,7 +31,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "latin.h"
--- a/unfinished/numgame.c
+++ b/unfinished/numgame.c
@@ -40,7 +40,7 @@
#include <string.h>
#include <limits.h>
#include <assert.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/unfinished/separate.c
+++ b/unfinished/separate.c
@@ -94,7 +94,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/unfinished/slide.c
+++ b/unfinished/slide.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"
--- a/unfinished/sokoban.c
+++ b/unfinished/sokoban.c
@@ -58,7 +58,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/unruly.c
+++ b/unruly.c
@@ -47,7 +47,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
--- a/untangle.c
+++ b/untangle.c
@@ -32,7 +32,7 @@
#include <assert.h>
#include <ctype.h>
#include <limits.h>
-#include <math.h>
+#include <tgmath.h>
#include "puzzles.h"
#include "tree234.h"