API: suffix the time unit to get_timestamp functions
Subsystems (2)
PATCH v2 1/1 API: suffix the time unit to get_timestamp functions
In order to make it clear what unit we're using - add the _ns suffix to timestamp getters for both the edge and info events.
Signed-off-by Bartosz Golaszewski <[email protected]>
--- include/gpiod.h | 4 ++-- lib/edge-event.c | 2 +- lib/info-event.c | 2 +- tests/tests-edge-event.c | 4 ++-- tests/tests-info-event.c | 6 +++--- tools/gpiomon.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
include/gpiod.h +2 -2
@@ -493,7 +493,7 @@ int gpiod_info_event_get_event_type(struct gpiod_info_event *event);* @param event Line status watch event. * @return Timestamp in nanoseconds, read from the monotonic clock. */ -uint64_t gpiod_info_event_get_timestamp (struct gpiod_info_event *event); +uint64_t gpiod_info_event_get_timestamp_ns (struct gpiod_info_event *event);/** * @brief Get the snapshot of line-info associated with the event.
@@ -1401,7 +1401,7 @@ int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event);* @note The source clock for the timestamp depends on the event_clock * setting for the line. */ -uint64_t gpiod_edge_event_get_timestamp (struct gpiod_edge_event *event); +uint64_t gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event);/** * @brief Get the offset of the line which triggered the event.
lib/edge-event.c +1 -1
@@ -55,7 +55,7 @@ GPIOD_API int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event) } GPIOD_API uint64_t -gpiod_edge_event_get_timestamp (struct gpiod_edge_event *event) +gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event) {return event->timestamp; }
lib/info-event.c +1 -1
@@ -67,7 +67,7 @@ GPIOD_API int gpiod_info_event_get_event_type(struct gpiod_info_event *event) } GPIOD_API uint64_t -gpiod_info_event_get_timestamp (struct gpiod_info_event *event) +gpiod_info_event_get_timestamp_ns (struct gpiod_info_event *event) {return event->timestamp; }
tests/tests-edge-event.c +2 -2
@@ -145,7 +145,7 @@ GPIOD_TEST_CASE(read_both_events)g_assert_cmpint (gpiod_edge_event_get_event_type (event), ==, GPIOD_EDGE_EVENT_RISING_EDGE); g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2); - ts_rising =gpiod_edge_event_get_timestamp (event); + ts_rising =gpiod_edge_event_get_timestamp_ns (event);/* Second event. */
@@ -165,7 +165,7 @@ GPIOD_TEST_CASE(read_both_events)g_assert_cmpint (gpiod_edge_event_get_event_type (event), ==, GPIOD_EDGE_EVENT_FALLING_EDGE); g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2); - ts_falling =gpiod_edge_event_get_timestamp (event); + ts_falling =gpiod_edge_event_get_timestamp_ns (event);g_thread_join (thread);
tests/tests-info-event.c +3 -3
@@ -184,9 +184,9 @@ GPIOD_TEST_CASE(request_reconfigure_release_events)g_thread_join (thread); - request_ts =gpiod_info_event_get_timestamp (request_event); - reconfigure_ts =gpiod_info_event_get_timestamp (reconfigure_event); - release_ts =gpiod_info_event_get_timestamp (release_event); + request_ts =gpiod_info_event_get_timestamp_ns (request_event); + reconfigure_ts =gpiod_info_event_get_timestamp_ns (reconfigure_event); + release_ts =gpiod_info_event_get_timestamp_ns (release_event); g_assert_cmpuint(request_ts, <, reconfigure_ts); g_assert_cmpuint(reconfigure_ts, <, release_ts);
tools/gpiomon.c +1 -1
@@ -299,7 +299,7 @@ int main(int argc, char **argv)handle_event (gpiod_edge_event_get_line_offset (event),gpiod_edge_event_get_event_type (event), -gpiod_edge_event_get_timestamp (event), +gpiod_edge_event_get_timestamp_ns (event), &ctx); events_done++;
Signature · 1 line
2.30.1
Quoted 3 lines · Bartosz Golaszewski
In order to make it clear what unit we're using - add the
_nssuffix to timestamp getters for both the edge and info events.
Makes sense.
A couple of minor tweaks below, but assuming those:
Signed-off-by Kent Gibson <[email protected]>
Quoted 37 lines
Signed-off-by Bartosz Golaszewski <[email protected]>--- include/gpiod.h | 4 ++-- lib/edge-event.c | 2 +- lib/info-event.c | 2 +- tests/tests-edge-event.c | 4 ++-- tests/tests-info-event.c | 6 +++--- tools/gpiomon.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)include/gpiod.h +2
-2@@ -493,7 +493,7 @@ int gpiod_info_event_get_event_type(struct gpiod_info_event *event);* @param event Line status watch event. * @return Timestamp in nanoseconds, read from the monotonic clock. */ -uint64_t gpiod_info_event_get_timestamp (struct gpiod_info_event *event); +uint64_t gpiod_info_event_get_timestamp_ns (struct gpiod_info_event *event);/** * @brief Get the snapshot of line-info associated with the event. @@ -1401,7 +1401,7 @@ int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event);* @note The source clock for the timestamp depends on the event_clock * setting for the line. */ -uint64_t gpiod_edge_event_get_timestamp (struct gpiod_edge_event *event); +uint64_t gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event);/** * @brief Get the offset of the line which triggered the event. lib/edge-event.c +0
-0
lib/edge-event.c GPIOD_API int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event) · line 61
Quoted 8 lines
lib/edge-event.c +1
-1@@ -55,7 +55,7 @@ GPIOD_API int gpiod_edge_event_get_event_type(struct gpiod_edge_event *event) } GPIOD_API uint64_t -gpiod_edge_event_get_timestamp (struct gpiod_edge_event *event) +gpiod_edge_event_get_timestamp_ns (struct gpiod_edge_event *event) {return event->timestamp; }
Shouldn't that field be timestamp_ns?
lib/info-event.c GPIOD_API int gpiod_info_event_get_event_type(struct gpiod_info_event *event) · line 73
Quoted 13 lines
lib/info-event.c +1
-1@@ -67,7 +67,7 @@ GPIOD_API int gpiod_info_event_get_event_type(struct gpiod_info_event *event) } GPIOD_API uint64_t -gpiod_info_event_get_timestamp (struct gpiod_info_event *event) +gpiod_info_event_get_timestamp_ns (struct gpiod_info_event *event) {return event->timestamp; }
Ditto.
Quoted 55 lines
tests/tests-edge-event.c +2
-2@@ -145,7 +145,7 @@ GPIOD_TEST_CASE(read_both_events)g_assert_cmpint (gpiod_edge_event_get_event_type (event), ==, GPIOD_EDGE_EVENT_RISING_EDGE); g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2); - ts_rising =gpiod_edge_event_get_timestamp (event); + ts_rising =gpiod_edge_event_get_timestamp_ns (event);/* Second event. */ @@ -165,7 +165,7 @@ GPIOD_TEST_CASE(read_both_events)g_assert_cmpint (gpiod_edge_event_get_event_type (event), ==, GPIOD_EDGE_EVENT_FALLING_EDGE); g_assert_cmpuint(gpiod_edge_event_get_line_offset(event), ==, 2); - ts_falling =gpiod_edge_event_get_timestamp (event); + ts_falling =gpiod_edge_event_get_timestamp_ns (event);g_thread_join (thread);tests/tests-info-event.c +3
-3@@ -184,9 +184,9 @@ GPIOD_TEST_CASE(request_reconfigure_release_events)g_thread_join (thread); - request_ts =gpiod_info_event_get_timestamp (request_event); - reconfigure_ts =gpiod_info_event_get_timestamp (reconfigure_event); - release_ts =gpiod_info_event_get_timestamp (release_event); + request_ts =gpiod_info_event_get_timestamp_ns (request_event); + reconfigure_ts =gpiod_info_event_get_timestamp_ns (reconfigure_event); + release_ts =gpiod_info_event_get_timestamp_ns (release_event); g_assert_cmpuint(request_ts, <, reconfigure_ts); g_assert_cmpuint(reconfigure_ts, <, release_ts);tools/gpiomon.c +1
-1@@ -299,7 +299,7 @@ int main(int argc, char **argv)handle_event (gpiod_edge_event_get_line_offset (event),gpiod_edge_event_get_event_type (event), -gpiod_edge_event_get_timestamp (event), +gpiod_edge_event_get_timestamp_ns (event), &ctx); events_done++;Signature · 1 line
2.30.1