59
flags If MY_WME is set, write error if time call fails
63
time_t my_time(myf flags)
68
(void) my_micro_time_and_time(&t);
71
/* The following loop is here beacuse time() may fail on some systems */
72
while ((t= time(0)) == (time_t) -1)
75
fprintf(stderr, "%s: Warning: time() call failed\n", my_progname);
83
57
Return time in micro seconds
144
118
uint64_t my_micro_time_and_time(time_t *time_arg)
146
#if defined(HAVE_GETHRTIME)
148
Solaris has a very slow time() call. We optimize this by using the very
149
fast gethrtime() call and only calling time() every 1/2 second
152
#define DELTA_FOR_SECONDS 500000000LL /* Half a second */
154
static hrtime_t prev_gethrtime= 0;
155
static time_t cur_time= 0;
156
hrtime_t cur_gethrtime;
158
pthread_mutex_lock(&THR_LOCK_time);
159
cur_gethrtime= gethrtime();
160
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
163
prev_gethrtime= cur_gethrtime;
166
pthread_mutex_unlock(&THR_LOCK_time);
167
return cur_gethrtime/1000;
169
120
uint64_t newtime;
170
121
struct timeval t;
172
123
The following loop is here because gettimeofday may fail on some systems
174
while (gettimeofday(&t, NULL) != 0)
125
while (gettimeofday(&t, NULL) != 0) {}
176
126
*time_arg= t.tv_sec;
177
127
newtime= (uint64_t)t.tv_sec * 1000000 + t.tv_usec;
179
#endif /* defined(HAVE_GETHRTIME) */
187
my_time_possible_from_micro()
188
microtime Value from very recent my_micro_time()
191
This function returns the current time. The microtime argument is only used
192
if my_micro_time() uses a function that can safely be converted to the
199
time_t my_time_possible_from_micro(uint64_t microtime)
201
#if defined(HAVE_GETHRTIME)
203
return my_time(0); /* Cached time */
205
return (time_t) (microtime / 1000000);
206
#endif /* defined(HAVE_GETHRTIME) */
132
} /* namespace drizzled */