Il 17/08/2013 10:23, Laszlo Ersek ha scritto: > What Paolo posted seems almost identical. > > clz32(l): leading zeros in "l" > qemu_fls(l) == 32 - clz32(l): position of leftmost bit set, 1-based > qemu_fls(l) - 1: position of leftmost bit set, 0-based > > Not sure if the (l & (l - 1)) check is needed in Paolo's patch. clz32() > is not generally usable when l==0, so maybe that's (too) what the check > is for. OTOH maybe l==0 is not even possible when entering > memory_access_size().
The check was an attempt at placating complaints about possible performance problems. :) > Second, Paolo's patch might lack the "max(3, ...)" part. Since you > didn't call my previous example with l==9 retarded, I guess clamping > (qemu_fls(l) - 1) at 3 would be necessary. That shouldn't happen, since an uint64_t is all you have for the datum. access_size_max should never exceed 8. I don't really care which patch goes in, Alex's is fine as well. Paolo