-
Notifications
You must be signed in to change notification settings - Fork 475
Coalesce PSIO system call macros #2741
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
Conversation
| #include <cstdio> | ||
| #ifdef _MSC_VER | ||
| #include <io.h> | ||
| #define SYSTEM_LSEEK ::_lseek |
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.
Only possible trouble I see is here with _lseek vs _lseeki64. Docs say: _lseek returns the offset, in bytes, of the new position from the beginning of the file. _lseeki64 returns the offset in a 64-bit integer. Harmless?
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.
Eagle-eyed review! This is something I have not noticed until now.
volseek.cc used _lseeki64 on Windows, while toclen.cc used _lseek.
Re-drafting this until I have had time to ponder the docs and the impact on the code.
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.
In volseek.cc the return value is never stored, only compared with -1, so 32/64 bit should not matter.
In toclen.cc, the return value is stored in an auto variable, which is then only compared with -1.
So I think it is harmless.
loriab
left a comment
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.
nice cleanup, thank you!
Description
Definitions of various IO system call macros are currently replicated and/or scattered across files. These macros were added to paper over differences between Windows and Linux/Mac.
This PR coalesces all of them into
psio.h.User API & Changelog headlines
None
Dev notes & details
SYSTEM_WRITE,SYSTEM_READ,SYSTEM_LSEEK,SYSTEM_OPEN,SYSTEM_CLOSE,SYSTEM_UNLINK,PSIO_OPEN_OLD_FLAGS,PSIO_OPEN_NEW_FLAGSandPERMISSION_MODEare now only defined inpsio.h, which is already included by pretty much all PSIO-related files anyways.io.hinclude, and the non-Windowsunistd.h.Checklist
Status