函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:mm\kasan\generic.c Create Date:2022-07-27 17:27:32
首页 Copyright©Brick

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
static __always_inline unsigned long memory_is_nonzero(const void *start,
                        const void *end)
{
    unsigned int words;
    unsigned long ret;
    unsigned int prefix = (unsigned long)start % 8;
 
    if (end - start <= 16)
        return bytes_is_nonzero(start, end - start);
 
    if (prefix) {
        prefix = 8 - prefix;
        ret = bytes_is_nonzero(start, prefix);
        if (unlikely(ret))
            return ret;
        start += prefix;
    }
 
    words = (end - start) / 8;
    while (words) {
        if (unlikely(*(u64 *)start))
            return bytes_is_nonzero(start, 8);
        start += 8;
        words--;
    }
 
    return bytes_is_nonzero(start, (end - start) % 8);
}