[rtems-central commit] spec: Update X/STRING and adding ALIGNOF specs

Sebastian Huber sebh at rtems.org
Tue Mar 9 15:37:45 UTC 2021


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

Author:    Frank Kühndel <frank.kuehndel at embedded-brains.de>
Date:      Tue Mar  9 11:28:01 2021 +0100

spec: Update X/STRING and adding ALIGNOF specs

This specification is up to date for
./cpukit/include/rtems/score/basedefs.h with
commit be60372136ac4f5acd8bc3286da6ed3fc50fa053

---

 spec/rtems/basedefs/if/string.yml     |  3 +-
 spec/rtems/basedefs/if/xstring.yml    |  3 +-
 spec/rtems/basedefs/req/alignof-0.yml | 26 ++++++++++++
 spec/rtems/basedefs/req/alignof-1.yml | 20 +++++++++
 spec/rtems/basedefs/req/alignof-2.yml | 21 ++++++++++
 spec/rtems/basedefs/req/alignof-3.yml | 15 +++++++
 spec/rtems/basedefs/req/xstring-0.yml |  2 +-
 spec/rtems/basedefs/val/basedefs.yml  | 78 ++++++++++++++++++++++++++++++-----
 8 files changed, 155 insertions(+), 13 deletions(-)

diff --git a/spec/rtems/basedefs/if/string.yml b/spec/rtems/basedefs/if/string.yml
index 925fb8b..24d2f6a 100644
--- a/spec/rtems/basedefs/if/string.yml
+++ b/spec/rtems/basedefs/if/string.yml
@@ -24,6 +24,7 @@ params:
   name: ...
 return:
   return: |
-    Returns the stringification of the arguments.
+    Returns the stringification of the arguments.  In case of several arguments
+    a single string is returned not several.
   return-values: []
 type: interface
diff --git a/spec/rtems/basedefs/if/xstring.yml b/spec/rtems/basedefs/if/xstring.yml
index 8dc7bcc..3fec2fc 100644
--- a/spec/rtems/basedefs/if/xstring.yml
+++ b/spec/rtems/basedefs/if/xstring.yml
@@ -24,6 +24,7 @@ params:
   name: ...
 return:
   return: |
-    Returns the stringification of the expansion of the arguments.
+    Returns the stringification of the expansion of the arguments.  In case of
+    several arguments a single string is returned not several.
   return-values: []
 type: interface
diff --git a/spec/rtems/basedefs/req/alignof-0.yml b/spec/rtems/basedefs/req/alignof-0.yml
new file mode 100644
index 0000000..fcce6ba
--- /dev/null
+++ b/spec/rtems/basedefs/req/alignof-0.yml
@@ -0,0 +1,26 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/alignof
+non-functional-type: interface
+rationale: |
+  Note that if not ``__STDC_VERSION__ >= 201112L`` and neither
+  ``__cplusplus >= 201103L``, the result of this call may return a value
+  which is not appropriate for alignment.
+references: []
+requirement-type: non-functional
+text: |
+  When the code is compiled with a C compiler and
+  the ``__STDC_VERSION__`` symbol is defined with version ``201112L`` or
+  higher or
+  the code is compiled with a C++ compiler
+  and the ``__cplusplus`` symbol is defined with version ``201103L`` or higher,
+  and the argument ${../if/alignof:/params[0]/name} is a type,
+  and the argument ${../if/alignof:/params[0]/name} is not a function type,
+  and the argument ${../if/alignof:/params[0]/name} is a complete type,
+  the macro ${../if/alignof:/name} shall result in
+  the alignment requirement in bytes required for any instance of the type.
+type: requirement
diff --git a/spec/rtems/basedefs/req/alignof-1.yml b/spec/rtems/basedefs/req/alignof-1.yml
new file mode 100644
index 0000000..9853768
--- /dev/null
+++ b/spec/rtems/basedefs/req/alignof-1.yml
@@ -0,0 +1,20 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/alignof
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  When the code is compiled with a C compiler and
+  the ``__STDC_VERSION__`` symbol is defined with version ``201112L`` or
+  higher or
+  the code is compiled with a C++ compiler
+  and the ``__cplusplus`` symbol is defined with version ``201103L`` or higher,
+  the macro ${../if/alignof:/name} shall not evaluate its
+  argument ${../if/alignof:/params[0]/name}.
+type: requirement
diff --git a/spec/rtems/basedefs/req/alignof-2.yml b/spec/rtems/basedefs/req/alignof-2.yml
new file mode 100644
index 0000000..2b66aeb
--- /dev/null
+++ b/spec/rtems/basedefs/req/alignof-2.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/alignof
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  When the code is compiled with a C compiler and
+  the ``__STDC_VERSION__`` symbol is defined with version ``201112L`` or
+  higher or
+  the code is compiled with a C++ compiler
+  and the ``__cplusplus`` symbol is defined with version ``201103L`` or higher,
+  when the argument ${../if/alignof:/params[0]/name} is an array type
+  with none constant size expression,
+  the macro ${../if/alignof:/name} shall not evaluate the size expression.
+type: requirement
diff --git a/spec/rtems/basedefs/req/alignof-3.yml b/spec/rtems/basedefs/req/alignof-3.yml
new file mode 100644
index 0000000..43db85e
--- /dev/null
+++ b/spec/rtems/basedefs/req/alignof-3.yml
@@ -0,0 +1,15 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/alignof
+non-functional-type: interface
+rationale: null
+references: []
+requirement-type: non-functional
+text: |
+  The macro ${../if/alignof:/name} shall result in
+  an constant integer of type size_t.
+type: requirement
diff --git a/spec/rtems/basedefs/req/xstring-0.yml b/spec/rtems/basedefs/req/xstring-0.yml
index 48e8659..0ffb141 100644
--- a/spec/rtems/basedefs/req/xstring-0.yml
+++ b/spec/rtems/basedefs/req/xstring-0.yml
@@ -13,7 +13,7 @@ references: []
 requirement-type: non-functional
 text: |
   The macro ${../if/xstring:/name} shall apply all possible C
-  pre-processor substitutions to its argument value before
+  pre-processor substitutions to its argument values before
   the result of this substitution is converted to a
   a string formed by the C pre-processor ``#`` operator and
   the macro results in this string.
diff --git a/spec/rtems/basedefs/val/basedefs.yml b/spec/rtems/basedefs/val/basedefs.yml
index 40f5f5c..d357081 100644
--- a/spec/rtems/basedefs/val/basedefs.yml
+++ b/spec/rtems/basedefs/val/basedefs.yml
@@ -125,6 +125,50 @@ test-actions:
       uid: ../req/aligned-0
   links: []
 - action-brief: |
+    Use the ${../if/alignof:/name} macro.
+  action-code: |
+    size_t alignof_char = RTEMS_ALIGNOF( char );
+    size_t alignof_long = RTEMS_ALIGNOF( long );
+    size_t alignof_long_array = RTEMS_ALIGNOF( long[3] );
+    size_t alignof_not_eval_array = RTEMS_ALIGNOF( long[7 / 0] );
+  checks:
+  - brief: |
+      Check that the ${../if/alignof:/name} macro results in the alignment
+      of the type.
+    code: |
+      T_step_eq_sz( ${step}, alignof_char, 1 );
+      T_step_eq_sz( ${step}, alignof_long, alignof_long_array );
+    links:
+    - role: validation
+      uid: ../req/alignof-0
+  - brief: |
+      If the ${../if/alignof:/name} macro would evaluate its argument,
+      it could not figure out how much menory to reserve for it.
+    code: |
+      T_step_eq_sz( ${step}, alignof_long, alignof_not_eval_array );
+    links:
+    - role: validation
+      uid: ../req/alignof-1
+  - brief: |
+      If the ${../if/alignof:/name} macro would evaluate the size expression,
+      the division by zero would cause an error.
+    code: |
+      T_step_eq_sz( ${step}, alignof_long, alignof_not_eval_array );
+    links:
+    - role: validation
+      uid: ../req/alignof-2
+  - brief: |
+      Ensure the constant value of the ${../if/alignof:/name} macro is
+      of type size_t.
+    code: |
+      T_step_true( ${step},
+        __builtin_types_compatible_p( __typeof__( RTEMS_ALIGNOF( char ) ),
+        size_t ) );
+    links:
+    - role: validation
+      uid: ../req/alignof-3
+  links: []
+- action-brief: |
     Use a function declared with the ${../if/alloc-align:/name} macro.
   action-code: |
     void *free_ptr;
@@ -907,17 +951,24 @@ test-actions:
   links: []
 - action-brief: |
     Use the ${../if/string:/name} macro.
-  action-code: "const char *string_var;\nconst char *string_empty_var;\n/* strange\
-    \ spacing and tabs belong to the test */\nstring_var = RTEMS_STRING( \\\\ STRING_PREFIX\
-    \ \t\tcat\"\"\\n   );\nstring_empty_var = RTEMS_STRING();\n"
+  action-code: |
+    const char *string_var;
+    const char *string_empty_var;
+    const char *string_multi_args_var;
+    /* strange spacing and tabs belong to the test */
+    string_var = RTEMS_STRING( \\ STRING_PREFIX 		cat""\n   );
+    string_empty_var = RTEMS_STRING();
+    string_multi_args_var = RTEMS_STRING( STRING_PREFIX, "abc", DEF );
   checks:
   - brief: |
       Check that the ${../if/string:/name} macro
-      converts its argument into a string without applying
-      pre-processor substitutions on its argument.
+      converts its arguments into a single string without applying
+      pre-processor substitutions on its arguments.
     code: |
       T_step_eq_str( ${step}, string_var, "\\ STRING_PREFIX cat\"\"\n" );
       T_step_eq_str( ${step}, string_empty_var, "" );
+      T_step_eq_str( ${step}, string_multi_args_var,
+        "STRING_PREFIX, \"abc\", DEF" );
     links:
     - role: validation
       uid: ../req/string-0
@@ -1278,17 +1329,24 @@ test-actions:
   links: []
 - action-brief: |
     Use the ${../if/xstring:/name} macro.
-  action-code: "const char *xstring_var;\nconst char *xstring_empty_var;\n/* strange\
-    \ spacing and tabs belong to the test */\nxstring_var = RTEMS_XSTRING( \\\\ STRING_PREFIX\
-    \ \t\tcat\"\"\\n   );\nxstring_empty_var = RTEMS_XSTRING();\n"
+  action-code: |
+    const char *xstring_var;
+    const char *xstring_empty_var;
+    const char *string_multi_args_var;
+    /* strange spacing and tabs belong to the test */
+    xstring_var = RTEMS_XSTRING( \\ STRING_PREFIX 		cat""\n   );
+    xstring_empty_var = RTEMS_XSTRING();
+    string_multi_args_var = RTEMS_XSTRING( STRING_PREFIX, abc, "abc", DEF );
   checks:
   - brief: |
       Check that the ${../if/xstring:/name} macro applies
-      pre-processor substitutions on its argument and
-      converts its argument into a string.
+      pre-processor substitutions on its arguments and
+      converts its arguments into a single string.
     code: |
       T_step_eq_str( ${step}, xstring_var, "\\ str cat\"\"\n" );
       T_step_eq_str( ${step}, xstring_empty_var, "" );
+      T_step_eq_str( ${step}, string_multi_args_var,
+        "str, ABC, \"abc\", DEF" );
     links:
     - role: validation
       uid: ../req/xstring-0



More information about the vc mailing list