Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: timers: Remove local NSEC_PER_SEC and USEC_PER_SEC defines

Remove local NSEC_PER_SEC and USEC_PER_SEC defines. Pick them up from
include/vdso/time64.h. This requires -I $(top_srcdir) to the timers
Makefile to include the include/vdso/time64.h.

posix_timers test names the defines NSECS_PER_SEC and USECS_PER_SEC.
Change posix_timers test references to the defines to match the
defines in the header file.

Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: John Stultz <jstultz@google.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

+19 -28
+1 -1
tools/testing/selftests/timers/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - CFLAGS += -O3 -Wl,-no-as-needed -Wall 2 + CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir) 3 3 LDLIBS += -lrt -lpthread -lm 4 4 5 5 # these are all "safe" tests that don't modify
+1 -3
tools/testing/selftests/timers/adjtick.c
··· 22 22 #include <sys/time.h> 23 23 #include <sys/timex.h> 24 24 #include <time.h> 25 + #include <include/vdso/time64.h> 25 26 26 27 #include "../kselftest.h" 27 28 28 29 #define CLOCK_MONOTONIC_RAW 4 29 - 30 - #define NSEC_PER_SEC 1000000000LL 31 - #define USEC_PER_SEC 1000000 32 30 33 31 #define MILLION 1000000 34 32
+1 -1
tools/testing/selftests/timers/alarmtimer-suspend.c
··· 28 28 #include <signal.h> 29 29 #include <stdlib.h> 30 30 #include <pthread.h> 31 + #include <include/vdso/time64.h> 31 32 #include "../kselftest.h" 32 33 33 34 #define CLOCK_REALTIME 0 ··· 46 45 #define NR_CLOCKIDS 12 47 46 48 47 49 - #define NSEC_PER_SEC 1000000000ULL 50 48 #define UNREASONABLE_LAT (NSEC_PER_SEC * 5) /* hopefully we resume in 5 secs */ 51 49 52 50 #define SUSPEND_SECS 15
+1 -1
tools/testing/selftests/timers/inconsistency-check.c
··· 28 28 #include <sys/timex.h> 29 29 #include <string.h> 30 30 #include <signal.h> 31 + #include <include/vdso/time64.h> 31 32 #include "../kselftest.h" 32 33 33 34 #define CALLS_PER_LOOP 64 34 - #define NSEC_PER_SEC 1000000000ULL 35 35 36 36 #define CLOCK_REALTIME 0 37 37 #define CLOCK_MONOTONIC 1
+1 -1
tools/testing/selftests/timers/leap-a-day.c
··· 48 48 #include <string.h> 49 49 #include <signal.h> 50 50 #include <unistd.h> 51 + #include <include/vdso/time64.h> 51 52 #include "../kselftest.h" 52 53 53 - #define NSEC_PER_SEC 1000000000ULL 54 54 #define CLOCK_TAI 11 55 55 56 56 time_t next_leap;
+1 -1
tools/testing/selftests/timers/mqueue-lat.c
··· 29 29 #include <signal.h> 30 30 #include <errno.h> 31 31 #include <mqueue.h> 32 + #include <include/vdso/time64.h> 32 33 #include "../kselftest.h" 33 34 34 - #define NSEC_PER_SEC 1000000000ULL 35 35 36 36 #define TARGET_TIMEOUT 100000000 /* 100ms in nanoseconds */ 37 37 #define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */
+1 -2
tools/testing/selftests/timers/nanosleep.c
··· 27 27 #include <sys/timex.h> 28 28 #include <string.h> 29 29 #include <signal.h> 30 + #include <include/vdso/time64.h> 30 31 #include "../kselftest.h" 31 - 32 - #define NSEC_PER_SEC 1000000000ULL 33 32 34 33 #define CLOCK_REALTIME 0 35 34 #define CLOCK_MONOTONIC 1
+1 -2
tools/testing/selftests/timers/nsleep-lat.c
··· 24 24 #include <sys/timex.h> 25 25 #include <string.h> 26 26 #include <signal.h> 27 + #include <include/vdso/time64.h> 27 28 #include "../kselftest.h" 28 - 29 - #define NSEC_PER_SEC 1000000000ULL 30 29 31 30 #define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */ 32 31
+7 -8
tools/testing/selftests/timers/posix_timers.c
··· 15 15 #include <string.h> 16 16 #include <unistd.h> 17 17 #include <time.h> 18 + #include <include/vdso/time64.h> 18 19 #include <pthread.h> 19 20 20 21 #include "../kselftest.h" 21 22 22 23 #define DELAY 2 23 - #define USECS_PER_SEC 1000000 24 - #define NSECS_PER_SEC 1000000000 25 24 26 25 static void __fatal_error(const char *test, const char *name, const char *what) 27 26 { ··· 85 86 long long diff; 86 87 87 88 diff = end.tv_usec - start.tv_usec; 88 - diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC; 89 + diff += (end.tv_sec - start.tv_sec) * USEC_PER_SEC; 89 90 90 - if (llabs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { 91 + if (llabs(diff - DELAY * USEC_PER_SEC) > USEC_PER_SEC / 2) { 91 92 printf("Diff too high: %lld..", diff); 92 93 return -1; 93 94 } ··· 447 448 { 448 449 int64_t diff; 449 450 450 - diff = NSECS_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec); 451 + diff = NSEC_PER_SEC * (int64_t)((int) t1.tv_sec - (int) t2.tv_sec); 451 452 diff += ((int) t1.tv_nsec - (int) t2.tv_nsec); 452 453 return diff; 453 454 } ··· 478 479 do { 479 480 if (clock_gettime(which, &now)) 480 481 fatal_error(name, "clock_gettime()"); 481 - } while (calcdiff_ns(now, start) < NSECS_PER_SEC); 482 + } while (calcdiff_ns(now, start) < NSEC_PER_SEC); 482 483 483 484 if (timer_gettime(timerid, &its)) 484 485 fatal_error(name, "timer_gettime()"); ··· 535 536 wraps++; 536 537 prev = its; 537 538 538 - } while (calcdiff_ns(now, start) < NSECS_PER_SEC); 539 + } while (calcdiff_ns(now, start) < NSEC_PER_SEC); 539 540 540 541 if (timer_delete(timerid)) 541 542 fatal_error(name, "timer_delete()"); ··· 586 587 do { 587 588 if (clock_gettime(which, &now)) 588 589 fatal_error(name, "clock_gettime()"); 589 - } while (calcdiff_ns(now, start) < NSECS_PER_SEC); 590 + } while (calcdiff_ns(now, start) < NSEC_PER_SEC); 590 591 591 592 /* Unblock it, which should deliver a signal */ 592 593 if (sigprocmask(SIG_UNBLOCK, &set, NULL))
+1 -1
tools/testing/selftests/timers/raw_skew.c
··· 25 25 #include <sys/time.h> 26 26 #include <sys/timex.h> 27 27 #include <time.h> 28 + #include <include/vdso/time64.h> 28 29 #include "../kselftest.h" 29 30 30 31 #define CLOCK_MONOTONIC_RAW 4 31 - #define NSEC_PER_SEC 1000000000LL 32 32 33 33 #define shift_right(x, s) ({ \ 34 34 __typeof__(x) __x = (x); \
+1 -2
tools/testing/selftests/timers/set-2038.c
··· 27 27 #include <unistd.h> 28 28 #include <time.h> 29 29 #include <sys/time.h> 30 + #include <include/vdso/time64.h> 30 31 #include "../kselftest.h" 31 - 32 - #define NSEC_PER_SEC 1000000000LL 33 32 34 33 #define KTIME_MAX ((long long)~((unsigned long long)1 << 63)) 35 34 #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC)
+1 -2
tools/testing/selftests/timers/set-timer-lat.c
··· 28 28 #include <signal.h> 29 29 #include <stdlib.h> 30 30 #include <pthread.h> 31 + #include <include/vdso/time64.h> 31 32 #include "../kselftest.h" 32 33 33 34 #define CLOCK_REALTIME 0 ··· 45 44 #define CLOCK_TAI 11 46 45 #define NR_CLOCKIDS 12 47 46 48 - 49 - #define NSEC_PER_SEC 1000000000ULL 50 47 #define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */ 51 48 52 49 #define TIMER_SECS 1
+1 -3
tools/testing/selftests/timers/valid-adjtimex.c
··· 29 29 #include <string.h> 30 30 #include <signal.h> 31 31 #include <unistd.h> 32 + #include <include/vdso/time64.h> 32 33 #include "../kselftest.h" 33 - 34 - #define NSEC_PER_SEC 1000000000LL 35 - #define USEC_PER_SEC 1000000LL 36 34 37 35 #define ADJ_SETOFFSET 0x0100 38 36