Well hello there, I& #39;d like to share some code I wrote in, oh gosh, 2008. I don& #39;t actually have the code any more. But here& #39;s a picture I drew of the architecture
I did find somebody made a copy on github, and I think it& #39;s missing a bunch of stuff. but it has my favourite parts!
Here& #39;s my implementation of C89& #39;s malloc() — as you can see it returns NULL based on a probability:
Here& #39;s my implementation of C89& #39;s malloc() — as you can see it returns NULL based on a probability:
The probability there is seedable and deterministic, and doesn& #39;t affect rand(). Which means I had to keep my own prng internally, and provide rand() separately, too.
So here& #39;s my C99 rand()! It sometimes returns 7.
So here& #39;s my C99 rand()! It sometimes returns 7.
The C99 malloc is more complicated! Because there& #39;s an extra clause about IDB when you request an allocation of 0 bytes.
If you ever need a valid pointer value to return, but you& #39;d like to invoke UB whenever somebody dereferences it, you can do it like this, and return great_nothing + 1.
It looks like my gettimeofday() returns (again, seedable and deterministic) a random time, because I couldn& #39;t find a clause that required it to be monotonic.
If you ever have the pleasure of writing a specification, please imagine people like me are sitting on your shoulder
https://abs.twimg.com/emoji/v2/... draggable="false" alt="💕" title="Zwei Herzen" aria-label="Emoji: Zwei Herzen">
If you ever have the pleasure of writing a specification, please imagine people like me are sitting on your shoulder
Anyway this person& #39;s copy of my code taken at some arbitrary revision is here, if you& #39;d like to see! I quite understand if you& #39;d rather not. hehe
https://github.com/lispmeister/libgreat">https://github.com/lispmeist...
https://github.com/lispmeister/libgreat">https://github.com/lispmeist...
Oh what do you know, he& #39;s on twitter.
Hello @lispmeister!! Thirteen years ago you did something that& #39;s made my day a little nicer today. Thank you very much!
Hello @lispmeister!! Thirteen years ago you did something that& #39;s made my day a little nicer today. Thank you very much!
ps. This is how to comment code when you& #39;re writing to a spec.