mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-05 05:18:53 +08:00
9697f95b8f
This reverts commit 15d999759e
.
21 lines
436 B
C++
21 lines
436 B
C++
#include "stdafx.h"
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include "util.h"
|
|
|
|
double util::stamp_sub(const struct timeval *from, const struct timeval *sub_by)
|
|
{
|
|
struct timeval res;
|
|
|
|
memcpy(&res, from, sizeof(struct timeval));
|
|
|
|
res.tv_usec -= sub_by->tv_usec;
|
|
if (res.tv_usec < 0) {
|
|
--res.tv_sec;
|
|
res.tv_usec += 1000000;
|
|
}
|
|
res.tv_sec -= sub_by->tv_sec;
|
|
|
|
return (res.tv_sec * 1000.0 + res.tv_usec/1000.0);
|
|
}
|