mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-18 23:12:15 +08:00
Cygwin: Drop HZ usage in favor of MSPERSEC and CLOCKS_PER_SEC
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
58f72783ee
commit
01c643e49f
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user