New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mingw: adds (partial) implementations of pread/pwrite #6015
Conversation
This saves some lines of code and a few thousand syscalls per event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two comments below aside, it looks good to me.
overlapped.OffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ? | ||
(DWORD)0 : (DWORD)((offset >> 32) & 0xFFFFFFFFL); | ||
overlapped.Offset = (sizeof(off_t) <= sizeof(DWORD)) ? | ||
(DWORD)offset : (DWORD)(offset & 0xFFFFFFFFL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a macro to avoid repeating 0xFFFFFFFFL
multiple times?
#define DWORD_MASK 0xFFFFFFFFL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is entirely consistent with the conventions used throughout compat.c
. There are many things about that file that I would change if I was going to refactor it, but all that I'm doing here is adding these two wrapper functions.
{ | ||
c3_assert(0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's print strerror(errno)
here if pwrite()
fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR builds on #5889. It's a draft due to conflicts, and should wait to be reconciled with #6003.
The implementations are "partial" because
ReadFile()
andWriteFile()
update the file position after i/o completion -- these are not spec-conformant implementations, but are fit for our single-threaded use-cases (so long as calls to their non-positioned counterparts aren't intermingled on the same file description).