On 2017-02-23 04:25, Yousong Zhou wrote:
> This also fixes FS#544 as the allocation causing possible address alignment
> issue should now disappear
> 
> Size comparison on x86_64 system
> 
>       function                                             old     new   delta
>       alloc_module                                         398     245    -153
>       
> ------------------------------------------------------------------------------
>       (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-153)           Total: 
> -153 bytes
> 
> Signed-off-by: Yousong Zhou <yszhou4t...@gmail.com>
> ---
> Ted, please test it on your board to see if it can fix your issue.
> 
> The patch was only run-tested on armvirt cortex-a15 machine.
> 
> I actually thought about patching calloc_a to make sizeof_long-aligned
> allocation as the comment in libubox/utils.h says the func should "allocate a
> block of memory big enough to hold multiple aligned objects."
> 
> But that's too corase a solution for a fundamental lib and can waste runtime
> memory.  Maybe we should reword that comment and provide a few helper macros
> like SHORT_ALIGN, INT_ALIGN, LONG_ALIGN?
I think aligning to 4 bytes by default in calloc_a might be a good idea.
For cases where it's important to not waste any bytes, we could have an
unaligned variant of it.

- Felix

_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to