diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-10-12 15:41:35 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-10-12 15:41:57 +0200 |
commit | e7fd4541df08c674157b842e46db4877e074716b (patch) | |
tree | cc73bf9c02d190ec16935665855083ac8b5c0806 | |
parent | spec: Add function attributes (diff) | |
download | rtems-central-e7fd4541df08c674157b842e46db4877e074716b.tar.bz2 |
interface: Support function attributes
-rw-r--r-- | rtemsspec/interface.py | 6 | ||||
-rw-r--r-- | rtemsspec/tests/spec-interface/func2.yml | 2 | ||||
-rw-r--r-- | rtemsspec/tests/test_interface.py | 2 | ||||
-rw-r--r-- | spec/rtems/fatal/if/error-occurred.yml | 4 | ||||
-rw-r--r-- | spec/rtems/fatal/if/fatal.yml | 4 | ||||
-rw-r--r-- | spec/rtems/fatal/if/panic.yml | 6 | ||||
-rw-r--r-- | spec/rtems/init/if/initialize-executive.yml | 4 | ||||
-rw-r--r-- | spec/rtems/init/if/shutdown-executive.yml | 4 | ||||
-rw-r--r-- | 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 fdbcfc90..5c121680 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 c3ee4f0b..e66e7e9a 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 897430fa..636aaf98 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 09c84c34..0bd33d1a 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 e00b9b5a..e04bf62a 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 526f9a3a..112399c7 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 231e0fb7..3e0095b2 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 c37aa449..7679b1a2 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 d0ac87bd..3c547e8f 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 |