summaryrefslogtreecommitdiff
path: root/tools.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-08-21 14:15:00 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-08-21 14:15:00 +0200
commita8fe90b28bdd9643cfd4168c006069d165cef101 (patch)
tree80cd5820ce9be0d4a803e1f9c55188b9eb68208d /tools.h
parent0b9aa1c1a8c5df42270866baf5f80cfb73cccdea (diff)
downloadvdr-a8fe90b28bdd9643cfd4168c006069d165cef101.tar.gz
vdr-a8fe90b28bdd9643cfd4168c006069d165cef101.tar.bz2
Replaced the get/put_unaligned() macros from <asm/unaligned.h> with own inline functions1.3.30
Diffstat (limited to 'tools.h')
-rw-r--r--tools.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/tools.h b/tools.h
index 0644f4e6..0a8ee8b6 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 1.73 2005/08/06 09:53:21 kls Exp $
+ * $Id: tools.h 1.74 2005/08/21 14:06:38 kls Exp $
*/
#ifndef __TOOLS_H
@@ -57,6 +57,21 @@ template<class T> inline void swap(T &a, T &b) { T t = a; a = b; b = t; }
#define BCDCHARTOINT(x) (10 * ((x & 0xF0) >> 4) + (x & 0xF))
int BCD2INT(int x);
+// Unfortunately there are no platform independent macros for unaligned
+// access. so we do it this way:
+
+template<class T> inline T get_unaligned(T *p)
+{
+ struct s { T v; } __attribute__((packed));
+ return ((s *)p)->v;
+}
+
+template<class T> inline void put_unaligned(unsigned int v, T* p)
+{
+ struct s { T v; } __attribute__((packed));
+ ((s *)p)->v = v;
+}
+
class cString {
private:
char *s;