__umoddi3 error

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

__umoddi3 error

Post by AlfaOmega08 »

I'm writing down a pit driver.
about each 18 ticks, a second is past.

If i put

Code: Select all

if (ticks % 18 == 0) {
      puts("one second has past\n");
}
ticks is an unsigned long long

when linking. I've the following error:
undefined reference to `__umoddi3'

if I put only

Code: Select all

puts("the pit has fired\n");
it works!!!

so the "if (ticks % 18 == 0)" create the problem...

why?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Looks like you're trying to do 64bit arithmetic, the support functions for that are in libgcc...
(umoddi3 for multiplication and udivdi3 for division..)

I'm not entirely sure what licence libgcc is under, so personally I keep away from it.. ;)

A BSD/ISC licenced implementation exists though...
http://www.openbsd.org/cgi-bin/cvsweb/s ... libc/quad/

Good luck 8)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Either: Don't do 64 bit division, or add "-lgcc" at the end of your linker line.
Cemre
Member
Member
Posts: 31
Joined: Fri Nov 09, 2007 5:25 am

Post by Cemre »

I am curious... ( out of subject )
why doesn't gcc developpers include native support for "mod" or "div" for 64bit numbers ?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Cemre wrote:I am curious... ( out of subject )
why doesn't gcc developpers include native support for "mod" or "div" for 64bit numbers ?
http://gcc.gnu.org/onlinedocs/gccint/Libgcc.html wrote:Most of the routines in libgcc handle arithmetic operations that the target processor cannot perform directly.
So I'm assuming on 64bit architectures, it might not even be used at all....

Does anyone here know for sure? :?
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Post by Korona »

Inlining 64 bit multiplication and division code would produce very huge code, so gcc inserts a call to its library instead. On amd64 cpus gcc produces usual div and mul instructions. 64 bit addition and substraction is always inlined.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post by lukem95 »

you should change the frequency to get a more accurate timer.

i use 100, one every ms. ABOUT 18 isnt very accurate.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Post Reply