summaryrefslogtreecommitdiff
path: root/util/cutils.c
diff options
context:
space:
mode:
authorVeronia Bahaa <veroniabahaa@gmail.com>2016-03-20 19:16:19 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-22 22:20:17 +0100
commitf348b6d1a53e5271cf1c9f9acc4646b4b98c1771 (patch)
tree2eb2da02e51400b1b1ecae295e32a81c7a889ab1 /util/cutils.c
parent73bcb24d932912f8e75e1d88da0fc0ac6d4bce78 (diff)
downloadqemu-f348b6d1a53e5271cf1c9f9acc4646b4b98c1771.tar.gz
util: move declarations out of qemu-common.h
Move declarations out of qemu-common.h for functions declared in utils/ files: e.g. include/qemu/path.h for utils/path.c. Move inline functions out of qemu-common.h and into new files (e.g. include/qemu/bcd.h) Signed-off-by: Veronia Bahaa <veroniabahaa@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util/cutils.c')
-rw-r--r--util/cutils.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/cutils.c b/util/cutils.c
index c3dd53453a..43d1afbbec 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -29,6 +29,7 @@
#include "qemu/sockets.h"
#include "qemu/iov.h"
#include "net/net.h"
+#include "qemu/cutils.h"
void strpadcpy(char *buf, int buf_size, const char *str, char pad)
{
@@ -160,6 +161,38 @@ int qemu_fdatasync(int fd)
#endif
}
+/* vector definitions */
+#ifdef __ALTIVEC__
+#include <altivec.h>
+/* The altivec.h header says we're allowed to undef these for
+ * C++ compatibility. Here we don't care about C++, but we
+ * undef them anyway to avoid namespace pollution.
+ */
+#undef vector
+#undef pixel
+#undef bool
+#define VECTYPE __vector unsigned char
+#define SPLAT(p) vec_splat(vec_ld(0, p), 0)
+#define ALL_EQ(v1, v2) vec_all_eq(v1, v2)
+#define VEC_OR(v1, v2) ((v1) | (v2))
+/* altivec.h may redefine the bool macro as vector type.
+ * Reset it to POSIX semantics. */
+#define bool _Bool
+#elif defined __SSE2__
+#include <emmintrin.h>
+#define VECTYPE __m128i
+#define SPLAT(p) _mm_set1_epi8(*(p))
+#define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF)
+#define VEC_OR(v1, v2) (_mm_or_si128(v1, v2))
+#else
+#define VECTYPE unsigned long
+#define SPLAT(p) (*(p) * (~0UL / 255))
+#define ALL_EQ(v1, v2) ((v1) == (v2))
+#define VEC_OR(v1, v2) ((v1) | (v2))
+#endif
+
+#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8
+
static bool
can_use_buffer_find_nonzero_offset_inner(const void *buf, size_t len)
{