smol-rs / polling

Portable interface to epoll, kqueue, event ports, and wepoll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for PS Vita

notgull opened this issue · comments

Related: tokio-rs/mio#1721

This will probably need to be tacked onto the poll() backend like ESP-IDF is.

Hi, I will be glad to help with this target, although this will require porting rustix first

rustix 0.38.20 now compiles under armv7-sony-vita-newlibeabihf.

@nikarh You said you wanted to help for this target; any updates on this?

@nikarh You said you wanted to help for this target; any updates on this?

Hi, sorry for the delay. I haven't started working on it yet.
I'm vacating till Christmas, but after that, I'll have some free time and do it.

Will attempt this one

The last time I checked almost everything worked, except for the waker.
There was a problem here https://github.com/smol-rs/polling/blob/1c16a1e4affaecc9e1f149c5d00133624b268405/src/poll.rs#L225C40-L225C56

As far as I remember, this code assumes that if it writes to the pipe, the message becomes immediately available on the other side of the pipe (pop_notification does a read syscall on a NONBLOCK pipe).

On Vita message written to pipe is not immediately available for read after calling write on the other side of the pipe.

This is because Vita doesn't have a syscall that could poll both network sockets and pipes, so pipes in the Vita newlib are implemented (or more like mocked) as a net socket on a loopback, because this implementation is much simpler than reimplementing poll as a custom busy loop with multiple syscalls for different fd types.

TBH I am not sure how to solve this - we can either make pipes and poll more sensible in Vita newlib (a lot of work), or make some specific code branch for vita in this crate, which may not be something worth the maintenance burden

@nikarh Thank you for pointing it out before I got started!
Which decision do we go with? keep me posted

On Vita message written to pipe is not immediately available for read after calling write on the other side of the pipe.

Could this be solved by blocking on the read instead of using NONBLOCK?

On Vita message written to pipe is not immediately available for read after calling write on the other side of the pipe.

Could this be solved by blocking on the read instead of using NONBLOCK?

Yes, I made a PR with just that. With this PR all tests actually pass on Vita (except for many_connections due to severely limited max fd count on the platform, but changing 100 to something like 60 makes it pass)

@mamaicode Sorry for stealing this from you 🙏 I had this code stashed locally on my machine and wasn't sure about making a PR since the solution is kinda ugly.