diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-04-24 15:15:15 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2023-04-25 08:19:30 +0200 |
commit | 9eb5dd34018a42767942d8d525540b5c08d27e3a (patch) | |
tree | 7ab7c7c9ff9f61de25e0dd17e9c3137dde465aa2 | |
parent | spec: Add missing interface function link (diff) | |
download | rtems-central-9eb5dd34018a42767942d8d525540b5c08d27e3a.tar.bz2 |
spec: Avoid cyclic header file dependencies
There was a cyclic dependency: For RTEMS_STATIC_ANALYSIS we needed
basedefs.h in assert.h. For RTEMS_UNREACHABLE() we needed _Assert() from
assert.h in basedefs.h.
Fix this by introducing _Debug_Unreachable() in basedefs.h.
Add RTEMS_FUNCTION_NAME to basedefs.h and use it in basedefs.h and
assert.h.
Update #4900.
-rw-r--r-- | spec/compiler/if/file.yml | 14 | ||||
-rw-r--r-- | spec/compiler/if/func.yml | 14 | ||||
-rw-r--r-- | spec/compiler/if/line.yml | 14 | ||||
-rw-r--r-- | spec/compiler/if/pretty-function.yml | 14 | ||||
-rw-r--r-- | spec/rtems/basedefs/if/function-name.yml | 27 | ||||
-rw-r--r-- | spec/rtems/basedefs/if/unreachable.yml | 19 | ||||
-rw-r--r-- | spec/rtems/basedefs/req/function-name.yml | 16 | ||||
-rw-r--r-- | spec/rtems/basedefs/req/unreachable-gnuc.yml | 7 | ||||
-rw-r--r-- | spec/rtems/basedefs/val/basedefs-no-debug.yml | 18 | ||||
-rw-r--r-- | spec/score/basedefs/if/assert-unreachable.yml | 35 | ||||
-rw-r--r-- | spec/score/basedefs/if/debug-unreachable.yml | 41 | ||||
-rw-r--r-- | spec/score/basedefs/req/assert-unreachable.yml | 18 |
12 files changed, 166 insertions, 71 deletions
diff --git a/spec/compiler/if/file.yml b/spec/compiler/if/file.yml new file mode 100644 index 00000000..b3f6998a --- /dev/null +++ b/spec/compiler/if/file.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: domain +- role: interface-ingroup + uid: group +name: __FILE__ +references: [] +type: interface diff --git a/spec/compiler/if/func.yml b/spec/compiler/if/func.yml new file mode 100644 index 00000000..24735e20 --- /dev/null +++ b/spec/compiler/if/func.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: domain +- role: interface-ingroup + uid: group +name: __func__ +references: [] +type: interface diff --git a/spec/compiler/if/line.yml b/spec/compiler/if/line.yml new file mode 100644 index 00000000..ea2f5be9 --- /dev/null +++ b/spec/compiler/if/line.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: domain +- role: interface-ingroup + uid: group +name: __LINE__ +references: [] +type: interface diff --git a/spec/compiler/if/pretty-function.yml b/spec/compiler/if/pretty-function.yml new file mode 100644 index 00000000..81796b4c --- /dev/null +++ b/spec/compiler/if/pretty-function.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +index-entries: [] +interface-type: unspecified-define +links: +- role: interface-placement + uid: domain +- role: interface-ingroup + uid: group +name: __PRETTY_FUNCTION__ +references: [] +type: interface diff --git a/spec/rtems/basedefs/if/function-name.yml b/spec/rtems/basedefs/if/function-name.yml new file mode 100644 index 00000000..1f36d1ee --- /dev/null +++ b/spec/rtems/basedefs/if/function-name.yml @@ -0,0 +1,27 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +brief: | + Expands to the name of the function containing the use of this define. +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +definition: + default: + ${/compiler/if/func:/name} + variants: + - definition: | + ${/compiler/if/pretty-function:/name} + enabled-by: + and: + - defined(${/compiler/if/cplusplus:/name}) + - defined(${/compiler/if/gnuc:/name}) +description: null +enabled-by: true +index-entries: [] +interface-type: define +links: +- role: interface-placement + uid: header +- role: interface-ingroup + uid: group +name: RTEMS_FUNCTION_NAME +notes: null +type: interface diff --git a/spec/rtems/basedefs/if/unreachable.yml b/spec/rtems/basedefs/if/unreachable.yml index 10f15379..786842d9 100644 --- a/spec/rtems/basedefs/if/unreachable.yml +++ b/spec/rtems/basedefs/if/unreachable.yml @@ -2,26 +2,29 @@ SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause brief: | Tells the compiler that this program point is unreachable. copyrights: -- Copyright (C) 2016 embedded brains GmbH (http://www.embedded-brains.de) +- Copyright (C) 2016, 2023 embedded brains GmbH (http://www.embedded-brains.de) definition: default: attributes: null body: | - ${/score/basedefs/if/assert-unreachable:/name}() + do { } while ( 0 ) params: [] return: null variants: - definition: attributes: null body: | - do { - ${/compiler/if/builtin-unreachable:/name}(); - ${/score/basedefs/if/assert-unreachable:/name}(); - } while ( 0 ) + ${/score/basedefs/if/debug-unreachable:/name}( ${/compiler/if/file:/name}, ${/compiler/if/line:/name}, ${function-name:/name} ) params: [] return: null - enabled-by: - - defined(${/compiler/if/gnuc:/name}) + enabled-by: defined(${/build-options/if/debug:/name}) + - definition: + attributes: null + body: | + ${/compiler/if/builtin-unreachable:/name}() + params: [] + return: null + enabled-by: defined(${/compiler/if/gnuc:/name}) description: null enabled-by: true index-entries: [] diff --git a/spec/rtems/basedefs/req/function-name.yml b/spec/rtems/basedefs/req/function-name.yml new file mode 100644 index 00000000..6cd852dc --- /dev/null +++ b/spec/rtems/basedefs/req/function-name.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +enabled-by: true +links: +- role: interface-function + uid: ../if/function-name +functional-type: function +rationale: null +references: [] +requirement-type: functional +text: | + While the ${../if/function-name:/name} define is used inside a function body, + the ${../if/function-name:/name} define shall expand the name of the + function. +type: requirement diff --git a/spec/rtems/basedefs/req/unreachable-gnuc.yml b/spec/rtems/basedefs/req/unreachable-gnuc.yml index 5174793f..b4825fc9 100644 --- a/spec/rtems/basedefs/req/unreachable-gnuc.yml +++ b/spec/rtems/basedefs/req/unreachable-gnuc.yml @@ -1,7 +1,8 @@ SPDX-License-Identifier: CC-BY-SA-4.0 copyrights: - Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) -enabled-by: true +enabled-by: + not: RTEMS_DEBUG links: - role: requirement-refinement uid: unreachable-0 @@ -11,7 +12,5 @@ references: [] requirement-type: functional text: | Where ${/compiler/if/gnuc:/name} is defined, the ${../if/unreachable:/name} - macro shall expand to a statement which contains a call to - ${/compiler/if/builtin-unreachable:/name} followed by a call to - ${/score/basedefs/if/assert-unreachable:/name}. + macro shall expand to call to ${/compiler/if/builtin-unreachable:/name}. type: requirement diff --git a/spec/rtems/basedefs/val/basedefs-no-debug.yml b/spec/rtems/basedefs/val/basedefs-no-debug.yml index 630635ea..291011a2 100644 --- a/spec/rtems/basedefs/val/basedefs-no-debug.yml +++ b/spec/rtems/basedefs/val/basedefs-no-debug.yml @@ -18,7 +18,7 @@ test-actions: ${step}, IsEqualIgnoreWhiteSpace( s, - "do{__builtin_unreachable();do{}while(0);}while(0)" + "__builtin_unreachable()" ) ); links: @@ -26,19 +26,25 @@ test-actions: uid: ../req/unreachable-gnuc links: [] - action-brief: | - Expand and stringify ${/score/basedefs/if/assert-unreachable:/name}. + Expand ${../if/function-name:/name}. action-code: | const char *s; - s = RTEMS_XSTRING( _Assert_Unreachable() ); + s = RTEMS_FUNCTION_NAME; checks: - brief: | - Check that the string is equal to the expected statement. + Check that the string is equal to the expected function name. code: | - T_step_true( ${step}, IsEqualIgnoreWhiteSpace( s, "do{}while(0)" ) ); + T_step_true( + ${step}, + IsEqualIgnoreWhiteSpace( + s, + "RtemsBasedefsValBasedefsNoDebug_Action_1" + ) + ); links: - role: validation - uid: /score/basedefs/req/assert-unreachable + uid: ../req/function-name links: [] test-brief: | Tests the basedefs macros where RTEMS_DEBUG is disabled. diff --git a/spec/score/basedefs/if/assert-unreachable.yml b/spec/score/basedefs/if/assert-unreachable.yml deleted file mode 100644 index a6112fff..00000000 --- a/spec/score/basedefs/if/assert-unreachable.yml +++ /dev/null @@ -1,35 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause -brief: | - Asserts that this program point is unreachable. -copyrights: -- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) -definition: - default: - attributes: null - body: | - do { } while ( 0 ) - params: [] - return: null - variants: - - definition: - attributes: null - body: | - _Assert( 0 ) - params: [] - return: null - enabled-by: - - defined(${/build-options/if/debug:/name}) -description: null -enabled-by: true -index-entries: [] -interface-type: macro -links: -- role: interface-placement - uid: /rtems/basedefs/if/header -- role: interface-ingroup - uid: ../../if/group -name: _Assert_Unreachable -notes: null -params: [] -return: null -type: interface diff --git a/spec/score/basedefs/if/debug-unreachable.yml b/spec/score/basedefs/if/debug-unreachable.yml new file mode 100644 index 00000000..9a861e25 --- /dev/null +++ b/spec/score/basedefs/if/debug-unreachable.yml @@ -0,0 +1,41 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +brief: | + Terminates the program with a failed assertion. +copyrights: +- Copyright (C) 2023 embedded brains GmbH (http://www.embedded-brains.de) +definition: + default: + attributes: ${/rtems/basedefs/if/no-return:/name} + body: null + params: + - const char *${.:/params[0]/name} + - int ${.:/params[1]/name} + - const char *${.:/params[2]/name} + return: void + variants: [] +description: null +enabled-by: + and: + - not: ASM + - RTEMS_DEBUG +index-entries: [] +interface-type: function +links: +- role: interface-placement + uid: /rtems/basedefs/if/header +- role: interface-ingroup + uid: ../../if/group +name: _Debug_Unreachable +notes: null +params: +- description: is the file name. + dir: null + name: file +- description: is the line of the file. + dir: null + name: line +- description: is the function name. + dir: null + name: func +return: null +type: interface diff --git a/spec/score/basedefs/req/assert-unreachable.yml b/spec/score/basedefs/req/assert-unreachable.yml deleted file mode 100644 index b33c6375..00000000 --- a/spec/score/basedefs/req/assert-unreachable.yml +++ /dev/null @@ -1,18 +0,0 @@ -SPDX-License-Identifier: CC-BY-SA-4.0 -copyrights: -- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de) -enabled-by: - not: RTEMS_DEBUG -links: -- role: requirement-refinement - uid: ../../if/group -- role: interface-function - uid: ../if/assert-unreachable -functional-type: function -rationale: null -references: [] -requirement-type: functional -text: | - The ${../if/assert-unreachable:/name} macro shall expand to a statement which - performs no operation. -type: requirement |