summaryrefslogtreecommitdiff
path: root/core/pkg/tbox.pkg/inc/tbox/math
diff options
context:
space:
mode:
authorruki <[email protected]>2015-07-02 14:54:00 +0800
committerruki <[email protected]>2015-07-02 14:54:00 +0800
commitf69c00a7ddcb835fe52169fa9b7e097680fba5c1 (patch)
treefdbe29e9037607dd09335a117c730cc3f07a04d1 /core/pkg/tbox.pkg/inc/tbox/math
parentc6cc4e543cbfc3e23761ebb4cc0f825055928ed2 (diff)
update tbox and fix copy file bug
Diffstat (limited to 'core/pkg/tbox.pkg/inc/tbox/math')
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/fixed.h2
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/fixed16.h26
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/fixed30.h12
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/fixed6.h2
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h66
-rwxr-xr-xcore/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h65
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/int32.h0
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/math.h0
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/prefix.h0
-rw-r--r--[-rwxr-xr-x]core/pkg/tbox.pkg/inc/tbox/math/random.h2
10 files changed, 22 insertions, 153 deletions
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h
index 97bf82338..590578a73 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h
@@ -46,7 +46,7 @@
#define TB_FIXED_NEAR0 TB_FIXED16_NEAR0
// conversion
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed_to_float(x) tb_fixed16_to_float(x)
# define tb_float_to_fixed(x) tb_float_to_fixed16(x)
#endif
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h
index 4ac998f04..abe99aadc 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h
@@ -55,7 +55,7 @@ __tb_extern_c_enter__
#define TB_FIXED16_NEAR0 (1 << 4)
// conversion
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# ifndef tb_fixed16_to_float
# define tb_fixed16_to_float(x) ((tb_float_t)((x) * 1.5258789e-5))
# endif
@@ -175,7 +175,7 @@ __tb_extern_c_enter__
// sin
#ifndef tb_fixed16_sin
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_sin(x) tb_fixed16_sin_float(x)
# else
# define tb_fixed16_sin(x) tb_fixed16_sin_int32(x)
@@ -184,7 +184,7 @@ __tb_extern_c_enter__
// cos
#ifndef tb_fixed16_cos
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_cos(x) tb_fixed16_cos_float(x)
# else
# define tb_fixed16_cos(x) tb_fixed16_cos_int32(x)
@@ -193,7 +193,7 @@ __tb_extern_c_enter__
// sincos
#ifndef tb_fixed16_sincos
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_sincos(x, s, c) tb_fixed16_sincos_float(x, s, c)
# else
# define tb_fixed16_sincos(x, s, c) tb_fixed16_sincos_int32(x, s, c)
@@ -202,7 +202,7 @@ __tb_extern_c_enter__
// tan
#ifndef tb_fixed16_tan
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_tan(x) tb_fixed16_tan_float(x)
# else
# define tb_fixed16_tan(x) tb_fixed16_tan_int32(x)
@@ -211,7 +211,7 @@ __tb_extern_c_enter__
// asin
#ifndef tb_fixed16_asin
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_asin(x) tb_fixed16_asin_float(x)
# else
# define tb_fixed16_asin(x) tb_fixed16_asin_int32(x)
@@ -220,7 +220,7 @@ __tb_extern_c_enter__
// acos
#ifndef tb_fixed16_acos
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_acos(x) tb_fixed16_acos_float(x)
# else
# define tb_fixed16_acos(x) tb_fixed16_acos_int32(x)
@@ -229,7 +229,7 @@ __tb_extern_c_enter__
// atan
#ifndef tb_fixed16_atan
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_atan(x) tb_fixed16_atan_float(x)
# else
# define tb_fixed16_atan(x) tb_fixed16_atan_int32(x)
@@ -238,7 +238,7 @@ __tb_extern_c_enter__
// atan2
#ifndef tb_fixed16_atan2
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_atan2(y, x) tb_fixed16_atan2_float(y, x)
# else
# define tb_fixed16_atan2(y, x) tb_fixed16_atan2_int32(y, x)
@@ -247,7 +247,7 @@ __tb_extern_c_enter__
// exp
#ifndef tb_fixed16_exp
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_exp(x) tb_fixed16_exp_float(x)
# else
# define tb_fixed16_exp(x) tb_fixed16_exp_int32(x)
@@ -255,7 +255,7 @@ __tb_extern_c_enter__
#endif
#ifndef tb_fixed16_expi
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_expi(x) tb_fixed16_expi_float(x)
# else
# define tb_fixed16_expi(x) tb_assert(0)
@@ -263,7 +263,7 @@ __tb_extern_c_enter__
#endif
#ifndef tb_fixed16_exp1
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# define tb_fixed16_exp1(x) tb_fixed16_exp1_float(x)
# else
# define tb_fixed16_exp1(x) tb_assert(0)
@@ -424,7 +424,7 @@ static __tb_inline__ tb_fixed16_t tb_fixed16_imulsub_check(tb_fixed16_t x, tb_lo
// ok
return (tb_fixed16_t)v;
}
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
static __tb_inline__ tb_fixed16_t tb_fixed16_sin_float(tb_fixed16_t x)
{
return tb_float_to_fixed16(tb_sinf(tb_fixed16_to_float(x)));
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h
index b7232b715..41965701a 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h
@@ -53,7 +53,7 @@ __tb_extern_c_enter__
#define TB_FIXED30_SQRT2 (0x5a827999)
// conversion
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# ifndef tb_fixed30_to_float
# define tb_fixed30_to_float(x) (((x) * 0.00000000093132257f))
# endif
@@ -83,7 +83,7 @@ __tb_extern_c_enter__
#ifndef tb_fixed30_mul
# if 1
# define tb_fixed30_mul(x, y) tb_fixed30_mul_int64(x, y)
-# elif defined(TB_CONFIG_TYPE_FLOAT)
+# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT)
# define tb_fixed30_mul(x, y) tb_fixed30_mul_float(x, y)
# else
# define tb_fixed30_mul(x, y) tb_fixed30_mul_int32(x, y)
@@ -94,7 +94,7 @@ __tb_extern_c_enter__
#ifndef tb_fixed30_div
# if 1
# define tb_fixed30_div(x, y) tb_fixed30_div_int64(x, y)
-# elif defined(TB_CONFIG_TYPE_FLOAT)
+# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT)
# define tb_fixed30_div(x, y) tb_fixed30_div_float(x, y)
# else
# define tb_fixed30_div(x, y) tb_int32_div(x, y, 30)
@@ -105,7 +105,7 @@ __tb_extern_c_enter__
#ifndef tb_fixed30_sqre
# if 1
# define tb_fixed30_sqre(x) tb_fixed30_sqre_int64(x)
-# elif defined(TB_CONFIG_TYPE_FLOAT)
+# elif defined(TB_CONFIG_TYPE_HAVE_FLOAT)
# define tb_fixed30_sqre(x) tb_fixed30_sqre_float(x)
# else
# define tb_fixed30_sqre(x) tb_fixed30_sqre_int32(x)
@@ -122,7 +122,7 @@ __tb_extern_c_enter__
*/
#ifdef __tb_debug__
-# ifdef TB_CONFIG_TYPE_FLOAT
+# ifdef TB_CONFIG_TYPE_HAVE_FLOAT
static __tb_inline__ tb_fixed30_t tb_float_to_fixed30_check(tb_float_t x)
{
// check overflow, [-2., 2.]
@@ -152,7 +152,7 @@ static __tb_inline__ tb_fixed30_t tb_fixed30_sqre_int64(tb_fixed30_t x)
return (tb_fixed30_t)((tb_hong_t)x * x >> 30);
}
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
static __tb_inline__ tb_fixed30_t tb_fixed30_mul_float(tb_fixed30_t x, tb_fixed30_t y)
{
tb_float_t f = tb_fixed30_to_float(x) * tb_fixed30_to_float(y);
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h
index d3a01669c..0703e2b0d 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h
@@ -51,7 +51,7 @@ __tb_extern_c_enter__
#define TB_FIXED6_NEAR0 (0)
// conversion
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
# ifndef tb_fixed6_to_float
# define tb_fixed6_to_float(x) (((x) * 0.015625))
# endif
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h
deleted file mode 100755
index 2a84fca64..000000000
--- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*!The Treasure Box Library
- *
- * TBox is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * TBox is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with TBox;
- * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
- *
- * Copyright (C) 2009 - 2015, ruki All rights reserved.
- *
- * @author ruki
- * @file fixed16_arm.h
- *
- */
-#ifndef TB_MATH_IMPL_FIXED16_ARM_H
-#define TB_MATH_IMPL_FIXED16_ARM_H
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * includes
- */
-#include "../prefix.h"
-
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * macros
- */
-
-#ifdef TB_ASSEMBLER_IS_GAS
-
-#if 0
-# define tb_fixed16_mul(x, y) tb_fixed16_mul_asm(x, y)
-#endif
-
-#endif /* TB_ASSEMBLER_IS_GAS */
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * interfaces
- */
-
-#if defined(TB_ASSEMBLER_IS_GAS) && !defined(TB_ARCH_ARM64)
-static __tb_inline__ tb_fixed16_t tb_fixed16_mul_asm(tb_fixed16_t x, tb_fixed16_t y)
-{
- __tb_register__ tb_fixed16_t t;
- __tb_asm__ __tb_volatile__
- (
- "smull %0, %2, %1, %3 \n" // r64 = (l, h) = x * y
- "mov %0, %0, lsr #16 \n" // to fixed16: r64 >>= 16
- "orr %0, %0, %2, lsl #16 \n" // x = l = (h << (32 - 16)) | (l >> 16);
-
- : "=r"(x), "=&r"(y), "=r"(t)
- : "r"(x), "1"(y)
- );
- return x;
-}
-#endif
-
-#endif
-
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h
deleted file mode 100755
index 68ea25f26..000000000
--- a/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*!The Treasure Box Library
- *
- * TBox is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * TBox is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with TBox;
- * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
- *
- * Copyright (C) 2009 - 2015, ruki All rights reserved.
- *
- * @author ruki
- * @file fixed30_arm.h
- *
- */
-#ifndef TB_MATH_IMPL_FIXED30_ARM_H
-#define TB_MATH_IMPL_FIXED30_ARM_H
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * includes
- */
-#include "../prefix.h"
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * macros
- */
-
-#ifdef TB_ASSEMBLER_IS_GAS
-
-#if 0
-# define tb_fixed30_mul(x, y) tb_fixed30_mul_asm(x, y)
-#endif
-
-#endif /* TB_ASSEMBLER_IS_GAS */
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * interfaces
- */
-#if defined(TB_ASSEMBLER_IS_GAS)
-static __tb_inline__ tb_fixed30_t tb_fixed30_mul_asm(tb_fixed30_t x, tb_fixed30_t y)
-{
- __tb_register__ tb_fixed30_t t;
- __tb_asm__ __tb_volatile__
- (
- "smull %0, %2, %1, %3 \n" // r64 = (l, h) = x * y
- "mov %0, %0, lsr #30 \n" // to fixed30: r64 >>= 30
- "orr %0, %0, %2, lsl #2 \n" // x = l = (h << (32 - 30)) | (l >> 30);
-
- : "=r"(x), "=&r"(y), "=r"(t)
- : "r"(x), "1"(y)
- );
- return x;
-}
-#endif
-
-
-#endif
-
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/int32.h b/core/pkg/tbox.pkg/inc/tbox/math/int32.h
index b51d425a3..b51d425a3 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/int32.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/int32.h
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/math.h b/core/pkg/tbox.pkg/inc/tbox/math/math.h
index 9eef102c4..9eef102c4 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/math.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/math.h
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h
index e42d4e57a..e42d4e57a 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/prefix.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/prefix.h
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/random.h b/core/pkg/tbox.pkg/inc/tbox/math/random.h
index 86b99ae36..f21a364ee 100755..100644
--- a/core/pkg/tbox.pkg/inc/tbox/math/random.h
+++ b/core/pkg/tbox.pkg/inc/tbox/math/random.h
@@ -83,7 +83,7 @@ tb_void_t tb_random_clear(tb_random_ref_t random);
*/
tb_long_t tb_random_range(tb_random_ref_t random, tb_long_t beg, tb_long_t end);
-#ifdef TB_CONFIG_TYPE_FLOAT
+#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
/*! generate the float random with range: [beg, end)
*
* @param random the random, using the default random if be null