mirror of https://github.com/xemu-project/xemu.git
vhost: replace ffsl with ctzl
Avoid using the GNU extesion ffsl which is not implemented in musl libc.
The atomic_xchg() means we know that vhost_log_chunk_t will never be
larger than the 'long' type, so ctzl() is always sufficient.
See also commit fbeadf50
(bitops: unify bitops_ffsl with the one in
host-utils.h, call it bitops_ctzl) on why ctzl should be used instead
of ffsl.
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
adf9d70b0d
commit
747eb78baa
|
@ -41,7 +41,6 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
|
||||||
|
|
||||||
for (;from < to; ++from) {
|
for (;from < to; ++from) {
|
||||||
vhost_log_chunk_t log;
|
vhost_log_chunk_t log;
|
||||||
int bit;
|
|
||||||
/* We first check with non-atomic: much cheaper,
|
/* We first check with non-atomic: much cheaper,
|
||||||
* and we expect non-dirty to be the common case. */
|
* and we expect non-dirty to be the common case. */
|
||||||
if (!*from) {
|
if (!*from) {
|
||||||
|
@ -51,12 +50,11 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
|
||||||
/* Data must be read atomically. We don't really need barrier semantics
|
/* Data must be read atomically. We don't really need barrier semantics
|
||||||
* but it's easier to use atomic_* than roll our own. */
|
* but it's easier to use atomic_* than roll our own. */
|
||||||
log = atomic_xchg(from, 0);
|
log = atomic_xchg(from, 0);
|
||||||
while ((bit = sizeof(log) > sizeof(int) ?
|
while (log) {
|
||||||
ffsll(log) : ffs(log))) {
|
int bit = ctzl(log);
|
||||||
hwaddr page_addr;
|
hwaddr page_addr;
|
||||||
hwaddr section_offset;
|
hwaddr section_offset;
|
||||||
hwaddr mr_offset;
|
hwaddr mr_offset;
|
||||||
bit -= 1;
|
|
||||||
page_addr = addr + bit * VHOST_LOG_PAGE;
|
page_addr = addr + bit * VHOST_LOG_PAGE;
|
||||||
section_offset = page_addr - section->offset_within_address_space;
|
section_offset = page_addr - section->offset_within_address_space;
|
||||||
mr_offset = section_offset + section->offset_within_region;
|
mr_offset = section_offset + section->offset_within_region;
|
||||||
|
|
Loading…
Reference in New Issue