Clean up the way windows headers are included

Plus make inclusion order a little more consistent in general
This commit is contained in:
Bert Belder 2011-01-18 00:22:36 +01:00
parent 43d75952ff
commit e0f47be9d0
13 changed files with 99 additions and 63 deletions

View File

@ -1,8 +1,10 @@
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org> // Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
#include <node.h> #include <node.h>
#include <locale.h> #include <v8-debug.h>
#include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h> #include <strings.h>
@ -14,17 +16,18 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> /* setuid, getuid */ #include <unistd.h> /* setuid, getuid */
#include "platform.h"
#ifdef __MINGW32__ #ifdef __MINGW32__
# include <platform_win32.h> /* winapi_perror() */ # include <platform_win32.h> /* winapi_perror() */
# include <platform_win32_winsock.h> /* wsa_init() */ # include <platform_win32_winsock.h> /* wsa_init() */
#else // __POSIX__ #endif
#ifdef __POSIX__
# include <dlfcn.h> /* dlopen(), dlsym() */ # include <dlfcn.h> /* dlopen(), dlsym() */
# include <pwd.h> /* getpwnam() */ # include <pwd.h> /* getpwnam() */
# include <grp.h> /* getgrnam() */ # include <grp.h> /* getgrnam() */
#endif #endif
#include <platform.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_io_watcher.h> #include <node_io_watcher.h>
#include <node_net.h> #include <node_net.h>
@ -49,8 +52,6 @@
#endif #endif
#include <node_script.h> #include <node_script.h>
#include <v8-debug.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
using namespace v8; using namespace v8;

View File

@ -1,18 +1,22 @@
#include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <v8.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h> // malloc, free #include <stdlib.h> // malloc, free
#include <v8.h>
#include <string.h> // memcpy #include <string.h> // memcpy
#ifdef __MINGW32__ #ifdef __MINGW32__
# include <winsock2.h> // htons, htonl # include <platform.h>
#else // __POSIX__ # include <platform_win32_winsock.h> // htons, htonl
#endif
#ifdef __POSIX__
# include <arpa/inet.h> // htons, htonl # include <arpa/inet.h> // htons, htonl
#endif #endif
#include <node.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))

View File

@ -4,11 +4,12 @@
#include <node.h> #include <node.h>
#include <node_object_wrap.h> #include <node_object_wrap.h>
#include <v8.h> #include <v8.h>
#include <ev.h> #include <ev.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
# include <windows.h> // HANDLE type # include <platform_win32.h> // HANDLE type
#endif #endif
// ChildProcess is a thin wrapper around ev_child. It has the extra // ChildProcess is a thin wrapper around ev_child. It has the extra

View File

@ -1,16 +1,6 @@
// RegisterWaitForSingleObject requires Windows 2000,
// GetProcessId requires windows XP SP1
#define _WIN32_WINNT 0x0501
#include <node.h> #include <node.h>
#include <node_child_process.h> #include <node_child_process.h>
#include <platform_win32.h>
#include <platform_win32_winsock.h>
#include <windows.h>
#include <winsock.h>
#include <v8.h> #include <v8.h>
#include <ev.h> #include <ev.h>
@ -23,6 +13,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <platform_win32.h>
#include <platform_win32_winsock.h>
namespace node { namespace node {

View File

@ -1,6 +1,8 @@
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org> // Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
#include <node_constants.h> #include <node_constants.h>
#include <ev.h>
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
@ -8,8 +10,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ev.h>
namespace node { namespace node {
using namespace v8; using namespace v8;

View File

@ -16,7 +16,7 @@
#include <limits.h> #include <limits.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <windows.h> # include <platform_win32.h>
#endif #endif
/* used for readlink, AIX doesn't provide it */ /* used for readlink, AIX doesn't provide it */

View File

@ -1,9 +1,11 @@
#include <node_net.h>
#include <v8.h>
#include <node.h> #include <node.h>
#include <node_buffer.h> #include <node_buffer.h>
#include <node_net.h>
#include <v8.h>
#include <errno.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -12,16 +14,15 @@
#include <fcntl.h> #include <fcntl.h>
#ifdef __MINGW32__ #ifdef __MINGW32__
# include <winsock2.h> # include <platform_win32.h>
# include <ws2tcpip.h> # include <platform_win32_winsock.h>
#endif
#else // __POSIX__ #ifdef __POSIX__
# include <sys/ioctl.h> # include <sys/ioctl.h>
# include <sys/socket.h> # include <sys/socket.h>
# include <sys/un.h> # include <sys/un.h>
# include <arpa/inet.h> /* inet_pton */ # include <arpa/inet.h> /* inet_pton */
# include <netdb.h> # include <netdb.h>
# include <netinet/in.h> # include <netinet/in.h>
# include <netinet/tcp.h> # include <netinet/tcp.h>
@ -30,13 +31,12 @@
#ifdef __linux__ #ifdef __linux__
# include <linux/sockios.h> /* For the SIOCINQ / FIONREAD ioctl */ # include <linux/sockios.h> /* For the SIOCINQ / FIONREAD ioctl */
#endif #endif
/* Non-linux platforms like OS X define this ioctl elsewhere */ /* Non-linux platforms like OS X define this ioctl elsewhere */
#ifndef FIONREAD #ifndef FIONREAD
# include <sys/filio.h> # include <sys/filio.h>
#endif #endif
#include <errno.h>
#ifdef __OpenBSD__ #ifdef __OpenBSD__
# include <sys/uio.h> # include <sys/uio.h>
#endif #endif

View File

@ -1,20 +1,22 @@
#include <node_os.h>
#include <node.h> #include <node.h>
#include <v8.h> #include <node_os.h>
#include <platform.h>
#include "platform.h" #include <v8.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#ifdef __MINGW32__
# include <platform_win32.h>
# include <platform_win32_winsock.h>
#endif
#ifdef __POSIX__ #ifdef __POSIX__
# include <unistd.h> // gethostname, sysconf # include <unistd.h> // gethostname, sysconf
# include <sys/utsname.h> # include <sys/utsname.h>
#else // __MINGW32__ #endif
# include <windows.h> // GetVersionEx
# include <winsock2.h> // gethostname
#endif // __MINGW32__
namespace node { namespace node {

View File

@ -1,9 +1,13 @@
#include <io.h>
#include <node.h> #include <node.h>
#include <node_stdio.h> #include <node_stdio.h>
#include <platform_win32.h>
#include <v8.h> #include <v8.h>
#include <errno.h>
#include <io.h>
#include <platform_win32.h>
using namespace v8; using namespace v8;
namespace node { namespace node {

View File

@ -1,15 +1,17 @@
#include "node.h"
#include "platform.h" #include <node.h>
#include "platform_win32.h" #include <platform.h>
#include <v8.h> #include <v8.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h>
#include <sys/param.h> // for MAXPATHLEN #include <sys/param.h> // for MAXPATHLEN
#include <unistd.h> // getpagesize #include <unistd.h> // getpagesize
#include <windows.h>
#include "platform_win32_winsock.cc" #include <platform_win32.h>
#include <platform_win32_winsock.cc>
namespace node { namespace node {

View File

@ -1,10 +1,42 @@
#ifndef NODE_PLATFORM_WIN32_H_ #ifndef NODE_PLATFORM_WIN32_H_
#define NODE_PLATFORM_WIN32_H_ #define NODE_PLATFORM_WIN32_H_
// 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 <windows.h> #include <windows.h>
namespace node { namespace node {
#define NO_IMPL_MSG(name...) \ #define NO_IMPL_MSG(name...) \
@ -15,3 +47,4 @@ void winapi_perror(const char* prefix);
} }
#endif // NODE_PLATFORM_WIN32_H_ #endif // NODE_PLATFORM_WIN32_H_

View File

@ -7,14 +7,8 @@
*/ */
#include <windows.h>
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <ws2spi.h>
#include <platform_win32_winsock.h> #include <platform_win32_winsock.h>
namespace node { namespace node {

View File

@ -1,12 +1,15 @@
#ifndef NODE_PLATFORM_WIN32_WINSOCK_H_ #ifndef NODE_PLATFORM_WIN32_WINSOCK_H_
#define NODE_PLATFORM_WIN32_WINSOCK_H_ #define NODE_PLATFORM_WIN32_WINSOCK_H_
#include <windows.h> #include <platform_win32.h>
#include <winsock.h>
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <ws2spi.h>
namespace node { namespace node {
void wsa_init(); void wsa_init();
void wsa_perror(const char* prefix = ""); void wsa_perror(const char* prefix = "");