diff options
| -rw-r--r-- | src/device.c | 10 | ||||
| -rw-r--r-- | src/utils.c | 14 | ||||
| -rw-r--r-- | src/utils.h | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/src/device.c b/src/device.c index ef97f72..e36509e 100644 --- a/src/device.c +++ b/src/device.c | |||
| @@ -120,16 +120,6 @@ struct mux_device | |||
| 120 | static struct collection device_list; | 120 | static struct collection device_list; |
| 121 | pthread_mutex_t device_list_mutex; | 121 | pthread_mutex_t device_list_mutex; |
| 122 | 122 | ||
| 123 | static uint64_t mstime64(void) | ||
| 124 | { | ||
| 125 | struct timeval tv; | ||
| 126 | gettimeofday(&tv, NULL); | ||
| 127 | |||
| 128 | // Careful, avoid overflow on 32 bit systems | ||
| 129 | // time_t could be 4 bytes | ||
| 130 | return ((long long)tv.tv_sec) * 1000LL + ((long long)tv.tv_usec) / 1000LL; | ||
| 131 | } | ||
| 132 | |||
| 133 | static struct mux_device* get_mux_device_for_id(int device_id) | 123 | static struct mux_device* get_mux_device_for_id(int device_id) |
| 134 | { | 124 | { |
| 135 | struct mux_device *dev = NULL; | 125 | struct mux_device *dev = NULL; |
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 | } | ||
diff --git a/src/utils.h b/src/utils.h index 67477b5..92a7d68 100644 --- a/src/utils.h +++ b/src/utils.h | |||
| @@ -87,4 +87,6 @@ enum plist_format_t { | |||
| 87 | int plist_read_from_filename(plist_t *plist, const char *filename); | 87 | int plist_read_from_filename(plist_t *plist, const char *filename); |
| 88 | int plist_write_to_filename(plist_t plist, const char *filename, enum plist_format_t format); | 88 | int plist_write_to_filename(plist_t plist, const char *filename, enum plist_format_t format); |
| 89 | 89 | ||
| 90 | uint64_t mstime64(void); | ||
| 91 | |||
| 90 | #endif | 92 | #endif |
