Changeset 4738d84 in mainline


Ignore:
Timestamp:
2010-07-20T13:58:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46757a6
Parents:
e2650d3
Message:

explicitly use 64b types to avoid overflows in trivial cases
(overflow due to adding two large 64b values can still occur, but it is less likely)

File:
1 edited

Legend:

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

    re2650d3 r4738d84  
    4949 *
    5050 */
    51 NO_TRACE static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2,
    52     size_t sz2)
     51NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2,
     52    uint64_t sz2)
    5353{
    54         uintptr_t e1 = s1 + sz1;
    55         uintptr_t e2 = s2 + sz2;
     54        uint64_t e1 = s1 + sz1;
     55        uint64_t e2 = s2 + sz2;
    5656       
    5757        return ((s1 < e2) && (s2 < e1));
     
    6666 *
    6767 */
    68 NO_TRACE static inline int iswithin(uintptr_t s1, size_t sz1, uintptr_t s2,
    69     size_t sz2)
     68NO_TRACE static inline int iswithin(uint64_t s1, uint64_t sz1, uint64_t s2,
     69    uint64_t sz2)
    7070{
    71         uintptr_t e1 = s1 + sz1;
    72         uintptr_t e2 = s2 + sz2;
     71        uint64_t e1 = s1 + sz1;
     72        uint64_t e2 = s2 + sz2;
    7373       
    7474        return ((s1 <= s2) && (e1 >= e2));
Note: See TracChangeset for help on using the changeset viewer.