diff options
author | Kay Sievers <kay@vrfy.org> | 2012-11-11 20:45:05 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-11-12 01:03:14 +0100 |
commit | 40fe8b11be9c1a1b38b91db097a5d6ebfa99304c (patch) | |
tree | 41183236fc9e51fe054afe378151c045893e75f8 /src/libudev | |
parent | 1707b36c6da447a42b0223840cf2eb84ca3f2f34 (diff) |
udev: use usec_t and now()
Diffstat (limited to 'src/libudev')
-rw-r--r-- | src/libudev/libudev-device-private.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-device.c | 14 | ||||
-rw-r--r-- | src/libudev/libudev-hwdb.c | 2 | ||||
-rw-r--r-- | src/libudev/libudev-private.h | 9 | ||||
-rw-r--r-- | src/libudev/libudev-util.c | 17 |
5 files changed, 13 insertions, 31 deletions
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c index 489bea8480..489afe2125 100644 --- a/src/libudev/libudev-device-private.c +++ b/src/libudev/libudev-device-private.c @@ -147,7 +147,7 @@ int udev_device_update_db(struct udev_device *udev_device) } if (udev_device_get_usec_initialized(udev_device) > 0) - fprintf(f, "I:%llu\n", udev_device_get_usec_initialized(udev_device)); + fprintf(f, "I:%llu\n", (unsigned long long)udev_device_get_usec_initialized(udev_device)); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) { if (!udev_list_entry_get_num(list_entry)) diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 08476e6596..181a9d8eeb 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -67,7 +67,7 @@ struct udev_device { struct udev_list sysattr_list; struct udev_list tags_list; unsigned long long int seqnum; - unsigned long long int usec_initialized; + usec_t usec_initialized; int devlink_priority; int refcount; dev_t devnum; @@ -246,7 +246,7 @@ static int udev_device_set_devtype(struct udev_device *udev_device, const char * return 0; } -static int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem) +int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem) { free(udev_device->subsystem); udev_device->subsystem = strdup(subsystem); @@ -1267,7 +1267,7 @@ _public_ const char *udev_device_get_action(struct udev_device *udev_device) **/ _public_ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device) { - unsigned long long now_ts; + usec_t now_ts; if (udev_device == NULL) return 0; @@ -1275,23 +1275,23 @@ _public_ unsigned long long int udev_device_get_usec_since_initialized(struct ud udev_device_read_db(udev_device, NULL); if (udev_device->usec_initialized == 0) return 0; - now_ts = now_usec(); + now_ts = now(CLOCK_MONOTONIC); if (now_ts == 0) return 0; return now_ts - udev_device->usec_initialized; } -unsigned long long udev_device_get_usec_initialized(struct udev_device *udev_device) +usec_t udev_device_get_usec_initialized(struct udev_device *udev_device) { return udev_device->usec_initialized; } -void udev_device_set_usec_initialized(struct udev_device *udev_device, unsigned long long usec_initialized) +void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized) { char num[32]; udev_device->usec_initialized = usec_initialized; - snprintf(num, sizeof(num), "%llu", usec_initialized); + snprintf(num, sizeof(num), "%llu", (unsigned long long)usec_initialized); udev_device_add_property(udev_device, "USEC_INITIALIZED", num); } diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 8fe24a4320..e72123a3af 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -356,7 +356,7 @@ bool udev_hwdb_validate(struct udev_hwdb *hwdb) { return false; if (fstat(fileno(hwdb->f), &st) < 0) return true; - if (ts_usec(&hwdb->st.st_mtim) != ts_usec(&st.st_mtim)) + if (timespec_load(&hwdb->st.st_mtim) != timespec_load(&st.st_mtim)) return true; return false; } diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h index d233565fb8..e3fc9a76f4 100644 --- a/src/libudev/libudev-private.h +++ b/src/libudev/libudev-private.h @@ -41,13 +41,14 @@ void udev_log(struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, ...) __attribute__((format(printf, 6, 7))); -int udev_get_rules_path(struct udev *udev, char **path[], unsigned long long *ts_usec[]); +int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]); struct udev_list_entry *udev_add_property(struct udev *udev, const char *key, const char *value); struct udev_list_entry *udev_get_properties_list_entry(struct udev *udev); /* libudev-device.c */ struct udev_device *udev_device_new(struct udev *udev); mode_t udev_device_get_devnode_mode(struct udev_device *udev_device); +int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem); int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath); int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode); int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink); @@ -65,8 +66,8 @@ const char *udev_device_get_id_filename(struct udev_device *udev_device); void udev_device_set_is_initialized(struct udev_device *udev_device); int udev_device_add_tag(struct udev_device *udev_device, const char *tag); void udev_device_cleanup_tags_list(struct udev_device *udev_device); -unsigned long long udev_device_get_usec_initialized(struct udev_device *udev_device); -void udev_device_set_usec_initialized(struct udev_device *udev_device, unsigned long long usec_initialized); +usec_t udev_device_get_usec_initialized(struct udev_device *udev_device); +void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized); int udev_device_get_devlink_priority(struct udev_device *udev_device); int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio); int udev_device_get_watch_handle(struct udev_device *udev_device); @@ -167,7 +168,5 @@ int util_delete_path(struct udev *udev, const char *path); uid_t util_lookup_user(struct udev *udev, const char *user); gid_t util_lookup_group(struct udev *udev, const char *group); int util_resolve_subsys_kernel(struct udev *udev, const char *string, char *result, size_t maxsize, int read_value); -unsigned long long ts_usec(const struct timespec *ts); -unsigned long long now_usec(void); ssize_t print_kmsg(const char *fmt, ...) __attribute__((format(printf, 1, 2))); #endif diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index b1c113046e..b609857eaf 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -691,23 +691,6 @@ uint64_t util_string_bloom64(const char *str) return bits; } -#define USEC_PER_SEC 1000000ULL -#define NSEC_PER_USEC 1000ULL -unsigned long long ts_usec(const struct timespec *ts) -{ - return (unsigned long long) ts->tv_sec * USEC_PER_SEC + - (unsigned long long) ts->tv_nsec / NSEC_PER_USEC; -} - -unsigned long long now_usec(void) -{ - struct timespec ts; - - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) - return 0; - return ts_usec(&ts); -} - ssize_t print_kmsg(const char *fmt, ...) { int fd; |