Statistics
| Branch: | Tag: | Revision:

amiro-os / kernel / patches / chTimeAddX-overflow-fix.patch @ df5aa9b6

History | View | Annotate | Download (672 Bytes)

1
diff --git a/os/rt/include/chtime.h b/os/rt/include/chtime.h
2
--- a/os/rt/include/chtime.h
3
+++ b/os/rt/include/chtime.h
4
@@ -441,11 +441,11 @@ static inline time_usecs_t chTimeI2US(sysinterval_t interval) {
5
 static inline systime_t chTimeAddX(systime_t systime,
6
                                    sysinterval_t interval) {
7
 
8
-#if CH_CFG_ST_RESOLUTION != CH_CFG_INTERVALS_SIZE
9
-  chDbgCheck(interval <= (sysinterval_t)TIME_MAX_SYSTIME);
10
+#if CH_CFG_ST_RESOLUTION < CH_CFG_INTERVALS_SIZE
11
+  return  systime + (systime_t)(interval % ((sysinterval_t)1 << CH_CFG_ST_RESOLUTION));
12
+#else
13
+  return systime + interval;
14
 #endif
15
-
16
-  return systime + (systime_t)interval;
17
 }
18
 
19
 /**