* 64-bit modulus operation in a 32-bit kernel @ 2012-04-24 17:50 Alan Stern 2012-04-24 18:20 ` Takashi Iwai 2012-04-24 19:15 ` Andreas Schwab 0 siblings, 2 replies; 4+ messages in thread From: Alan Stern @ 2012-04-24 17:50 UTC (permalink / raw) To: Kernel development list I need to compute the remainder when a 64-bit quantity is divided by a small value (126 in this case). The % operator doesn't work in an x86/32 kernel. What's the Right Way to do it? Alan Stern ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 64-bit modulus operation in a 32-bit kernel 2012-04-24 17:50 64-bit modulus operation in a 32-bit kernel Alan Stern @ 2012-04-24 18:20 ` Takashi Iwai 2012-04-24 18:57 ` Alan Stern 2012-04-24 19:15 ` Andreas Schwab 1 sibling, 1 reply; 4+ messages in thread From: Takashi Iwai @ 2012-04-24 18:20 UTC (permalink / raw) To: Alan Stern; +Cc: Kernel development list At Tue, 24 Apr 2012 13:50:01 -0400 (EDT), Alan Stern wrote: > > I need to compute the remainder when a 64-bit quantity is divided by a > small value (126 in this case). The % operator doesn't work in an > x86/32 kernel. What's the Right Way to do it? div_u64_rem() in linux/math64.h? Takashi ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 64-bit modulus operation in a 32-bit kernel 2012-04-24 18:20 ` Takashi Iwai @ 2012-04-24 18:57 ` Alan Stern 0 siblings, 0 replies; 4+ messages in thread From: Alan Stern @ 2012-04-24 18:57 UTC (permalink / raw) To: Takashi Iwai; +Cc: Kernel development list On Tue, 24 Apr 2012, Takashi Iwai wrote: > At Tue, 24 Apr 2012 13:50:01 -0400 (EDT), > Alan Stern wrote: > > > > I need to compute the remainder when a 64-bit quantity is divided by a > > small value (126 in this case). The % operator doesn't work in an > > x86/32 kernel. What's the Right Way to do it? > > div_u64_rem() in linux/math64.h? Thanks for the pointer. Alan Stern ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 64-bit modulus operation in a 32-bit kernel 2012-04-24 17:50 64-bit modulus operation in a 32-bit kernel Alan Stern 2012-04-24 18:20 ` Takashi Iwai @ 2012-04-24 19:15 ` Andreas Schwab 1 sibling, 0 replies; 4+ messages in thread From: Andreas Schwab @ 2012-04-24 19:15 UTC (permalink / raw) To: Alan Stern; +Cc: Kernel development list Alan Stern <stern@rowland.harvard.edu> writes: > I need to compute the remainder when a 64-bit quantity is divided by a > small value (126 in this case). The % operator doesn't work in an > x86/32 kernel. What's the Right Way to do it? #include <asm/div64.h> do_div(n,base) returns the remainder. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-24 19:15 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-04-24 17:50 64-bit modulus operation in a 32-bit kernel Alan Stern 2012-04-24 18:20 ` Takashi Iwai 2012-04-24 18:57 ` Alan Stern 2012-04-24 19:15 ` Andreas Schwab
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox