Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
156 user(s) are online (150 user(s) are browsing Forums)

Members: 1
Guests: 155

MartinW, more...

Support us!

Headlines

 
  Register To Post  

is clock()/CLOCKS_PER_SEC on newlib broken ?
Home away from home
Home away from home


See User information
@All
While fighting with some bug find out that on newlib (and probabaly clib2) clock()/CLOCKS_PER_SEC behave weird, there are test case:

#include <stdio.h>
#include <time.h>

int main()
{
    
int lastSentTime = -10;
    
lastSentTime clock()/CLOCKS_PER_SEC;
    
printf("lastSentTime = %d\n"lastSentTime);
}


On newlib we have : 12645297 , that cleary broken
On clib2 we have 894 on sam460 and 973 on x5k, so not sure if it correct or not, but seems also not.

If i build the same test case on Cygwin/x86, then result is "0". If i build the same test case over VBCC for 68k, and run on X5000, then result is also "0".

Can anyone comment about ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: is clock()/CLOCKS_PER_SEC on newlib broken ?
Amigans Defender
Amigans Defender


See User information
new clib2 version has clock fixed and now works as expected

I've tried this example:

#include <stdio.h>
#include <time.h>

int main()
{
int lastSentTime = clock() / CLOCKS_PER_SEC;
printf("lastSentTime = %d\n", lastSentTime);
usleep(5000000);
lastSentTime = clock() / CLOCKS_PER_SEC;
printf("lastSentTime = %d\n", lastSentTime);
}

And works correctly. It print 0 and 5

i'm really tired...
Go to top
Re: is clock()/CLOCKS_PER_SEC on newlib broken ?
Home away from home
Home away from home


See User information
@Andrea
Cool ! Mean that there indeed issue and need to be fixed in newlib as well, will report it to OS4's bugzilla

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project