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

Commited9b360

Browse files
committed
Further refactoring of c.h and nearby files.
This continues the work of commit91aec93 by getting rid of a lot ofWindows-specific funny business in "section 0". Instead of includingpg_config_os.h in different places depending on platform, let'sstandardize on putting it before the system headers, and in consequencereduce win32.h to just what has to appear before the system headers orthe body of c.h (the latter category seems to include only PGDLLIMPORTand PGDLLEXPORT). The rest of what was in win32.h is moved to a newsub-include of port.h, win32_port.h. Some of what was in port.h seemsto better belong there too.It's possible that I missed some declaration ordering dependency thatneeds to be preserved, but hopefully the buildfarm will find thatout in short order.Unlike the previous commit, no back-patch, since this is just cleanupnot a prerequisite for a bug fix.Discussion:https://postgr.es/m/29650.1510761080@sss.pgh.pa.us
1 parent642bafa commited9b360

File tree

5 files changed

+512
-495
lines changed

5 files changed

+512
-495
lines changed

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99
*-------------------------------------------------------------------------
1010
*/
1111

12-
#ifdefWIN32
13-
/*
14-
* Need this to get defines for restricted tokens and jobs. And it
15-
* has to be set before any header from the Win32 API is loaded.
16-
*/
17-
#define_WIN32_WINNT 0x0501
18-
#endif
19-
2012
#include"postgres_fe.h"
2113

2214
#include<fcntl.h>

‎src/include/c.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,9 @@
5252

5353
#include"pg_config.h"
5454
#include"pg_config_manual.h"/* must be after pg_config.h */
55-
56-
/*
57-
* We always rely on the WIN32 macro being set by our build system,
58-
* but _WIN32 is the compiler pre-defined macro. So make sure we define
59-
* WIN32 whenever _WIN32 is set, to facilitate standalone building.
60-
*/
61-
#if defined(_WIN32)&& !defined(WIN32)
62-
#defineWIN32
63-
#endif
64-
65-
#if !defined(WIN32)&& !defined(__CYGWIN__)/* win32 includes further down */
6655
#include"pg_config_os.h"/* must be before any system header files */
67-
#endif
68-
69-
#if_MSC_VER >=1400|| defined(HAVE_CRTDEFS_H)
70-
#defineerrcode __msvc_errcode
71-
#include<crtdefs.h>
72-
#undef errcode
73-
#endif
74-
75-
/*
76-
* We have to include stdlib.h here because it defines many of these macros
77-
* on some platforms, and we only want our definitions used if stdlib.h doesn't
78-
* have its own. The same goes for stddef and stdarg if present.
79-
*/
8056

57+
/* System header files that should be available everywhere in Postgres */
8158
#include<stdio.h>
8259
#include<stdlib.h>
8360
#include<string.h>
@@ -99,11 +76,6 @@
9976
#include<libintl.h>
10077
#endif
10178

102-
#if defined(WIN32)|| defined(__CYGWIN__)
103-
/* We have to redefine some system functions after they are included above. */
104-
#include"pg_config_os.h"
105-
#endif
106-
10779

10880
/* ----------------------------------------------------------------
10981
*Section 1: compiler characteristics

‎src/include/port.h

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
#include<netdb.h>
1818
#include<pwd.h>
1919

20+
/*
21+
* Windows has enough specialized port stuff that we push most of it off
22+
* into another file.
23+
* Note: Some CYGWIN includes might #define WIN32.
24+
*/
25+
#if defined(WIN32)&& !defined(__CYGWIN__)
26+
#include"port/win32_port.h"
27+
#endif
28+
2029
/* socket has a different definition on WIN32 */
2130
#ifndefWIN32
2231
typedefintpgsocket;
@@ -101,11 +110,6 @@ extern int find_other_exec(const char *argv0, const char *target,
101110
/* Doesn't belong here, but this is used with find_other_exec(), so... */
102111
#definePG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
103112

104-
/* Windows security token manipulation (in exec.c) */
105-
#ifdefWIN32
106-
externBOOLAddUserToTokenDacl(HANDLEhToken);
107-
#endif
108-
109113

110114
#if defined(WIN32)|| defined(__CYGWIN__)
111115
#defineEXE ".exe"
@@ -185,36 +189,10 @@ extern intpg_printf(const char *fmt,...) pg_attribute_printf(1, 2);
185189
#endif
186190
#endif/* USE_REPL_SNPRINTF */
187191

188-
#if defined(WIN32)
189-
/*
190-
* Versions of libintl >= 0.18? try to replace setlocale() with a macro
191-
* to their own versions. Remove the macro, if it exists, because it
192-
* ends up calling the wrong version when the backend and libintl use
193-
* different versions of msvcrt.
194-
*/
195-
#if defined(setlocale)
196-
#undef setlocale
197-
#endif
198-
199-
/*
200-
* Define our own wrapper macro around setlocale() to work around bugs in
201-
* Windows' native setlocale() function.
202-
*/
203-
externchar*pgwin32_setlocale(intcategory,constchar*locale);
204-
205-
#definesetlocale(a,b) pgwin32_setlocale(a,b)
206-
#endif/* WIN32 */
207-
208192
/* Portable prompt handling */
209193
externvoidsimple_prompt(constchar*prompt,char*destination,size_tdestlen,
210194
boolecho);
211195

212-
#ifdefWIN32
213-
#definePG_SIGNAL_COUNT 32
214-
#definekill(pid,sig)pgkill(pid,sig)
215-
externintpgkill(intpid,intsig);
216-
#endif
217-
218196
externintpclose_check(FILE*stream);
219197

220198
/* Global variable holding time zone information. */
@@ -262,23 +240,6 @@ extern bool pgwin32_is_junction(const char *path);
262240

263241
externboolrmtree(constchar*path,boolrmtopdir);
264242

265-
/*
266-
* stat() is not guaranteed to set the st_size field on win32, so we
267-
* redefine it to our own implementation that is.
268-
*
269-
* We must pull in sys/stat.h here so the system header definition
270-
* goes in first, and we redefine that, and not the other way around.
271-
*
272-
* Some frontends don't need the size from stat, so if UNSAFE_STAT_OK
273-
* is defined we don't bother with this.
274-
*/
275-
#if defined(WIN32)&& !defined(__CYGWIN__)&& !defined(UNSAFE_STAT_OK)
276-
#include<sys/stat.h>
277-
externintpgwin32_safestat(constchar*path,structstat*buf);
278-
279-
#definestat(a,b) pgwin32_safestat(a,b)
280-
#endif
281-
282243
#if defined(WIN32)&& !defined(__CYGWIN__)
283244

284245
/*
@@ -353,7 +314,7 @@ extern intgettimeofday(struct timeval *tp, struct timezone *tzp);
353314
externchar*crypt(constchar*key,constchar*setting);
354315
#endif
355316

356-
/* WIN32 handled in port/win32.h */
317+
/* WIN32 handled in port/win32_port.h */
357318
#ifndefWIN32
358319
#definepgoff_t off_t
359320
#ifdef__NetBSD__

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp