add function get_current_time_us and get_current_time_ms
parent
46e191925e
commit
cb81992905
3
HISTORY
3
HISTORY
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
Version 1.23 2015-10-16
|
Version 1.23 2015-10-26
|
||||||
* sched_thread.c: task can execute in a new thread
|
* sched_thread.c: task can execute in a new thread
|
||||||
* sched_thread.c: support delay tasks
|
* sched_thread.c: support delay tasks
|
||||||
|
* add function get_current_time_us and get_current_time_ms
|
||||||
|
|
||||||
Version 1.22 2015-10-10
|
Version 1.22 2015-10-10
|
||||||
* export php function: fastcommon_get_first_local_ip
|
* export php function: fastcommon_get_first_local_ip
|
||||||
|
|
|
||||||
|
|
@ -2251,3 +2251,19 @@ bool is_private_ip(const char* ip)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t get_current_time_us()
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
|
||||||
|
if (gettimeofday(&tv, NULL) != 0)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
"call gettimeofday fail, " \
|
||||||
|
"errno=%d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno != 0 ? errno : EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((int64_t)tv.tv_sec * 1000 * 1000 + (int64_t)tv.tv_usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -520,6 +520,14 @@ double get_line_distance_km(const double lat1, const double lon1,
|
||||||
*/
|
*/
|
||||||
bool is_private_ip(const char* ip);
|
bool is_private_ip(const char* ip);
|
||||||
|
|
||||||
|
|
||||||
|
/** get current time in us
|
||||||
|
* return: current time
|
||||||
|
*/
|
||||||
|
int64_t get_current_time_us();
|
||||||
|
|
||||||
|
#define get_current_time_ms() (get_current_time_us() / 1000)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue