diff options
| author | ruki <[email protected]> | 2015-11-25 22:07:25 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-11-25 22:07:25 +0800 |
| commit | 59ab74881403640bc58dd73cf6fbd56d01e1fca6 (patch) | |
| tree | c0b54a0d10d44ff926d5051c17e481464e1e6e6f /core/pkg/tbox.pkg/inc/tbox/math | |
| parent | c8e83565addad6ca85d9a6c0386dae52409791cc (diff) | |
update tbox and fix remove relative file bug
Diffstat (limited to 'core/pkg/tbox.pkg/inc/tbox/math')
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/fixed.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/fixed16.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/fixed30.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/fixed6.h | 0 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h | 66 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h | 65 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h | 33 | ||||
| -rwxr-xr-x | core/pkg/tbox.pkg/inc/tbox/math/impl/random.h | 85 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/int32.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/math.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/prefix.h | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | core/pkg/tbox.pkg/inc/tbox/math/random.h | 0 |
12 files changed, 249 insertions, 0 deletions
diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h index 590578a73..590578a73 100644..100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h index abe99aadc..abe99aadc 100644..100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed16.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h index 41965701a..41965701a 100644..100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed30.h diff --git a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h index 0703e2b0d..0703e2b0d 100644..100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/fixed6.h 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 new file mode 100755 index 000000000..2a84fca64 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed16_arm.h @@ -0,0 +1,66 @@ +/*!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 new file mode 100755 index 000000000..68ea25f26 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/fixed30_arm.h @@ -0,0 +1,65 @@ +/*!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/impl/prefix.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h new file mode 100755 index 000000000..55e9f3aff --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/prefix.h @@ -0,0 +1,33 @@ +/*!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 prefix.h + * + */ +#ifndef TB_MATH_IMPL_PREFIX_H +#define TB_MATH_IMPL_PREFIX_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "../prefix.h" + + + +#endif diff --git a/core/pkg/tbox.pkg/inc/tbox/math/impl/random.h b/core/pkg/tbox.pkg/inc/tbox/math/impl/random.h new file mode 100755 index 000000000..c73accf88 --- /dev/null +++ b/core/pkg/tbox.pkg/inc/tbox/math/impl/random.h @@ -0,0 +1,85 @@ +/*!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 random.h + * + */ +#ifndef TB_MATH_IMPL_RANDOM_H +#define TB_MATH_IMPL_RANDOM_H + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_enter__ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * types + */ + +// the random type enum +typedef enum __tb_random_type_e +{ + TB_RANDOM_TYPE_NONE = 0 +, TB_RANDOM_TYPE_LINEAR = 1 + +}tb_random_type_e; + +// the random impl type +typedef struct __tb_random_impl_t +{ + // the type + tb_size_t type; + + // exit + tb_void_t (*exit)(struct __tb_random_impl_t* random); + + // seed + tb_void_t (*seed)(struct __tb_random_impl_t* random, tb_size_t seed); + + // clear + tb_void_t (*clear)(struct __tb_random_impl_t* random); + + // range + tb_long_t (*range)(struct __tb_random_impl_t* random, tb_long_t beg, tb_long_t end); + +}tb_random_impl_t; + +/* ////////////////////////////////////////////////////////////////////////////////////// + * declaration + */ + +/* init the linear random + * + * @param seed the seed + * + * @return the random + */ +tb_random_impl_t* tb_random_linear_init(tb_size_t seed); + +/* ////////////////////////////////////////////////////////////////////////////////////// + * extern + */ +__tb_extern_c_leave__ + +#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 100644..100755 --- 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 100644..100755 --- 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 100644..100755 --- 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 f21a364ee..f21a364ee 100644..100755 --- a/core/pkg/tbox.pkg/inc/tbox/math/random.h +++ b/core/pkg/tbox.pkg/inc/tbox/math/random.h |
