25#ifndef MY_SYSTIME_INCLUDED
26#define MY_SYSTIME_INCLUDED
65 std::this_thread::sleep_for(std::chrono::microseconds{m_seconds});
76inline struct tm *localtime_r(
const time_t *timep,
struct tm *tmp) {
77 localtime_s(tmp, timep);
81inline struct tm *gmtime_r(
const time_t *clock,
struct tm *res) {
91inline void sleep(
unsigned long seconds) {
103#ifdef HAVE_CLOCK_GETTIME
106 clock_gettime(CLOCK_REALTIME, &tp);
107 return (
static_cast<unsigned long long int>(tp.tv_sec) * 10000000 +
108 static_cast<unsigned long long int>(tp.tv_nsec) / 100);
110 return std::chrono::duration_cast<
111 std::chrono::duration<std::int64_t, std::ratio<1, 10000000>>>(
112 UTC_clock::now().time_since_epoch())
122 std::numeric_limits<
decltype(timespec::tv_sec)>::max(), 999999999};
129 std::numeric_limits<Timeout_type>::max() - 1;
143 if (ts1->tv_sec > ts2->tv_sec ||
144 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec > ts2->tv_nsec))
146 if (ts1->tv_sec < ts2->tv_sec ||
147 (ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec < ts2->tv_nsec))
158 struct timespec *ts2) {
159 return (ts1->tv_sec - ts2->tv_sec) * 1000000000ULL + ts1->tv_nsec -
171[[deprecated]]
inline time_t
my_time(
int) {
return time(
nullptr); }
184 return std::chrono::duration_cast<std::chrono::microseconds>(
185 UTC_clock::now().time_since_epoch())
192 while (gettimeofday(&t,
nullptr) != 0) {
194 return (
static_cast<unsigned long long int>(t.tv_sec) * 1000000 + t.tv_usec);
209 return std::chrono::duration_cast<std::chrono::milliseconds>(
210 UTC_clock::now().time_since_epoch())
217 while (gettimeofday(&t,
nullptr) != 0) {
219 return (
static_cast<unsigned long long int>(t.tv_sec) * 1000 +
230 tm->
m_tv_sec =
static_cast<int64_t
>(micro_time / 1000000);
231 tm->
m_tv_usec =
static_cast<int64_t
>(micro_time % 1000000);
248 assert(
static_cast<std::int64_t
>(micro_time / 1000000) <=
249 std::numeric_limits<long>::max());
250 tm->tv_sec =
static_cast<long>(micro_time / 1000000);
251 tm->tv_usec =
static_cast<long>(micro_time % 1000000);
static struct my_cs_file_section_st sec[]
Definition: ctype.cc:162
static int flag
Definition: hp_test1.cc:40
constexpr const int GETDATE_T_DELIMITER
Definition: my_systime.h:56
void set_timespec_nsec(struct timespec *abstime, Timeout_type nsec)
Set the value of a timespec object to the current time plus a number of nanosconds.
Definition: my_systime.cc:58
time_t my_time(int)
Return current time.
Definition: my_systime.h:171
void get_date(char *to, int flag, time_t date)
Store textual representation of date in a character array.
Definition: my_systime.cc:109
int cmp_timespec(struct timespec *ts1, struct timespec *ts2)
Compare two timespec structs.
Definition: my_systime.h:142
constexpr const timespec TIMESPEC_POSINF
The maximum timespec value used to represent "inifinity" (as when requesting an "infinite" timeout.
Definition: my_systime.h:121
unsigned long long int my_getsystime()
Get high-resolution time.
Definition: my_systime.h:102
std::chrono::system_clock UTC_clock
Definition: my_systime.h:48
constexpr const int GETDATE_GMT
Definition: my_systime.h:54
void my_micro_time_to_timeval(std::uint64_t micro_time, my_timeval *tm)
Convert microseconds since epoch to my_timeval.
Definition: my_systime.h:229
constexpr const int GETDATE_SHORT_DATE_FULL_YEAR
Definition: my_systime.h:57
constexpr const int GETDATE_FIXEDLENGTH
Definition: my_systime.h:55
unsigned long long int my_milli_time()
Return time in milliseconds.
Definition: my_systime.h:207
unsigned long long int diff_timespec(struct timespec *ts1, struct timespec *ts2)
Calculate the diff between two timespec values.
Definition: my_systime.h:157
void my_sleep(time_t m_seconds)
Wait a given number of microseconds.
Definition: my_systime.h:64
constexpr const int GETDATE_DATE_TIME
Definition: my_systime.h:51
constexpr const int GETDATE_HHMMSSTIME
Definition: my_systime.h:53
unsigned long long int my_micro_time()
Return time in microseconds.
Definition: my_systime.h:182
void set_timespec(struct timespec *abstime, Timeout_type sec)
Set the value of a timespec object to the current time plus a number of seconds using seconds.
Definition: my_systime.cc:84
constexpr const int GETDATE_SHORT_DATE
Definition: my_systime.h:52
constexpr const Timeout_type TIMEOUT_INF
Value representing "infinite" timeout.
Definition: my_systime.h:128
std::uint64_t Timeout_type
Type alias to reduce chance of conversion errors on timeout values.
Definition: my_systime.h:125
static int count
Definition: myisam_ftdump.cc:43
Replacement of system's struct timeval to ensure we can carry 64 bit values even on a platform which ...
Definition: my_time_t.h:45
int64_t m_tv_sec
Definition: my_time_t.h:46
int64_t m_tv_usec
Definition: my_time_t.h:47
double seconds()
Definition: task.cc:310
Include file for Sun RPC to compile out of the box.