1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

* numbers.c (SCM_COMPLEX_VALUE): Use GUILE_I instead of _Complex_I

directly, and only if GUILE_I was defined by the configure step.
(scm_log, scm_log10, scm_exp, scm_sqrt): Use SCM_COMPLEX_VALUE
code only if SCM_COMPLEX_VALUE is defined.

* configure.in (--without-64-calls): Use AC_MSG_CHECKING and
AC_MSG_RESULT instead of just echo.
(GUILE_I): New programs to try using _Complex_I or 1.0fi for the
imaginary unit.
This commit is contained in:
Neil Jerram 2008-02-11 21:20:14 +00:00
parent 7f74cf9a67
commit 4b26c03ec7
5 changed files with 48 additions and 7 deletions

View file

@ -1,3 +1,10 @@
2008-02-11 Neil Jerram <neil@ossau.uklinux.net>
* configure.in (--without-64-calls): Use AC_MSG_CHECKING and
AC_MSG_RESULT instead of just echo.
(GUILE_I): New programs to try using _Complex_I or 1.0fi for the
imaginary unit.
2008-02-06 Neil Jerram <neil@ossau.uklinux.net> 2008-02-06 Neil Jerram <neil@ossau.uklinux.net>
* configure.in: Default to --without-64-calls for * configure.in: Default to --without-64-calls for

1
NEWS
View file

@ -55,6 +55,7 @@ system and library calls.
** Fixed wrong-type-arg errors when creating zero length SRFI-4 ** Fixed wrong-type-arg errors when creating zero length SRFI-4
uniform vectors on AIX. uniform vectors on AIX.
** Fixed a deadlock that occurs upon GC with multiple threads. ** Fixed a deadlock that occurs upon GC with multiple threads.
** Fixed compile problem with GCC on Solaris and AIX (use of _Complex_I)
* New modules (see the manual for details) * New modules (see the manual for details)

View file

@ -196,6 +196,7 @@ dnl to use a "64" call, and hence that by using --without-64-calls we're
dnl missing out on that. If so, someone can work on that in the future. dnl missing out on that. If so, someone can work on that in the future.
dnl For now, --without-64-calls allows Guile to build on OSs where it dnl For now, --without-64-calls allows Guile to build on OSs where it
dnl wasn't building before. dnl wasn't building before.
AC_MSG_CHECKING([whether to use system and library "64" calls])
AC_ARG_WITH([64-calls], AC_ARG_WITH([64-calls],
AC_HELP_STRING([--without-64-calls], AC_HELP_STRING([--without-64-calls],
[don't attempt to use system and library calls with "64" in their names]), [don't attempt to use system and library calls with "64" in their names]),
@ -209,7 +210,7 @@ AC_ARG_WITH([64-calls],
use_64_calls=no use_64_calls=no
;; ;;
esac]) esac])
echo "use_64_calls=$use_64_calls" AC_MSG_RESULT($use_64_calls)
case "$use_64_calls" in case "$use_64_calls" in
y* ) y* )
AC_DEFINE(GUILE_USE_64_CALLS, 1, AC_DEFINE(GUILE_USE_64_CALLS, 1,
@ -719,6 +720,30 @@ AC_SEARCH_LIBS(crypt, crypt,
[AC_DEFINE(HAVE_CRYPT,1, [AC_DEFINE(HAVE_CRYPT,1,
[Define to 1 if you have the `crypt' function.])]) [Define to 1 if you have the `crypt' function.])])
# When compiling with GCC on some OSs (Solaris, AIX), _Complex_I doesn't work;
# in the reported cases so far, 1.0fi works well instead.
if test "$ac_cv_type_complex_double" = yes; then
AC_MSG_CHECKING([for i])
AC_TRY_COMPILE([
#if HAVE_COMPLEX_H
#include <complex.h>
#endif
complex double z;
],[
z = _Complex_I;
],[AC_DEFINE(GUILE_I,_Complex_I,[The imaginary unit (positive square root of -1).])
AC_MSG_RESULT([_Complex_I])],[AC_TRY_COMPILE([
#if HAVE_COMPLEX_H
#include <complex.h>
#endif
complex double z;
],[
z = 1.0fi;
],[AC_DEFINE(GUILE_I,1.0fi)
AC_MSG_RESULT([1.0fi])],[ac_cv_type_complex_double=no
AC_MSG_RESULT([not available])])])
fi
# glibc 2.3.6 (circa 2006) and various prior versions had a bug where # glibc 2.3.6 (circa 2006) and various prior versions had a bug where
# csqrt(-i) returned a negative real part, when it should be positive # csqrt(-i) returned a negative real part, when it should be positive
# for the principal root. # for the principal root.

View file

@ -1,3 +1,10 @@
2008-02-11 Neil Jerram <neil@ossau.uklinux.net>
* numbers.c (SCM_COMPLEX_VALUE): Use GUILE_I instead of _Complex_I
directly, and only if GUILE_I was defined by the configure step.
(scm_log, scm_log10, scm_exp, scm_sqrt): Use SCM_COMPLEX_VALUE
code only if SCM_COMPLEX_VALUE is defined.
2008-02-07 Ludovic Courtès <ludo@gnu.org> 2008-02-07 Ludovic Courtès <ludo@gnu.org>
Fix bug #21378. Fix bug #21378.

View file

@ -162,11 +162,12 @@ xisnan (double x)
#endif #endif
} }
#if defined (GUILE_I)
/* For an SCM object Z which is a complex number (ie. satisfies /* For an SCM object Z which is a complex number (ie. satisfies
SCM_COMPLEXP), return its value as a C level "complex double". */ SCM_COMPLEXP), return its value as a C level "complex double". */
#define SCM_COMPLEX_VALUE(z) \ #define SCM_COMPLEX_VALUE(z) \
(SCM_COMPLEX_REAL (z) + _Complex_I * SCM_COMPLEX_IMAG (z)) (SCM_COMPLEX_REAL (z) + GUILE_I * SCM_COMPLEX_IMAG (z))
#endif
/* Convert a C "complex double" to an SCM value. */ /* Convert a C "complex double" to an SCM value. */
#if HAVE_COMPLEX_DOUBLE #if HAVE_COMPLEX_DOUBLE
@ -6011,7 +6012,7 @@ SCM_DEFINE (scm_log, "log", 1, 0, 0,
{ {
if (SCM_COMPLEXP (z)) if (SCM_COMPLEXP (z))
{ {
#if HAVE_COMPLEX_DOUBLE && HAVE_CLOG #if HAVE_COMPLEX_DOUBLE && HAVE_CLOG && defined (SCM_COMPLEX_VALUE)
return scm_from_complex_double (clog (SCM_COMPLEX_VALUE (z))); return scm_from_complex_double (clog (SCM_COMPLEX_VALUE (z)));
#else #else
double re = SCM_COMPLEX_REAL (z); double re = SCM_COMPLEX_REAL (z);
@ -6045,7 +6046,7 @@ SCM_DEFINE (scm_log10, "log10", 1, 0, 0,
/* Mingw has clog() but not clog10(). (Maybe it'd be worth using /* Mingw has clog() but not clog10(). (Maybe it'd be worth using
clog() and a multiply by M_LOG10E, rather than the fallback clog() and a multiply by M_LOG10E, rather than the fallback
log10+hypot+atan2.) */ log10+hypot+atan2.) */
#if HAVE_COMPLEX_DOUBLE && HAVE_CLOG10 #if HAVE_COMPLEX_DOUBLE && HAVE_CLOG10 && defined (SCM_COMPLEX_VALUE)
return scm_from_complex_double (clog10 (SCM_COMPLEX_VALUE (z))); return scm_from_complex_double (clog10 (SCM_COMPLEX_VALUE (z)));
#else #else
double re = SCM_COMPLEX_REAL (z); double re = SCM_COMPLEX_REAL (z);
@ -6077,7 +6078,7 @@ SCM_DEFINE (scm_exp, "exp", 1, 0, 0,
{ {
if (SCM_COMPLEXP (z)) if (SCM_COMPLEXP (z))
{ {
#if HAVE_COMPLEX_DOUBLE && HAVE_CEXP #if HAVE_COMPLEX_DOUBLE && HAVE_CEXP && defined (SCM_COMPLEX_VALUE)
return scm_from_complex_double (cexp (SCM_COMPLEX_VALUE (z))); return scm_from_complex_double (cexp (SCM_COMPLEX_VALUE (z)));
#else #else
return scm_c_make_polar (exp (SCM_COMPLEX_REAL (z)), return scm_c_make_polar (exp (SCM_COMPLEX_REAL (z)),
@ -6111,7 +6112,7 @@ SCM_DEFINE (scm_sqrt, "sqrt", 1, 0, 0,
{ {
if (SCM_COMPLEXP (x)) if (SCM_COMPLEXP (x))
{ {
#if HAVE_COMPLEX_DOUBLE && HAVE_USABLE_CSQRT #if HAVE_COMPLEX_DOUBLE && HAVE_USABLE_CSQRT && defined (SCM_COMPLEX_VALUE)
return scm_from_complex_double (csqrt (SCM_COMPLEX_VALUE (x))); return scm_from_complex_double (csqrt (SCM_COMPLEX_VALUE (x)));
#else #else
double re = SCM_COMPLEX_REAL (x); double re = SCM_COMPLEX_REAL (x);