Changeset 082b7f1 in mainline


Ignore:
Timestamp:
2012-11-02T19:07:28Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0941e9ae
Parents:
35a3d950
Message:

Make the overlaps() macro accept zero sizes and also tolerate
bases and sizes that wrap-around -1UL back to 0 when added together.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/macros.h

    r35a3d950 r082b7f1  
    5252    uint64_t sz2)
    5353{
    54         uint64_t e1 = s1 + sz1;
    55         uint64_t e2 = s2 + sz2;
    56        
    57         return ((s1 < e2) && (s2 < e1));
     54        uint64_t e1 = s1 + sz1 - 1;
     55        uint64_t e2 = s2 + sz2 - 1;
     56
     57        /* both sizes are non-zero */
     58        if (sz1 && sz2)
     59                return ((s1 <= e2) && (s2 <= e1));
     60
     61        /* one size is non-zero */
     62        if (sz2)
     63                return ((s1 >= s2) && (s1 <= e2));
     64        if (sz1)
     65                return ((s2 >= s1) && (s2 <= e1));
     66
     67        /* both are zero */
     68        return (s1 == s2);
    5869}
    5970
Note: See TracChangeset for help on using the changeset viewer.