mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Make stdin pollable on Windows
You can now play Super Mario Bros in CMD.EXE using Cosmopolitan! This is thanks to a new worker thread that's spawned on Windows whenever any one of poll(), select(), or ioctl(FIONREAD) is linked.
This commit is contained in:
parent
ef6387ee5e
commit
9c0821def7
15 changed files with 280 additions and 58 deletions
|
@ -28,12 +28,24 @@ struct Fd {
|
|||
int64_t extra;
|
||||
};
|
||||
|
||||
struct StdinRelay {
|
||||
_Atomic(uint32_t) once;
|
||||
int64_t inisem; /* semaphore to delay 1st read */
|
||||
int64_t handle; /* should == g_fds.p[0].handle */
|
||||
int64_t reader; /* ReadFile() use this instead */
|
||||
int64_t writer; /* only used by WinStdinThread */
|
||||
};
|
||||
|
||||
struct Fds {
|
||||
_Atomic(int) f; /* lowest free slot */
|
||||
size_t n;
|
||||
struct Fd *p, *e;
|
||||
struct StdinRelay stdin;
|
||||
};
|
||||
|
||||
int64_t __resolve_stdin_handle(int64_t);
|
||||
void WinMainStdin(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue