Remove ftime and sys/timeb.h
PATCH 1/1 Remove ftime and sys/timeb.h
The two case use ftime to get the current milliseconds and it was used to generate random value. Use gettimeofday() to get the microseconds can reach the same aim.
This also fixes the travis build error[1] on Fedora:Rawhide because the <sys/timeb.h> has been deprecated[2].
[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.html
--- testcases/kernel/mem/hugetlb/lib/hugetlb.c | 12 ++++++------ testcases/kernel/sched/tool/trace_sched.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-)
testcases/kernel/mem/hugetlb/lib/hugetlb.c +6 -6
@@ -35,7 +35,7 @@#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <pwd.h> #include "hugetlb.h"
@@ -52,7 +52,7 @@ int getipckey(void)char *curdir =NULL ;size_t size =0 ;key_t ipc_key; -struct timeb time_info; +struct timeval time_info; curdir =getcwd (curdir, size);if (curdir ==NULL )
@@ -67,11 +67,11 @@ int getipckey(void)* project identifier is a "random character" produced by * generating a random number between 0 and 25 and then adding * that to the ascii value of 'a'. The "seed" for the random -* number is the millisecond value that is set in the timeb -* structure after calling ftime(). +* number is the microseconds value that is set in the timeval +* structure after calling gettimeofday(). */ -ftime (&time_info); -srandom ((unsigned int )time_info.millitm); +gettimeofday (&time_info,NULL ); +srandom ((unsigned int )time_info.tv_usec); ipc_key =ftok (curdir, ascii_a +random () %26 );if (ipc_key ==-1 )
testcases/kernel/sched/tool/trace_sched.c +4 -4
@@ -52,7 +52,7 @@#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <unistd.h> #include <string.h>
@@ -199,7 +199,7 @@ void *thread_func(void *args)static int sched_policy;/* scheduling policy as set by user/default */ struct sched_param ssp;/* set schedule priority. */ struct sched_param gsp;/* gsp schedule priority. */ -struct timeb tptr;/* tptr.millitm will be used to seed srand. */ +struct timeval tptr;/* tv_usec will be used to seed srand. */ thread_sched_t *locargptr =/* local ptr to the arguments. */ (thread_sched_t *) args;
@@ -215,8 +215,8 @@ void *thread_func(void *args) ssp.sched_priority =0 ; else {/* Set a random value between max_priority and min_priority */ -ftime (&tptr); -srand ((tptr.millitm) %1000 ); +gettimeofday (&tptr,NULL ); +srand ((tptr.tv_usec) %1000000 ); set_priority = (min_priority + (int )((float )max_priority *rand () / (RAND_MAX +1.0 )));
Signature · 1 line
2.23.0
PATCH 1/1 Remove ftime and sys/timeb.h
Quoted 4 lines · Yang Xu
The two case use ftime to get the current milliseconds and it was used to generate random value. Use
gettimeofday()to get the microseconds can reach the same aim.
Quoted 8 lines
This also fixes the travis build error[1] on Fedora:Rawhide because the <
sys/timeb.h> has been deprecated[2].[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.htmlReported-by Petr Vorel <[email protected]>Signed-off-by Yang Xu <[email protected]>
Travis CI Passed: https://travis-ci.org/github/wangli5665/ltp/builds/737927003
Signature · 2 lines
Regards, Li Wang
PATCH 1/1 Remove ftime and sys/timeb.h
In reply to Yang Xu----- Original Message -----
Quoted 8 lines
The two case use ftime to get the current milliseconds and it was used to generate random value. Use
gettimeofday()to get the microseconds can reach the same aim.This also fixes the travis build error[1] on Fedora:Rawhide because the <
sys/timeb.h>
has been deprecated[2].
Quoted 5 lines
[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.htmlReported-by Petr Vorel <[email protected]>Signed-off-by Yang Xu <[email protected]>
PATCH 1/1 Remove ftime and sys/timeb.h
In reply to Yang XuQuoted 78 lines · Yang Xu
The two case use ftime to get the current milliseconds and it was used to generate random value. Use
gettimeofday()to get the microseconds can reach the same aim.This also fixes the travis build error[1] on Fedora:Rawhide because the<sys/timeb.h> has been deprecated[2].
[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.htmlReported-by Petr Vorel<[email protected]>Signed-off-by Yang Xu<[email protected]>--- testcases/kernel/mem/hugetlb/lib/hugetlb.c | 12 ++++++------ testcases/kernel/sched/tool/trace_sched.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-)testcases/kernel/mem/hugetlb/lib/hugetlb.c +6
-6@@ -35,7 +35,7 @@#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <pwd.h> #include "hugetlb.h" @@ -52,7 +52,7 @@ int getipckey(void)char *curdir =NULL ;size_t size =0 ;key_t ipc_key; -struct timeb time_info; +struct timeval time_info; curdir =getcwd (curdir, size);if (curdir ==NULL )@@ -67,11 +67,11 @@ int getipckey(void)* project identifier is a "random character" produced by * generating a random number between 0 and 25 and then adding * that to the ascii value of 'a'. The "seed" for the random -* number is the millisecond value that is set in the timeb -* structure after calling ftime(). +* number is the microseconds value that is set in the timeval +* structure after calling gettimeofday(). */ -ftime (&time_info); -srandom ((unsigned int )time_info.millitm); +gettimeofday (&time_info,NULL ); +srandom ((unsigned int )time_info.tv_usec); ipc_key =ftok (curdir, ascii_a +random () %26 );if (ipc_key ==-1 )testcases/kernel/sched/tool/trace_sched.c +2
-2@@ -52,7 +52,7 @@#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <unistd.h> #include <string.h> @@ -199,7 +199,7 @@ void *thread_func(void *args)static int sched_policy;/* scheduling policy as set by user/default */ struct sched_param ssp;/* set schedule priority. */ struct sched_param gsp;/* gsp schedule priority. */ -struct timeb tptr;/* tptr.millitm will be used to seed srand. */ +struct timeval tptr;/* tv_usec will be used to seed srand. */ thread_sched_t *locargptr =/* local ptr to the arguments. */ (thread_sched_t *) args;
testcases/kernel/sched/tool/trace_sched.c void *thread_func(void *args) · line 219
Quoted 7 lines
testcases/kernel/sched/tool/trace_sched.c +2
-2@@ -215,8 +215,8 @@ void *thread_func(void *args) ssp.sched_priority =0 ; else {/* Set a random value between max_priority and min_priority */ -ftime (&tptr); -srand ((tptr.millitm) %1000 ); +gettimeofday (&tptr,NULL ); +srand ((tptr.tv_usec) %1000000 );
Hi Yang,
One minor issue:
'% 1000000' seems useless because the range of tv_usec is 0~999999.
Other than that, it's good to me.
Best Regards,
Xiao Yang
Quoted 3 lines
testcases/kernel/sched/tool/trace_sched.c +0
-0set_priority = (min_priority + (int )((float )max_priority *rand () / (RAND_MAX +1.0 )));
PATCH 1/1 Remove ftime and sys/timeb.h
Hi Xiao
Quoted 91 lines · Yang Xu
Quoted 81 lines
The two case use ftime to get the current milliseconds and it was used to generate random value. Use
gettimeofday()to get the microseconds can reach the same aim.This also fixes the travis build error[1] on Fedora:Rawhide because the<sys/timeb.h>
has been deprecated[2].[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.htmlReported-by Petr Vorel<[email protected]>Signed-off-by Yang Xu<[email protected]>---
testcases/kernel/mem/hugetlb/lib/hugetlb.c| 12 ++++++------testcases/kernel/sched/tool/trace_sched.c| 8 ++++----2 files changed, 10 insertions(+), 10 deletions(-)testcases/kernel/mem/hugetlb/lib/hugetlb.c +6
-6@@ -35,7 +35,7 @@#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <pwd.h> #include "hugetlb.h" @@ -52,7 +52,7 @@ int getipckey(void)char *curdir =NULL ;size_t size =0 ;key_t ipc_key; -struct timeb time_info; +struct timeval time_info; curdir =getcwd (curdir, size);if (curdir ==NULL )@@ -67,11 +67,11 @@ int getipckey(void)* project identifier is a "random character" produced by * generating a random number between 0 and 25 and then adding * that to the ascii value of 'a'. The "seed" for the random -* number is the millisecond value that is set in the timeb -* structure after calling ftime(). +* number is the microseconds value that is set in the timeval +* structure after calling gettimeofday(). */ -ftime (&time_info); -srandom ((unsigned int )time_info.millitm); +gettimeofday (&time_info,NULL ); +srandom ((unsigned int )time_info.tv_usec); ipc_key =ftok (curdir, ascii_a +random () %26 );if (ipc_key ==-1 )testcases/kernel/sched/tool/trace_sched.c +1
-1@@ -52,7 +52,7 @@#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <unistd.h> #include <string.h> @@ -199,7 +199,7 @@ void *thread_func(void *args)static int
sched_policy; /* scheduling policy as set by user/default */ structsched_paramssp; /* set schedule priority. */
structsched_paramgsp; /* gsp schedule priority. */
- struct timeb tptr; /* tptr.millitm will be used to seed srand. */
+ struct timeval tptr; /*tv_usecwill be used to seed srand. */thread_sched_t*locargptr = /* local ptr to the arguments. */ (thread_sched_t*) args;testcases/kernel/sched/tool/trace_sched.c void *thread_func(void *args) · line 219
Quoted 7 lines
testcases/kernel/sched/tool/trace_sched.c +2
-2@@ -215,8 +215,8 @@ void *thread_func(void *args) ssp.sched_priority =0 ; else {/* Set a random value between max_priority and min_priority */ -ftime (&tptr); -srand ((tptr.millitm) %1000 ); +gettimeofday (&tptr,NULL ); +srand ((tptr.tv_usec) %1000000 );Hi Yang,
Quoted 2 lines
One minor issue:
'% 1000000' seems useless because the range oftv_usecis 0~999999.
Agree. Will fix it in v2 patch.
Best Regards
Yang Xu
Quoted 11 lines
Other than that, it's good to me.
Best Regards,
Xiao YangQuoted 3 lines
set_priority= (min_priority+ (int)((float)max_priority
*rand()/ (RAND_MAX+
1.0)));.
PATCH v2 1/1 Remove ftime and sys/timeb.h
The two case uses ftime to get the current milliseconds and it was used to generate random value. Using gettimeofday() to get the microseconds can reach the same aim.
This also fixes the travis build error[1] on Fedora:Rawhide because the <sys/timeb.h> has been deprecated[2].
[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.html
---v1->v2
1.Remove useless "% 1000000" since the range of tv_usec is 0~999999. 2.case suseconds_t to unsigned int
testcases/kernel/mem/hugetlb/lib/hugetlb.c | 12 ++++++------ testcases/kernel/sched/tool/trace_sched.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-)
testcases/kernel/mem/hugetlb/lib/hugetlb.c +6 -6
@@ -35,7 +35,7 @@#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <pwd.h> #include "hugetlb.h"
@@ -52,7 +52,7 @@ int getipckey(void)char *curdir =NULL ;size_t size =0 ;key_t ipc_key; -struct timeb time_info; +struct timeval time_info; curdir =getcwd (curdir, size);if (curdir ==NULL )
@@ -67,11 +67,11 @@ int getipckey(void)* project identifier is a "random character" produced by * generating a random number between 0 and 25 and then adding * that to the ascii value of 'a'. The "seed" for the random -* number is the millisecond value that is set in the timeb -* structure after calling ftime(). +* number is the microseconds value that is set in the timeval +* structure after calling gettimeofday(). */ -ftime (&time_info); -srandom ((unsigned int )time_info.millitm); +gettimeofday (&time_info,NULL ); +srandom ((unsigned int )time_info.tv_usec); ipc_key =ftok (curdir, ascii_a +random () %26 );if (ipc_key ==-1 )
testcases/kernel/sched/tool/trace_sched.c +4 -4
@@ -52,7 +52,7 @@#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/timeb.h> +#include <sys/time.h> #include <unistd.h> #include <string.h>
@@ -199,7 +199,7 @@ void *thread_func(void *args)static int sched_policy;/* scheduling policy as set by user/default */ struct sched_param ssp;/* set schedule priority. */ struct sched_param gsp;/* gsp schedule priority. */ -struct timeb tptr;/* tptr.millitm will be used to seed srand. */ +struct timeval tptr;/* tptr.tv_usec will be used to seed srand. */ thread_sched_t *locargptr =/* local ptr to the arguments. */ (thread_sched_t *) args;
@@ -215,8 +215,8 @@ void *thread_func(void *args) ssp.sched_priority =0 ; else {/* Set a random value between max_priority and min_priority */ -ftime (&tptr); -srand ((tptr.millitm) %1000 ); +gettimeofday (&tptr,NULL ); +srand ((unsigned int )tptr.tv_usec); set_priority = (min_priority + (int )((float )max_priority *rand () / (RAND_MAX +1.0 )));
Signature · 1 line
2.23.0
PATCH v2 1/1 Remove ftime and sys/timeb.h
Quoted 7 lines · Yang Xu
The two case uses ftime to get the current milliseconds and it was used to generate random value. Using
gettimeofday()to get the microseconds can reach the same aim.This also fixes the travis build error[1] on Fedora:Rawhide because the <
sys/timeb.h> has been deprecated[2].
Quoted 7 lines
[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.htmlReviewed-by Li Wang <[email protected]>Acked-by Jan Stancek <[email protected]>Acked-by Xiao Yang <[email protected]>Signed-off-by Yang Xu <[email protected]>
Pushed, thanks!
Signature · 2 lines
Regards, Li Wang
PATCH v2 1/1 Remove ftime and sys/timeb.h
Hi all,
Quoted 12 lines
Quoted 9 lines · Yang Xu
The two case uses ftime to get the current milliseconds and it was used to generate random value. Using
gettimeofday()to get the microseconds can reach the same aim.This also fixes the travis build error[1] on Fedora:Rawhide because the <
sys/timeb.h> has been deprecated[2].[1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948
[2] https://www.spinics.net/lists/fedora-devel/msg279545.html
Quoted 6 lines
Quoted 4 lines
Reviewed-by Li Wang <[email protected]>Acked-by Jan Stancek <[email protected]>Acked-by Xiao Yang <[email protected]>Signed-off-by Yang Xu <[email protected]>Pushed, thanks!
Thanks for handling these!
Kind regards,
Petr