unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mike Crowe <mac@mcrowe.com>
To: libc-alpha@sourceware.org
Cc: Mike Crowe <mac@mcrowe.com>
Subject: [PATCH 1/5] support: Add xclock_gettime
Date: Thu,  2 May 2019 21:54:31 +0100	[thread overview]
Message-ID: <effd524dc2717f61b6cc8e3d3b75cb0273586919.1556830454.git-series.mac@mcrowe.com> (raw)
In-Reply-To: <cover.72079c6b2f406499e2ce64755c03c43050b698b8.1556830454.git-series.mac@mcrowe.com>

* support/xclock_gettime.c (xclock_gettime): New file. Provide
	clock_gettime wrapper for use in tests that fails the test rather
	than returning failure.

	* support/xtime.h: New file to declare xclock_gettime.

	* support/Makefile: Add xclock_gettime.c.

	* support/README: Mention xtime.h.
---
 ChangeLog                | 12 ++++++++++++
 support/Makefile         |  1 +
 support/README           |  1 +
 support/xclock_gettime.c | 31 +++++++++++++++++++++++++++++++
 support/xtime.h          | 33 +++++++++++++++++++++++++++++++++
 5 files changed, 78 insertions(+)
 create mode 100644 support/xclock_gettime.c
 create mode 100644 support/xtime.h

diff --git a/ChangeLog b/ChangeLog
index 2d1907b..6008265 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2019-05-02  Mike Crowe  <mac@mcrowe.com>
+
+	* support/xclock_gettime.c (xclock_gettime): New file. Provide
+	clock_gettime wrapper for use in tests that fails the test rather
+	than returning failure.
+
+	* support/xtime.h: New file to declare xclock_gettime.
+
+	* support/Makefile: Add xclock_gettime.c.
+
+	* support/README: Mention xtime.h.
+
 2019-05-02  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	[BZ #24506]
diff --git a/support/Makefile b/support/Makefile
index 574e34c..05865fe 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -78,6 +78,7 @@ libsupport-routines = \
   xbind \
   xcalloc \
   xchroot \
+  xclock_gettime \
   xclose \
   xconnect \
   xcopy_file_range \
diff --git a/support/README b/support/README
index 476cfcd..d82f472 100644
--- a/support/README
+++ b/support/README
@@ -10,6 +10,7 @@ error.  They are declared in these header files:
 * support.h
 * xsignal.h
 * xthread.h
+* xtime.h
 
 In general, new wrappers should be added to support.h if possible.
 However, support.h must remain fully compatible with C90 and therefore
diff --git a/support/xclock_gettime.c b/support/xclock_gettime.c
new file mode 100644
index 0000000..0961e75
--- /dev/null
+++ b/support/xclock_gettime.c
@@ -0,0 +1,31 @@
+/* clock_gettime with error checking.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <support/check.h>
+#include <support/xtime.h>
+#include <support/xthread.h>
+
+void
+xclock_gettime (clockid_t clockid,
+                struct timespec *ts)
+{
+  const int ret = clock_gettime (clockid, ts);
+  if (ret < 0)
+    FAIL_EXIT1 ("clock_gettime (%d): %m",
+                clockid);
+}
diff --git a/support/xtime.h b/support/xtime.h
new file mode 100644
index 0000000..68af1a5
--- /dev/null
+++ b/support/xtime.h
@@ -0,0 +1,33 @@
+/* Support functionality for using time.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef SUPPORT_TIME_H
+#define SUPPORT_TIME_H
+
+#include <time.h>
+
+__BEGIN_DECLS
+
+/* The following functions call the corresponding libc functions and
+   terminate the process on error.  */
+
+void xclock_gettime (clockid_t clock, struct timespec *ts);
+
+__END_DECLS
+
+#endif /* SUPPORT_TIME_H */
-- 
git-series 0.9.1

  reply	other threads:[~2019-05-02 20:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 20:54 [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe
2019-05-02 20:54 ` Mike Crowe [this message]
2019-05-08 13:46   ` [PATCH 1/5] support: Add xclock_gettime Florian Weimer
2019-05-08 14:22     ` Mike Crowe
2019-05-08 15:00       ` Florian Weimer
2019-05-08 16:17         ` Mike Crowe
2019-05-08 15:11     ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 2/5] nptl: Convert tst-cond11.c to use libsupport Mike Crowe
2019-05-09 16:39   ` Adhemerval Zanella
2019-05-09 17:08     ` Florian Weimer
2019-05-09 17:16       ` Adhemerval Zanella
2019-05-09 23:03         ` Joseph Myers
2019-05-10  9:42           ` Adhemerval Zanella
2019-05-10 12:20             ` Adhemerval Zanella
2019-05-10 12:22               ` Florian Weimer
2019-05-02 20:54 ` [PATCH 3/5] nptl: Use recent additions to libsupport in tst-sem5 Mike Crowe
2019-05-09 16:55   ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 4/5] nptl: Convert some rwlock tests to use libsupport Mike Crowe
2019-05-09 17:25   ` Adhemerval Zanella
2019-05-02 20:54 ` [PATCH 5/5] nptl/tst-abstime: Use libsupport Mike Crowe
2019-05-09 17:26   ` Adhemerval Zanella
2019-05-03 20:38 ` [PATCH 0/5] Add new helper functions+macros to libsupport and use them in some nptl tests Mike Crowe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=effd524dc2717f61b6cc8e3d3b75cb0273586919.1556830454.git-series.mac@mcrowe.com \
    --to=mac@mcrowe.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).