chiark / gitweb /
handle missing C99/IEEE copysign function, e.g. for WWin32; thanks to Benoit Scherrer...
authorstevenj <stevenj@alum.mit.edu>
Fri, 30 Jul 2010 02:35:46 +0000 (22:35 -0400)
committerstevenj <stevenj@alum.mit.edu>
Fri, 30 Jul 2010 02:35:46 +0000 (22:35 -0400)
darcs-hash:20100730023546-c8de0-2d82e58615ba8036734a2b104aefb4a53a88f9b5.gz

configure.ac
util/nlopt-util.h

index 7c88f3d48f320e2fd1d3eae14971cfbac1a275ad..b5c6d2a1d72cc49c9b37a789bf2d5d4c5671a416 100644 (file)
@@ -86,6 +86,14 @@ if test "$ok" = "yes"; then
 fi
 AC_MSG_RESULT(${ok})
 
+AC_MSG_CHECKING([for copysign])
+AC_TRY_LINK([#include <math.h>
+], [double x = copysign(3.14159, -2.7183);], ok=yes, ok=no)
+if test "$ok" = "yes"; then
+       AC_DEFINE(HAVE_COPYSIGN,1,[Define if the copysign function/macro is available.])
+fi
+AC_MSG_RESULT(${ok})
+
 dnl -----------------------------------------------------------------------
 
 if test "x$with_cxx" = xyes; then
index 9b4f51f1f48b766a642151cdf2b6a098b26d50bb..222ce6f69d2f34cd4fd186a084632a0d0b9e9cce 100644 (file)
 #  define HUGE_VAL REPLACEMENT_HUGE_VAL
 #endif
 
+#ifndef HAVE_COPYSIGN
+   /* not quite right for y == -0, but good enough for us */
+#  define copysign(x, y) ((y) < 0 ? -fabs(x) : fabs(x))
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {