* from where comes "__moddi3"?
@ 2007-07-21 19:21 Robert P. J. Day
2007-07-21 19:31 ` Peter Zijlstra
2007-07-21 19:33 ` Alexander Shishkin
0 siblings, 2 replies; 10+ messages in thread
From: Robert P. J. Day @ 2007-07-21 19:21 UTC (permalink / raw)
To: Linux Kernel Mailing List
again, probably displaying my abject ignorance, but i wrote a
trivial module that tries to "var % 15", and i get:
WARNING: "__moddi3" undefined!
and, not surprisingly, when i try to insmod:
insmod: error inserting 'seq.ko': -1 Unknown symbol in module
(using 16 rather than 15 works fine, as i assume that the modulus
call is simply replaced by an optimized bitwise comparison.)
so ... from where comes __moddi3? i know there are places in the
kernel source tree that do non-power-of-2 moduli, and they work fine,
no? thanks.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:21 from where comes "__moddi3"? Robert P. J. Day
@ 2007-07-21 19:31 ` Peter Zijlstra
2007-07-21 19:34 ` Robert P. J. Day
2007-07-21 19:58 ` Jan-Benedict Glaw
2007-07-21 19:33 ` Alexander Shishkin
1 sibling, 2 replies; 10+ messages in thread
From: Peter Zijlstra @ 2007-07-21 19:31 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux Kernel Mailing List
On Sat, 2007-07-21 at 15:21 -0400, Robert P. J. Day wrote:
> again, probably displaying my abject ignorance, but i wrote a
> trivial module that tries to "var % 15", and i get:
>
> WARNING: "__moddi3" undefined!
>
> and, not surprisingly, when i try to insmod:
>
> insmod: error inserting 'seq.ko': -1 Unknown symbol in module
>
> (using 16 rather than 15 works fine, as i assume that the modulus
> call is simply replaced by an optimized bitwise comparison.)
>
> so ... from where comes __moddi3? i know there are places in the
> kernel source tree that do non-power-of-2 moduli, and they work fine,
> no? thanks.
let me guess, 32 bit kernel, and var is 64 bit?
gcc translates that into a libgcc call, which we _explicitly_ do not
have because 64bit divisions are expensive!
use do_div().
16 works because gcc translates that into a right shift.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:31 ` Peter Zijlstra
@ 2007-07-21 19:34 ` Robert P. J. Day
2007-07-21 19:58 ` Jan-Benedict Glaw
1 sibling, 0 replies; 10+ messages in thread
From: Robert P. J. Day @ 2007-07-21 19:34 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Linux Kernel Mailing List
On Sat, 21 Jul 2007, Peter Zijlstra wrote:
> On Sat, 2007-07-21 at 15:21 -0400, Robert P. J. Day wrote:
> > again, probably displaying my abject ignorance, but i wrote a
> > trivial module that tries to "var % 15", and i get:
> >
> > WARNING: "__moddi3" undefined!
> >
> > and, not surprisingly, when i try to insmod:
> >
> > insmod: error inserting 'seq.ko': -1 Unknown symbol in module
> >
> > (using 16 rather than 15 works fine, as i assume that the modulus
> > call is simply replaced by an optimized bitwise comparison.)
> >
> > so ... from where comes __moddi3? i know there are places in the
> > kernel source tree that do non-power-of-2 moduli, and they work fine,
> > no? thanks.
>
> let me guess, 32 bit kernel, and var is 64 bit?
um ... yeah. duh. var type is actually loff_t. i should have
realized that.
> gcc translates that into a libgcc call, which we _explicitly_ do not
> have because 64bit divisions are expensive!
>
> use do_div().
gotcha. thanks.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:31 ` Peter Zijlstra
2007-07-21 19:34 ` Robert P. J. Day
@ 2007-07-21 19:58 ` Jan-Benedict Glaw
2007-07-21 20:00 ` Peter Zijlstra
1 sibling, 1 reply; 10+ messages in thread
From: Jan-Benedict Glaw @ 2007-07-21 19:58 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Robert P. J. Day, Linux Kernel Mailing List
[-- Attachment #1: Type: text/plain, Size: 558 bytes --]
On Sat, 2007-07-21 21:31:13 +0200, Peter Zijlstra <peterz@infradead.org> wrote:
> On Sat, 2007-07-21 at 15:21 -0400, Robert P. J. Day wrote:
>
> use do_div().
>
> 16 works because gcc translates that into a right shift.
Right shift? Doesn't it just mask out everything but the low 4 bit?
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de +49-172-7608481
Signature of: God put me on earth to accomplish a certain number of
the second : things. Right now I am so far behind I will never die.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: from where comes "__moddi3"?
2007-07-21 19:58 ` Jan-Benedict Glaw
@ 2007-07-21 20:00 ` Peter Zijlstra
0 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2007-07-21 20:00 UTC (permalink / raw)
To: Jan-Benedict Glaw; +Cc: Robert P. J. Day, Linux Kernel Mailing List
On Sat, 2007-07-21 at 21:58 +0200, Jan-Benedict Glaw wrote:
> On Sat, 2007-07-21 21:31:13 +0200, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Sat, 2007-07-21 at 15:21 -0400, Robert P. J. Day wrote:
> >
> > use do_div().
> >
> > 16 works because gcc translates that into a right shift.
>
> Right shift? Doesn't it just mask out everything but the low 4 bit?
Yeah, its bitwise and for modulo and shifts for mult and div.
Silly mistake on my side.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:21 from where comes "__moddi3"? Robert P. J. Day
2007-07-21 19:31 ` Peter Zijlstra
@ 2007-07-21 19:33 ` Alexander Shishkin
2007-07-21 19:34 ` Jan Engelhardt
1 sibling, 1 reply; 10+ messages in thread
From: Alexander Shishkin @ 2007-07-21 19:33 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: Linux Kernel Mailing List
On 7/21/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
>
> again, probably displaying my abject ignorance, but i wrote a
> trivial module that tries to "var % 15", and i get:
>
> WARNING: "__moddi3" undefined!
...which comes from libgcc1 which you obviously don't want to link against.
Does (var & 0x0f) not work for you?
Regards,
--
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:33 ` Alexander Shishkin
@ 2007-07-21 19:34 ` Jan Engelhardt
2007-07-21 20:00 ` Alexander Shishkin
0 siblings, 1 reply; 10+ messages in thread
From: Jan Engelhardt @ 2007-07-21 19:34 UTC (permalink / raw)
To: Alexander Shishkin; +Cc: Robert P. J. Day, Linux Kernel Mailing List
On Jul 21 2007 23:33, Alexander Shishkin wrote:
> On 7/21/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
>>
>> again, probably displaying my abject ignorance, but i wrote a
>> trivial module that tries to "var % 15", and i get:
>>
>> WARNING: "__moddi3" undefined!
> ...which comes from libgcc1 which you obviously don't want to link against.
>
> Does (var & 0x0f) not work for you?
v & 0x0F <=> v % 16
Jan
--
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: from where comes "__moddi3"?
2007-07-21 19:34 ` Jan Engelhardt
@ 2007-07-21 20:00 ` Alexander Shishkin
2007-07-21 21:27 ` David Schwartz
0 siblings, 1 reply; 10+ messages in thread
From: Alexander Shishkin @ 2007-07-21 20:00 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Robert P. J. Day, Linux Kernel Mailing List
On 7/21/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
> v & 0x0F <=> v % 16
Indeed. (Why would anyone want to mod/div by 15 anyway?). My bad.
Regards,
--
Alex
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: from where comes "__moddi3"?
2007-07-21 20:00 ` Alexander Shishkin
@ 2007-07-21 21:27 ` David Schwartz
2007-07-21 22:02 ` Arjan van de Ven
0 siblings, 1 reply; 10+ messages in thread
From: David Schwartz @ 2007-07-21 21:27 UTC (permalink / raw)
To: Linux-Kernel@Vger. Kernel. Org
> On 7/21/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
> > v & 0x0F <=> v % 16
> Indeed. (Why would anyone want to mod/div by 15 anyway?). My bad.
Actually, it's the compiler's bad. That's a pretty fundamental equivalence that the compiler should recognize for native integral types.
DS
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: from where comes "__moddi3"?
2007-07-21 21:27 ` David Schwartz
@ 2007-07-21 22:02 ` Arjan van de Ven
0 siblings, 0 replies; 10+ messages in thread
From: Arjan van de Ven @ 2007-07-21 22:02 UTC (permalink / raw)
To: davids; +Cc: Linux-Kernel@Vger. Kernel. Org
On Sat, 2007-07-21 at 14:27 -0700, David Schwartz wrote:
> > On 7/21/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
> > > v & 0x0F <=> v % 16
> > Indeed. (Why would anyone want to mod/div by 15 anyway?). My bad.
>
> Actually, it's the compiler's bad. That's a pretty fundamental equivalence that the compiler should recognize for native integral types.
for unsigned ones for sure yes... but the original question was about 15
not 16.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-07-21 22:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-21 19:21 from where comes "__moddi3"? Robert P. J. Day
2007-07-21 19:31 ` Peter Zijlstra
2007-07-21 19:34 ` Robert P. J. Day
2007-07-21 19:58 ` Jan-Benedict Glaw
2007-07-21 20:00 ` Peter Zijlstra
2007-07-21 19:33 ` Alexander Shishkin
2007-07-21 19:34 ` Jan Engelhardt
2007-07-21 20:00 ` Alexander Shishkin
2007-07-21 21:27 ` David Schwartz
2007-07-21 22:02 ` Arjan van de Ven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®