checkpoint of win32

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@391 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
mheily 2011-01-16 23:29:12 +00:00
parent af29ed30b3
commit 926fbfd0ec
5 changed files with 110 additions and 10 deletions

View File

@ -172,7 +172,7 @@ extern "C" {
#ifdef _WIN32
#define EVENT_QUEUE struct event_queue *
#define EVENT_QUEUE struct kqueue *
__declspec(dllexport) EVENT_QUEUE
CreateEventQueue(void);

88
libkqueue.vcxproj Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBKQUEUE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBKQUEUE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\common\filter.c" />
<ClCompile Include="src\common\kevent.c" />
<ClCompile Include="src\common\knote.c" />
<ClCompile Include="src\common\kqueue.c" />
<ClCompile Include="src\windows\platform.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\kqueue.h" />
<ClInclude Include="include\sys\event.h" />
<ClInclude Include="src\common\private.h" />
<ClInclude Include="src\common\queue.h" />
<ClInclude Include="src\common\tree.h" />
<ClInclude Include="src\windows\platform.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -148,6 +148,7 @@ struct kqueue {
fd_set kq_fds, kq_rfds;
int kq_nfds;
pthread_mutex_t kq_mtx;
KQUEUE_PLATFORM_SPECIFIC;
#ifdef __sun__
int kq_port; /* see: port_create(2) */
TAILQ_HEAD(event_buf_listhead,event_buf) kq_events;

View File

@ -25,12 +25,6 @@ const struct filter evfilt_read = EVFILT_NOTIMPL;
const struct filter evfilt_timer = EVFILT_NOTIMPL;
const struct filter evfilt_user = EVFILT_NOTIMPL;
struct event_queue {
HANDLE notifier;
HANDLE events[MAXIMUM_WAIT_OBJECTS];
size_t nevents;
};
BOOL WINAPI DllMain(
HINSTANCE self,
DWORD reason,
@ -41,6 +35,8 @@ BOOL WINAPI DllMain(
/* XXX-FIXME: initialize kqtree mutex */
if (WSAStartup(MAKEWORD(2,2), NULL) != 0)
return (FALSE);
if (_libkqueue_init() < 0)
return (FALSE);
/* TODO: bettererror handling */
break;
@ -55,13 +51,20 @@ BOOL WINAPI DllMain(
__declspec(dllexport) EVENT_QUEUE
CreateEventQueue(void)
{
EVENT_QUEUE *evq;
EVENT_QUEUE evq;
int kqfd;
kqfd = kqueue();
if (kqfd < 0)
return (NULL);
evq = calloc(1, sizeof(*evq));
if (evq == NULL)
return (NULL);
evq->notifier = CreateEvent(NULL, FALSE, FALSE, NULL);
if (evq->notifier == NULL) {
evq->kq_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
if (evq->kq_handle == NULL) {
free(evq);
return (NULL);
}

View File

@ -42,6 +42,14 @@
#define atomic_inc InterlockedIncrement
#define atomic_dec InterlockedDecrement
/*
* Additional members of struct kqueue
*/
#define KQUEUE_PLATFORM_SPECIFIC \
HANDLE kq_handle; \
HANDLE kq_events[MAXIMUM_WAIT_OBJECTS]; \
size_t kq_nevents
/* Windows does not support this attribute.
DllMain() is the only available constructor function.
This means the constructor must be called from within DllMain().