What's the purpose of this code in the original decompressor? Assuming c is an uchar, aren't EOF and 0xFF equal? if (c == 0xFF) { len = getchar(); c = getchar(); while (len--) emit(c); }
Coroutines in C (2000)
11–20 of 61 posts
Re: Coroutines in C (2000)
#12What's the purpose of this code in the original decompressor? Assuming c is an uchar, aren't EOF and 0xFF equal? if (c == 0xFF) { len = getchar(); c = getchar(); while (len--) emit(c); }
Decompression, the first byte is the number of repeats and the second is the byte to repeat.
Re: Coroutines in C (2000)
#13Re: Coroutines in C (2000)
#14What's the purpose of this code in the original decompressor? Assuming c is an uchar, aren't EOF and 0xFF equal? if (c == 0xFF) { len = getchar(); c = getchar(); while (len--) emit(c); }
Re: Coroutines in C (2000)
#15What's the purpose of this code in the original decompressor? Assuming c is an uchar, aren't EOF and 0xFF equal? if (c == 0xFF) { len = getchar(); c = getchar(); while (len--) emit(c); }
The code snippet itself is run length encoding with 0xff as an escape.
Re: Coroutines in C (2000)
#16Re: Coroutines in C (2000)
#17Re: Coroutines in C (2000)
#18CoroutineTS uses coroutines that are implemented on the LLVM-IR level, as a result they get optimized away in many cases.
Unfortunately the CoroutineTS has also some design flaws around allocations and ownership
Re: Coroutines in C (2000)
#19That page uses very simple HTML. Just paragraphs of text divided into sections with headings. Some code examples laid out side-by-side with a table. Tiny stylesheet. No JS. Loads quickly, easy to read. Warms the cockles of my heart.
Re: Coroutines in C (2000)
#20A cool library that implements C coroutines, available for both idiomatic C ( http://libdill.org/ ) and in the same style as Go ( http://libmill.org/ ) with line by line translations
For those wondering how it works, libdill keeps track of context between function calls and does some clever stack modification in assembly.