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.
AlfaOmega08
Member
Posts: 226 Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy
Post
by AlfaOmega08 » Sat Jan 19, 2008 10:29 am
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
it works!!!
so the "if (ticks % 18 == 0)" create the problem...
why?
Brynet-Inc
Member
Posts: 2426 Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:
Post
by Brynet-Inc » Sat Jan 19, 2008 11:14 am
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
Twitter: @canadianbryan . Award by smcerm, I stole it. Original was larger.
JamesM
Member
Posts: 2935 Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:
Post
by JamesM » Sat Jan 19, 2008 12:31 pm
Either: Don't do 64 bit division, or add "-lgcc" at the end of your linker line.
Cemre
Member
Posts: 31 Joined: Fri Nov 09, 2007 5:25 am
Post
by Cemre » Sat Jan 19, 2008 12:55 pm
I am curious... ( out of subject )
why doesn't gcc developpers include native support for "mod" or "div" for 64bit numbers ?
Brynet-Inc
Member
Posts: 2426 Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:
Post
by Brynet-Inc » Sat Jan 19, 2008 1:14 pm
Cemre wrote: I am curious... ( out of subject )
why doesn't gcc developpers include native support for "mod" or "div" for 64bit numbers ?
So I'm assuming on 64bit architectures, it might not even be used at all....
Does anyone here know for sure?
Twitter: @canadianbryan . Award by smcerm, I stole it. Original was larger.
Korona
Member
Posts: 1000 Joined: Thu May 17, 2007 1:27 pm
Contact:
Post
by Korona » Sat Jan 19, 2008 1:52 pm
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.
lukem95
Member
Posts: 536 Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK
Post
by lukem95 » Sat Jan 19, 2008 2:51 pm
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