On Sun, Aug 04 2024 at 10:39, Koakuma via wrote: > From: Koakuma <koachan@xxxxxxxxxxxxxx> > > Add helper function for 64-bit right shift on 32-bit target so that > clang does not emit a runtime library call. > > Signed-off-by: Koakuma <koachan@xxxxxxxxxxxxxx> > --- > Hi~ > > This adds a small function to do 64-bit right shifts for use in vDSO > code, needed so that clang does not emit a call to runtime library. > --- > arch/sparc/vdso/vclock_gettime.c | 8 ++++---- > include/vdso/math64.h | 28 ++++++++++++++++++++++++++++ > --- a/include/vdso/math64.h > +++ b/include/vdso/math64.h > @@ -21,6 +21,34 @@ __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) > return ret; > } > > +#if BITS_PER_LONG == 32 > +/* This is to prevent the compiler from emitting a call to __lshrdi3. */ > +static __always_inline u64 > +__shr64(u64 val, int amt) > +{ > + u32 mask = (1U << amt) - 1; > + u32 lo = val; > + u32 hi = val >> 32; > + u32 mi; > + > + if (amt >= 32) > + return hi >> (amt - 32); > + > + > + mi = (hi & mask) << (32 - amt); > + hi >>= amt; > + lo = (lo >> amt) | mi; > + > + return ((u64) hi) << 32 | lo; > +} > +#else > +static __always_inline u64 > +__shr64(u64 val, int amt) > +{ > + return val >> amt; > +} Why does this sparc'ism need to be in generic code? Thanks, tglx