[1/6] support: Add xclock_gettime
diff mbox series

Message ID 120a887625ceeca4b06ee73d4af08827ec68ecde.1553797867.git-series.mac@mcrowe.com
State New
Headers show
Series
  • Improve various nptl tests
Related show

Commit Message

Mike Crowe March 28, 2019, 6:31 p.m. UTC
* 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.
---
 ChangeLog                | 10 ++++++++++
 support/Makefile         |  1 +
 support/xclock_gettime.c | 28 ++++++++++++++++++++++++++++
 support/xtime.h          | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 100644 support/xclock_gettime.c
 create mode 100644 support/xtime.h

Comments

Adhemerval Zanella April 3, 2019, 1:16 a.m. UTC | #1
On 29/03/2019 01:31, Mike Crowe wrote:
> * 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.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella <adhemerva.zanella@linaro.org>

> ---
>  ChangeLog                | 10 ++++++++++
>  support/Makefile         |  1 +
>  support/xclock_gettime.c | 28 ++++++++++++++++++++++++++++
>  support/xtime.h          | 33 +++++++++++++++++++++++++++++++++
>  4 files changed, 72 insertions(+)
>  create mode 100644 support/xclock_gettime.c
>  create mode 100644 support/xtime.h
> 
> diff --git a/ChangeLog b/ChangeLog
> index 19d3e90..ff4dabd 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,13 @@
> +2019-03-28  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.
> +
>  2019-03-26  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>  
>  	* math/math.h (fpclassify, isfinite, isnormal, isnan): Use builtin for
> diff --git a/support/Makefile b/support/Makefile
> index f173565..1d37f70 100644
> --- a/support/Makefile
> +++ b/support/Makefile
> @@ -77,6 +77,7 @@ libsupport-routines = \
>    xbind \
>    xcalloc \
>    xchroot \
> +  xclock_gettime \
>    xclose \
>    xconnect \
>    xcopy_file_range \
> diff --git a/support/xclock_gettime.c b/support/xclock_gettime.c
> new file mode 100644
> index 0000000..a0d4ee6
> --- /dev/null
> +++ b/support/xclock_gettime.c
> @@ -0,0 +1,28 @@
> +/* 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/xtime.h>
> +#include <support/xthread.h>
> +
> +void
> +xclock_gettime (clockid_t clockid,
> +                struct timespec *ts)
> +{
> +  xpthread_check_return
> +    ("clock_gettime", clock_gettime (clockid, ts));
> +}
> 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 */
>
Florian Weimer April 5, 2019, 11:07 a.m. UTC | #2
* Adhemerval Zanella:

> On 29/03/2019 01:31, Mike Crowe wrote:
>> * 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.
>
> LGTM, thanks.
>
> Reviewed-by: Adhemerval Zanella <adhemerva.zanella@linaro.org>

Agreed, this looks good.

Thanks,
Florian

Patch
diff mbox series

diff --git a/ChangeLog b/ChangeLog
index 19d3e90..ff4dabd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@ 
+2019-03-28  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.
+
 2019-03-26  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
 	* math/math.h (fpclassify, isfinite, isnormal, isnan): Use builtin for
diff --git a/support/Makefile b/support/Makefile
index f173565..1d37f70 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -77,6 +77,7 @@  libsupport-routines = \
   xbind \
   xcalloc \
   xchroot \
+  xclock_gettime \
   xclose \
   xconnect \
   xcopy_file_range \
diff --git a/support/xclock_gettime.c b/support/xclock_gettime.c
new file mode 100644
index 0000000..a0d4ee6
--- /dev/null
+++ b/support/xclock_gettime.c
@@ -0,0 +1,28 @@ 
+/* 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/xtime.h>
+#include <support/xthread.h>
+
+void
+xclock_gettime (clockid_t clockid,
+                struct timespec *ts)
+{
+  xpthread_check_return
+    ("clock_gettime", clock_gettime (clockid, ts));
+}
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 */