Skip to content

Proof of concept: Variable args count #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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