From 74a3c378b2e41a3a3c492ca1b18485c63de43320 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beat=20K=C3=BCng?= <beat-kueng@gmx.net>
Date: Wed, 23 Jan 2019 15:16:18 +0100
Subject: [PATCH] drv_hrt: inline hrt_elapsed_time

GCC did not do that.
---
 platforms/posix/src/px4_layer/drv_hrt.cpp | 13 -------------
 src/drivers/drv_hrt.h                     |  5 ++++-
 src/drivers/kinetis/drv_hrt.c             | 11 -----------
 src/drivers/samv7/drv_hrt.c               | 11 -----------
 src/drivers/stm32/drv_hrt.c               | 11 -----------
 5 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/platforms/posix/src/px4_layer/drv_hrt.cpp b/platforms/posix/src/px4_layer/drv_hrt.cpp
index 874ce5db3a..b075e0b30a 100644
--- a/platforms/posix/src/px4_layer/drv_hrt.cpp
+++ b/platforms/posix/src/px4_layer/drv_hrt.cpp
@@ -198,19 +198,6 @@ hrt_abstime ts_to_abstime(const struct timespec *ts)
 	return result;
 }
 
-/*
- * Compute the delta between a timestamp taken in the past
- * and now.
- *
- * This function is safe to use even if the timestamp is updated
- * by an interrupt during execution.
- */
-hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
-{
-	hrt_abstime delta = hrt_absolute_time() - *then;
-	return delta;
-}
-
 /*
  * Compute the delta between a timestamp taken in the past
  * and now.
diff --git a/src/drivers/drv_hrt.h b/src/drivers/drv_hrt.h
index 4f4787ab16..6f8cbcb4e0 100644
--- a/src/drivers/drv_hrt.h
+++ b/src/drivers/drv_hrt.h
@@ -98,7 +98,10 @@ __EXPORT extern void	abstime_to_ts(struct timespec *ts, hrt_abstime abstime);
  *
  * This function is not interrupt save.
  */
-__EXPORT extern hrt_abstime hrt_elapsed_time(const hrt_abstime *then);
+static inline hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
+{
+	return hrt_absolute_time() - *then;
+}
 
 /**
  * Compute the delta between a timestamp taken in the past
diff --git a/src/drivers/kinetis/drv_hrt.c b/src/drivers/kinetis/drv_hrt.c
index 9a221223bc..c39b4989e3 100644
--- a/src/drivers/kinetis/drv_hrt.c
+++ b/src/drivers/kinetis/drv_hrt.c
@@ -594,17 +594,6 @@ abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
 	ts->tv_nsec = abstime * 1000;
 }
 
-/**
- * Compare a time value with the current time.
- */
-hrt_abstime
-hrt_elapsed_time(const hrt_abstime *then)
-{
-	hrt_abstime delta = hrt_absolute_time() - *then;
-
-	return delta;
-}
-
 /**
  * Compare a time value with the current time as atomic operation.
  */
diff --git a/src/drivers/samv7/drv_hrt.c b/src/drivers/samv7/drv_hrt.c
index 7be4bbb487..e1cbac4f30 100644
--- a/src/drivers/samv7/drv_hrt.c
+++ b/src/drivers/samv7/drv_hrt.c
@@ -675,17 +675,6 @@ abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
 	ts->tv_nsec = abstime * 1000;
 }
 
-/**
- * Compare a time value with the current time.
- */
-hrt_abstime
-hrt_elapsed_time(const hrt_abstime *then)
-{
-	hrt_abstime delta = hrt_absolute_time() - *then;
-
-	return delta;
-}
-
 /**
  * Compare a time value with the current time as atomic operation.
  */
diff --git a/src/drivers/stm32/drv_hrt.c b/src/drivers/stm32/drv_hrt.c
index c247cb2209..fdae0eb07d 100644
--- a/src/drivers/stm32/drv_hrt.c
+++ b/src/drivers/stm32/drv_hrt.c
@@ -715,17 +715,6 @@ abstime_to_ts(struct timespec *ts, hrt_abstime abstime)
 	ts->tv_nsec = abstime * 1000;
 }
 
-/**
- * Compare a time value with the current time.
- */
-hrt_abstime
-hrt_elapsed_time(const hrt_abstime *then)
-{
-	hrt_abstime delta = hrt_absolute_time() - *then;
-
-	return delta;
-}
-
 /**
  * Compare a time value with the current time as atomic operation
  */
-- 
GitLab