aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-03-07 08:29:19 -0800
committerPaul Eggert2017-03-07 08:32:04 -0800
commit14af3395e6d8a2a95268138355ade408743922ac (patch)
tree85a38267025e4af11bb490d89129846273129e2a
parent641ce935b79c63020553f33fc5ca8f4d05e56b0b (diff)
downloademacs-14af3395e6d8a2a95268138355ade408743922ac.tar.gz
emacs-14af3395e6d8a2a95268138355ade408743922ac.zip
Define copysign on all platforms
* configure.ac (copysign): Remove test. * src/floatfns.c (signbit): New macro, if not already defined. (Fcopysign): Use it instead of copysign. (Fcopysign, syms_of_floatfns): Define the function on all platforms.
-rw-r--r--admin/CPP-DEFINES1
-rw-r--r--configure.ac2
-rw-r--r--src/floatfns.c14
3 files changed, 10 insertions, 7 deletions
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 487c1501bb9..cead305aee1 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -113,7 +113,6 @@ HAVE_CLOCK_GETTIME
113HAVE_CLOCK_SETTIME 113HAVE_CLOCK_SETTIME
114HAVE_COFF_H 114HAVE_COFF_H
115HAVE_COM_ERR_H 115HAVE_COM_ERR_H
116HAVE_COPYSIGN
117HAVE_DBUS 116HAVE_DBUS
118HAVE_DBUS_TYPE_IS_VALID 117HAVE_DBUS_TYPE_IS_VALID
119HAVE_DBUS_VALIDATE_BUS_NAME 118HAVE_DBUS_VALIDATE_BUS_NAME
diff --git a/configure.ac b/configure.ac
index 6926076fadc..ba944e6cebd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3888,7 +3888,7 @@ pthread_sigmask strsignal setitimer \
3888sendto recvfrom getsockname getifaddrs freeifaddrs \ 3888sendto recvfrom getsockname getifaddrs freeifaddrs \
3889gai_strerror sync \ 3889gai_strerror sync \
3890getpwent endpwent getgrent endgrent \ 3890getpwent endpwent getgrent endgrent \
3891cfmakeraw cfsetspeed copysign __executable_start log2 prctl) 3891cfmakeraw cfsetspeed __executable_start log2 prctl)
3892LIBS=$OLD_LIBS 3892LIBS=$OLD_LIBS
3893 3893
3894dnl No need to check for posix_memalign if aligned_alloc works. 3894dnl No need to check for posix_memalign if aligned_alloc works.
diff --git a/src/floatfns.c b/src/floatfns.c
index 4c09036ac79..8534f1d04e4 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -147,7 +147,12 @@ DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
147 return isnan (XFLOAT_DATA (x)) ? Qt : Qnil; 147 return isnan (XFLOAT_DATA (x)) ? Qt : Qnil;
148} 148}
149 149
150#ifdef HAVE_COPYSIGN 150/* Although the substitute does not work on NaNs, it is good enough
151 for platforms lacking the signbit macro. */
152#ifndef signbit
153# define signbit(x) ((x) < 0 || (IEEE_FLOATING_POINT && !(x) && 1 / (x) < 0))
154#endif
155
151DEFUN ("copysign", Fcopysign, Scopysign, 2, 2, 0, 156DEFUN ("copysign", Fcopysign, Scopysign, 2, 2, 0,
152 doc: /* Copy sign of X2 to value of X1, and return the result. 157 doc: /* Copy sign of X2 to value of X1, and return the result.
153Cause an error if X1 or X2 is not a float. */) 158Cause an error if X1 or X2 is not a float. */)
@@ -161,9 +166,10 @@ Cause an error if X1 or X2 is not a float. */)
161 f1 = XFLOAT_DATA (x1); 166 f1 = XFLOAT_DATA (x1);
162 f2 = XFLOAT_DATA (x2); 167 f2 = XFLOAT_DATA (x2);
163 168
164 return make_float (copysign (f1, f2)); 169 /* Use signbit instead of copysign, to avoid calling make_float when
170 the result is X1. */
171 return signbit (f1) != signbit (f2) ? make_float (-f1) : x1;
165} 172}
166#endif
167 173
168DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0, 174DEFUN ("frexp", Ffrexp, Sfrexp, 1, 1, 0,
169 doc: /* Get significand and exponent of a floating point number. 175 doc: /* Get significand and exponent of a floating point number.
@@ -552,9 +558,7 @@ syms_of_floatfns (void)
552 defsubr (&Ssin); 558 defsubr (&Ssin);
553 defsubr (&Stan); 559 defsubr (&Stan);
554 defsubr (&Sisnan); 560 defsubr (&Sisnan);
555#ifdef HAVE_COPYSIGN
556 defsubr (&Scopysign); 561 defsubr (&Scopysign);
557#endif
558 defsubr (&Sfrexp); 562 defsubr (&Sfrexp);
559 defsubr (&Sldexp); 563 defsubr (&Sldexp);
560 defsubr (&Sfceiling); 564 defsubr (&Sfceiling);