summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-01-06 11:33:20 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-01-06 15:58:46 -0800
commit8e7d7d9d58710b0a2373db7e71110cabaeaac5dc (patch)
tree3bbb8573a61c67dbd7e6f3c2caee72733555d7c9 /src/lib/eina
parent89f429c0e7c7b71916230a6634d061dae7457db1 (diff)
eina: move to use memcmp and rename eina_{flt,dbl}eq to eina_{flt,dbl}_exact.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_inline_util.x36
-rw-r--r--src/lib/eina/eina_util.c32
-rw-r--r--src/lib/eina/eina_util.h6
3 files changed, 40 insertions, 34 deletions
diff --git a/src/lib/eina/eina_inline_util.x b/src/lib/eina/eina_inline_util.x
new file mode 100644
index 0000000000..aa04917af6
--- /dev/null
+++ b/src/lib/eina/eina_inline_util.x
@@ -0,0 +1,36 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2017 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_UTIL_INLINE_H_
20#define EINA_UTIL_INLINE_H_
21
22#include <string.h>
23
24static inline Eina_Bool
25eina_dbl_exact(double a, double b)
26{
27 return memcmp(&a, &b, sizeof (double)) == 0;
28}
29
30static inline Eina_Bool
31eina_flt_exact(float a, float b)
32{
33 return memcmp(&a, &b, sizeof (float)) == 0;
34}
35
36#endif /* EINA_UTIL_INLINE_H_ */
diff --git a/src/lib/eina/eina_util.c b/src/lib/eina/eina_util.c
index a35888491d..62e1a79b42 100644
--- a/src/lib/eina/eina_util.c
+++ b/src/lib/eina/eina_util.c
@@ -100,35 +100,3 @@ eina_environment_tmp_get(void)
100 return tmp; 100 return tmp;
101#endif 101#endif
102} 102}
103
104#if defined(_MSC_VER)
105#elif defined(__clang__)
106# pragma clang diagnostic push
107# pragma clang diagnostic ignored "-Wfloat-equal"
108#elif defined(__GNUC__)
109# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
110# pragma GCC diagnostic push
111# pragma GCC diagnostic ignored "-Wfloat-equal"
112# endif
113#endif
114
115EAPI Eina_Bool
116eina_dbleq(double a, double b)
117{
118 return a == b;
119}
120
121EAPI Eina_Bool
122eina_flteq(float a, float b)
123{
124 return a == b;
125}
126
127#if defined(_MSC_VER)
128#elif defined(__clang__)
129# pragma clang diagnostic pop
130#elif defined(__GNUC__)
131# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
132# pragma GCC diagnostic pop
133# endif
134#endif
diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h
index e0b27c6c89..cc5843db76 100644
--- a/src/lib/eina/eina_util.h
+++ b/src/lib/eina/eina_util.h
@@ -58,7 +58,7 @@ EAPI const char *eina_environment_tmp_get(void);
58 * @return @c true if two doubles match 58 * @return @c true if two doubles match
59 * @since 1.19 59 * @since 1.19
60 */ 60 */
61EAPI Eina_Bool eina_dbleq(double a, double b); 61static inline Eina_Bool eina_dbl_exact(double a, double b);
62 62
63/** 63/**
64 * @brief Warningless comparison of floats using == 64 * @brief Warningless comparison of floats using ==
@@ -68,7 +68,7 @@ EAPI Eina_Bool eina_dbleq(double a, double b);
68 * @return @c true if two floats match 68 * @return @c true if two floats match
69 * @since 1.19 69 * @since 1.19
70 */ 70 */
71EAPI Eina_Bool eina_flteq(float a, float b); 71static inline Eina_Bool eina_flt_exact(float a, float b);
72 72
73/** 73/**
74 * @brief Safe comparison of float 74 * @brief Safe comparison of float
@@ -112,4 +112,6 @@ EAPI Eina_Bool eina_flteq(float a, float b);
112 * @} 112 * @}
113 */ 113 */
114 114
115#include "eina_inline_util.x"
116
115#endif 117#endif