EVFILT_USER implementation on windows

Change VS Solution structure to be more well-arranged

git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@490 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
marius 2011-04-26 20:12:28 +00:00
parent 3ea5de4571
commit 731410fef0
5 changed files with 196 additions and 1 deletions

View File

@ -78,6 +78,7 @@
<ClCompile Include="src\windows\platform.c" />
<ClCompile Include="src\windows\read.c" />
<ClCompile Include="src\windows\timer.c" />
<ClCompile Include="src\windows\user.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\kqueue.h" />

67
libkqueue.vcxproj.filters Normal file
View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="src\common\map.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="src\common\filter.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="src\common\kevent.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="src\common\knote.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="src\common\kqueue.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="src\windows\user.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="src\windows\event_loop.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="src\windows\platform.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="src\windows\read.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="src\windows\timer.c">
<Filter>windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\common\tree.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="src\common\debug.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="src\common\private.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="src\common\queue.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="src\windows\event_loop.h">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="include\kqueue.h">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="src\windows\platform.h">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="include\sys\event.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="common">
<UniqueIdentifier>{d00529d5-005e-4a55-950f-987dc27e5101}</UniqueIdentifier>
</Filter>
<Filter Include="windows">
<UniqueIdentifier>{11f5eddb-b2fe-4fc5-9733-f52ee80e8a4c}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -33,7 +33,6 @@ const struct filter evfilt_proc = EVFILT_NOTIMPL;
const struct filter evfilt_vnode = EVFILT_NOTIMPL;
const struct filter evfilt_signal = EVFILT_NOTIMPL;
const struct filter evfilt_write = EVFILT_NOTIMPL;
const struct filter evfilt_user = EVFILT_NOTIMPL;
const struct kqueue_vtable kqops = {
windows_kqueue_init,

127
src/windows/user.c Normal file
View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2009 Mark Heily <mark@heily.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "../common/private.h"
int
evfilt_user_init(struct filter *filt)
{
return (0);
}
void
evfilt_user_destroy(struct filter *filt)
{
}
int
evfilt_user_copyout(struct kevent* dst, struct knote* src, void* ptr)
{
memcpy(dst, &src->kev, sizeof(struct kevent));
dst->fflags &= ~NOTE_FFCTRLMASK; //FIXME: Not sure if needed
dst->fflags &= ~NOTE_TRIGGER;
if (src->kev.flags & EV_ADD) {
/* NOTE: True on FreeBSD but not consistent behavior with
other filters. */
dst->flags &= ~EV_ADD;
}
if (src->kev.flags & EV_CLEAR)
src->kev.fflags &= ~NOTE_TRIGGER;
if (src->kev.flags & EV_DISPATCH)
src->kev.fflags &= ~NOTE_TRIGGER;
return (0);
}
int
evfilt_user_knote_create(struct filter *filt, struct knote *kn)
{
return (0);
}
int
evfilt_user_knote_modify(struct filter *filt, struct knote *kn,
const struct kevent *kev)
{
unsigned int ffctrl;
unsigned int fflags;
/* Excerpted from sys/kern/kern_event.c in FreeBSD HEAD */
ffctrl = kev->fflags & NOTE_FFCTRLMASK;
fflags = kev->fflags & NOTE_FFLAGSMASK;
switch (ffctrl) {
case NOTE_FFNOP:
break;
case NOTE_FFAND:
kn->kev.fflags &= fflags;
break;
case NOTE_FFOR:
kn->kev.fflags |= fflags;
break;
case NOTE_FFCOPY:
kn->kev.fflags = fflags;
break;
default:
/* XXX Return error? */
break;
}
if ((!(kn->kev.flags & EV_DISABLE)) && kev->fflags & NOTE_TRIGGER) {
kn->kev.fflags |= NOTE_TRIGGER;
if (!PostQueuedCompletionStatus(kn->kn_kq->kq_iocp, 1, (ULONG_PTR) 0, (LPOVERLAPPED) kn)) {
dbg_lasterror("PostQueuedCompletionStatus()");
return (-1);
}
}
return (0);
}
int
evfilt_user_knote_delete(struct filter *filt, struct knote *kn)
{
return (0);
}
int
evfilt_user_knote_enable(struct filter *filt, struct knote *kn)
{
return evfilt_user_knote_create(filt, kn);
}
int
evfilt_user_knote_disable(struct filter *filt, struct knote *kn)
{
return evfilt_user_knote_delete(filt, kn);
}
const struct filter evfilt_user = {
EVFILT_USER,
evfilt_user_init,
evfilt_user_destroy,
evfilt_user_copyout,
evfilt_user_knote_create,
evfilt_user_knote_modify,
evfilt_user_knote_delete,
evfilt_user_knote_enable,
evfilt_user_knote_disable,
};

View File

@ -51,6 +51,7 @@
#else
# include "../include/sys/event.h"
# include "../src/windows/platform.h"
# define HAVE_EVFILT_USER 1
#endif