diff options
| author | 2014-03-19 21:29:13 +0100 | |
|---|---|---|
| committer | 2014-03-24 17:01:30 +0100 | |
| commit | 427da9b898ad6d6d6b091b375f9fc38f155b4813 (patch) | |
| tree | 146baa967432cb9b215b6a2a2da87d9cf7b6d1bc /src/utils.c | |
| parent | f87407aacfd335398cc6897d3d65103f20ead20a (diff) | |
| download | usbmuxd-427da9b898ad6d6d6b091b375f9fc38f155b4813.tar.gz usbmuxd-427da9b898ad6d6d6b091b375f9fc38f155b4813.tar.bz2 | |
device/utils: move mstime64() into utils since it is generally useful
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index 9fa4d80..4218758 100644 --- a/src/utils.c +++ b/src/utils.c | |||
| @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| 29 | #include <string.h> | 29 | #include <string.h> |
| 30 | #include <stdio.h> | 30 | #include <stdio.h> |
| 31 | #include <stdarg.h> | 31 | #include <stdarg.h> |
| 32 | #include <sys/time.h> | ||
| 32 | 33 | ||
| 33 | #include "utils.h" | 34 | #include "utils.h" |
| 34 | 35 | ||
| @@ -272,3 +273,16 @@ int plist_write_to_filename(plist_t plist, const char *filename, enum plist_form | |||
| 272 | 273 | ||
| 273 | return 1; | 274 | return 1; |
| 274 | } | 275 | } |
| 276 | |||
| 277 | /** | ||
| 278 | * Get number of milliseconds since the epoch. | ||
| 279 | */ | ||
| 280 | uint64_t mstime64(void) | ||
| 281 | { | ||
| 282 | struct timeval tv; | ||
| 283 | gettimeofday(&tv, NULL); | ||
| 284 | |||
| 285 | // Careful, avoid overflow on 32 bit systems | ||
| 286 | // time_t could be 4 bytes | ||
| 287 | return ((long long)tv.tv_sec) * 1000LL + ((long long)tv.tv_usec) / 1000LL; | ||
| 288 | } | ||
