[lttng-dev] [PATCH v2] Fix: alignment problems on targets not supporting unaligned access.

rongqing.li at windriver.com rongqing.li at windriver.com
Thu May 15 21:10:07 EDT 2014


From: Fredrik Markström <fredrik.markstrom at gmail.com>

Accessing floats, doubles and 64 bit int at unaligned addresses is not
supported on all configurations of arm processors and if it is it's
emulated and slow. This patch replaces direct assignments with memcpy.

Signed-off-by: Fredrik Markström <fredrik.markstrom at gmail.com>
Signed-off-by: Roy Li <rongqing.li at windriver.com>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c b/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c
index 762d604..8c6dc96 100644
--- a/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c
+++ b/src/lib/lttng-ctl/filter/filter-visitor-generate-bytecode.c
@@ -222,7 +222,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node)
 		if (!insn)
 			return -ENOMEM;
 		insn->op = FILTER_OP_LOAD_S64;
-		*(int64_t *) insn->data = node->u.load.u.num;
+		memcpy(insn->data, &node->u.load.u.num, sizeof(int64_t));
 		ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len);
 		free(insn);
 		return ret;
@@ -237,7 +237,7 @@ int visit_node_load(struct filter_parser_ctx *ctx, struct ir_op *node)
 		if (!insn)
 			return -ENOMEM;
 		insn->op = FILTER_OP_LOAD_DOUBLE;
-		*(double *) insn->data = node->u.load.u.flt;
+		memcpy(insn->data, &node->u.load.u.flt, sizeof(double));
 		ret = bytecode_push(&ctx->bytecode, insn, 1, insn_len);
 		free(insn);
 		return ret;
-- 
1.7.10.4




More information about the lttng-dev mailing list