diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-08-11 19:12:13 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-08-11 19:12:13 +0400 |
commit | 7a022d706155cb2ac00936d6829883b40af7f147 (patch) | |
tree | 2688e55bead181720dd75330769ea758c5909fb5 /sql/structs.h | |
parent | 73a5dd8c54a12fd5efaa90df6a99dad73aee1679 (diff) | |
download | mariadb-git-7a022d706155cb2ac00936d6829883b40af7f147.tar.gz |
A cleanup for MDEV-16939: avoid timeval initialization related problems in the future (compilation failures on Windows)
Adding a helper class Timeval, to initialize "struct timeval" in a safe way.
As a bonus, adding a method Timeval::trunc(), so the caller now can have
one line instead of five lines (declaration, initializations of sec and usec,
truncation, passing to store_TIMEVAL()).
Diffstat (limited to 'sql/structs.h')
-rw-r--r-- | sql/structs.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/structs.h b/sql/structs.h index 21b3904faa4..355d6e75e48 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -831,4 +831,20 @@ public: }; +class Timeval: public timeval +{ +public: + Timeval(my_time_t sec, ulong usec) + { + tv_sec= sec; + tv_usec= usec; + } + Timeval &trunc(uint dec) + { + my_timeval_trunc(this, dec); + return *this; + } +}; + + #endif /* STRUCTS_INCLUDED */ |