From 36db3c8623c0267b57f6bf8b4b433d4b3002efea Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 16 Sep 2017 09:48:00 +0000 Subject: [PATCH] added fallback match::log2() code for platforms lacking log2 --- qse/include/qse/types.h | 8 ++++---- qse/lib/awk/mod-math.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index 1d76c90d..7b1092c9 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -239,7 +239,7 @@ typedef enum qse_bool_t qse_bool_t; typedef __uint16_t qse_uint16_t; #endif -#ifdef QSE_HAVE_INT16_T +#if defined(QSE_HAVE_INT16_T) # define QSE_SIZEOF_INT16_T 2 # define QSE_SIZEOF_UINT16_T 2 # undef QSE_SIZEOF_INTMAX_T @@ -279,7 +279,7 @@ typedef enum qse_bool_t qse_bool_t; typedef __uint32_t qse_uint32_t; #endif -#ifdef QSE_HAVE_INT32_T +#if defined(QSE_HAVE_INT32_T) # define QSE_SIZEOF_INT32_T 4 # define QSE_SIZEOF_UINT32_T 4 # undef QSE_SIZEOF_INTMAX_T @@ -324,7 +324,7 @@ typedef enum qse_bool_t qse_bool_t; typedef __uint64_t qse_uint64_t; #endif -#ifdef QSE_HAVE_INT64_T +#if defined(QSE_HAVE_INT64_T) # define QSE_SIZEOF_INT64_T 8 # define QSE_SIZEOF_UINT64_T 8 # undef QSE_SIZEOF_INTMAX_T @@ -363,7 +363,7 @@ typedef enum qse_bool_t qse_bool_t; typedef __uint128_t qse_uint128_t; #endif -#ifdef QSE_HAVE_INT128_T +#if defined(QSE_HAVE_INT128_T) # define QSE_SIZEOF_INT128_T 16 # define QSE_SIZEOF_UINT128_T 16 # undef QSE_SIZEOF_INTMAX_T diff --git a/qse/lib/awk/mod-math.c b/qse/lib/awk/mod-math.c index 9ed2a09d..74742933 100644 --- a/qse/lib/awk/mod-math.c +++ b/qse/lib/awk/mod-math.c @@ -359,7 +359,7 @@ static qse_awk_flt_t math_atan2 (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t #endif } -static qse_awk_flt_t math_log (qse_awk_t* awk, qse_awk_flt_t x) +static QSE_INLINE qse_awk_flt_t math_log (qse_awk_t* awk, qse_awk_flt_t x) { #if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_LOGQ) return logq (x); @@ -385,7 +385,7 @@ static qse_awk_flt_t math_log2 (qse_awk_t* awk, qse_awk_flt_t x) #elif defined(HAVE_LOG2F) return log2f (x); #else - #error ### no log2 function available ### + return math_log(x) / math_log(2.0); #endif }