(Maybe) a small bug in thread/linux/SDL_syscond.c?

Hello,

I think I’ve found a small bug in thread/linux/SDL_syscond.c…

In the SDL_CondWaitTimeout(), there is written:

gettimeofday(&delta, NULL);
abstime.tv_sec = delta.tv_sec + (ms/1000);
abstime.tv_nsec = (delta.tv_usec+(ms%1000)) * 1000;
if ( abstime.tv_nsec > 1000000 ) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000;
}

However, when I used this function I thought the timeout is much
longer than it should be. I think the author wanted to say

gettimeofday(&delta, NULL);
abstime.tv_sec = delta.tv_sec + (ms/1000);
abstime.tv_nsec = (delta.tv_usec + (ms%1000) * 1000) * 1000;
if (abstime.tv_nsec > 1000000000) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}

I’ve tried this code and it seems to work (which of course does
not mean it is correct).

What do you think? Am I just stupid or was it really a bug?

Have a nice day,

Jiri "BlueBear" Dluhos-----

Nov? vyhled?va? pro ?esk? internet www.webfast.cz - prost? najde …

Hello,

I think I’ve found a small bug in thread/linux/SDL_syscond.c…

In the SDL_CondWaitTimeout(), there is written:

[snipped]

However, when I used this function I thought the timeout is much
longer than it should be. I think the author wanted to say

gettimeofday(&delta, NULL);
abstime.tv_sec = delta.tv_sec + (ms/1000);
abstime.tv_nsec = (delta.tv_usec + (ms%1000) * 1000) * 1000;
if (abstime.tv_nsec > 1000000000) {
abstime.tv_sec += 1;
abstime.tv_nsec -= 1000000000;
}

Thanks, I’ve added your fix to CVS. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment