[lttng-dev] [PATCH v2] Fix: alignment problems on targets not supporting unaligned access.
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Fri May 16 13:58:52 EDT 2014
David, just in case you missed this one, it's for tools.
(it lacks the usual [PATCH lttng-tools] header prefix)
Thanks,
Mathieu
----- Original Message -----
> From: "rongqing li" <rongqing.li at windriver.com>
> To: lttng-dev at lists.lttng.org, "mathieu desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: dgoulet at efficios.com
> Sent: Thursday, May 15, 2014 9:10:07 PM
> Subject: [PATCH v2] Fix: alignment problems on targets not supporting unaligned access.
>
> 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
>
>
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list