from where comes "__moddi3"?
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
Signature · 7 lines
======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ========================================================================
Quoted 7 lines · Robert P. J. Day
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:
Quoted 8 lines
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.
Quoted 10 lines · Peter Zijlstra
Quoted 9 lines · Robert P. J. Day
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
Quoted 8 lines
Quoted 6 lines
(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.
Quoted 4 lines
gcc translates that into a libgcc call, which we _explicitly_ do not have because 64bit divisions are expensive!
use
do_div().
gotcha. thanks.
rday
Signature · 7 lines
======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ========================================================================
Quoted 5 lines · Peter Zijlstra
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
Signature · 3 lines
Jan-Benedict Glaw [email protected] +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.
Quoted 8 lines · Jan-Benedict Glaw
Quoted 5 lines · Peter Zijlstra
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.
Quoted 5 lines · Robert P. J. Day
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,
Signature · 1 line
Alex
Quoted 9 lines · Alexander Shishkin
Quoted 5 lines · Robert P. J. Day
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
Quoted 1 line · Jan Engelhardt
v &
0x0F<=> v % 16
Indeed. (Why would anyone want to mod/div by 15 anyway?). My bad.
Regards,
Signature · 1 line
Alex
Quoted 4 lines · Jan Engelhardt
Quoted 1 line
v &
0x0F<=> v % 16Indeed. (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
Quoted 5 lines · David Schwartz
Quoted 3 lines · Jan Engelhardt
Quoted 1 line
v &
0x0F<=> v % 16Indeed. (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.