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

Commit09a7774

Browse files
committed
Clean up warnings in MinGW builds.
Experimentation with modern MinGW (specifically the 5.0.2 version packagedfor Fedora 26) shows that its version of sys/stat.h *does* provide S_IRGRPand friends, contrary to the expectation of win32_port.h. This results inan astonishing number of compiler warnings, and perhaps in incorrect code--- I'm not sure if the nonzero values supplied by MinGW's header actuallydo anything. Hence, adjust win32_port.h to only define these macros if<sys/stat.h> doesn't.This might be worth back-patching, but given the lack of complaints sofar, I'm not too excited about it.
1 parent687f096 commit09a7774

File tree

1 file changed

+47
-23
lines changed

1 file changed

+47
-23
lines changed

‎src/include/port/win32_port.h

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include<direct.h>
5353
#include<sys/utime.h>/* for non-unicode version */
5454
#undef near
55+
#include<sys/stat.h>/* needed before sys/stat hacking below */
5556

5657
/* Must be here to avoid conflicting with prototype in windows.h */
5758
#definemkdir(a,b)mkdir(a)
@@ -248,26 +249,67 @@ typedef int pid_t;
248249

249250
/*
250251
* Supplement to <sys/stat.h>.
252+
*
253+
* We must pull in sys/stat.h before this part, else our overrides lose.
251254
*/
252255
#definelstat(path,sb) stat(path, sb)
253256

254257
/*
255258
* stat() is not guaranteed to set the st_size field on win32, so we
256259
* redefine it to our own implementation that is.
257260
*
258-
* We must pull in sys/stat.h here so the system header definition
259-
* goes in first, and we redefine that, and not the other way around.
260-
*
261261
* Some frontends don't need the size from stat, so if UNSAFE_STAT_OK
262262
* is defined we don't bother with this.
263263
*/
264264
#ifndefUNSAFE_STAT_OK
265-
#include<sys/stat.h>
266265
externintpgwin32_safestat(constchar*path,structstat*buf);
267-
268266
#definestat(a,b) pgwin32_safestat(a,b)
269267
#endif
270268

269+
/* These macros are not provided by older MinGW, nor by MSVC */
270+
#ifndefS_IRUSR
271+
#defineS_IRUSR _S_IREAD
272+
#endif
273+
#ifndefS_IWUSR
274+
#defineS_IWUSR _S_IWRITE
275+
#endif
276+
#ifndefS_IXUSR
277+
#defineS_IXUSR _S_IEXEC
278+
#endif
279+
#ifndefS_IRWXU
280+
#defineS_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
281+
#endif
282+
#ifndefS_IRGRP
283+
#defineS_IRGRP 0
284+
#endif
285+
#ifndefS_IWGRP
286+
#defineS_IWGRP 0
287+
#endif
288+
#ifndefS_IXGRP
289+
#defineS_IXGRP 0
290+
#endif
291+
#ifndefS_IRWXG
292+
#defineS_IRWXG 0
293+
#endif
294+
#ifndefS_IROTH
295+
#defineS_IROTH 0
296+
#endif
297+
#ifndefS_IWOTH
298+
#defineS_IWOTH 0
299+
#endif
300+
#ifndefS_IXOTH
301+
#defineS_IXOTH 0
302+
#endif
303+
#ifndefS_IRWXO
304+
#defineS_IRWXO 0
305+
#endif
306+
#ifndefS_ISDIR
307+
#defineS_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
308+
#endif
309+
#ifndefS_ISREG
310+
#defineS_ISREG(m) (((m) & S_IFMT) == S_IFREG)
311+
#endif
312+
271313
/*
272314
* Supplement to <fcntl.h>.
273315
* This is the same value as _O_NOINHERIT in the MS header file. This is
@@ -456,14 +498,6 @@ typedef __int64 ssize_t;
456498

457499
typedefunsigned shortmode_t;
458500

459-
#defineS_IRUSR _S_IREAD
460-
#defineS_IWUSR _S_IWRITE
461-
#defineS_IXUSR _S_IEXEC
462-
#defineS_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
463-
/* see also S_IRGRP etc below */
464-
#defineS_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
465-
#defineS_ISREG(m) (((m) & S_IFMT) == S_IFREG)
466-
467501
#defineF_OK 0
468502
#defineW_OK 2
469503
#defineR_OK 4
@@ -478,14 +512,4 @@ typedef unsigned short mode_t;
478512

479513
#endif/* _MSC_VER */
480514

481-
/* These aren't provided by either MinGW or MSVC */
482-
#defineS_IRGRP 0
483-
#defineS_IWGRP 0
484-
#defineS_IXGRP 0
485-
#defineS_IRWXG 0
486-
#defineS_IROTH 0
487-
#defineS_IWOTH 0
488-
#defineS_IXOTH 0
489-
#defineS_IRWXO 0
490-
491515
#endif/* PG_WIN32_PORT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp