[lttng-dev] [PATCH] Fixed alignment problems on targets not supporting unaligned access.

rongqing.li at windriver.com rongqing.li at windriver.com
Thu May 15 04:50:49 EDT 2014


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

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

Signed-off-by: Fredrik Markstr枚m <fredrik.markstrom at gmail.com>
Signed-off-by: Li RongQing <rongqing.li at windriver.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