Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b8d8a45

Browse files
committed
windows: Set UMDF_USING_NTSTATUS globally, include ntstatus.h
We'd like to use precompiled headers on windows to reduce compile times. Right now we rely on defining UMDF_USING_NTSTATUS before including postgres.h in a few select places - which doesn't work with precompiled headers. Instead define it globally. When UMDF_USING_NTSTATUS is defined we need to explicitly include ntstatus.h, winternl.h to get a comparable set of symbols. Right now these includes would be required in a number of non-platform-specific .c files - to avoid that, include them in win32_port.h. Based on my measurements that doesn't increase compile times measurably. Reviewed-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/20220927011951.j3h4o7n6bhf7dwau@awork3.anarazel.de
1 parent a1b3bca commit b8d8a45

File tree

6 files changed

+9
-14
lines changed

6 files changed

+9
-14
lines changed

src/include/port/win32_port.h

+9
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@
4848
* significantly. WIN32_LEAN_AND_MEAN reduces that a bit. It'd be better to
4949
* remove the include of windows.h (as well as indirect inclusions of it) from
5050
* such a central place, but until then...
51+
*
52+
* To be able to include ntstatus.h tell windows.h to not declare NTSTATUS by
53+
* temporarily defining UMDF_USING_NTSTATUS, otherwise we'll get warning about
54+
* macro redefinitions, as windows.h also defines NTSTATUS (yuck). That in
55+
* turn requires including ntstatus.h, winternl.h to get common symbols.
5156
*/
5257
#define WIN32_LEAN_AND_MEAN
58+
#define UMDF_USING_NTSTATUS
5359

5460
#include <winsock2.h>
5561
#include <ws2tcpip.h>
5662
#include <windows.h>
63+
#include <ntstatus.h>
64+
#include <winternl.h>
65+
5766
#undef small
5867
#include <process.h>
5968
#include <signal.h>

src/include/port/win32ntdll.h

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
#ifndef WIN32NTDLL_H
1515
#define WIN32NTDLL_H
1616

17-
/*
18-
* Because this includes NT headers that normally conflict with Win32 headers,
19-
* any translation unit that includes it should #define UMDF_USING_NTSTATUS
20-
* before including <windows.h>.
21-
*/
22-
2317
#include <ntstatus.h>
2418
#include <winternl.h>
2519

src/port/open.c

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#ifdef WIN32
1515

16-
#define UMDF_USING_NTSTATUS
17-
1816
#ifndef FRONTEND
1917
#include "postgres.h"
2018
#else

src/port/win32fdatasync.c

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*-------------------------------------------------------------------------
1212
*/
1313

14-
#define UMDF_USING_NTSTATUS
15-
1614
#ifdef FRONTEND
1715
#include "postgres_fe.h"
1816
#else

src/port/win32ntdll.c

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*-------------------------------------------------------------------------
1414
*/
1515

16-
#define UMDF_USING_NTSTATUS
17-
1816
#include "c.h"
1917

2018
#include "port/win32ntdll.h"

src/port/win32stat.c

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
#ifdef WIN32
1717

18-
#define UMDF_USING_NTSTATUS
19-
2018
#include "c.h"
2119
#include "port/win32ntdll.h"
2220

0 commit comments

Comments
 (0)