Hacker News new | ask | show | jobs
by manwe150 1632 days ago
Though it also requires a quick lock acquire to advance the pointer afterwards, so it does not come quite as cheaply as that makes it sound.
1 comments

... In which case, getchar_unlocked() from POSIX 1993 and later is your friend, when used together with flockfile() / funlockfile(). Or, well, as much of a friend as an explicit locking function can ever be. (Over in Windows land, MSVC used to have a non-threaded static C runtime as well, which doesn’t strike me as a stupid idea for this kind of simple program, but for some reason musl on Linux doesn’t do non-threaded builds.)