Skip to content

Commit 407f9d9

Browse files
committed
STATIC_ASSERT to forbid device structs 4 GiB or larger
1 parent 3db85e8 commit 407f9d9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

py/dml/c_backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ def generate_hfile(device, headers, filename):
268268
reset_line_directive()
269269
out('\n')
270270

271+
out('#include <simics/util/help-macros.h>\n')
272+
out('#include <stdint.h>\n')
271273
out('#include "'+os.path.basename(structfilename)+'"\n\n')
272274

273275
for name in dml.globals.traits:
@@ -349,6 +351,10 @@ def generate_hfile(device, headers, filename):
349351

350352
print_device_substruct(device)
351353

354+
out('// allows generated code to store device struct offsets in uint32,\n')
355+
out('// which saves space\n')
356+
out(f'STATIC_ASSERT(sizeof(struct {crep.cname(device)}) <= UINT32_MAX);\n')
357+
352358
if dml.globals.log_groups:
353359
i = 1
354360
for g in dml.globals.log_groups:

0 commit comments

Comments
 (0)