Fix FreeBSD build

This commit is contained in:
2016-12-24 22:25:34 +01:00
parent 200fff3714
commit c966b42ac3
6 changed files with 129 additions and 106 deletions

View File

@ -6,103 +6,10 @@
* Copyright: Eugene Wissner 2016.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:belka@caraus.de, Eugene Wissner)
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)
*/
module tanya.async.event.kqueue;
version (OSX)
{
version = MissingKevent;
}
else version (iOS)
{
version = MissingKevent;
}
else version (TVOS)
{
version = MissingKevent;
}
else version (WatchOS)
{
version = MissingKevent;
}
else version (OpenBSD)
{
version = MissingKevent;
}
else version (DragonFlyBSD)
{
version = MissingKevent;
}
version (MissingKevent)
{
extern (C):
nothrow:
@nogc:
import core.stdc.stdint; // intptr_t, uintptr_t
import core.sys.posix.time; // timespec
enum : short
{
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3, /* attached to aio requests */
EVFILT_VNODE = -4, /* attached to vnodes */
EVFILT_PROC = -5, /* attached to struct proc */
EVFILT_SIGNAL = -6, /* attached to struct proc */
EVFILT_TIMER = -7, /* timers */
EVFILT_MACHPORT = -8, /* Mach portsets */
EVFILT_FS = -9, /* filesystem events */
EVFILT_USER = -10, /* User events */
EVFILT_VM = -12, /* virtual memory events */
EVFILT_SYSCOUNT = 11
}
extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
{
*kevp = kevent_t(args);
}
struct kevent_t
{
uintptr_t ident; /* identifier for this event */
short filter; /* filter for event */
ushort flags;
uint fflags;
intptr_t data;
void *udata; /* opaque user data identifier */
}
enum
{
/* actions */
EV_ADD = 0x0001, /* add event to kq (implies enable) */
EV_DELETE = 0x0002, /* delete event from kq */
EV_ENABLE = 0x0004, /* enable event */
EV_DISABLE = 0x0008, /* disable event (not reported) */
/* flags */
EV_ONESHOT = 0x0010, /* only report one occurrence */
EV_CLEAR = 0x0020, /* clear event state after reporting */
EV_RECEIPT = 0x0040, /* force EV_ERROR on success, data=0 */
EV_DISPATCH = 0x0080, /* disable event after reporting */
EV_SYSFLAGS = 0xF000, /* reserved by system */
EV_FLAG1 = 0x2000, /* filter-specific flag */
/* returned values */
EV_EOF = 0x8000, /* EOF detected */
EV_ERROR = 0x4000, /* error, data contains errno */
}
int kqueue();
int kevent(int kq, const kevent_t *changelist, int nchanges,
kevent_t *eventlist, int nevents,
const timespec *timeout);
}
version (OSX)
{
version = MacBSD;
@ -111,10 +18,17 @@ else version (iOS)
{
version = MacBSD;
}
else version (TVOS)
{
version = MacBSD;
}
else version (WatchOS)
{
version = MacBSD;
}
else version (FreeBSD)
{
version = MacBSD;
public import core.sys.freebsd.sys.event;
}
else version (OpenBSD)
{
@ -127,6 +41,67 @@ else version (DragonFlyBSD)
version (MacBSD):
import core.stdc.stdint; // intptr_t, uintptr_t
import core.sys.posix.time; // timespec
void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args) pure nothrow @nogc
{
*kevp = kevent_t(args);
}
enum : short
{
EVFILT_READ = -1,
EVFILT_WRITE = -2,
EVFILT_AIO = -3, /* attached to aio requests */
EVFILT_VNODE = -4, /* attached to vnodes */
EVFILT_PROC = -5, /* attached to struct proc */
EVFILT_SIGNAL = -6, /* attached to struct proc */
EVFILT_TIMER = -7, /* timers */
EVFILT_MACHPORT = -8, /* Mach portsets */
EVFILT_FS = -9, /* filesystem events */
EVFILT_USER = -10, /* User events */
EVFILT_VM = -12, /* virtual memory events */
EVFILT_SYSCOUNT = 11
}
struct kevent_t
{
uintptr_t ident; /* identifier for this event */
short filter; /* filter for event */
ushort flags;
uint fflags;
intptr_t data;
void *udata; /* opaque user data identifier */
}
enum
{
/* actions */
EV_ADD = 0x0001, /* add event to kq (implies enable) */
EV_DELETE = 0x0002, /* delete event from kq */
EV_ENABLE = 0x0004, /* enable event */
EV_DISABLE = 0x0008, /* disable event (not reported) */
/* flags */
EV_ONESHOT = 0x0010, /* only report one occurrence */
EV_CLEAR = 0x0020, /* clear event state after reporting */
EV_RECEIPT = 0x0040, /* force EV_ERROR on success, data=0 */
EV_DISPATCH = 0x0080, /* disable event after reporting */
EV_SYSFLAGS = 0xF000, /* reserved by system */
EV_FLAG1 = 0x2000, /* filter-specific flag */
/* returned values */
EV_EOF = 0x8000, /* EOF detected */
EV_ERROR = 0x4000, /* error, data contains errno */
}
extern(C) int kqueue() nothrow @nogc;
extern(C) int kevent(int kq, const kevent_t *changelist, int nchanges,
kevent_t *eventlist, int nevents, const timespec *timeout)
nothrow @nogc;
import tanya.async.event.selector;
import tanya.async.loop;
import tanya.async.transport;
@ -206,8 +181,8 @@ class KqueueLoop : SelectorLoop
* Returns: $(D_KEYWORD true) if the operation was successful.
*/
override protected bool reify(ConnectionWatcher watcher,
EventMask oldEvents,
EventMask events) @nogc
EventMask oldEvents,
EventMask events) @nogc
{
if (events != oldEvents)
{
@ -251,7 +226,7 @@ class KqueueLoop : SelectorLoop
{
if (errno != EINTR)
{
throw defaultAllocatorAllocator.make!BadLoopException();
throw defaultAllocator.make!BadLoopException();
}
return;
}

View File

@ -239,7 +239,7 @@ abstract class SelectorLoop : Loop
if (io is null)
{
io = MmapPool.instance.make!IOWatcher(transport,
connection.protocol);
connection.protocol);
connections[client.handle] = io;
}
else

View File

@ -17,17 +17,17 @@
* {
* private DuplexTransport transport;
*
* void received(ubyte[] data)
* void received(ubyte[] data) @nogc
* {
* transport.write(data);
* }
*
* void connected(DuplexTransport transport)
* void connected(DuplexTransport transport) @nogc
* {
* this.transport = transport;
* }
*
* void disconnected(SocketException e = null)
* void disconnected(SocketException e = null) @nogc
* {
* }
* }

View File

@ -12,7 +12,6 @@
*/
module tanya.math.random;
import std.experimental.allocator;
import std.digest.sha;
import std.typecons;
import tanya.memory;
@ -167,7 +166,7 @@ class Entropy
private ubyte sourceCount_;
private IAllocator allocator;
private shared Allocator allocator;
/// Entropy accumulator.
protected SHA!(maxGather * 8, 512) accumulator;