lkml.org 
[lkml]   [2013]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 2/2] word-at-a-time: provide generic big-endian zero_bytemask implementation
    Date
    Whilst architectures may be able to do better than this (which they can,
    by simply defining their own macro), this is a generic stab at a
    zero_bytemask implementation for the asm-generic, big-endian
    word-at-a-time implementation.

    On arm64, a clz instruction is used to implement the fls efficiently.

    Signed-off-by: Will Deacon <will.deacon@arm.com>
    ---

    I'm happy to move this into the arch/ backends, but there's a strong
    linkage between this and the generic word-at-a-time algorithm that could
    easily break if they don't live together.

    include/asm-generic/word-at-a-time.h | 8 ++++++++
    1 file changed, 8 insertions(+)

    diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
    index 3f21f1b72e45..d3909effd725 100644
    --- a/include/asm-generic/word-at-a-time.h
    +++ b/include/asm-generic/word-at-a-time.h
    @@ -49,4 +49,12 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
    return (val + c->high_bits) & ~rhs;
    }

    +#ifndef zero_bytemask
    +#ifdef CONFIG_64BIT
    +#define zero_bytemask(mask) (~0ul << fls64(mask))
    +#else
    +#define zero_bytemask(mask) (~0ul << fls(mask))
    +#endif /* CONFIG_64BIT */
    +#endif /* zero_bytemask */
    +
    #endif /* _ASM_WORD_AT_A_TIME_H */
    --
    1.8.2.2


    \
     
     \ /
      Last update: 2013-12-10 20:41    [W:2.965 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site