This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 6/7] nptl/tst-rwlock: Use clock_gettime/timespec rather than gettimeofday/timeval
- From: Yann Droneaud <ydroneaud at opteya dot com>
- To: Mike Crowe <mac at mcrowe dot com>, libc-alpha at sourceware dot org
- Date: Thu, 14 Mar 2019 15:44:07 +0100
- Subject: Re: [PATCH 6/7] nptl/tst-rwlock: Use clock_gettime/timespec rather than gettimeofday/timeval
- References: <cover.b0c66849a87ca79889a49f2f1f2563b1a8a15d8b.1551291557.git-series.mac@mcrowe.com> <e7a012d809a6f0cf8b33b923345ebe05b5d739e1.1551291557.git-series.mac@mcrowe.com>
Hi,
Le mercredi 27 février 2019 à 18:23 +0000, Mike Crowe a écrit :
> diff --git a/nptl/tst-rwlock9.c b/nptl/tst-rwlock9.c
> index 34f2d04..ff15f90 100644
> --- a/nptl/tst-rwlock9.c
> +++ b/nptl/tst-rwlock9.c
> @@ -56,9 +56,7 @@ writer_thread (void *nr)
> int e;
> do
> {
> - struct timeval tv;
> - (void) gettimeofday (&tv, NULL);
> - TIMEVAL_TO_TIMESPEC (&tv, &ts);
> + (void) clock_gettime (CLOCK_REALTIME, &ts);
>
> ts.tv_nsec += 2 * TIMEOUT;
> if (ts.tv_nsec >= 1000000000)
Should timespec_add() be used here too ?
> @@ -110,9 +108,7 @@ reader_thread (void *nr)
> int e;
> do
> {
> - struct timeval tv;
> - (void) gettimeofday (&tv, NULL);
> - TIMEVAL_TO_TIMESPEC (&tv, &ts);
> + (void) clock_gettime (CLOCK_REALTIME, &ts);
>
> ts.tv_nsec += TIMEOUT;
> if (ts.tv_nsec >= 1000000000)
Same here
Regards.
--
Yann Droneaud
OPTEYA