diff --git a/legacy/eina/src/include/Eina.h b/legacy/eina/src/include/Eina.h index e87359e870..c7b921fc11 100644 --- a/legacy/eina/src/include/Eina.h +++ b/legacy/eina/src/include/Eina.h @@ -155,9 +155,7 @@ extern "C" { #include "eina_config.h" #include "eina_types.h" #include "eina_main.h" -#include "eina_f16p16.h" -#include "eina_f8p24.h" -#include "eina_f32p32.h" +#include "eina_fp.h" #include "eina_rectangle.h" #include "eina_inlist.h" #include "eina_file.h" diff --git a/legacy/eina/src/include/Makefile.am b/legacy/eina/src/include/Makefile.am index fff22a4da0..568ca0b010 100644 --- a/legacy/eina/src/include/Makefile.am +++ b/legacy/eina/src/include/Makefile.am @@ -4,9 +4,11 @@ EINAHEADERS = \ eina_safety_checks.h \ eina_error.h \ eina_log.h \ -eina_f16p16.h \ -eina_f8p24.h \ -eina_f32p32.h \ +eina_fp.h \ +eina_inline_f32p32.x \ +eina_inline_f16p16.x \ +eina_inline_f8p24.x \ +eina_inline_fp.x \ eina_hash.h \ eina_inline_hash.x \ eina_lalloc.h \ diff --git a/legacy/eina/src/include/eina_convert.h b/legacy/eina/src/include/eina_convert.h index dda61a6614..cd935e130c 100644 --- a/legacy/eina/src/include/eina_convert.h +++ b/legacy/eina/src/include/eina_convert.h @@ -22,7 +22,7 @@ #include "eina_types.h" #include "eina_error.h" -#include "eina_f32p32.h" +#include "eina_fp.h" /** * @addtogroup Eina_Tools_Group Tools diff --git a/legacy/eina/src/include/eina_f16p16.h b/legacy/eina/src/include/eina_f16p16.h deleted file mode 100644 index 7f09cf8045..0000000000 --- a/legacy/eina/src/include/eina_f16p16.h +++ /dev/null @@ -1,129 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * - * This library 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. - * - * This library 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 this library; - * if not, see . - */ - -#ifndef EINA_F16P16_H_ -#define EINA_F16P16_H_ - -#ifdef _MSC_VER -# include -#else -# include -#endif - -/** - * To be documented - * FIXME: To be fixed - */ -typedef int32_t Eina_F16p16; - -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_int_from(int32_t v) -{ - return v << 16; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline int32_t eina_f16p16_int_to(Eina_F16p16 v) -{ - return v >> 16; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_float_from(float v) -{ - Eina_F16p16 r; - r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f)); - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline float eina_f16p16_float_to(Eina_F16p16 v) -{ - float r; - r = v / 65536.0f; - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b) -{ - return a + b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b) -{ - return a - b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b) -{ - return ((int64_t)a * (int64_t)b) >> 16; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a) -{ - unsigned int root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (15 + (16 >> 1)); /* Load loop counter */ - do - { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - return (root); -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v) -{ - return (v & 0xffff); -} - -#endif /*EINA_F16P16_H_*/ diff --git a/legacy/eina/src/include/eina_f32p32.h b/legacy/eina/src/include/eina_f32p32.h deleted file mode 100644 index d6b2ee30bf..0000000000 --- a/legacy/eina/src/include/eina_f32p32.h +++ /dev/null @@ -1,136 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library 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. - * - * This library 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 this library; - * if not, see . - */ - -#ifndef EINA_F32P32_H_ -#define EINA_F32P32_H_ - -#ifdef _MSC_VER -# include -#else -# include -#endif - -/** - * To be documented - * FIXME: To be fixed - */ -typedef int64_t Eina_F32p32; - -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_int_from(int32_t v) -{ - return (Eina_F32p32) v << 32; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline int32_t eina_f32p32_int_to(Eina_F32p32 v) -{ - return v >> 32; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_double_from(double v) -{ - Eina_F32p32 r; - r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5)); - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline double eina_f32p32_double_to(Eina_F32p32 v) -{ - double r; - r = v / 4294967296.0; - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b) -{ - return a + b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b) -{ - return a - b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b) -{ - int64_t low; - int64_t high; - - low = a * (b & 0xffffffff); - high = a * (b >> 32); - - return (low >> 32) + high; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a) -{ - uint64_t root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (31 + (32 >> 1)); /* Load loop counter */ - do - { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - return (root); -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v) -{ - return (unsigned int)v; -} - -#endif /*EINA_F32P32_H_*/ diff --git a/legacy/eina/src/include/eina_f8p24.h b/legacy/eina/src/include/eina_f8p24.h deleted file mode 100644 index fe8513a3a5..0000000000 --- a/legacy/eina/src/include/eina_f8p24.h +++ /dev/null @@ -1,130 +0,0 @@ -/* EINA - EFL data type library - * Copyright (C) 2007-2008 Jorge Luis Zapata Muga - * Copyright (C) 2009 Cedric BAIL - * - * This library 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. - * - * This library 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 this library; - * if not, see . - */ - -#ifndef EINA_F8P24_H_ -#define EINA_F8P24_H_ - -#ifdef _MSC_VER -# include -#else -# include -#endif - -/** - * To be documented - * FIXME: To be fixed - */ -typedef int32_t Eina_F8p24; - -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_int_from(int32_t v) -{ - return v << 24; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline int32_t eina_f8p24_int_to(Eina_F8p24 v) -{ - return v >> 24; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_float_from(float v) -{ - Eina_F8p24 r; - r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f)); - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline float eina_f8p24_float_to(Eina_F8p24 v) -{ - float r; - r = v / 16777216.0f; - return r; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b) -{ - return a + b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b) -{ - return a - b; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b) -{ - return ((int64_t)a * (int64_t)b) >> 24; -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a) -{ - unsigned int root, remHi, remLo, testDiv, count; - - root = 0; /* Clear root */ - remHi = 0; /* Clear high part of partial remainder */ - remLo = a; /* Get argument into low part of partial remainder */ - count = (23 + (24 >> 1)); /* Load loop counter */ - do - { - remHi = (remHi << 2) | (remLo >> 30); - remLo <<= 2; /* get 2 bits of arg */ - root <<= 1; /* Get ready for the next bit in the root */ - testDiv = (root << 1) + 1; /* Test radical */ - if (remHi >= testDiv) - { - remHi -= testDiv; - root++; - } - } while (count-- != 0); - return (root); -} -/** - * To be documented - * FIXME: To be fixed - */ -static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v) -{ - return (v & 0xffffff); -} - -#endif /*EINA_F8P24_H_*/ diff --git a/legacy/eina/src/include/eina_fp.h b/legacy/eina/src/include/eina_fp.h new file mode 100644 index 0000000000..a488dfe294 --- /dev/null +++ b/legacy/eina/src/include/eina_fp.h @@ -0,0 +1,81 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2008 Jorge Luis Zapata Muga + * Copyright (C) 2009 Cedric BAIL + * + * This library 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. + * + * This library 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 this library; + * if not, see . + */ + +#ifndef EINA_FP_H_ +# define EINA_FP_H_ + +#ifdef _MSC_VER +# include +#else +# include +#endif + +typedef int64_t Eina_F32p32; +typedef int32_t Eina_F16p16; +typedef int32_t Eina_F8p24; + +static inline Eina_F32p32 eina_f32p32_int_from(int32_t v); +static inline int32_t eina_f32p32_int_to(Eina_F32p32 v); +static inline Eina_F32p32 eina_f32p32_double_from(double v); +static inline double eina_f32p32_double_to(Eina_F32p32 v); + +static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b); +static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b); +static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b); +static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b); +static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a); +static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v); + +static inline Eina_F16p16 eina_f16p16_int_from(int32_t v); +static inline int32_t eina_f16p16_int_to(Eina_F16p16 v); +static inline Eina_F16p16 eina_f16p16_float_from(float v); +static inline float eina_f16p16_float_to(Eina_F16p16 v); + +static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b); +static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b); +static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b); +static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b); +static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a); +static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v); + +static inline Eina_F8p24 eina_f8p24_int_from(int32_t v); +static inline int32_t eina_f8p24_int_to(Eina_F8p24 v); +static inline Eina_F8p24 eina_f8p24_float_from(float v); +static inline float eina_f8p24_float_to(Eina_F8p24 v); + +static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b); +static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b); +static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b); +static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b); +static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a); +static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v); + +static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a); +static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a); +static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a); +static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a); +static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a); +static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a); + +#include "eina_inline_f32p32.x" +#include "eina_inline_f16p16.x" +#include "eina_inline_f8p24.x" +#include "eina_inline_fp.x" + +#endif diff --git a/legacy/eina/src/include/eina_inline_f16p16.x b/legacy/eina/src/include/eina_inline_f16p16.x new file mode 100644 index 0000000000..f62a3c8824 --- /dev/null +++ b/legacy/eina/src/include/eina_inline_f16p16.x @@ -0,0 +1,77 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2008 Jorge Luis Zapata Muga + * Copyright (C) 2009 Cedric BAIL + * + * This library 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. + * + * This library 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 this library; + * if not, see . + */ + +#ifndef EINA_INLINE_F16P16_X_ +#define EINA_INLINE_F16P16_X_ + +static inline Eina_F16p16 +eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b) +{ + return a + b; +} + +static inline Eina_F16p16 +eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b) +{ + return a - b; +} + +static inline Eina_F16p16 +eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b) +{ + return ((int64_t)a * (int64_t)b) >> 16; +} + +static inline Eina_F16p16 +eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b) +{ + return (Eina_F16p16) ((((int64_t) a) << 16) / (int64_t) b); +} + +static inline Eina_F16p16 +eina_f16p16_sqrt(Eina_F16p16 a) +{ + unsigned int root, remHi, remLo, testDiv, count; + + root = 0; /* Clear root */ + remHi = 0; /* Clear high part of partial remainder */ + remLo = a; /* Get argument into low part of partial remainder */ + count = (15 + (16 >> 1)); /* Load loop counter */ + do { + remHi = (remHi << 2) | (remLo >> 30); + remLo <<= 2; /* get 2 bits of arg */ + root <<= 1; /* Get ready for the next bit in the root */ + testDiv = (root << 1) + 1; /* Test radical */ + if (remHi >= testDiv) + { + remHi -= testDiv; + root++; + } + } while (count-- != 0); + + return root; +} + +static inline unsigned int +eina_f16p16_fracc_get(Eina_F16p16 v) +{ + return (v & 0xffff); +} + +#endif diff --git a/legacy/eina/src/include/eina_inline_f32p32.x b/legacy/eina/src/include/eina_inline_f32p32.x new file mode 100644 index 0000000000..9e90e87325 --- /dev/null +++ b/legacy/eina/src/include/eina_inline_f32p32.x @@ -0,0 +1,76 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2009 Jorge Luis Zapata Muga, Cedric BAIL + * + * This library 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. + * + * This library 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 this library; + * if not, see . + */ + +#ifndef EINA_INLINE_F32P32_X_ +# define EINA_INLINE_F32P32_X_ + +static inline Eina_F32p32 +eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b) +{ + return a + b; +} + +static inline Eina_F32p32 +eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b) +{ + return a - b; +} + +static inline Eina_F32p32 +eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b) +{ + return (a * b) >> 32; +} + +static inline Eina_F32p32 +eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b) +{ + /* If a > 2³², you will have a wrong result due to overflow. */ + return (a << 32) / b; +} + +static inline Eina_F32p32 +eina_f32p32_sqrt(Eina_F32p32 a) +{ + uint64_t root, remHi, remLo, testDiv, count; + + root = 0; /* Clear root */ + remHi = 0; /* Clear high part of partial remainder */ + remLo = a; /* Get argument into low part of partial remainder */ + count = (31 + (32 >> 1)); /* Load loop counter */ + do { + remHi = (remHi << 2) | (remLo >> 30); + remLo <<= 2; /* get 2 bits of arg */ + root <<= 1; /* Get ready for the next bit in the root */ + testDiv = (root << 1) + 1; /* Test radical */ + if (remHi >= testDiv) { + remHi -= testDiv; + root++; + } + } while (count-- != 0); + + return root; +} + +static inline unsigned int +eina_f32p32_fracc_get(Eina_F32p32 v) +{ + return (unsigned int)v; +} + +#endif diff --git a/legacy/eina/src/include/eina_inline_f8p24.x b/legacy/eina/src/include/eina_inline_f8p24.x new file mode 100644 index 0000000000..7e452202df --- /dev/null +++ b/legacy/eina/src/include/eina_inline_f8p24.x @@ -0,0 +1,76 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2008 Jorge Luis Zapata Muga + * Copyright (C) 2009 Cedric BAIL + * + * This library 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. + * + * This library 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 this library; + * if not, see . + */ + +#ifndef EINA_INLINE_F8P24_X_ +#define EINA_INLINE_F8P24_X_ + +static inline Eina_F8p24 +eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b) +{ + return a + b; +} + +static inline Eina_F8p24 +eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b) +{ + return a - b; +} + +static inline Eina_F8p24 +eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b) +{ + return ((int64_t) a * (int64_t) b) >> 24; +} + +static inline Eina_F8p24 +eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b) +{ + return (Eina_F8p24) ((((int64_t) a) << 24) / (int64_t) b); +} + +static inline Eina_F8p24 +eina_f8p24_sqrt(Eina_F8p24 a) +{ + unsigned int root, remHi, remLo, testDiv, count; + + root = 0; /* Clear root */ + remHi = 0; /* Clear high part of partial remainder */ + remLo = a; /* Get argument into low part of partial remainder */ + count = (23 + (24 >> 1)); /* Load loop counter */ + do { + remHi = (remHi << 2) | (remLo >> 30); + remLo <<= 2; /* get 2 bits of arg */ + root <<= 1; /* Get ready for the next bit in the root */ + testDiv = (root << 1) + 1; /* Test radical */ + if (remHi >= testDiv) + { + remHi -= testDiv; + root++; + } + } while (count-- != 0); + return (root); +} + +static inline unsigned int +eina_f8p24_fracc_get(Eina_F8p24 v) +{ + return (v & 0xffffff); +} + +#endif diff --git a/legacy/eina/src/include/eina_inline_fp.x b/legacy/eina/src/include/eina_inline_fp.x new file mode 100644 index 0000000000..b8603bba2e --- /dev/null +++ b/legacy/eina/src/include/eina_inline_fp.x @@ -0,0 +1,153 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2008 Jorge Luis Zapata Muga + * Copyright (C) 2009 Cedric BAIL + * + * This library 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. + * + * This library 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 this library; + * if not, see . + */ + +#ifndef EINA_INLINE_FP_X_ +# define EINA_INLINE_FP_X_ + +static inline Eina_F32p32 +eina_f32p32_int_from(int32_t v) +{ + return (Eina_F32p32) v << 32; +} + +static inline int32_t +eina_f32p32_int_to(Eina_F32p32 v) +{ + return v >> 32; +} + +static inline Eina_F32p32 +eina_f32p32_double_from(double v) +{ + Eina_F32p32 r; + r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5)); + return r; +} + +static inline double +eina_f32p32_double_to(Eina_F32p32 v) +{ + double r; + r = v / 4294967296.0; + return r; +} + + + +static inline Eina_F16p16 +eina_f16p16_int_from(int32_t v) +{ + return v << 16; +} + +static inline int32_t +eina_f16p16_int_to(Eina_F16p16 v) +{ + return v >> 16; +} + +static inline Eina_F16p16 +eina_f16p16_float_from(float v) +{ + Eina_F16p16 r; + + r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f)); + return r; +} + +static inline float +eina_f16p16_float_to(Eina_F16p16 v) +{ + float r; + + r = v / 65536.0f; + return r; +} + + + +static inline Eina_F8p24 +eina_f8p24_int_from(int32_t v) +{ + return v << 24; +} + +static inline int32_t +eina_f8p24_int_to(Eina_F8p24 v) +{ + return v >> 24; +} + +static inline Eina_F8p24 +eina_f8p24_float_from(float v) +{ + Eina_F8p24 r; + + r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f)); + return r; +} + +static inline float +eina_f8p24_float_to(Eina_F8p24 v) +{ + float r; + + r = v / 16777216.0f; + return r; +} + + + +static inline Eina_F32p32 +eina_f16p16_to_f32p32(Eina_F16p16 a) +{ + return ((Eina_F32p32) a) << 16; +} + +static inline Eina_F32p32 +eina_f8p24_to_f32p32(Eina_F8p24 a) +{ + return ((Eina_F32p32) a) << 8; +} + +static inline Eina_F16p16 +eina_f32p32_to_f16p16(Eina_F32p32 a) +{ + return (Eina_F16p16) a >> 16; +} + +static inline Eina_F16p16 +eina_f8p24_to_f16p16(Eina_F8p24 a) +{ + return (Eina_F16p16) a >> 8; +} + +static inline Eina_F8p24 +eina_f32p32_to_f8p24(Eina_F32p32 a) +{ + return (Eina_F8p24) a >> 8; +} + +static inline Eina_F8p24 +eina_f16p16_to_f8p24(Eina_F16p16 a) +{ + return (Eina_F8p24) a << 8; +} + +#endif diff --git a/legacy/eina/src/lib/eina_convert.c b/legacy/eina/src/lib/eina_convert.c index 4d6566f3fe..175c9e7a63 100644 --- a/legacy/eina/src/lib/eina_convert.c +++ b/legacy/eina/src/lib/eina_convert.c @@ -32,7 +32,7 @@ /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */ #include "eina_safety_checks.h" #include "eina_convert.h" -#include "eina_f32p32.h" +#include "eina_fp.h" /*============================================================================* * Local *