[rtems-central commit] interface: Support function attributes

Sebastian Huber sebh at rtems.org
Mon Oct 12 13:42:57 UTC 2020


Module:    rtems-central
Branch:    master
Commit:    e7fd4541df08c674157b842e46db4877e074716b
Changeset: http://git.rtems.org/rtems-central/commit/?id=e7fd4541df08c674157b842e46db4877e074716b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Oct 12 15:41:35 2020 +0200

interface: Support function attributes

---

 rtemsspec/interface.py                      | 6 ++++--
 rtemsspec/tests/spec-interface/func2.yml    | 2 +-
 rtemsspec/tests/test_interface.py           | 2 +-
 spec/rtems/fatal/if/error-occurred.yml      | 4 ++--
 spec/rtems/fatal/if/fatal.yml               | 4 ++--
 spec/rtems/fatal/if/panic.yml               | 6 +++---
 spec/rtems/init/if/initialize-executive.yml | 4 ++--
 spec/rtems/init/if/shutdown-executive.yml   | 4 ++--
 spec/rtems/task/if/exit.yml                 | 4 ++--
 9 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/rtemsspec/interface.py b/rtemsspec/interface.py
index fdbcfc9..5c12168 100644
--- a/rtemsspec/interface.py
+++ b/rtemsspec/interface.py
@@ -356,16 +356,18 @@ class Node:
     def _get_function_definition(self, item: Item, definition: Any) -> Lines:
         content = CContent()
         name = item["name"]
+        attrs = self.substitute_code(definition["attributes"])
+        attrs = f"{attrs} " if attrs else ""
         ret = self.substitute_code(definition["return"])
         params = [
             self.substitute_code(param) for param in definition["params"]
         ]
         body = definition["body"]
         if body:
-            with content.function("static inline " + ret, name, params):
+            with content.function(f"{attrs}static inline {ret}", name, params):
                 content.add(self.substitute_code(body))
         else:
-            content.declare_function(ret, name, params)
+            content.declare_function(f"{attrs}{ret}", name, params)
         return content.lines
 
     def _get_macro_definition(self, item: Item, definition: Any) -> Lines:
diff --git a/rtemsspec/tests/spec-interface/func2.yml b/rtemsspec/tests/spec-interface/func2.yml
index c3ee4f0..e66e7e9 100644
--- a/rtemsspec/tests/spec-interface/func2.yml
+++ b/rtemsspec/tests/spec-interface/func2.yml
@@ -4,7 +4,7 @@ copyrights:
 - Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
 definition:
   default:
-    attributes: null
+    attributes: __attribute__((__const__))
     body: |
       (void) ${.:/params[1]/name};
       (void) ${.:/params[2]/name};
diff --git a/rtemsspec/tests/test_interface.py b/rtemsspec/tests/test_interface.py
index 897430f..636aaf9 100644
--- a/rtemsspec/tests/test_interface.py
+++ b/rtemsspec/tests/test_interface.py
@@ -380,7 +380,7 @@ typedef uint32_t Integer /* Some comment. */;
  *
  * @return Sometimes some value.  See Function().
  */
-static inline int VeryLongFunction(
+__attribute__((__const__)) static inline int VeryLongFunction(
   int                  VeryLongParam0,
   const struct Struct *VeryLongParam1,
   struct Struct    *( *VeryLongParam2 )( void ),
diff --git a/spec/rtems/fatal/if/error-occurred.yml b/spec/rtems/fatal/if/error-occurred.yml
index 09c84c3..0bd33d1 100644
--- a/spec/rtems/fatal/if/error-occurred.yml
+++ b/spec/rtems/fatal/if/error-occurred.yml
@@ -5,11 +5,11 @@ copyrights:
 - Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
 definition:
   default:
-    attributes: null
+    attributes: ${../../basedefs/if/no-return:/name}
     body: null
     params:
     - ${/c/if/uint32_t:/name} ${.:/params[0]/name}
-    return: ${../../basedefs/if/no-return:/name} void
+    return: void
   variants: []
 description: null
 enabled-by: true
diff --git a/spec/rtems/fatal/if/fatal.yml b/spec/rtems/fatal/if/fatal.yml
index e00b9b5..e04bf62 100644
--- a/spec/rtems/fatal/if/fatal.yml
+++ b/spec/rtems/fatal/if/fatal.yml
@@ -5,13 +5,13 @@ copyrights:
 - Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
 definition:
   default:
-    attributes: null
+    attributes: ${../../basedefs/if/no-return:/name}
     body: |
       ${/score/interr/if/terminate:/name}( ${.:/params[0]/name}, ${.:/params[1]/name} );
     params:
     - ${../../userext/if/fatal-source:/name} ${.:/params[0]/name}
     - ${../../userext/if/fatal-code:/name} ${.:/params[1]/name}
-    return: ${../../basedefs/if/no-return:/name} void
+    return: void
   variants: []
 description: null
 enabled-by: true
diff --git a/spec/rtems/fatal/if/panic.yml b/spec/rtems/fatal/if/panic.yml
index 526f9a3..112399c 100644
--- a/spec/rtems/fatal/if/panic.yml
+++ b/spec/rtems/fatal/if/panic.yml
@@ -5,13 +5,13 @@ copyrights:
 - Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
 definition:
   default:
-    attributes: null
+    attributes: |
+      ${../../basedefs/if/no-return:/name} ${../../basedefs/if/printflike:/name}( 1, 2 )
     body: null
     params:
     - const char *${.:/params[0]/name}
     - '...'
-    return: |
-      ${../../basedefs/if/no-return:/name} ${../../basedefs/if/printflike:/name}( 1, 2 ) void
+    return: void
   variants: []
 description: null
 enabled-by: true
diff --git a/spec/rtems/init/if/initialize-executive.yml b/spec/rtems/init/if/initialize-executive.yml
index 231e0fb..3e0095b 100644
--- a/spec/rtems/init/if/initialize-executive.yml
+++ b/spec/rtems/init/if/initialize-executive.yml
@@ -5,10 +5,10 @@ copyrights:
 - Copyright (C) 2015, 2020 embedded brains GmbH (http://www.embedded-brains.de)
 definition:
   default:
-    attributes: null
+    attributes: ${../../basedefs/if/no-return:/name}
     body: null
     params: []
-    return: ${../../basedefs/if/no-return:/name} void
+    return: void
   variants: []
 description: |
   Iterates through the system initialization linker set and invokes the
diff --git a/spec/rtems/init/if/shutdown-executive.yml b/spec/rtems/init/if/shutdown-executive.yml
index c37aa44..7679b1a 100644
--- a/spec/rtems/init/if/shutdown-executive.yml
+++ b/spec/rtems/init/if/shutdown-executive.yml
@@ -6,11 +6,11 @@ copyrights:
 - Copyright (C) 1989, 2008 On-Line Applications Research Corporation (OAR)
 definition:
   default:
-    attributes: null
+    attributes: ${../../basedefs/if/no-return:/name}
     body: null
     params:
     - ${/c/if/uint32_t:/name} ${.:/params[0]/name}
-    return: ${../../basedefs/if/no-return:/name} void
+    return: void
   variants: []
 description: |
   The invocation of this directive results in the RTEMS environment being
diff --git a/spec/rtems/task/if/exit.yml b/spec/rtems/task/if/exit.yml
index d0ac87b..3c547e8 100644
--- a/spec/rtems/task/if/exit.yml
+++ b/spec/rtems/task/if/exit.yml
@@ -5,10 +5,10 @@ copyrights:
 - Copyright (C) 1988, 2017 On-Line Applications Research Corporation (OAR)
 definition:
   default:
-    attributes: null
+    attributes: ${../../basedefs/if/no-return:/name}
     body: null
     params: []
-    return: ${../../basedefs/if/no-return:/name} void
+    return: void
   variants: []
 description: null
 enabled-by: true



More information about the vc mailing list