public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
@ 2019-09-15 17:15 Ken Brown
0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2019-09-15 17:15 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d5f84126e56ee860b10a8a5826dc568e2c266f1b
commit d5f84126e56ee860b10a8a5826dc568e2c266f1b
Author: Achim Gratz <Stromeko@nexgo.de>
Date: Sun Sep 15 18:28:21 2019 +0200
winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
Adresses the problem reported here:
https://cygwin.com/ml/cygwin/2019-09/msg00141.html
Diff:
---
winsup/cygwin/times.cc | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 8908d44..909cae1 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -72,12 +72,17 @@ times (struct tms *buf)
/* ticks is in in 100ns, convert to clock ticks. */
tc = (clock_t) (ticks.QuadPart * CLOCKS_PER_SEC / NS100PERSEC);
- buf->tms_stime = __to_clock_t (&kut.KernelTime, 0);
- buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
- timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
- buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
- timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
- buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
+ /* Linux allows a NULL buf and just returns tc in that case, so
+ mimic that */
+ if (buf)
+ {
+ buf->tms_stime = __to_clock_t (&kut.KernelTime, 0);
+ buf->tms_utime = __to_clock_t (&kut.UserTime, 0);
+ timeval_to_filetime (&myself->rusage_children.ru_stime, &kut.KernelTime);
+ buf->tms_cstime = __to_clock_t (&kut.KernelTime, 1);
+ timeval_to_filetime (&myself->rusage_children.ru_utime, &kut.UserTime);
+ buf->tms_cutime = __to_clock_t (&kut.UserTime, 1);
+ }
}
__except (EFAULT)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-09-15 17:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-15 17:15 [newlib-cygwin] winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument Ken Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).