From c966b42ac310488cb1c4174e0dbe4013c0af9bf5 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 24 Dec 2016 22:25:34 +0100 Subject: Fix FreeBSD build --- source/tanya/async/event/kqueue.d | 155 +++++++++++++++--------------------- source/tanya/async/event/selector.d | 2 +- source/tanya/async/loop.d | 6 +- source/tanya/math/random.d | 3 +- 4 files changed, 70 insertions(+), 96 deletions(-) (limited to 'source') diff --git a/source/tanya/async/event/kqueue.d b/source/tanya/async/event/kqueue.d index cf7f3c1..5014b33 100644 --- a/source/tanya/async/event/kqueue.d +++ b/source/tanya/async/event/kqueue.d @@ -6,126 +6,101 @@ * 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; + version = MacBSD; } else version (iOS) { - version = MissingKevent; + version = MacBSD; } else version (TVOS) { - version = MissingKevent; + version = MacBSD; } else version (WatchOS) { - version = MissingKevent; + version = MacBSD; +} +else version (FreeBSD) +{ + version = MacBSD; } else version (OpenBSD) { - version = MissingKevent; + version = MacBSD; } else version (DragonFlyBSD) { - version = MissingKevent; + version = MacBSD; } -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 */ - } +version (MacBSD): - int kqueue(); - int kevent(int kq, const kevent_t *changelist, int nchanges, - kevent_t *eventlist, int nevents, - const timespec *timeout); -} +import core.stdc.stdint; // intptr_t, uintptr_t +import core.sys.posix.time; // timespec -version (OSX) -{ - version = MacBSD; -} -else version (iOS) +void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args) pure nothrow @nogc { - version = MacBSD; + *kevp = kevent_t(args); } -else version (FreeBSD) + +enum : short { - version = MacBSD; - public import core.sys.freebsd.sys.event; + 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 } -else version (OpenBSD) + +struct kevent_t { - version = MacBSD; + 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 */ } -else version (DragonFlyBSD) + +enum { - version = MacBSD; + /* 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 */ } -version (MacBSD): +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; @@ -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; } diff --git a/source/tanya/async/event/selector.d b/source/tanya/async/event/selector.d index 5f42bd2..28dbaee 100644 --- a/source/tanya/async/event/selector.d +++ b/source/tanya/async/event/selector.d @@ -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 diff --git a/source/tanya/async/loop.d b/source/tanya/async/loop.d index a7859d4..1526251 100644 --- a/source/tanya/async/loop.d +++ b/source/tanya/async/loop.d @@ -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 * { * } * } diff --git a/source/tanya/math/random.d b/source/tanya/math/random.d index 0405bc0..e58d209 100644 --- a/source/tanya/math/random.d +++ b/source/tanya/math/random.d @@ -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; -- cgit v1.2.3