diff mbox series

[v3,1/2] lib: include SAFE_CLOCK_ADJTIME() macro

Message ID 20190226160804.16596-1-rafael.tinoco@linaro.org
State Superseded
Headers show
Series [v3,1/2] lib: include SAFE_CLOCK_ADJTIME() macro | expand

Commit Message

Rafael David Tinoco Feb. 26, 2019, 4:08 p.m. UTC
Adds SAFE_CLOCK_ADJTIME() macro to tst_safe_clocks.h.

Signed-off-by: Rafael David Tinoco <rafael.tinoco@linaro.org>
---
 include/tst_safe_clocks.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Cyril Hrubis March 13, 2019, 4:09 p.m. UTC | #1
Hi!
> +static inline void safe_clock_adjtime(const char *file, const int lineno,
> +	clockid_t clk_id, struct timex *txc)
> +{
> +	int rval;
> +
> +	rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);

Any reason why we don't use clock_adjtime() here?

Or is the glibc wrapper missing?

> +	if (rval != 0)
> +		tst_brk(TBROK | TERRNO,
> +			"%s:%d clock_adjtime() failed", file, lineno);
> +}
>  #define SAFE_CLOCK_GETRES(clk_id, res)\
>  	safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))
>  
> @@ -50,3 +63,6 @@ static inline void safe_clock_settime(const char *file, const int lineno,
>  
>  #define SAFE_CLOCK_SETTIME(clk_id, tp)\
>  	safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp))
> +
> +#define SAFE_CLOCK_ADJTIME(clk_id, txc)\
> +	safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc))
> -- 
> 2.20.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Rafael David Tinoco March 13, 2019, 4:26 p.m. UTC | #2
> On 13 Mar 2019, at 13:09, Cyril Hrubis <chrubis@suse.cz <mailto:chrubis@suse.cz>> wrote:

> 

> Hi!

>> +static inline void safe_clock_adjtime(const char *file, const int lineno,

>> +	clockid_t clk_id, struct timex *txc)

>> +{

>> +	int rval;

>> +

>> +	rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);

> 

> Any reason why we don't use clock_adjtime() here?

> 

> Or is the glibc wrapper missing?


Yes, it is missing. It was added in glibc NEWS in a “new Linux interfaces” list and put into the syscalls list, but, at the moment, there is nothing wrapping it. 

> 

>> +	if (rval != 0)

>> +		tst_brk(TBROK | TERRNO,

>> +			"%s:%d clock_adjtime() failed", file, lineno);

>> +}

>> #define SAFE_CLOCK_GETRES(clk_id, res)\

>> 	safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))

>> 

>> @@ -50,3 +63,6 @@ static inline void safe_clock_settime(const char *file, const int lineno,

>> 

>> #define SAFE_CLOCK_SETTIME(clk_id, tp)\

>> 	safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp))

>> +

>> +#define SAFE_CLOCK_ADJTIME(clk_id, txc)\

>> +	safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc))

>> -- 

>> 2.20.1

>> 

>> 

>> -- 

>> Mailing list info: https://lists.linux.it/listinfo/ltp <https://lists.linux.it/listinfo/ltp>

> -- 

> Cyril Hrubis

> chrubis@suse.cz <mailto:chrubis@suse.cz>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On 13 Mar 2019, at 13:09, Cyril Hrubis &lt;<a href="mailto:chrubis@suse.cz" class="">chrubis@suse.cz</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Hi!</span><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+static inline void safe_clock_adjtime(const char *file, const int lineno,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span>clockid_t clk_id, struct timex *txc)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span>int rval;<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span>rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);</blockquote><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Any reason why we don't use clock_adjtime() here?</span><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Or is the glibc wrapper missing?</span><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div>Yes, it is missing. It was added in glibc NEWS in a “new Linux interfaces” list and put into the syscalls list, but, at the moment, there is nothing wrapping it.&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span>if (rval != 0)<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span><span class="Apple-tab-span" style="white-space: pre;">	</span>tst_brk(TBROK | TERRNO,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span><span class="Apple-tab-span" style="white-space: pre;">	</span><span class="Apple-tab-span" style="white-space: pre;">	</span>"%s:%d clock_adjtime() failed", file, lineno);<br class="">+}<br class="">#define SAFE_CLOCK_GETRES(clk_id, res)\<br class=""><span class="Apple-tab-span" style="white-space: pre;">	</span>safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))<br class=""><br class="">@@ -50,3 +63,6 @@ static inline void safe_clock_settime(const char *file, const int lineno,<br class=""><br class="">#define SAFE_CLOCK_SETTIME(clk_id, tp)\<br class=""><span class="Apple-tab-span" style="white-space: pre;">	</span>safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp))<br class="">+<br class="">+#define SAFE_CLOCK_ADJTIME(clk_id, txc)\<br class="">+<span class="Apple-tab-span" style="white-space: pre;">	</span>safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc))<br class="">--<span class="Apple-converted-space">&nbsp;</span><br class="">2.20.1<br class=""><br class=""><br class="">--<span class="Apple-converted-space">&nbsp;</span><br class="">Mailing list info:<span class="Apple-converted-space">&nbsp;</span><a href="https://lists.linux.it/listinfo/ltp" class="">https://lists.linux.it/listinfo/ltp</a></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">--<span class="Apple-converted-space">&nbsp;</span></span><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Cyril Hrubis</span><br style="caret-color: rgb(0, 0, 0); font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><a href="mailto:chrubis@suse.cz" style="font-family: LucidaSansTypewriterStd; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">chrubis@suse.cz</a></div></blockquote><br class=""></div><div><br class=""></div></body></html>
diff mbox series

Patch

diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h
index 553f8464a..304207f6b 100644
--- a/include/tst_safe_clocks.h
+++ b/include/tst_safe_clocks.h
@@ -6,6 +6,8 @@ 
 
 #include <time.h>
 #include "tst_test.h"
+#include <sys/timex.h>
+#include "lapi/syscalls.h"
 
 static inline void safe_clock_getres(const char *file, const int lineno,
 	clockid_t clk_id, struct timespec *res)
@@ -42,6 +44,17 @@  static inline void safe_clock_settime(const char *file, const int lineno,
 			"%s:%d clock_gettime() failed", file, lineno);
 }
 
+static inline void safe_clock_adjtime(const char *file, const int lineno,
+	clockid_t clk_id, struct timex *txc)
+{
+	int rval;
+
+	rval = tst_syscall(__NR_clock_adjtime, clk_id, txc);
+
+	if (rval != 0)
+		tst_brk(TBROK | TERRNO,
+			"%s:%d clock_adjtime() failed", file, lineno);
+}
 #define SAFE_CLOCK_GETRES(clk_id, res)\
 	safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))
 
@@ -50,3 +63,6 @@  static inline void safe_clock_settime(const char *file, const int lineno,
 
 #define SAFE_CLOCK_SETTIME(clk_id, tp)\
 	safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp))
+
+#define SAFE_CLOCK_ADJTIME(clk_id, txc)\
+	safe_clock_adjtime(__FILE__, __LINE__, (clk_id), (txc))