Attention is currently required from: Bora Guvendik, Selma Bensaid, Subrata Banik. Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/59555 )
Change subject: util/cbmem: Rebase to handle negative timestamps ......................................................................
Patch Set 2:
(1 comment)
File util/cbmem/cbmem.c:
https://review.coreboot.org/c/coreboot/+/59555/comment/9d2a1e34_d757636b PS2, Line 665: /* No, I don't think you should need all this. I think the easiest solution here is to add the "base timestamp" as just another timestamp to the existing array. When allocating sorted_tst_p, just malloc(size + sizeof(struct timestamp_entry)) so you have room for one more. Then set the extra entry to .entry_id = 0 and .entry_stamp = 0. The qsort() will then automatically sort it in at the right place between negative and positive values, and the printing code below will output it.
The only remaining thing you should need to do then is
if (sorted_tst_p->entries[0].entry_stamp < 0) sorted_tst_p->base_time = -sorted_tst_p->entries[0].entry_stamp; prev_stamp = sorted_tst_p->base_time;
This way, the "Make all timestamps absolute" step below should interpret each timestamp as relative to the first (negative) timestamp in the list (that first timestamp becomes the new 0). In essence, that first timestamp becomes your new base time, and the previous base_time becomes just another timestamp entry in the middle.