Skip to content

Commit 89945aa

Browse files
mstorsjotkrasnukha
authored andcommitted
Consistently include "Platform.h" instead of including <windows.h>
Platform.h includes lldb/Host/windows/windows.h, which overrides e.g. NTDDI_VERSION and _WIN32_WINNT before including <windows.h>. If we directly include <windows.h> somewhere first, and then later include lldb/Host/windows/windows.h (via Platform.h) we end up redefining NTDDI_VERSION. Also include lldb/Host/windows/PosixApi.h (for consistency, as it ends up included in some files but not in others) and add ifdefs around some defines that are defined by lldb's PosixApi.h. (Adding ifdefs instead of removing the definitions altogether, as older versions of lldb might not have the same defines.)
1 parent f05c9d2 commit 89945aa

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/MICmnStreamStdin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
// Third Party Headers
10-
#ifdef _MSC_VER
11-
#include <windows.h>
10+
#ifdef _WIN32
11+
#include "Platform.h"
1212
#endif
1313
#include <string.h>
1414

src/MIDataTypes.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
// Windows headers:
1818
#ifdef _WIN32
1919

20-
// Suppress the min and max macro definitions in Windef.h.
21-
#define NOMINMAX
22-
#include <windows.h>
20+
#include "Platform.h"
2321

2422
// Debugging:
2523
#ifdef _DEBUG

src/MIUtilDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Third party headers:
1010
#ifdef _WIN32
11-
#include <windows.h>
11+
#include "Platform.h"
1212
#endif
1313

1414
// In-house headers:

src/Platform.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <signal.h>
1515

1616
#include "lldb/Host/HostGetOpt.h"
17+
#include "lldb/Host/windows/PosixApi.h"
1718
#include "lldb/Host/windows/windows.h"
1819

1920
struct winsize {
@@ -25,7 +26,9 @@ typedef unsigned int speed_t;
2526
typedef unsigned int tcflag_t;
2627

2728
// fcntl.h // This is not used by MI
29+
#ifndef O_NOCTTY
2830
#define O_NOCTTY 0400
31+
#endif
2932

3033
// ioctls.h
3134
#define TIOCGWINSZ 0x5413
@@ -50,7 +53,9 @@ typedef long pid_t;
5053
#endif
5154

5255
#define STDIN_FILENO 0
56+
#ifndef PATH_MAX
5357
#define PATH_MAX 32768
58+
#endif
5459
#define snprintf _snprintf
5560

5661
extern int ioctl(int d, int request, ...);
@@ -64,12 +69,14 @@ typedef void (*sighandler_t)(int);
6469

6570
// CODETAG_IOR_SIGNALS
6671
// signal.h
67-
#define SIGQUIT 3 // Terminal quit signal
68-
#define SIGKILL 9 // Kill (cannot be caught or ignored)
69-
#define SIGPIPE 13 // Write on a pipe with no one to read it
70-
#define SIGCONT 18 // Continue executing, if stopped.
71-
#define SIGTSTP 20 // Terminal stop signal
72-
#define SIGSTOP 23 // Stop executing (cannot be caught or ignored)
72+
#define SIGQUIT 3 // Terminal quit signal
73+
#define SIGKILL 9 // Kill (cannot be caught or ignored)
74+
#define SIGPIPE 13 // Write on a pipe with no one to read it
75+
#define SIGCONT 18 // Continue executing, if stopped.
76+
#define SIGTSTP 20 // Terminal stop signal
77+
#ifndef SIGSTOP
78+
#define SIGSTOP 23 // Stop executing (cannot be caught or ignored)
79+
#endif
7380
#define SIGWINCH 28 // (== SIGVTALRM)
7481

7582
#else

0 commit comments

Comments
 (0)