Skip to content

Commit

Permalink
Minor update related to #36
Browse files Browse the repository at this point in the history
  • Loading branch information
MirMohammadd committed Mar 22, 2024
1 parent 37d7808 commit eec2b8b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions include/vdso/math64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef __VDSO_MATH64_H
#define __VDSO_MATH64_H

static __always_inline u32
__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{
u32 ret = 0;

while (dividend >= divisor) {
/* The following asm() prevents the compiler from
optimising this loop into a modulo operation. */
asm("" : "+rm"(dividend));

dividend -= divisor;
ret++;
}

*remainder = dividend;

return ret;
}

#endif /* __VDSO_MATH64_H */

0 comments on commit eec2b8b

Please sign in to comment.