freq: 1000000000
offset:
seconds: 1434072888
- return-ctype: uint64_t
+ $return-ctype: uint64_t
env:
my_system_version: '0.3.2-2015.03'
bID: 15
| `error-cycles` | Integer (zero or positive) | Error (uncertainty) of clock in clock cycles | Optional | 0 |
| `offset` | [Clock offset object](#clock-offset-object) | Offset | Optional | Default clock offset object |
| `absolute` | Boolean | Absolute clock | Optional | `false` |
-| `return-ctype` | String | Return C type of the associated clock callback | Optional | `uint32_t` |
+| `$return-ctype` | String | Return C type of the associated clock callback | Optional | `uint32_t` |
-The `return-ctype` property must be set to a valid C integer type
+The `$return-ctype` property must be set to a valid C integer type
(or valid type definition). This is not currently validated by barectf
itself, but the C compiler will fail to compile the generated C code
if the clock's return type is not a valid C integer type.
seconds: 1434072888
cycles: 2003912
absolute: false
-return-ctype: unsigned long long
+$return-ctype: unsigned long long
```
def _create_clock(self, node):
# create clock object
clock = metadata.Clock()
-
- unk_prop = _get_first_unknown_prop(node, [
+ known_props = [
'uuid',
'description',
'freq',
'offset',
'absolute',
'return-ctype',
- ])
+ ]
+
+ if self._version >= 201:
+ known_props.append('$return-ctype')
+
+ unk_prop = _get_first_unknown_prop(node, known_props)
if unk_prop:
raise ConfigError('unknown clock object property: "{}"'.format(unk_prop))
clock.absolute = absolute
- # return C type
- if 'return-ctype' in node:
- ctype = node['return-ctype']
+ # return C type:
+ # v2.0: "return-ctype"
+ # v2.1+: "$return-ctype"
+ return_ctype_node = None
+
+ if self._version >= 200:
+ if 'return-ctype' in node:
+ return_ctype_prop = 'return-ctype'
+ return_ctype_node = node[return_ctype_prop]
+
+ if self._version >= 201:
+ if '$return-ctype' in node:
+ if return_ctype_node is not None:
+ raise ConfigError('cannot specify both "return-ctype" and "$return-ctype" properties of clock object: prefer "$return-ctype"')
+
+ return_ctype_prop = '$return-ctype'
+ return_ctype_node = node[return_ctype_prop]
- if not _is_str_prop(ctype):
- raise ConfigError('"return-ctype" property of clock object must be a string')
+ if return_ctype_node is not None:
+ if not _is_str_prop(return_ctype_node):
+ raise ConfigError('"{}" property of clock object must be a string'.format(return_ctype_prop))
- clock.return_ctype = ctype
+ clock.return_ctype = return_ctype_node
return clock