Revert "FROMLIST: Fix an integer overflow issue in the NSEC_PER_SEC constant"
This reverts commit 062cbc4876.
There was no follow up of this patch upstream, also the cherry-pick is
not clean. Revert this as it creates merge conflicts with upstream
changes and if really needed, please send a new version upstream.
Bug: 444295917
Cc: Wake Liu <wakel@google.com>
Change-Id: I8ffdf3e8331c9318749fdadf9759921b209e424b
Signed-off-by: Carlos Llamas <cmllamas@google.com>
This commit is contained in:
1 parent
ea7d27455d
commit
31a93e5f13
6 files changed
+25
-44
No files matched your search
@@ -2424,7 +2424,6 @@ cc_library(
|
||||
name = "kselftest_timers_common_hdrs",
|
||||
hdrs = [
|
||||
"include/vdso/time64.h",
|
||||
"tools/testing/selftests/timers/helpers.h",
|
||||
],
|
||||
copts = _KSELFTEST_COPTS,
|
||||
includes = ["."],
|
||||
|
||||
@@ -31,9 +31,8 @@
|
||||
#include <include/vdso/time64.h>
|
||||
#include <errno.h>
|
||||
#include "../kselftest.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#define UNREASONABLE_LAT (NSEC_PER_SEC * 5LL) /* hopefully we resume in 5 secs */
|
||||
#define UNREASONABLE_LAT (NSEC_PER_SEC * 5) /* hopefully we resume in 5 secs */
|
||||
|
||||
#define SUSPEND_SECS 15
|
||||
int alarmcount;
|
||||
@@ -71,6 +70,14 @@ char *clockstring(int clockid)
|
||||
}
|
||||
|
||||
|
||||
long long timespec_sub(struct timespec a, struct timespec b)
|
||||
{
|
||||
long long ret = NSEC_PER_SEC * b.tv_sec + b.tv_nsec;
|
||||
|
||||
ret -= NSEC_PER_SEC * a.tv_sec + a.tv_nsec;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int final_ret;
|
||||
|
||||
void sigalarm(int signo)
|
||||
@@ -81,8 +88,8 @@ void sigalarm(int signo)
|
||||
clock_gettime(alarm_clock_id, &ts);
|
||||
alarmcount++;
|
||||
|
||||
delta_ns = timespec_sub(ts, start_time);
|
||||
delta_ns -= (long long)NSEC_PER_SEC * SUSPEND_SECS * alarmcount;
|
||||
delta_ns = timespec_sub(start_time, ts);
|
||||
delta_ns -= NSEC_PER_SEC * SUSPEND_SECS * alarmcount;
|
||||
|
||||
printf("ALARM(%i): %ld:%ld latency: %lld ns ", alarmcount, ts.tv_sec,
|
||||
ts.tv_nsec, delta_ns);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef SELFTESTS_TIMERS_HELPERS_H
|
||||
#define SELFTESTS_TIMERS_HELPERS_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifndef NSEC_PER_SEC
|
||||
#define NSEC_PER_SEC 1000000000L
|
||||
#endif
|
||||
|
||||
/*
|
||||
* timespec_to_ns - Convert timespec to nanoseconds
|
||||
*/
|
||||
static inline long long timespec_to_ns(const struct timespec *ts)
|
||||
{
|
||||
return ((long long) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
|
||||
}
|
||||
|
||||
/*
|
||||
* timespec_sub - Subtract two timespec values
|
||||
*
|
||||
* @a: first timespec
|
||||
* @b: second timespec
|
||||
*
|
||||
* Returns a - b in nanoseconds.
|
||||
*/
|
||||
static inline long long timespec_sub(struct timespec a, struct timespec b)
|
||||
{
|
||||
return timespec_to_ns(&a) - timespec_to_ns(&b);
|
||||
}
|
||||
|
||||
#endif /* SELFTESTS_TIMERS_HELPERS_H */
|
||||
@@ -188,7 +188,7 @@ int main(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
|
||||
length = 10;
|
||||
while (length <= (NSEC_PER_SEC * 10LL)) {
|
||||
while (length <= (NSEC_PER_SEC * 10)) {
|
||||
ret = nanosleep_test(clockid, length);
|
||||
if (ret == UNSUPPORTED) {
|
||||
ksft_test_result_skip("%-31s\n", clockstring(clockid));
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <signal.h>
|
||||
#include <include/vdso/time64.h>
|
||||
#include "../kselftest.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#define UNRESONABLE_LATENCY 40000000 /* 40ms in nanosecs */
|
||||
|
||||
@@ -75,6 +74,14 @@ struct timespec timespec_add(struct timespec ts, unsigned long long ns)
|
||||
}
|
||||
|
||||
|
||||
long long timespec_sub(struct timespec a, struct timespec b)
|
||||
{
|
||||
long long ret = NSEC_PER_SEC * b.tv_sec + b.tv_nsec;
|
||||
|
||||
ret -= NSEC_PER_SEC * a.tv_sec + a.tv_nsec;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int nanosleep_lat_test(int clockid, long long ns)
|
||||
{
|
||||
struct timespec start, end, target;
|
||||
@@ -139,7 +146,7 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
|
||||
length = 10;
|
||||
while (length <= (NSEC_PER_SEC * 10LL)) {
|
||||
while (length <= (NSEC_PER_SEC * 10)) {
|
||||
ret = nanosleep_lat_test(clockid, length);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
@@ -264,16 +264,16 @@ int validate_set_offset(void)
|
||||
if (set_offset(-NSEC_PER_SEC - 1, 1))
|
||||
return -1;
|
||||
|
||||
if (set_offset(5LL * NSEC_PER_SEC, 1))
|
||||
if (set_offset(5 * NSEC_PER_SEC, 1))
|
||||
return -1;
|
||||
|
||||
if (set_offset(-5LL * NSEC_PER_SEC, 1))
|
||||
if (set_offset(-5 * NSEC_PER_SEC, 1))
|
||||
return -1;
|
||||
|
||||
if (set_offset(5LL * NSEC_PER_SEC + NSEC_PER_SEC / 2, 1))
|
||||
if (set_offset(5 * NSEC_PER_SEC + NSEC_PER_SEC / 2, 1))
|
||||
return -1;
|
||||
|
||||
if (set_offset(-5LL * NSEC_PER_SEC - NSEC_PER_SEC / 2, 1))
|
||||
if (set_offset(-5 * NSEC_PER_SEC - NSEC_PER_SEC / 2, 1))
|
||||
return -1;
|
||||
|
||||
if (set_offset(USEC_PER_SEC - 1, 0))
|
||||
|
||||
Reference in new issue
Block a user