summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2009-12-06 12:57:45 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2009-12-06 12:57:45 +0100
commit6a208294bef44f588e067383aa2e35af1aa23a16 (patch)
tree463f2aa875c26a6d0df507c2559a9bb821111082 /tools.h
parent1b973fd8ebb0a5dca7c82fac0651c33ecb7edd50 (diff)
downloadvdr-6a208294bef44f588e067383aa2e35af1aa23a16.tar.gz
vdr-6a208294bef44f588e067383aa2e35af1aa23a16.tar.bz2
Several code modifications to avoid compiler warnings
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools.h b/tools.h
index 22b7e99b..4fbb27fb 100644
--- a/tools.h
+++ b/tools.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.h 2.2 2009/04/14 20:41:39 kls Exp $
+ * $Id: tools.h 2.3 2009/12/06 11:24:12 kls Exp $
*/
#ifndef __TOOLS_H
@@ -13,7 +13,9 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <float.h>
#include <iconv.h>
+#include <math.h>
#include <poll.h>
#include <stddef.h>
#include <stdint.h>
@@ -60,7 +62,7 @@ void syslog_with_tid(int priority, const char *format, ...) __attribute__ ((form
int BCD2INT(int x);
// Unfortunately there are no platform independent macros for unaligned
-// access. so we do it this way:
+// access, so we do it this way:
template<class T> inline T get_unaligned(T *p)
{
@@ -74,6 +76,14 @@ template<class T> inline void put_unaligned(unsigned int v, T* p)
((s *)p)->v = v;
}
+// Comparing doubles for equality is unsafe, but unfortunately we can't
+// overwrite operator==(double, double), so this will have to do:
+
+inline bool DoubleEqual(double a, double b)
+{
+ return fabs(a - b) <= DBL_EPSILON;
+}
+
// When handling strings that might contain UTF-8 characters, it may be necessary
// to process a "symbol" that consists of several actual character bytes. The
// following functions allow transparently accessing a "char *" string without