amiro-os / kernel / patches / chTimeAddX-overflow-fix.patch @ c3942f1c
History | View | Annotate | Download (701 Bytes)
1 |
diff --git a/os/rt/include/chtime.h b/os/rt/include/chtime.h
|
---|---|
2 |
index c975d10..99ce8d8 100644
|
3 |
--- a/os/rt/include/chtime.h
|
4 |
+++ b/os/rt/include/chtime.h
|
5 |
@@ -472,11 +472,11 @@ static inline time_usecs_t chTimeI2US(sysinterval_t interval) { |
6 |
static inline systime_t chTimeAddX(systime_t systime, |
7 |
sysinterval_t interval) { |
8 |
|
9 |
-#if CH_CFG_ST_RESOLUTION != CH_CFG_INTERVALS_SIZE
|
10 |
- chDbgCheck(interval <= (sysinterval_t)((systime_t)-1));
|
11 |
+#if CH_CFG_ST_RESOLUTION < CH_CFG_INTERVALS_SIZE
|
12 |
+ return systime + (systime_t)(interval % ((sysinterval_t)1 << CH_CFG_ST_RESOLUTION));
|
13 |
+#else
|
14 |
+ return systime + interval;
|
15 |
#endif
|
16 |
-
|
17 |
- return systime + (systime_t)interval;
|
18 |
} |
19 |
|
20 |
/**
|