Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Clean up the way windows headers are included
Browse files Browse the repository at this point in the history
Plus make inclusion order a little more consistent in general
  • Loading branch information
piscisaureus committed Jan 18, 2011
1 parent 43d7595 commit e0f47be
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 62 deletions.
15 changes: 8 additions & 7 deletions src/node.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org>

#include <node.h>

#include <locale.h>
#include <v8-debug.h>

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
Expand All @@ -14,17 +16,18 @@
#include <sys/types.h>
#include <unistd.h> /* setuid, getuid */

#include "platform.h"

#ifdef __MINGW32__
# include <platform_win32.h> /* winapi_perror() */
# include <platform_win32_winsock.h> /* wsa_init() */
#else // __POSIX__
#endif

#ifdef __POSIX__
# include <dlfcn.h> /* dlopen(), dlsym() */
# include <pwd.h> /* getpwnam() */
# include <grp.h> /* getgrnam() */
#endif

#include <platform.h>
#include <node_buffer.h>
#include <node_io_watcher.h>
#include <node_net.h>
Expand All @@ -45,12 +48,10 @@
#include <node_javascript.h>
#include <node_version.h>
#ifdef HAVE_OPENSSL
#include <node_crypto.h>
# include <node_crypto.h>
#endif
#include <node_script.h>

#include <v8-debug.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))

using namespace v8;
Expand Down
14 changes: 9 additions & 5 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@

#include <node.h>
#include <node_buffer.h>

#include <assert.h>
#include <stdlib.h> // malloc, free
#include <v8.h>

#include <assert.h>
#include <stdlib.h> // malloc, free
#include <string.h> // memcpy

#ifdef __MINGW32__
# include <winsock2.h> // htons, htonl
#else // __POSIX__
# include <platform.h>
# include <platform_win32_winsock.h> // htons, htonl
#endif

#ifdef __POSIX__
# include <arpa/inet.h> // htons, htonl
#endif

#include <node.h>

#define MIN(a,b) ((a) < (b) ? (a) : (b))

Expand Down
3 changes: 2 additions & 1 deletion src/node_child_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include <node.h>
#include <node_object_wrap.h>

#include <v8.h>
#include <ev.h>

#ifdef __MINGW32__
# include <windows.h> // HANDLE type
# include <platform_win32.h> // HANDLE type
#endif

// ChildProcess is a thin wrapper around ev_child. It has the extra
Expand Down
12 changes: 2 additions & 10 deletions src/node_child_process_win32.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@

// RegisterWaitForSingleObject requires Windows 2000,
// GetProcessId requires windows XP SP1
#define _WIN32_WINNT 0x0501


#include <node.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 <ev.h>
Expand All @@ -23,6 +13,8 @@
#include <unistd.h>
#include <sys/types.h>

#include <platform_win32.h>
#include <platform_win32_winsock.h>

namespace node {

Expand Down
4 changes: 2 additions & 2 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
#include <node_constants.h>

#include <ev.h>

#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <ev.h>

namespace node {

using namespace v8;
Expand Down
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <limits.h>

#ifdef __MINGW32__
#include <windows.h>
# include <platform_win32.h>
#endif

/* used for readlink, AIX doesn't provide it */
Expand Down
22 changes: 11 additions & 11 deletions src/node_net.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <node_net.h>
#include <v8.h>

#include <node.h>
#include <node_buffer.h>
#include <node_net.h>

#include <v8.h>

#include <errno.h>
#include <string.h>
#include <stdlib.h>

Expand All @@ -12,16 +14,15 @@
#include <fcntl.h>

#ifdef __MINGW32__
# include <winsock2.h>
# include <ws2tcpip.h>
# include <platform_win32.h>
# include <platform_win32_winsock.h>
#endif

#else // __POSIX__
#ifdef __POSIX__
# include <sys/ioctl.h>
# include <sys/socket.h>
# include <sys/un.h>

# include <arpa/inet.h> /* inet_pton */

# include <netdb.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
Expand All @@ -30,15 +31,14 @@
#ifdef __linux__
# include <linux/sockios.h> /* For the SIOCINQ / FIONREAD ioctl */
#endif

/* Non-linux platforms like OS X define this ioctl elsewhere */
#ifndef FIONREAD
#include <sys/filio.h>
# include <sys/filio.h>
#endif

#include <errno.h>

#ifdef __OpenBSD__
#include <sys/uio.h>
# include <sys/uio.h>
#endif

/*
Expand Down
16 changes: 9 additions & 7 deletions src/node_os.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#include <node_os.h>

#include <node.h>
#include <v8.h>
#include <node_os.h>
#include <platform.h>

#include "platform.h"
#include <v8.h>

#include <errno.h>
#include <string.h>

#ifdef __MINGW32__
# include <platform_win32.h>
# include <platform_win32_winsock.h>
#endif

#ifdef __POSIX__
# include <unistd.h> // gethostname, sysconf
# include <sys/utsname.h>
#else // __MINGW32__
# include <windows.h> // GetVersionEx
# include <winsock2.h> // gethostname
#endif // __MINGW32__
#endif

namespace node {

Expand Down
8 changes: 6 additions & 2 deletions src/node_stdio_win32.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include <io.h>
#include <node.h>
#include <node_stdio.h>
#include <platform_win32.h>

#include <v8.h>

#include <errno.h>
#include <io.h>

#include <platform_win32.h>

using namespace v8;
namespace node {

Expand Down
12 changes: 7 additions & 5 deletions src/platform_win32.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include "node.h"
#include "platform.h"
#include "platform_win32.h"

#include <node.h>
#include <platform.h>

#include <v8.h>

#include <errno.h>
#include <stdlib.h>
#include <sys/param.h> // for MAXPATHLEN
#include <unistd.h> // getpagesize
#include <windows.h>

#include "platform_win32_winsock.cc"
#include <platform_win32.h>

#include <platform_win32_winsock.cc>

namespace node {

Expand Down
37 changes: 35 additions & 2 deletions src/platform_win32.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
#ifndef NODE_PLATFORM_WIN32_H_
#define NODE_PLATFORM_WIN32_H_

#include <windows.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>

namespace node {

Expand All @@ -14,4 +46,5 @@ void winapi_perror(const char* prefix);

}

#endif // NODE_PLATFORM_WIN32_H_
#endif // NODE_PLATFORM_WIN32_H_

6 changes: 0 additions & 6 deletions src/platform_win32_winsock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
*/


#include <windows.h>
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <ws2spi.h>
#include <platform_win32_winsock.h>


namespace node {


Expand Down
9 changes: 6 additions & 3 deletions src/platform_win32_winsock.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#ifndef NODE_PLATFORM_WIN32_WINSOCK_H_
#define NODE_PLATFORM_WIN32_WINSOCK_H_

#include <windows.h>
#include <winsock.h>
#include <platform_win32.h>

namespace node {
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#include <ws2spi.h>

namespace node {

void wsa_init();

Expand Down

0 comments on commit e0f47be

Please sign in to comment.