[rtems commit] score: Add RTEMS_RETURN_ADDRESS()

Sebastian Huber sebh at rtems.org
Thu Aug 29 14:02:35 UTC 2019


Module:    rtems
Branch:    master
Commit:    807ea677b298ed13796d27c493c726c0bfe6e036
Changeset: http://git.rtems.org/rtems/commit/?id=807ea677b298ed13796d27c493c726c0bfe6e036

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Aug 28 14:59:16 2019 +0200

score: Add RTEMS_RETURN_ADDRESS()

---

 cpukit/include/rtems/score/basedefs.h | 13 ++++++++++++-
 testsuites/sptests/spmisc01/init.c    |  7 ++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h
index 7a36c74..7829589 100644
--- a/cpukit/include/rtems/score/basedefs.h
+++ b/cpukit/include/rtems/score/basedefs.h
@@ -10,7 +10,7 @@
  *  COPYRIGHT (c) 1989-2007.
  *  On-Line Applications Research Corporation (OAR).
  *
- *  Copyright (c) 2010, 2018 embedded brains GmbH.
+ *  Copyright (C) 2010, 2019 embedded brains GmbH
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -371,6 +371,17 @@
   #define RTEMS_PREDICT_FALSE( _exp ) ( _exp )
 #endif
 
+/**
+ * @brief Returns the return address of the current function.
+ *
+ * @return The return address.
+ */
+#if defined(__GNUC__)
+  #define RTEMS_RETURN_ADDRESS() __builtin_return_address( 0 )
+#else
+  #define RTEMS_RETURN_ADDRESS() NULL
+#endif
+
 #if __cplusplus >= 201103L
   #define RTEMS_STATIC_ASSERT(cond, msg) \
     static_assert(cond, # msg)
diff --git a/testsuites/sptests/spmisc01/init.c b/testsuites/sptests/spmisc01/init.c
index d179e12..9090069 100644
--- a/testsuites/sptests/spmisc01/init.c
+++ b/testsuites/sptests/spmisc01/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ * Copyright (C) 2018, 2019 embedded brains GmbH
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -192,6 +192,8 @@ static int concat(void)
 
 static void Init(rtems_task_argument arg)
 {
+  void *p;
+
   TEST_BEGIN();
   rtems_test_assert(inline_func() == 7);
   RTEMS_COMPILER_MEMORY_BARRIER();
@@ -260,6 +262,9 @@ static void Init(rtems_task_argument arg)
     rtems_test_assert(true);
   }
 
+  p = RTEMS_RETURN_ADDRESS();
+  (void) p;
+
   TEST_END();
   rtems_test_exit(0);
 }




More information about the vc mailing list