You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Mladen Turk (JIRA)" <ji...@apache.org> on 2010/05/28 19:56:38 UTC

[jira] Resolved: (TS-376) Fix memory alignmet inlies in ink_align.h

     [ https://issues.apache.org/jira/browse/TS-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mladen Turk resolved TS-376.
----------------------------

    Resolution: Fixed

Resolved by unifying alignment code

> Fix memory alignmet inlies in ink_align.h
> -----------------------------------------
>
>                 Key: TS-376
>                 URL: https://issues.apache.org/jira/browse/TS-376
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Core
>            Reporter: Mladen Turk
>            Assignee: Mladen Turk
>             Fix For: 2.1.1
>
>
> Alignment code defined in ink_align.h is:
> pointer = (char *)(((unsigned long) pointer + widthmask) & (~widthmask));
> It is assumed that widthmask parameter is power of two minus one.
> The upper math gives wrong results.
> Eg.
> Aligning memory with the base address of 0x1001 to 512 bytes is done as following in the code:
> aligned = align_pointer_forward(base, 511);
> This gives resulting address: 0x1200 which is fine
> However if the base address was 0x11F0 the resulting address would be 0x1F0 instead 0x1200
> Solution is to use the
> pointer = (char *)(((unsigned long) pointer + alignment) & ~(alignment - 1));
> and use the real alignment numbers in the api instead masked values

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.