diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bb9489ad0..47e0bb103 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Corinna Vinschen + + * times.cc (hires_ms::resolution): Make sure resolution is never 0. + (clock_setres): Ditto. + 2011-03-29 Corinna Vinschen * cygtls.h (struct _local_storage): Redefine process_ident as wchar_t diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index 19c03fdf8..e9f2b8e46 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -827,6 +827,10 @@ hires_ms::resolution () period /= 40000L; minperiod = (DWORD) period; } + /* The resolution can be as low as 5000 100ns intervals on recent OSes. + We have to make sure that the resolution in ms is never 0. */ + if (!minperiod) + minperiod = 1L; } return minperiod; } @@ -901,6 +905,10 @@ clock_setres (clockid_t clk_id, struct timespec *tp) return -1; } minperiod = actual / 10000L; + /* The resolution can be as low as 5000 100ns intervals on recent OSes. + We have to make sure that the resolution in ms is never 0. */ + if (!minperiod) + minperiod = 1L; period_set = true; return 0; }