exp2f/log2f implementations if not existing

This commit is contained in:
gbeauche 2004-12-18 23:45:33 +00:00
parent 0802f4d93d
commit 8677229f60
2 changed files with 20 additions and 0 deletions

View File

@ -303,6 +303,7 @@ AC_CHECK_FUNCS(sigaction signal)
AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(mmap mprotect munmap)
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
AC_CHECK_FUNCS(posix_memalign memalign valloc) AC_CHECK_FUNCS(posix_memalign memalign valloc)
AC_CHECK_FUNCS(exp2f log2f exp2 log2)
dnl Darwin seems to define mach_task_self() instead of task_self(). dnl Darwin seems to define mach_task_self() instead of task_self().
AC_CHECK_FUNCS(mach_task_self task_self) AC_CHECK_FUNCS(mach_task_self task_self)

View File

@ -127,6 +127,25 @@ DEFINE_ALIAS_OP(xor_64, xor, uint64);
// Floating-point basic operations // Floating-point basic operations
#ifndef HAVE_EXP2F
#ifdef HAVE_EXP2
#define exp2f(x) (float)exp2(x)
#else
#define exp2f(x) powf(2.0, (x))
#endif
#endif
#ifndef HAVE_LOG2F
#ifdef HAVE_LOG2
#define log2f(x) (float)log2(x)
#else
#ifndef M_LN2
#define M_LN2 logf(2.0)
#endif
#define log2f(x) logf(x) / M_LN2
#endif
#endif
DEFINE_OP1(fnop, double, x); DEFINE_OP1(fnop, double, x);
DEFINE_OP1(fabs, double, fabs(x)); DEFINE_OP1(fabs, double, fabs(x));
DEFINE_OP2(fadd, double, x + y); DEFINE_OP2(fadd, double, x + y);