Simple POSIX I/O emulation layer to work around Windows's defective
Unix I/O: [_WIN32] (socklen_t, accept, posix_accept, bind. posix_bind, listen) (posix_listen, setsockopt, posix_setsockopt, shutdown, posix_shutdown) (socket, posix_socket, close, posix_close, creat, fstat, posix_fstat) (lseek, posix_lseek, open, posix_open, read, posix_read, write) (posix_write, fileno, posix_fileno, fcntl, O_NONBLOCK, F_RDLCK) (F_WRLCK, F_GETFL, F_SETFL, F_SETLK, EWOULDBLOCK, ENOTSOCK) (flock, fsync, posix_fsync): New. (ef_open, io_close, io_input, io_output, io_shutdown, io_noblocking) (player_accept): Use them to simplify. [_WIN32] (posix_fd2socket): New. (empth_select): Use it. (gen_power): Use it.
This commit is contained in:
parent
e7b04123a9
commit
4bbc3f4286
17 changed files with 669 additions and 109 deletions
|
@ -35,11 +35,8 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include "commands.h"
|
||||
#include "item.h"
|
||||
|
@ -317,14 +314,13 @@ gen_power(struct powstr *powbuf, int save)
|
|||
return;
|
||||
for (i = 0; i < MAXNOC; i++)
|
||||
putpower(i, &powbuf[i]);
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* At least some versions of Windows fail to update mtime on
|
||||
* write(). Bad, because `power' displays that time. Attempt to
|
||||
* force an update.
|
||||
* At least some versions of Windows fail to update st_mtime on
|
||||
* write(), the st_mtime is not until the file is written to the
|
||||
* disk. Bad, because `power' displays that time.
|
||||
* Force a sync to ensure the st_time is correct.
|
||||
*/
|
||||
_commit(empfile[EF_POWER].fd);
|
||||
#endif
|
||||
fsync(empfile[EF_POWER].fd);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue