aboutsummaryrefslogtreecommitdiffstats
path: root/qemu-common.h
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-05-09 15:20:22 +0200
committerDavid 'Digit' Turner <digit@android.com>2011-06-01 17:08:17 +0200
commit795bb19daea966401df15bbf23c57b98848eec23 (patch)
tree650c9b1c3582f51707172fc73c14ea3e1a367f47 /qemu-common.h
parent45c3be00d4c1f85ba8bbf34827c024fbc636725f (diff)
downloadexternal_qemu-795bb19daea966401df15bbf23c57b98848eec23.zip
external_qemu-795bb19daea966401df15bbf23c57b98848eec23.tar.gz
external_qemu-795bb19daea966401df15bbf23c57b98848eec23.tar.bz2
qemu-common.h: other intergrates
Change-Id: Iaf5221814247d7686ec3d57abeab097b09c6a5dd
Diffstat (limited to 'qemu-common.h')
-rw-r--r--qemu-common.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/qemu-common.h b/qemu-common.h
index fd951d5..6860fb3 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -151,8 +151,6 @@ void qemu_bh_delete(QEMUBH *bh);
int qemu_bh_poll(void);
void qemu_bh_update_timeout(int *timeout);
-uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
-
void qemu_get_timedate(struct tm *tm, int offset);
int qemu_timedate_diff(struct tm *tm);
@@ -330,11 +328,16 @@ typedef struct QEMUIOVector {
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov);
void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
+void qemu_iovec_copy(QEMUIOVector *dst, QEMUIOVector *src, uint64_t skip,
+ size_t size);
void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t size);
void qemu_iovec_destroy(QEMUIOVector *qiov);
void qemu_iovec_reset(QEMUIOVector *qiov);
void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf);
void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
+void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t count);
+void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count,
+ size_t skip);
/* Convert a byte between binary and BCD. */
static inline uint8_t to_bcd(uint8_t val)
@@ -347,6 +350,30 @@ static inline uint8_t from_bcd(uint8_t val)
return ((val >> 4) * 10) + (val & 0x0f);
}
+/* compute with 96 bit intermediate result: (a*b)/c */
+static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
+{
+ union {
+ uint64_t ll;
+ struct {
+#ifdef HOST_WORDS_BIGENDIAN
+ uint32_t high, low;
+#else
+ uint32_t low, high;
+#endif
+ } l;
+ } u, res;
+ uint64_t rl, rh;
+
+ u.ll = a;
+ rl = (uint64_t)u.l.low * (uint64_t)b;
+ rh = (uint64_t)u.l.high * (uint64_t)b;
+ rh += (rl >> 32);
+ res.l.high = rh / c;
+ res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
+ return res.ll;
+}
+
#include "module.h"
typedef enum DisplayType