diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-21 14:15:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-08-21 14:15:00 +0200 |
commit | a8fe90b28bdd9643cfd4168c006069d165cef101 (patch) | |
tree | 80cd5820ce9be0d4a803e1f9c55188b9eb68208d /tools.h | |
parent | 0b9aa1c1a8c5df42270866baf5f80cfb73cccdea (diff) | |
download | vdr-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.h | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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; |