From e0f47be9d0d86a07faaf8eb74409592f2cdaecf3 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 18 Jan 2011 00:22:36 +0100 Subject: [PATCH] Clean up the way windows headers are included Plus make inclusion order a little more consistent in general --- src/node.cc | 15 ++++++------- src/node_buffer.cc | 14 ++++++++----- src/node_child_process.h | 3 ++- src/node_child_process_win32.cc | 12 ++--------- src/node_constants.cc | 4 ++-- src/node_file.cc | 2 +- src/node_net.cc | 22 ++++++++++---------- src/node_os.cc | 16 +++++++------- src/node_stdio_win32.cc | 8 +++++-- src/platform_win32.cc | 12 ++++++----- src/platform_win32.h | 37 +++++++++++++++++++++++++++++++-- src/platform_win32_winsock.cc | 6 ------ src/platform_win32_winsock.h | 9 +++++--- 13 files changed, 98 insertions(+), 62 deletions(-) diff --git a/src/node.cc b/src/node.cc index bab02aaa9c..5faa313c78 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1,8 +1,10 @@ // Copyright 2009 Ryan Dahl + #include -#include +#include +#include #include #include #include @@ -14,17 +16,18 @@ #include #include /* setuid, getuid */ -#include "platform.h" - #ifdef __MINGW32__ # include /* winapi_perror() */ # include /* wsa_init() */ -#else // __POSIX__ +#endif + +#ifdef __POSIX__ # include /* dlopen(), dlsym() */ # include /* getpwnam() */ # include /* getgrnam() */ #endif +#include #include #include #include @@ -45,12 +48,10 @@ #include #include #ifdef HAVE_OPENSSL -#include +# include #endif #include -#include - #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) using namespace v8; diff --git a/src/node_buffer.cc b/src/node_buffer.cc index ba74abcc5f..2c19662121 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -1,18 +1,22 @@ + +#include #include -#include -#include // malloc, free #include +#include +#include // malloc, free #include // memcpy #ifdef __MINGW32__ -# include // htons, htonl -#else // __POSIX__ +# include +# include // htons, htonl +#endif + +#ifdef __POSIX__ # include // htons, htonl #endif -#include #define MIN(a,b) ((a) < (b) ? (a) : (b)) diff --git a/src/node_child_process.h b/src/node_child_process.h index 05fedb5f08..29aedb96e4 100644 --- a/src/node_child_process.h +++ b/src/node_child_process.h @@ -4,11 +4,12 @@ #include #include + #include #include #ifdef __MINGW32__ -# include // HANDLE type +# include // HANDLE type #endif // ChildProcess is a thin wrapper around ev_child. It has the extra diff --git a/src/node_child_process_win32.cc b/src/node_child_process_win32.cc index 615b0daf38..5f7f2171ed 100644 --- a/src/node_child_process_win32.cc +++ b/src/node_child_process_win32.cc @@ -1,16 +1,6 @@ -// RegisterWaitForSingleObject requires Windows 2000, -// GetProcessId requires windows XP SP1 -#define _WIN32_WINNT 0x0501 - - #include #include -#include -#include - -#include -#include #include #include @@ -23,6 +13,8 @@ #include #include +#include +#include namespace node { diff --git a/src/node_constants.cc b/src/node_constants.cc index 2ad6ce78b7..d82bca855f 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1,6 +1,8 @@ // Copyright 2009 Ryan Dahl #include +#include + #include #include #include @@ -8,8 +10,6 @@ #include #include -#include - namespace node { using namespace v8; diff --git a/src/node_file.cc b/src/node_file.cc index 638479a82b..a4527ff688 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -16,7 +16,7 @@ #include #ifdef __MINGW32__ -#include +# include #endif /* used for readlink, AIX doesn't provide it */ diff --git a/src/node_net.cc b/src/node_net.cc index b711c39692..de45b2f923 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -1,9 +1,11 @@ -#include -#include #include #include +#include +#include + +#include #include #include @@ -12,16 +14,15 @@ #include #ifdef __MINGW32__ -# include -# include +# include +# include +#endif -#else // __POSIX__ +#ifdef __POSIX__ # include # include # include - # include /* inet_pton */ - # include # include # include @@ -30,15 +31,14 @@ #ifdef __linux__ # include /* For the SIOCINQ / FIONREAD ioctl */ #endif + /* Non-linux platforms like OS X define this ioctl elsewhere */ #ifndef FIONREAD -#include +# include #endif -#include - #ifdef __OpenBSD__ -#include +# include #endif /* diff --git a/src/node_os.cc b/src/node_os.cc index 758648835e..1c98b04975 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -1,20 +1,22 @@ -#include #include -#include +#include +#include -#include "platform.h" +#include #include #include +#ifdef __MINGW32__ +# include +# include +#endif + #ifdef __POSIX__ # include // gethostname, sysconf # include -#else // __MINGW32__ -# include // GetVersionEx -# include // gethostname -#endif // __MINGW32__ +#endif namespace node { diff --git a/src/node_stdio_win32.cc b/src/node_stdio_win32.cc index 74aafc8a85..468a110576 100644 --- a/src/node_stdio_win32.cc +++ b/src/node_stdio_win32.cc @@ -1,9 +1,13 @@ -#include #include #include -#include + #include +#include +#include + +#include + using namespace v8; namespace node { diff --git a/src/platform_win32.cc b/src/platform_win32.cc index 9ceeeeb925..5dd425e356 100644 --- a/src/platform_win32.cc +++ b/src/platform_win32.cc @@ -1,15 +1,17 @@ -#include "node.h" -#include "platform.h" -#include "platform_win32.h" + +#include +#include #include #include +#include #include // for MAXPATHLEN #include // getpagesize -#include -#include "platform_win32_winsock.cc" +#include + +#include namespace node { diff --git a/src/platform_win32.h b/src/platform_win32.h index fdaead76da..b40031473e 100644 --- a/src/platform_win32.h +++ b/src/platform_win32.h @@ -1,9 +1,41 @@ #ifndef NODE_PLATFORM_WIN32_H_ #define NODE_PLATFORM_WIN32_H_ -#include +// Require at least Windows XP SP1 +// (GetProcessId requires it) +#ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0501 +#endif + +#ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN // implies NOCRYPT and NOGDI. +#endif + +#ifndef NOMINMAX +# define NOMINMAX +#endif + +#ifndef NOKERNEL +# define NOKERNEL +#endif + +#ifndef NOUSER +# define NOUSER +#endif +#ifndef NOSERVICE +# define NOSERVICE +#endif +#ifndef NOSOUND +# define NOSOUND +#endif + +#ifndef NOMCX +# define NOMCX +#endif + +#include namespace node { @@ -14,4 +46,5 @@ void winapi_perror(const char* prefix); } -#endif // NODE_PLATFORM_WIN32_H_ +#endif // NODE_PLATFORM_WIN32_H_ + diff --git a/src/platform_win32_winsock.cc b/src/platform_win32_winsock.cc index d6eacff5b7..37c0ed6cf5 100644 --- a/src/platform_win32_winsock.cc +++ b/src/platform_win32_winsock.cc @@ -7,14 +7,8 @@ */ -#include -#include -#include -#include -#include #include - namespace node { diff --git a/src/platform_win32_winsock.h b/src/platform_win32_winsock.h index a80f612136..7206e5b14e 100644 --- a/src/platform_win32_winsock.h +++ b/src/platform_win32_winsock.h @@ -1,11 +1,14 @@ #ifndef NODE_PLATFORM_WIN32_WINSOCK_H_ #define NODE_PLATFORM_WIN32_WINSOCK_H_ -#include -#include +#include -namespace node { +#include +#include +#include +#include +namespace node { void wsa_init();