win: merge kernel32.h and ntdll.h; declare pointers in winapi.h

This commit is contained in:
Bert Belder 2011-08-21 21:46:20 +02:00
parent cc0b0e6238
commit 48a8f1959a
4 changed files with 50 additions and 73 deletions

View File

@ -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_ */

View File

@ -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 <windows.h>
#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_ */

View File

@ -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 <windows.h>
/*
* 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_ */
/*
* 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_ */

3
uv.gyp
View File

@ -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': [