forked from enlightenment/efl
eina: move to use memcmp and rename eina_{flt,dbl}eq to eina_{flt,dbl}_exact.
This commit is contained in:
parent
89f429c0e7
commit
8e7d7d9d58
|
@ -93,6 +93,7 @@ lib/eina/eina_crc.h \
|
|||
lib/eina/eina_inline_crc.x \
|
||||
lib/eina/eina_evlog.h \
|
||||
lib/eina/eina_util.h \
|
||||
lib/eina/eina_inline_util.x \
|
||||
lib/eina/eina_quaternion.h \
|
||||
lib/eina/eina_vector.h \
|
||||
lib/eina/eina_inline_vector.x \
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* EINA - EFL data type library
|
||||
* Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef EINA_UTIL_INLINE_H_
|
||||
#define EINA_UTIL_INLINE_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static inline Eina_Bool
|
||||
eina_dbl_exact(double a, double b)
|
||||
{
|
||||
return memcmp(&a, &b, sizeof (double)) == 0;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
eina_flt_exact(float a, float b)
|
||||
{
|
||||
return memcmp(&a, &b, sizeof (float)) == 0;
|
||||
}
|
||||
|
||||
#endif /* EINA_UTIL_INLINE_H_ */
|
|
@ -100,35 +100,3 @@ eina_environment_tmp_get(void)
|
|||
return tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#elif defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#elif defined(__GNUC__)
|
||||
# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wfloat-equal"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
EAPI Eina_Bool
|
||||
eina_dbleq(double a, double b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eina_flteq(float a, float b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#elif defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
@ -58,7 +58,7 @@ EAPI const char *eina_environment_tmp_get(void);
|
|||
* @return @c true if two doubles match
|
||||
* @since 1.19
|
||||
*/
|
||||
EAPI Eina_Bool eina_dbleq(double a, double b);
|
||||
static inline Eina_Bool eina_dbl_exact(double a, double b);
|
||||
|
||||
/**
|
||||
* @brief Warningless comparison of floats using ==
|
||||
|
@ -68,7 +68,7 @@ EAPI Eina_Bool eina_dbleq(double a, double b);
|
|||
* @return @c true if two floats match
|
||||
* @since 1.19
|
||||
*/
|
||||
EAPI Eina_Bool eina_flteq(float a, float b);
|
||||
static inline Eina_Bool eina_flt_exact(float a, float b);
|
||||
|
||||
/**
|
||||
* @brief Safe comparison of float
|
||||
|
@ -112,4 +112,6 @@ EAPI Eina_Bool eina_flteq(float a, float b);
|
|||
* @}
|
||||
*/
|
||||
|
||||
#include "eina_inline_util.x"
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue