From 8677229f6071c18fa2552ce9700a37e86bd33b4c Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 18 Dec 2004 23:45:33 +0000 Subject: [PATCH] exp2f/log2f implementations if not existing --- SheepShaver/src/Unix/configure.ac | 1 + .../kpx_cpu/src/cpu/ppc/ppc-operations.hpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/SheepShaver/src/Unix/configure.ac b/SheepShaver/src/Unix/configure.ac index 8a560358..62e56ed0 100644 --- a/SheepShaver/src/Unix/configure.ac +++ b/SheepShaver/src/Unix/configure.ac @@ -303,6 +303,7 @@ AC_CHECK_FUNCS(sigaction signal) AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) 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(). AC_CHECK_FUNCS(mach_task_self task_self) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp index a9338555..eb57972c 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operations.hpp @@ -127,6 +127,25 @@ DEFINE_ALIAS_OP(xor_64, xor, uint64); // 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(fabs, double, fabs(x)); DEFINE_OP2(fadd, double, x + y);