mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-02-02 13:10:58 +00:00
test_psa_constant_names: fix uses of C integer types
Some of the types may in principle be wider than `unsigned`, so use `unsigned long` in printf. Add support for signed types: a status is a signed value, and preferentially printed in decimal.
This commit is contained in:
parent
3f775264d3
commit
c4cd2adae8
|
@ -211,6 +211,12 @@ def remove_file_if_exists(filename):
|
||||||
|
|
||||||
def run_c(options, type, names):
|
def run_c(options, type, names):
|
||||||
'''Generate and run a program to print out numerical values for names.'''
|
'''Generate and run a program to print out numerical values for names.'''
|
||||||
|
if type == 'status':
|
||||||
|
cast_to = 'long'
|
||||||
|
printf_format = '%ld'
|
||||||
|
else:
|
||||||
|
cast_to = 'unsigned long'
|
||||||
|
printf_format = '0x%08lx'
|
||||||
c_name = None
|
c_name = None
|
||||||
exe_name = None
|
exe_name = None
|
||||||
try:
|
try:
|
||||||
|
@ -230,7 +236,8 @@ int main(void)
|
||||||
{
|
{
|
||||||
''')
|
''')
|
||||||
for name in names:
|
for name in names:
|
||||||
c_file.write(' printf("0x%08x\\n", {});\n'.format(name))
|
c_file.write(' printf("{}\\n", ({}) {});\n'
|
||||||
|
.format(printf_format, cast_to, name))
|
||||||
c_file.write(''' return 0;
|
c_file.write(''' return 0;
|
||||||
}
|
}
|
||||||
''')
|
''')
|
||||||
|
|
Loading…
Reference in a new issue