aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-11-20 00:03:47 +0000
committerPaul Brook <paul@codesourcery.com>2009-11-22 21:27:40 +0000
commitabd0c6bda0c89f36528e1a7efac99277607a5280 (patch)
treec9e5adc54b76a3e428c3222a5e48b2c1cd39764c /qemu-common.h
parentMakefile dependencies for device configs (diff)
downloadqemu-kvm-abd0c6bda0c89f36528e1a7efac99277607a5280.tar.gz
qemu-kvm-abd0c6bda0c89f36528e1a7efac99277607a5280.tar.bz2
qemu-kvm-abd0c6bda0c89f36528e1a7efac99277607a5280.zip
BCD cleanup
Combine multiple BCD implementations. Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'qemu-common.h')
-rw-r--r--qemu-common.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/qemu-common.h b/qemu-common.h
index b779cfe69..b1e038bd0 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -248,6 +248,17 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
struct Monitor;
typedef struct Monitor Monitor;
+/* Convert a byte between binary and BCD. */
+static inline uint8_t to_bcd(uint8_t val)
+{
+ return ((val / 10) << 4) | (val % 10);
+}
+
+static inline uint8_t from_bcd(uint8_t val)
+{
+ return ((val >> 4) * 10) + (val & 0x0f);
+}
+
#include "module.h"
#endif /* dyngen-exec.h hack */