PostgreSQL Source Code
git master
Loading...
Searching...
No Matches
win32pwrite.c
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* win32pwrite.c
4
* Implementation of pwrite(2) for Windows.
5
*
6
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7
*
8
* IDENTIFICATION
9
* src/port/win32pwrite.c
10
*
11
*-------------------------------------------------------------------------
12
*/
13
14
15
#include "
c.h
"
16
17
#include <windows.h>
18
19
ssize_t
20
pg_pwrite
(
int
fd
,
const
void
*
buf
,
size_t
size,
pgoff_t
offset)
21
{
22
OVERLAPPED
overlapped
= {0};
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
(!
WriteFile
(handle,
buf
, size, &result, &
overlapped
))
41
{
42
_dosmaperr
(
GetLastError
());
43
return
-1;
44
}
45
46
return
result;
47
}
c.h
Min
#define Min(x, y)
Definition
c.h:997
buf
static char buf[DEFAULT_XLOG_SEG_SIZE]
Definition
pg_test_fsync.c:71
pg_pwrite
#define pg_pwrite
Definition
port.h:248
pgoff_t
off_t pgoff_t
Definition
port.h:421
fd
static int fd(const char *x, int i)
Definition
preproc-init.c:105
fb
static int fb(int x)
Definition
preproc-init.c:92
_dosmaperr
void _dosmaperr(unsigned long)
Definition
win32error.c:177
src
port
win32pwrite.c
Generated on Tue Jan 27 2026 06:13:18 for PostgreSQL Source Code by
1.9.8