diff --git a/src/rdtime.h b/src/rdtime.h index a84b61526..ca640a3c0 100644 --- a/src/rdtime.h +++ b/src/rdtime.h @@ -26,6 +26,13 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +#include +#endif +#endif + + #ifndef _RDTIME_H_ #define _RDTIME_H_ @@ -209,6 +216,11 @@ static RD_INLINE rd_ts_t rd_timeout_init(int timeout_ms) { */ static RD_INLINE void rd_timeout_init_timespec_us(struct timespec *tspec, rd_ts_t timeout_us) { +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + __msan_unpoison(tspec, sizeof(*tspec)); +#endif +#endif if (timeout_us == RD_POLL_INFINITE || timeout_us == RD_POLL_NOWAIT) { tspec->tv_sec = timeout_us; tspec->tv_nsec = 0; @@ -239,6 +251,11 @@ static RD_INLINE void rd_timeout_init_timespec_us(struct timespec *tspec, */ static RD_INLINE void rd_timeout_init_timespec(struct timespec *tspec, int timeout_ms) { +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + __msan_unpoison(tspec, sizeof(*tspec)); +#endif +#endif if (timeout_ms == RD_POLL_INFINITE || timeout_ms == RD_POLL_NOWAIT) { tspec->tv_sec = timeout_ms; tspec->tv_nsec = 0;