From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17540 invoked by alias); 26 Jun 2019 15:46:54 -0000 Mailing-List: contact glibc-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: glibc-cvs-owner@sourceware.org List-Subscribe: Received: (qmail 17523 invoked by uid 9014); 26 Jun 2019 15:46:54 -0000 Date: Wed, 26 Jun 2019 15:46:00 -0000 Message-ID: <20190626154654.17522.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Zack Weinberg To: glibc-cvs@sourceware.org Subject: [glibc/zack/no-nested-includes] support: Add xclock_now helper function. X-Act-Checkin: glibc X-Git-Author: Mike Crowe X-Git-Refname: refs/heads/zack/no-nested-includes X-Git-Oldrev: 21cc130b78a4db9113fb6695e2b951e697662440 X-Git-Newrev: db13e32cb8d5f74fe61880459c7ddf8f47da436b X-SW-Source: 2019-q2/txt/msg00576.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=db13e32cb8d5f74fe61880459c7ddf8f47da436b commit db13e32cb8d5f74fe61880459c7ddf8f47da436b Author: Mike Crowe Date: Wed Jun 19 18:05:12 2019 -0300 support: Add xclock_now helper function. It's easier to read and write tests with: const struct timespec ts = xclock_now(CLOCK_REALTIME); than struct timespec ts; xclock_gettime(CLOCK_REALTIME, &ts); * support/xtime.h: Add xclock_now() helper function. Diff: --- ChangeLog | 4 ++++ support/xtime.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 05291d7..de58169 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2019-06-20 Mike Crowe + + * support/xtime.h: Add xclock_now() helper function. + 2019-06-20 Dmitry V. Levin Florian Weimer diff --git a/support/xtime.h b/support/xtime.h index 68af1a5..6e19ce1 100644 --- a/support/xtime.h +++ b/support/xtime.h @@ -28,6 +28,16 @@ __BEGIN_DECLS void xclock_gettime (clockid_t clock, struct timespec *ts); +/* This helper can often simplify tests by avoiding an explicit + variable declaration or allowing that declaration to be const. */ + +static inline struct timespec xclock_now (clockid_t clock) +{ + struct timespec ts; + xclock_gettime (clock, &ts); + return ts; +} + __END_DECLS #endif /* SUPPORT_TIME_H */