1# Upgrade single-threaded checkpoints to be properly supported with SMT.
2# SMT adds per-thread interrupts.  Thus we must move the interrupt status
3# from the CPU and into the execution context.
4def upgrader(cpt):
5    for sec in cpt.sections():
6        import re
7
8        re_cpu_match = re.match('^(.*sys.*\.cpu[^._]*)$', sec)
9        if re_cpu_match != None:
10            interrupts = cpt.get(sec, 'interrupts')
11            intStatus = cpt.get(sec, 'intStatus')
12
13            cpu_name = re_cpu_match.group(1)
14
15            cpt.set(cpu_name + ".xc.0", 'interrupts', interrupts)
16            cpt.set(cpu_name + ".xc.0", 'intStatus', intStatus)
17
18            cpt.remove_option(sec, 'interrupts')
19            cpt.remove_option(sec, 'intStatus')
20