[Spice-commits] meson.build meson_options.txt src/continuation.c src/meson.build

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Mar 6 14:45:52 UTC 2022


 meson.build        |    7 +++++++
 meson_options.txt  |    2 +-
 src/continuation.c |   12 +++++++++++-
 src/meson.build    |    2 +-
 4 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit fa812c88492641005a768c72502a8953bd1223b2
Author: osy <osy at turing.llc>
Date:   Fri Mar 4 15:52:48 2022 -0800

    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.

diff --git a/meson.build b/meson.build
index 11173fd..ec13ac3 100644
--- a/meson.build
+++ b/meson.build
@@ -317,6 +317,13 @@ if spice_gtk_coroutine == 'ucontext'
   endif
   endif
 
+if spice_gtk_coroutine == 'libucontext'
+  d = dependency('libucontext')
+  spice_glib_deps += d
+  spice_gtk_config_data.set('WITH_UCONTEXT', '1')
+  spice_gtk_config_data.set('HAVE_LIBUCONTEXT', '1')
+endif
+
 if spice_gtk_coroutine == 'gthread'
   spice_gtk_config_data.set('WITH_GTHREAD', '1')
 endif
diff --git a/meson_options.txt b/meson_options.txt
index 3cbc7c6..5acfc9a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -45,7 +45,7 @@ option('usb-ids-path',
 option('coroutine',
     type : 'combo',
     value : 'auto',
-    choices : ['auto', 'ucontext', 'gthread', 'winfiber'],
+    choices : ['auto', 'ucontext', 'libucontext', 'gthread', 'winfiber'],
     description : 'Use ucontext or GThread for coroutines')
 
 option('introspection',
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']


More information about the Spice-commits mailing list