PostgreSQL Source Code git master
Loading...
Searching...
No Matches
win32pread.c File Reference
#include "c.h"
#include <windows.h>
Include dependency graph for win32pread.c:

Go to the source code of this file.

Functions

ssize_t pg_pread (int fd, void *buf, size_t size, pgoff_t offset)
 

Function Documentation

◆ pg_pread()

ssize_t pg_pread ( int  fd,
void buf,
size_t  size,
pgoff_t  offset 
)

Definition at line 20 of file win32pread.c.

21{
23 HANDLE handle;
24 DWORD result;
25
26 handle = (HANDLE) _get_osfhandle(fd);
27 if (handle == INVALID_HANDLE_VALUE)
28 {
29 errno = EBADF;
30 return -1;
31 }
32
33 /* Avoid overflowing DWORD. */
34 size = Min(size, 1024 * 1024 * 1024);
35
36 /* Note that this changes the file position, despite not using it. */
37 overlapped.Offset = (DWORD) offset;
38 overlapped.OffsetHigh = (DWORD) (offset >> 32);
39
40 if (!ReadFile(handle, buf, size, &result, &overlapped))
41 {
43 return 0;
44
46 return -1;
47 }
48
49 return result;
50}
#define Min(x, y)
Definition c.h:997
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fd(const char *x, int i)
static int fb(int x)
void _dosmaperr(unsigned long)
Definition win32error.c:177

References _dosmaperr(), buf, fb(), fd(), and Min.