Skip to content

Proof of concept: Variable args count#96

Draft
Icedude907 wants to merge 1 commit intoundoio:mainfrom
Icedude907:main
Draft

Proof of concept: Variable args count#96
Icedude907 wants to merge 1 commit intoundoio:mainfrom
Icedude907:main

Conversation

@Icedude907
Copy link

Hi there!
I commented on Greg's video the other day about the possibility of extending this to support a variable number of format arguments - got me thinking so I've given it a go.

Expect this code to be slower than your version due to the runtime varargs, but hopefully not by much.

Below is all you need to know about this branch:

  • The assembly version is disabled since I don't have the skills to port my C over.
  • The macros support 0 to 9 args, but this can be extended.
  • I've only updated the sample-c-appln code.
  • Format arguments are stored in the ring buffer directly preceeding the entry metadata. The metadata is now 24 bytes and includes the argument count. The arguments list is padded to multiples of 24 to reduce the complexity of wrapping around the ring-buffer when we approach being full. (This limitation could be removed at the cost of more overflow checks.)
  • The dump script starts decoding from the final entry and works backwards. This is because each entry is a variable length, and so the only entry who's position we truly know is the most recent one (discovered by reading the header's idx % L3_MAX_SLOTS). This is also why the metadata is written last.

I don't plan to update this more, but I hope you found this interesting and potentially useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant