diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2021-10-09 19:12:36 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2021-10-18 23:01:19 +0200 |
commit | 4c8e78a5b4ebc62f3cee348f2ab74768df2a0c68 (patch) | |
tree | 5936fd4c960d31873e881ac829c8cdb857fd202b | |
parent | 1f0f42737c22cb589b35730023ce71a114f5bba1 (diff) | |
download | backports-4c8e78a5b4ebc62f3cee348f2ab74768df2a0c68.tar.gz |
headers: Add time_after32()v5.13.19-1
The function time_after32() was added in kernel 4.14 and is now used by
the mt76 driver.
The code was copied from the upstream kernel.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r-- | backport/backport-include/linux/time.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/backport/backport-include/linux/time.h b/backport/backport-include/linux/time.h index ce8a1b03..712881db 100644 --- a/backport/backport-include/linux/time.h +++ b/backport/backport-include/linux/time.h @@ -12,4 +12,21 @@ static inline void time64_to_tm(time64_t totalsecs, int offset, } #endif +#ifndef time_after32 +/** + * time_after32 - compare two 32-bit relative times + * @a: the time which may be after @b + * @b: the time which may be before @a + * + * time_after32(a, b) returns true if the time @a is after time @b. + * time_before32(b, a) returns true if the time @b is before time @a. + * + * Similar to time_after(), compare two 32-bit timestamps for relative + * times. This is useful for comparing 32-bit seconds values that can't + * be converted to 64-bit values (e.g. due to disk format or wire protocol + * issues) when it is known that the times are less than 68 years apart. + */ +#define time_after32(a, b) ((s32)((u32)(b) - (u32)(a)) < 0) +#endif + #endif /* __BACKPORT_LINUX_TIME_H */ |