jart / blink

tiniest x86-64-linux emulator
ISC License
6.96k stars 222 forks source link

timerfd_create not implemented #155

Open bradrn opened 1 year ago

bradrn commented 1 year ago

Out of curiosity I tried to run a Haskell program of mine on blink, and got the following error:

brassica: internal error: timerfd_create: Function not implemented
    (GHC version 9.2.7 for x86_64_unknown_linux)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug
Aborted (core dumped)

(brassica being the name of my program.)

The error description seems pretty descriptive to me: Blink does not yet implement timerfd_create. Is there any chance of getting it?

jart commented 1 year ago

I've thought about this interface a few times in the past. Something like this would most likely be tricky to polyfill on platforms where the kernel doesn't support it natively. It'd likely entail spawning a thread and creating some pipes to deliver timer notifications. Our team currently doesn't have any need for it, since most of the software we've built is able to work around it not being available. I'd be open to merging a contribution that implements this. But only if the timer fd implementation is relatively well contained, i.e. it only gets linked into your binary if you actually use it.

bradrn commented 1 year ago

Thanks for explaining! Alas, my knowledge of syscalls is depressingly miniscule, so I probably won’t be able to implement this myself. (Indeed, I’m interested in Blinkenlights mostly as a tool for learning this stuff.)

jart commented 1 year ago

Actually I want to take some of this back. I confused this with the Cosmopolitan Libc repository. Timer Fd is something that Blink SHOULD do. However I don't have immediate plans to develop it at the moment. Contributions are still very much welcome! Thank you again for reaching out! I'll update this issue when things change.