mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-04 11:46:35 +02:00
Fix overflow issues with thread-sleep!
This commit is contained in:
parent
d9656fc793
commit
5e4ab77f33
1 changed files with 4 additions and 3 deletions
|
@ -3211,11 +3211,12 @@ void Cyc_end_thread(gc_thread_data *thd)
|
||||||
// For now, accept a number of milliseconds to sleep
|
// For now, accept a number of milliseconds to sleep
|
||||||
object Cyc_thread_sleep(void *data, object timeout)
|
object Cyc_thread_sleep(void *data, object timeout)
|
||||||
{
|
{
|
||||||
// TODO: looks like there are overflow issues here:
|
|
||||||
struct timespec tim;
|
struct timespec tim;
|
||||||
|
long value;
|
||||||
Cyc_check_num(data, timeout);
|
Cyc_check_num(data, timeout);
|
||||||
tim.tv_sec = 0;
|
value = ((integer_type *)timeout)->value;
|
||||||
tim.tv_nsec = ((integer_type *)timeout)->value * NANOSECONDS_PER_MILLISECOND;
|
tim.tv_sec = value / 1000;
|
||||||
|
tim.tv_nsec = (value % 1000) * NANOSECONDS_PER_MILLISECOND;
|
||||||
nanosleep(&tim, NULL);
|
nanosleep(&tim, NULL);
|
||||||
return boolean_t;
|
return boolean_t;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue