aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/include/eina_inline_f8p24.x
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/include/eina_inline_f8p24.x')
-rw-r--r--libraries/eina/src/include/eina_inline_f8p24.x82
1 files changed, 82 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_inline_f8p24.x b/libraries/eina/src/include/eina_inline_f8p24.x
new file mode 100644
index 0000000..f80bf61
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_f8p24.x
@@ -0,0 +1,82 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_F8P24_X_
21#define EINA_INLINE_F8P24_X_
22
23static inline Eina_F8p24
24eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b)
25{
26 return a + b;
27}
28
29static inline Eina_F8p24
30eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b)
31{
32 return a - b;
33}
34
35static inline Eina_F8p24
36eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b)
37{
38 return (Eina_F8p24)(((int64_t) a * (int64_t) b) >> 24);
39}
40
41static inline Eina_F8p24
42eina_f8p24_scale(Eina_F8p24 a, int b)
43{
44 return a * b;
45}
46
47static inline Eina_F8p24
48eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b)
49{
50 return (Eina_F8p24) ((((int64_t) a) << 24) / (int64_t) b);
51}
52
53static inline Eina_F8p24
54eina_f8p24_sqrt(Eina_F8p24 a)
55{
56 unsigned int root, remHi, remLo, testDiv, count;
57
58 root = 0; /* Clear root */
59 remHi = 0; /* Clear high part of partial remainder */
60 remLo = a; /* Get argument into low part of partial remainder */
61 count = (23 + (24 >> 1)); /* Load loop counter */
62 do {
63 remHi = (remHi << 2) | (remLo >> 30);
64 remLo <<= 2; /* get 2 bits of arg */
65 root <<= 1; /* Get ready for the next bit in the root */
66 testDiv = (root << 1) + 1; /* Test radical */
67 if (remHi >= testDiv)
68 {
69 remHi -= testDiv;
70 root++;
71 }
72 } while (count-- != 0);
73 return (root);
74}
75
76static inline unsigned int
77eina_f8p24_fracc_get(Eina_F8p24 v)
78{
79 return (v & 0xffffff);
80}
81
82#endif