1/*-------------------------------------------------------------------------
4 * Implementation of pread(2) for Windows.
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
9 * src/port/win32pread.c
11 *-------------------------------------------------------------------------
22 OVERLAPPED overlapped = {0};
26 handle = (HANDLE) _get_osfhandle(
fd);
27 if (handle == INVALID_HANDLE_VALUE)
33 /* Avoid overflowing DWORD. */
34 size =
Min(size, 1024 * 1024 * 1024);
36 /* Note that this changes the file position, despite not using it. */
37 overlapped.Offset = offset;
38 if (!ReadFile(handle,
buf, size, &result, &overlapped))
40 if (GetLastError() == ERROR_HANDLE_EOF)
static int fd(const char *x, int i)
void _dosmaperr(unsigned long)
ssize_t pg_pread(int fd, void *buf, size_t size, off_t offset)