xref: /kernel/linux/linux-5.10/include/vdso/math64.h
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/include/vdso/
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __VDSO_MATH64_H
38c2ecf20Sopenharmony_ci#define __VDSO_MATH64_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_cistatic __always_inline u32
68c2ecf20Sopenharmony_ci__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
78c2ecf20Sopenharmony_ci{
88c2ecf20Sopenharmony_ci	u32 ret = 0;
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci	while (dividend >= divisor) {
118c2ecf20Sopenharmony_ci		/* The following asm() prevents the compiler from
128c2ecf20Sopenharmony_ci		   optimising this loop into a modulo operation.  */
138c2ecf20Sopenharmony_ci		asm("" : "+rm"(dividend));
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci		dividend -= divisor;
168c2ecf20Sopenharmony_ci		ret++;
178c2ecf20Sopenharmony_ci	}
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	*remainder = dividend;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	return ret;
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#endif /* __VDSO_MATH64_H */
25

Indexes created Thu Nov 07 10:32:03 CST 2024