Neil Brown wrote: >On Friday July 11, willy@debian.org wrote: > >># define do_div(n,base) ({ \ >> uint32_t __base = (base); \ >> uint32_t __rem; \ >> if (likely(((n) >> 32) == 0)) { \ >> >>so if we call do_div() on a u32, the compiler emits nasal daemons. >>and we do this -- in the antcipatory scheduler: >> >> if (aic->seek_samples) { >> aic->seek_mean = aic->seek_total + 128; >> do_div(aic->seek_mean, aic->seek_samples); >> } >> >>seek_mean is a sector_t so sometimes it's 64-bit on a 32-bit platform. >>so we can't avoid calling do_div(). >> >>This almost works (the warning is harmless since gcc optimises away the call) >> >># define do_div(n,base) ({ \ >> uint32_t __base = (base); \ >> uint32_t __rem; \ >> if ((sizeof(n) < 8) || (likely(((n) >> 32) == 0))) { \ >> __rem = (uint32_t)(n) % __base; \ >> (n) = (uint32_t)(n) / __base; \ >> } else \ >> __rem = __div64_32(&(n), __base); \ >> __rem; \ >> }) >> >>Better ideas? >> > >sector_div, defined in blkdev.h, is probably what you want. > Looks right. Following patch alright?