[CONFIGURATION]

* NEW: Check for missing mathematical function directly instead of relying 
  on operating system detection.


git-svn-id: svn://localhost/gambas/trunk@3166 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-08-31 08:54:51 +00:00
parent 93a7daf44e
commit 3fbd60c233
4 changed files with 48 additions and 14 deletions

View file

@ -194,7 +194,7 @@ AC_DEFUN([GB_INIT],
dnl AC_FUNC_WAIT3 dnl AC_FUNC_WAIT3
dnl AC_CHECK_FUNCS(getcwd gettimeofday mkdir rmdir select socket strdup strerror strtod strtol sysinfo) dnl AC_CHECK_FUNCS(getcwd gettimeofday mkdir rmdir select socket strdup strerror strtod strtol sysinfo)
AC_REPLACE_FUNCS(setenv unsetenv getdomainname getpt cfmakeraw) AC_CHECK_FUNCS(setenv unsetenv getdomainname getpt cfmakeraw)
dnl ---- Checks for libraries dnl ---- Checks for libraries
@ -342,6 +342,7 @@ AC_DEFUN([GB_INIT],
rm -f DISABLED rm -f DISABLED
]) ])
## --------------------------------------------------------------------------- ## ---------------------------------------------------------------------------
## GB_THREAD ## GB_THREAD
## Detect threading compiler options ## Detect threading compiler options
@ -405,6 +406,21 @@ AC_DEFUN([GB_MATH],
]) ])
## ---------------------------------------------------------------------------
## GB_MATH_FUNC
## Detect which mathematical functions are available
## ---------------------------------------------------------------------------
AC_DEFUN([GB_MATH_FUNC],
[
dnl AC_CHECK_LIB(m, main, true)
ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -lm"
AC_CHECK_FUNCS(log10l fabsl powl modfl exp10 exp2 log2)
LDFLAGS=$ac_save_LDFLAGS
])
## --------------------------------------------------------------------------- ## ---------------------------------------------------------------------------
## GB_SYSTEM ## GB_SYSTEM
## Detects the target system and its architecture ## Detects the target system and its architecture

View file

@ -4,6 +4,7 @@ AC_INIT
AC_CONFIG_SRCDIR([configure.ac]) AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
GB_INIT(main) GB_INIT(main)
GB_MATH_FUNC
LT_INIT LT_INIT
AM_PROG_CC_C_O AM_PROG_CC_C_O

View file

@ -177,50 +177,55 @@ double rnd(void)
return (double)val / 18446744073709551616.0; //0xFFFFFFFFFFFFFFFFULL; return (double)val / 18446744073709551616.0; //0xFFFFFFFFFFFFFFFFULL;
} }
#ifndef HAVE_EXP10
#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
double exp10(double x) double exp10(double x)
{ {
return pow(10, x); return pow(10, x);
} }
#endif
#ifndef HAVE_LOG2
double log2(double x) double log2(double x)
{ {
return log(x) / M_LN2; return log(x) / M_LN2;
} }
#endif
#ifndef HAVE_EXP2
double exp2(double x) double exp2(double x)
{ {
return pow(2, x); return pow(2, x);
} }
#endif #endif
#if defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(ARCH_ARM) || defined(OS_CYGWIN) #ifndef HAVE_LOG10L
long double log10l(long double x) long double log10l(long double x)
{ {
return log10((double) x); return log10((double) x);
} }
#endif
#ifndef HAVE_FABSL
long double fabsl(long double x) long double fabsl(long double x)
{ {
return fabs((double) x); return fabs((double) x);
} }
#endif
#ifndef HAVE_POWL
long double powl(long double x, long double y) long double powl(long double x, long double y)
{ {
return pow((double) x, (double) y); return pow((double) x, (double) y);
} }
#endif
#ifndef HAVE_MODFL
long double modfl(long double x, long double *iptr) long double modfl(long double x, long double *iptr)
{ {
double val; double val;
return modf((double)x, &val); return modf((double)x, &val);
*iptr = val; *iptr = val;
} }
#endif #endif
void MATH_init(void) void MATH_init(void)

View file

@ -42,20 +42,32 @@ double rnd(void);
#define deg(_x) ((_x) * 180 / M_PI) #define deg(_x) ((_x) * 180 / M_PI)
#define rad(_x) ((_x) * M_PI / 180) #define rad(_x) ((_x) * M_PI / 180)
#if defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_CYGWIN) #ifndef HAVE_EXP10
double exp10(double x); double exp10(double x);
#ifdef log2
#undef log2
#endif #endif
#ifndef HAVE_LOG2
double log2(double x); double log2(double x);
#endif
#ifndef HAVE_EXP2
double exp2(double x); double exp2(double x);
#endif #endif
#if defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_CYGWIN) || defined(ARCH_ARM) #ifndef HAVE_LOG10L
long double log10l(long double x); long double log10l(long double x);
#endif
#ifndef HAVE_FABSL
long double fabsl(long double x); long double fabsl(long double x);
long double powl(long double x, long double y); #endif
long double modfl(long double x, long double *p);
#ifndef HAVE_POWL
long double powl(long double x);
#endif
#ifndef HAVE_MODFL
long double modfl(long double x);
#endif #endif
#endif #endif