66 * LICENSE file in the root directory of this source tree.
77 */
88
9+ // This file ensures that a pread-compatible function is defined in the global namespace for windows and posix environments.
10+
911#pragma once
1012
1113#ifndef _WIN32
1517#include < io.h>
1618
1719#include < windows.h>
20+ // To avoid conflicts with std::numeric_limits<int32_t>::max() in
21+ // file_data_loader.cpp.
22+ #undef max
1823
19- inline ssize_t pread (int __fd , void * __buf , size_t __nbytes , size_t __offset ) {
24+ inline ssize_t pread (int fd , void * buf , size_t nbytes , size_t offset ) {
2025 OVERLAPPED overlapped; /* The offset for ReadFile. */
2126 memset (&overlapped, 0 , sizeof (overlapped));
22- overlapped.Offset = __offset ;
23- overlapped.OffsetHigh = __offset >> 32 ;
27+ overlapped.Offset = offset ;
28+ overlapped.OffsetHigh = offset >> 32 ;
2429
2530 BOOL result; /* The result of ReadFile. */
2631 DWORD bytes_read; /* The number of bytes read. */
27- HANDLE file = (HANDLE)_get_osfhandle (__fd );
32+ HANDLE file = (HANDLE)_get_osfhandle (fd );
2833
29- result = ReadFile (file, __buf, __nbytes , &bytes_read, &overlapped);
34+ result = ReadFile (file, buf, nbytes , &bytes_read, &overlapped);
3035 DWORD error = GetLastError ();
3136 if (!result) {
3237 if (error == ERROR_IO_PENDING) {
@@ -51,7 +56,4 @@ inline ssize_t pread(int __fd, void* __buf, size_t __nbytes, size_t __offset) {
5156 return bytes_read;
5257}
5358
54- // To avoid conflicts with std::numeric_limits<int32_t>::max() in
55- // file_data_loader.cpp.
56- #undef max
5759#endif
0 commit comments