Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaf109e3

Browse files
committed
Provide 64-bit ftruncate() and lseek() on Windows.
Change our ftruncate() macro to use the 64-bit variant of chsize(), andadd a new macro to redirect lseek() to _lseeki64().Back-patch to all supported releases, in preparation for a bug fix.Tested-by: Davinder Singh <davinder.singh@enterprisedb.com>Discussion:https://postgr.es/m/CAKZiRmyM4YnokK6Oenw5JKwAQ3rhP0YTz2T-tiw5dAQjGRXE3Q%40mail.gmail.com
1 parent45aef9f commitaf109e3

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

‎src/include/port.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,33 @@ extern bool rmtree(const char *path, bool rmtopdir);
306306

307307
#if defined(WIN32)&& !defined(__CYGWIN__)
308308

309+
/*
310+
* We want the 64-bit variant of lseek().
311+
*
312+
* For Visual Studio, this must be after <io.h> to avoid messing up its
313+
* lseek() and _lseeki64() function declarations.
314+
*
315+
* For MinGW there is already a macro, so we have to undefine it (depending on
316+
* _FILE_OFFSET_BITS, it may point at its own lseek64, but we don't want to
317+
* count on that being set).
318+
*/
319+
#undef lseek
320+
#definelseek(a,b,c) _lseeki64((a),(b),(c))
321+
322+
/*
323+
* We want the 64-bit variant of chsize(). It sets errno and also returns it,
324+
* so convert non-zero result to -1 to match POSIX.
325+
*
326+
* Prevent MinGW from declaring functions, and undefine its macro before we
327+
* define our own.
328+
*/
329+
#ifndef_MSC_VER
330+
#defineFTRUNCATE_DEFINED
331+
#include<unistd.h>
332+
#undef ftruncate
333+
#endif
334+
#defineftruncate(a,b) (_chsize_s((a),(b)) == 0 ? 0 : -1)
335+
309336
/*
310337
* open() and fopen() replacements to allow deletion of open files and
311338
* passing of other special options.

‎src/include/port/win32_port.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@
7979
/* Must be here to avoid conflicting with prototype in windows.h */
8080
#definemkdir(a,b)mkdir(a)
8181

82-
#defineftruncate(a,b)chsize(a,b)
83-
8482
/* Windows doesn't have fsync() as such, use _commit() */
8583
#definefsync(fd) _commit(fd)
8684

‎src/pl/plperl/plperl_system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
#undef fstat
110110
#undef kill
111111
#undef listen
112+
#undef lseek
112113
#undef lstat
113114
#undef mkdir
114115
#undef open

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp