From 567189cc7617a4d239d0f2ea052801fe2573d011 Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 17 Aug 2015 18:08:18 +0100 Subject: [PATCH] libdm: add per region precise timestamps property methods --- libdm/.exported_symbols.DM_1_02_106 | 2 ++ libdm/libdevmapper.h | 16 ++++++++++++++++ libdm/libdm-stats.c | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/libdm/.exported_symbols.DM_1_02_106 b/libdm/.exported_symbols.DM_1_02_106 index b664cc6d0..0bec54428 100644 --- a/libdm/.exported_symbols.DM_1_02_106 +++ b/libdm/.exported_symbols.DM_1_02_106 @@ -1,3 +1,5 @@ dm_message_supports_precise_timestamps dm_stats_create_region dm_stats_driver_supports_precise +dm_stats_get_current_region_precise_timestamps +dm_stats_get_region_precise_timestamps diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 71b8ce4c9..59eb5e98e 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -480,6 +480,22 @@ int dm_message_supports_precise_timestamps(void); */ int dm_stats_driver_supports_precise(void); +/* + * Returns 1 if the specified region has the precise_timestamps feature + * enabled (i.e. produces nanosecond-precision counter values) or 0 for + * a region using the default milisecond precision. + */ +int dm_stats_get_region_precise_timestamps(const struct dm_stats *dms, + uint64_t region_id); + +/* + * Returns 1 if the region at the current cursor location has the + * precise_timestamps feature enabled (i.e. produces + * nanosecond-precision counter values) or 0 for a region using the + * default milisecond precision. + */ +int dm_stats_get_current_region_precise_timestamps(const struct dm_stats *dms); + #define DM_STATS_ALL_PROGRAMS "" /* * Parse the response from a @stats_list message. dm_stats_list will diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c index b85300ff6..800bde6f9 100644 --- a/libdm/libdm-stats.c +++ b/libdm/libdm-stats.c @@ -1489,3 +1489,15 @@ const char *dm_stats_get_current_region_aux_data(const struct dm_stats *dms) { return dm_stats_get_region_aux_data(dms, dms->cur_region); } + +int dm_stats_get_region_precise_timestamps(const struct dm_stats *dms, + uint64_t region_id) +{ + struct dm_stats_region *region = &dms->regions[region_id]; + return region->timescale == 1; +} + +int dm_stats_get_current_region_precise_timestamps(const struct dm_stats *dms) +{ + return dm_stats_get_region_precise_timestamps(dms, dms->cur_region); +} -- 2.43.5