[v2] build: Ensure config.h does not undefine `sqrtf`

Submitted by Peter TB Brett on Oct. 10, 2016, 1:26 p.m.

Details

Message ID a4b60a03-a08b-f401-451c-33e28502bed1@peter-b.co.uk
State New
Headers show
Series "build: Ensure config.h does not undefine `sqrtf`" ( rev: 2 ) in Pixman

Not browsing as part of any series.

Commit Message

Peter TB Brett Oct. 10, 2016, 1:26 p.m.
On Windows, `sqrtf` is a macro.  Previously, `configure` was detecting
`sqrtf`'s availability, but then undefining it in `config.h`,
resulting in link failures.

This patch modifies `configure` to use `HAVE_SQRTF` as a feature macro
for the `sqrtf()` function, and adds an additional stanza to
`pixman-compiler.h` which defines a suitable alternative when
`HAVE_SQRTF` is not defined.

Signed-off-by: Peter TB Brett <peter.brett@livecode.com>

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index e833e45..5f57ea5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -932,9 +932,10 @@  fi
  dnl =====================================
  dnl Check for missing sqrtf() as, e.g., for Solaris 9

-AC_SEARCH_LIBS([sqrtf], [m], [],
-               [AC_DEFINE([sqrtf], [sqrt],
-                          [Define to sqrt if you do not have the 
`sqrtf' function.])])
+AC_SEARCH_LIBS([sqrtf], [m],
+               [AC_DEFINE([HAVE_SQRTF], [1],
+                          [Whether we have sqrtf()])],
+               [])

  dnl =====================================
  dnl Thread local storage
diff --git a/pixman/pixman-compiler.h b/pixman/pixman-compiler.h
index 2489adc..3b52101 100644
--- a/pixman/pixman-compiler.h
+++ b/pixman/pixman-compiler.h
@@ -71,6 +71,11 @@ 
  # define M_PI      3.14159265358979323846
  #endif

+#ifndef HAVE_SQRTF
+# define sqrtf sqrt
+#endif
+
+
  #ifdef _MSC_VER
  /* 'inline' is available only in C++ in MSVC */
  #   define inline __inline