Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2018-02-13 00:08:42 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-02-13 00:08:42 +0300
commit01c643e49fe93b9b70f3b83469e041f6754ebe5b (patch)
tree341b86ce95a736de363a9cdff6d3c964174b027f /winsup/cygwin
parent58f72783eec1c15a1d9835ada22c9b003cf41ad9 (diff)
Cygwin: Drop HZ usage in favor of MSPERSEC and CLOCKS_PER_SEC
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/fhandler_proc.cc13
-rw-r--r--winsup/cygwin/fhandler_process.cc13
-rw-r--r--winsup/cygwin/net.cc4
-rw-r--r--winsup/cygwin/sched.cc2
-rw-r--r--winsup/cygwin/timer.cc3
-rw-r--r--winsup/cygwin/times.cc9
6 files changed, 25 insertions, 19 deletions
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index 771235f0a..942cc9694 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -535,9 +535,9 @@ format_proc_stat (void *, char *&destbuf)
for (unsigned long i = 0; i < wincap.cpu_count (); i++)
{
kernel_time += (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart)
- * HZ / NS100PERSEC;
- user_time += spt[i].UserTime.QuadPart * HZ / NS100PERSEC;
- idle_time += spt[i].IdleTime.QuadPart * HZ / NS100PERSEC;
+ * CLOCKS_PER_SEC / NS100PERSEC;
+ user_time += spt[i].UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
+ idle_time += spt[i].IdleTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
}
eobuf += __small_sprintf (eobuf, "cpu %U %U %U %U\n",
@@ -546,9 +546,10 @@ format_proc_stat (void *, char *&destbuf)
for (unsigned long i = 0; i < wincap.cpu_count (); i++)
{
interrupt_count += spt[i].InterruptCount;
- kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart) * HZ / NS100PERSEC;
- user_time = spt[i].UserTime.QuadPart * HZ / NS100PERSEC;
- idle_time = spt[i].IdleTime.QuadPart * HZ / NS100PERSEC;
+ kernel_time = (spt[i].KernelTime.QuadPart - spt[i].IdleTime.QuadPart)
+ * CLOCKS_PER_SEC / NS100PERSEC;
+ user_time = spt[i].UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
+ idle_time = spt[i].IdleTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
eobuf += __small_sprintf (eobuf, "cpu%d %U %U %U %U\n", i,
user_time, 0ULL, kernel_time, idle_time);
}
diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc
index c74844784..f67c2de8d 100644
--- a/winsup/cygwin/fhandler_process.cc
+++ b/winsup/cygwin/fhandler_process.cc
@@ -1092,7 +1092,8 @@ format_process_stat (void *data, char *&destbuf)
state = 'T';
else
state = get_process_state (p->dwProcessId);
- start_time = (GetTickCount () / 1000 - time (NULL) + p->start_time) * HZ;
+ start_time = (GetTickCount () / MSPERSEC - time (NULL) + p->start_time)
+ * CLOCKS_PER_SEC;
NTSTATUS status;
HANDLE hProcess;
@@ -1139,19 +1140,21 @@ format_process_stat (void *data, char *&destbuf)
return 0;
}
fault_count = vmc.PageFaultCount;
- utime = put.UserTime.QuadPart * HZ / NS100PERSEC;
- stime = put.KernelTime.QuadPart * HZ / NS100PERSEC;
+ utime = put.UserTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
+ stime = put.KernelTime.QuadPart * CLOCKS_PER_SEC / NS100PERSEC;
#if 0
if (stodi.CurrentTime.QuadPart > put.CreateTime.QuadPart)
start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart -
- stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart) * HZ / NS100PERSEC;
+ stodi.CurrentTime.QuadPart + put.CreateTime.QuadPart)
+ * CLOCKS_PER_SEC / NS100PERSEC;
else
/*
* sometimes stodi.CurrentTime is a bit behind
* Note: some older versions of procps are broken and can't cope
* with process start times > time(NULL).
*/
- start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / NS100PERSEC;
+ start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart)
+ * CLOCKS_PER_SEC / NS100PERSEC;
#endif
/* The BasePriority returned to a 32 bit process under WOW64 is
apparently broken, for 32 and 64 bit target processes. 64 bit
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 43da5dcac..c7bd73611 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1033,8 +1033,8 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval,
}
else
{
- time_out->tv_sec = ms / HZ;
- time_out->tv_usec = ((ms % HZ) * USPERSEC) / HZ;
+ time_out->tv_sec = ms / MSPERSEC;
+ time_out->tv_usec = ((ms % MSPERSEC) * USPERSEC) / MSPERSEC;
}
*optlen = (socklen_t) sizeof *time_out;
res = 0;
diff --git a/winsup/cygwin/sched.cc b/winsup/cygwin/sched.cc
index b8e0a2b5d..a32e9424d 100644
--- a/winsup/cygwin/sched.cc
+++ b/winsup/cygwin/sched.cc
@@ -201,7 +201,7 @@ sched_rr_get_interval (pid_t pid, struct timespec *interval)
slindex -= 1;
nsec = quantable[vfindex][slindex][qindex] / quantapertick
- * clocktickinterval * (NSPERSEC / HZ);
+ * clocktickinterval * (NSPERSEC / MSPERSEC);
interval->tv_sec = nsec / NSPERSEC;
interval->tv_nsec = nsec % NSPERSEC;
diff --git a/winsup/cygwin/timer.cc b/winsup/cygwin/timer.cc
index 94679c323..9d3d7dc94 100644
--- a/winsup/cygwin/timer.cc
+++ b/winsup/cygwin/timer.cc
@@ -132,7 +132,8 @@ timer_thread (VOID *x)
if (sleep_us > 0)
{
tt->sleepto_us = sleepto_us;
- sleep_ms = (sleep_us + (USPERSEC/HZ) - 1) / (USPERSEC/HZ);
+ sleep_ms = (sleep_us + (USPERSEC / MSPERSEC) - 1)
+ / (USPERSEC / MSPERSEC);
}
else
{
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 677376e2c..11fb8f257 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -117,7 +117,7 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
st.wHour = ptm->tm_hour;
st.wMinute = ptm->tm_min;
st.wSecond = ptm->tm_sec;
- st.wMilliseconds = tv->tv_usec / (USPERSEC/HZ);
+ st.wMilliseconds = tv->tv_usec / (USPERSEC / MSPERSEC);
res = -!SetSystemTime (&st);
gtod.reset ();
@@ -223,11 +223,12 @@ timeval_to_ms (const struct timeval *time_in, DWORD &ms)
|| time_in->tv_usec >= USPERSEC)
return false;
if ((time_in->tv_sec == 0 && time_in->tv_usec == 0)
- || time_in->tv_sec >= (time_t) (INFINITE / HZ))
+ || time_in->tv_sec >= (time_t) (INFINITE / MSPERSEC))
ms = INFINITE;
else
- ms = time_in->tv_sec * HZ + (time_in->tv_usec + (USPERSEC/HZ) - 1)
- / (USPERSEC/HZ);
+ ms = time_in->tv_sec * MSPERSEC
+ + (time_in->tv_usec + (USPERSEC / MSPERSEC) - 1)
+ / (USPERSEC / MSPERSEC);
return true;
}