summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.cpm>2012-02-16 10:06:30 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:06:30 +0900
commitfb1209c72bbfd431b61fa4588785586d24ef67c9 (patch)
tree6c33ac55809c64e57e44b347879fe297e894be5e /src
parent0d384b7944c20f3389c2be9363afac99783d776a (diff)
More MSVC tests added
Signed-off-by: Martin Sustrik <sustrik@250bpm.cpm>
Diffstat (limited to 'src')
-rw-r--r--src/xpub.cpp2
-rw-r--r--src/xs_utils.cpp43
2 files changed, 44 insertions, 1 deletions
diff --git a/src/xpub.cpp b/src/xpub.cpp
index b4bc135..d27337e 100644
--- a/src/xpub.cpp
+++ b/src/xpub.cpp
@@ -177,7 +177,7 @@ void xs::xpub_t::send_unsubscription (unsigned char *data_, size_t size_,
xpub_t *self = (xpub_t*) arg_;
blob_t unsub (size_ + 1, 0);
unsub [0] = 0;
- memcpy (&unsub [1], data_, size_);
+ memcpy ((void*) (unsub.data () + 1), data_, size_);
self->pending.push_back (unsub);
}
}
diff --git a/src/xs_utils.cpp b/src/xs_utils.cpp
index e30ffe2..976f540 100644
--- a/src/xs_utils.cpp
+++ b/src/xs_utils.cpp
@@ -59,3 +59,46 @@ unsigned long xs_stopwatch_stop (void *watch_)
free (watch_);
return (unsigned long) (end - start);
}
+
+#if defined XS_HAVE_WINDOWS
+
+struct arg_t
+{
+ HANDLE handle;
+ void (*fn) (void *arg);
+ void *arg;
+};
+
+extern "C"
+{
+ static unsigned int __stdcall thread_routine (void *arg_)
+ {
+ arg_t *arg = (arg_t*) arg_;
+ arg->fn (arg->arg);
+ return 0;
+ }
+}
+
+void *xs_thread_create (void (*fn_) (void *arg_), void *arg_)
+{
+ arg_t *arg = (arg_t*) malloc (sizeof (arg_t));
+ alloc_assert (arg);
+ arg->fn = fn_;
+ arg->arg = arg_;
+ arg->handle = (HANDLE) _beginthreadex (NULL, 0,
+ &::thread_routine, (void*) arg, 0 , NULL);
+ win_assert (arg->handle != NULL);
+ return (void*) arg;
+}
+
+void xs_thread_join (void *thread_)
+{
+ arg_t *arg = (arg_t*) thread_;
+ DWORD rc = WaitForSingleObject (arg->handle, INFINITE);
+ win_assert (rc != WAIT_FAILED);
+ BOOL rc2 = CloseHandle (arg->handle);
+ win_assert (rc2 != 0);
+ free (arg);
+}
+
+#endif