Skip to content
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

Merged
merged 2 commits into from Nov 7, 2022
Merged

Conversation

joemfb
Copy link
Member

@joemfb joemfb commented Sep 28, 2022

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() and WriteFile() 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).

Copy link

@mcevoypeter mcevoypeter left a 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.

Comment on lines +153 to +156
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);

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

Copy link
Member Author

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.

Comment on lines 479 to 481
{
c3_assert(0);
}

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't touch the changes from #5889. More will be needed, but I'm going to wait for #6003 (which why this PR is a draft).

@joemfb joemfb merged commit 0554b9a into next/vere Nov 7, 2022
@joemfb joemfb deleted the jb/pread branch November 7, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants