xref: /linux/arch/sh/lib/div64-generic.c (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1*1da177e4SLinus Torvalds /*
2*1da177e4SLinus Torvalds  * Generic __div64_32 wrapper for __xdiv64_32.
3*1da177e4SLinus Torvalds  */
4*1da177e4SLinus Torvalds 
5*1da177e4SLinus Torvalds #include <linux/types.h>
6*1da177e4SLinus Torvalds 
7*1da177e4SLinus Torvalds extern u64 __xdiv64_32(u64 n, u32 d);
8*1da177e4SLinus Torvalds 
9*1da177e4SLinus Torvalds u64 __div64_32(u64 *xp, u32 y)
10*1da177e4SLinus Torvalds {
11*1da177e4SLinus Torvalds 	u64 rem;
12*1da177e4SLinus Torvalds 	u64 q = __xdiv64_32(*xp, y);
13*1da177e4SLinus Torvalds 
14*1da177e4SLinus Torvalds 	rem = *xp - q * y;
15*1da177e4SLinus Torvalds 	*xp = q;
16*1da177e4SLinus Torvalds 
17*1da177e4SLinus Torvalds 	return rem;
18*1da177e4SLinus Torvalds }
19*1da177e4SLinus Torvalds 
20