diff --git a/src/win/internal.h b/src/win/internal.h index fe435f522..cf739a924 100644 --- a/src/win/internal.h +++ b/src/win/internal.h @@ -26,8 +26,7 @@ #include "../uv-common.h" #include "tree.h" -#include "ntdll.h" -#include "kernel32.h" +#include "winapi.h" /* @@ -256,14 +255,9 @@ void uv_set_error(uv_err_code code, int sys_errno); /* - * Windows api functions that we need to retrieve dynamically + * Initialization for the windows and winsock api */ void uv_winapi_init(); -extern sRtlNtStatusToDosError pRtlNtStatusToDosError; -extern sNtQueryInformationFile pNtQueryInformationFile; -extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; -extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; - #endif /* UV_WIN_INTERNAL_H_ */ diff --git a/src/win/kernel32.h b/src/win/kernel32.h deleted file mode 100644 index fb2141d65..000000000 --- a/src/win/kernel32.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef UV_WIN_KERNEL32_H_ -#define UV_WIN_KERNEL32_H_ - -#include - - -#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 -#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 - - -#ifndef _MSC_VER - typedef struct _OVERLAPPED_ENTRY { - ULONG_PTR lpCompletionKey; - LPOVERLAPPED lpOverlapped; - ULONG_PTR Internal; - DWORD dwNumberOfBytesTransferred; - } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; -#endif - - -typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx) - (HANDLE CompletionPort, - LPOVERLAPPED_ENTRY lpCompletionPortEntries, - ULONG ulCount, - PULONG ulNumEntriesRemoved, - DWORD dwMilliseconds, - BOOL fAlertable); - -typedef BOOL (WINAPI* sSetFileCompletionNotificationModes) - (HANDLE FileHandle, - UCHAR Flags); - -#endif /* UV_WIN_KERNEL32_H_ */ diff --git a/src/win/ntdll.h b/src/win/winapi.h similarity index 75% rename from src/win/ntdll.h rename to src/win/winapi.h index d5db6ca4b..69a1f2f9e 100644 --- a/src/win/ntdll.h +++ b/src/win/winapi.h @@ -19,20 +19,23 @@ * IN THE SOFTWARE. */ -#ifndef UV_WIN_NTDLL_H_ -#define UV_WIN_NTDLL_H_ +#ifndef UV_WIN_WINAPI_H_ +#define UV_WIN_WINAPI_H_ #include +/* + * Ntdll headers + */ #ifndef _NTDEF_ typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; #endif - -#define STATUS_SUCCESS ((NTSTATUS)0x0) - +#ifndef STATUS_SUCCESS + #define STATUS_SUCCESS ((NTSTATUS) 0x0) +#endif typedef struct _IO_STATUS_BLOCK { union { @@ -42,7 +45,6 @@ typedef struct _IO_STATUS_BLOCK { ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; - typedef struct _FILE_PIPE_LOCAL_INFORMATION { ULONG NamedPipeType; ULONG NamedPipeConfiguration; @@ -56,7 +58,6 @@ typedef struct _FILE_PIPE_LOCAL_INFORMATION { ULONG NamedPipeEnd; } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION; - typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, FileFullDirectoryInformation, @@ -116,7 +117,6 @@ typedef enum _FILE_INFORMATION_CLASS { FileMaximumInformation } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; - typedef ULONG (NTAPI *sRtlNtStatusToDosError) (NTSTATUS Status); @@ -127,4 +127,42 @@ typedef NTSTATUS (NTAPI *sNtQueryInformationFile) ULONG Length, FILE_INFORMATION_CLASS FileInformationClass); -#endif /* UV_WIN_NTDLL_H_ */ \ No newline at end of file + +/* + * Kernel32 headers + */ +#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 +#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 + +#ifdef __MINGW32__ + typedef struct _OVERLAPPED_ENTRY { + ULONG_PTR lpCompletionKey; + LPOVERLAPPED lpOverlapped; + ULONG_PTR Internal; + DWORD dwNumberOfBytesTransferred; + } OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; +#endif + +typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx) + (HANDLE CompletionPort, + LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, + PULONG ulNumEntriesRemoved, + DWORD dwMilliseconds, + BOOL fAlertable); + +typedef BOOL (WINAPI* sSetFileCompletionNotificationModes) + (HANDLE FileHandle, + UCHAR Flags); + + +/* Ntapi function pointers */ +extern sRtlNtStatusToDosError pRtlNtStatusToDosError; +extern sNtQueryInformationFile pNtQueryInformationFile; + + +/* Kernel32 function pointers */ +extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx; +extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes; + +#endif /* UV_WIN_WINAPI_H_ */ \ No newline at end of file diff --git a/uv.gyp b/uv.gyp index 9e8d41c45..3c22129c0 100644 --- a/uv.gyp +++ b/uv.gyp @@ -101,9 +101,7 @@ 'src/win/getaddrinfo.c', 'src/win/handle.c', 'src/win/internal.h', - 'src/win/kernel32.h', 'src/win/loop-watcher.c', - 'src/win/ntdll.h', 'src/win/pipe.c', 'src/win/process.c', 'src/win/req.c', @@ -113,6 +111,7 @@ 'src/win/timer.c', 'src/win/util.c', 'src/win/winapi.c', + 'src/win/winapi.h', ], 'link_settings': { 'libraries': [