From: Fredrik Markström Date: Fri, 16 May 2014 01:10:07 +0000 (+0800) Subject: Fix: alignment problems on targets not supporting unaligned access. X-Git-Tag: v2.5.0-rc1~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=58d494e4e885915ac387de8aa74f810d4d160bb0;p=lttng-tools.git Fix: alignment problems on targets not supporting unaligned access. 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 Signed-off-by: Roy Li Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- 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 762d60464..8c6dc96ff 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;