185,186c185 < externC cyg_tick_count cyg_timespec_to_ticks( const struct timespec *tp, < cyg_bool roundup) --- > externC cyg_tick_count cyg_timespec_to_ticks(const struct timespec *tp, cyg_bool roundup) 187a187,190 > const cyg_tick_count ns_per_sec = 1000000000; > cyg_tick_count ticks; > cyg_tick_count ns; > 191,202c194 < if( tp->tv_sec == 0 && tp->tv_nsec == 0 ) < { < return 0; < } < < // Convert the seconds field to ticks. < cyg_tick_count ticks = Cyg_Clock::convert( tp->tv_sec, &sec_converter ); < < if( roundup ) < { < // Convert the nanoseconds. We add (tickns-1) to round the value up < // to the next whole tick. --- > if ((tp->tv_sec == 0) && (tp->tv_nsec == 0)) return 0; 204,210c196,197 < ticks += Cyg_Clock::convert( (cyg_tick_count)tp->tv_nsec+tickns-1, &ns_converter ); < } < else < { < // Convert the nanoseconds. This will round down to nearest whole tick. < ticks += Cyg_Clock::convert( (cyg_tick_count)tp->tv_nsec, &ns_converter ); < } --- > // how many nano-seconds to wait ? > ns = (ns_per_sec * (cyg_tick_count)tp->tv_sec) + (cyg_tick_count)tp->tv_nsec; 211a199,217 > if ((ns % tickns) != 0) > { > // the time to wait isn't an exact number of system ticks : roundup > if (roundup) > { > // roundup to the next integer. > ticks = (ns / tickns) + 1; > } > else > { > // roundup to the nearest integer. > ticks = (ns + (tickns/2)) / 2; > } > } > else > { > // the time to wait is an exact number of system ticks : no round up to be made. > ticks = ns / tickns; > }