diff options
author | osy <osy@turing.llc> | 2022-03-04 15:52:48 -0800 |
---|---|---|
committer | osy <osy@turing.llc> | 2022-03-04 21:56:12 -0800 |
commit | fa812c88492641005a768c72502a8953bd1223b2 (patch) | |
tree | 0486e262a45340eaac567b9abf6e27f51ecda073 /src | |
parent | 9f3b720e2f7fa793b263f12bb50f19f60b863760 (diff) |
coroutine: add support for libucontext
libucontext is a lightweight implementation of ucontext for platforms
that do not have a built-in implementation. This allows us to use the
same code to support libucontext as ucontext.
Diffstat (limited to 'src')
-rw-r--r-- | src/continuation.c | 12 | ||||
-rw-r--r-- | src/meson.build | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/continuation.c b/src/continuation.c index 65527ac..400169a 100644 --- a/src/continuation.c +++ b/src/continuation.c @@ -25,11 +25,21 @@ #endif #include <errno.h> -#include <ucontext.h> #include <glib.h> #include "continuation.h" +#ifdef HAVE_LIBUCONTEXT +#include <libucontext/libucontext.h> +#define ucontext_t libucontext_ucontext_t +#define getcontext libucontext_getcontext +#define setcontext libucontext_setcontext +#define swapcontext libucontext_swapcontext +#define makecontext libucontext_makecontext +#else +#include <ucontext.h> +#endif + /* * va_args to makecontext() must be type 'int', so passing * the pointer we need may require several int args. This diff --git a/src/meson.build b/src/meson.build index a9dfc57..961779f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -146,7 +146,7 @@ endif if spice_gtk_coroutine == 'gthread' spice_client_glib_sources += 'coroutine_gthread.c' -elif spice_gtk_coroutine == 'ucontext' +elif spice_gtk_coroutine in ['ucontext', 'libucontext'] spice_client_glib_sources += ['continuation.c', 'continuation.h', 'coroutine_ucontext.c'] |