[PATCH 10/19] include/glib-compat.h: Poison g_list_sort and g_slist_sort

Kohei Tokunaga posted 19 patches 8 months, 1 week ago
There is a newer version of this series
[PATCH 10/19] include/glib-compat.h: Poison g_list_sort and g_slist_sort
Posted by Kohei Tokunaga 8 months, 1 week ago
On emscripten, function pointer casts can cause function call
failure. g_list_sort and g_slist_sort performs this internally so can't be
used on Emscripten. Instead, g_list_sort_with_data and
g_slist_sort_with_data should be used.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
---
 include/glib-compat.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/glib-compat.h b/include/glib-compat.h
index 86be439ba0..e441b396ef 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -36,6 +36,12 @@
 #include <pwd.h>
 #endif
 
+/* These functions perform function pointer casts which can cause function call
+ * failure on Emscripten. Use g_slist_sort_with_data and g_list_sort_with_data
+ * insted of these functions.
+ */
+#pragma GCC poison g_slist_sort g_list_sort
+
 /*
  * Note that because of the GLIB_VERSION_MAX_ALLOWED constant above, allowing
  * use of functions from newer GLib via this compat header needs a little
-- 
2.25.1
Re: [PATCH 10/19] include/glib-compat.h: Poison g_list_sort and g_slist_sort
Posted by BALATON Zoltan 8 months, 1 week ago
On Wed, 16 Apr 2025, Kohei Tokunaga wrote:
> On emscripten, function pointer casts can cause function call
> failure. g_list_sort and g_slist_sort performs this internally so can't be
> used on Emscripten. Instead, g_list_sort_with_data and
> g_slist_sort_with_data should be used.
>
> Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
> ---
> include/glib-compat.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/glib-compat.h b/include/glib-compat.h
> index 86be439ba0..e441b396ef 100644
> --- a/include/glib-compat.h
> +++ b/include/glib-compat.h
> @@ -36,6 +36,12 @@
> #include <pwd.h>
> #endif
>
> +/* These functions perform function pointer casts which can cause function call
> + * failure on Emscripten. Use g_slist_sort_with_data and g_list_sort_with_data
> + * insted of these functions.

Typo: instead

Regards,
BALATON Zoltan

> + */
> +#pragma GCC poison g_slist_sort g_list_sort
> +
> /*
>  * Note that because of the GLIB_VERSION_MAX_ALLOWED constant above, allowing
>  * use of functions from newer GLib via this compat header needs a little
>
Re: [PATCH 10/19] include/glib-compat.h: Poison g_list_sort and g_slist_sort
Posted by Kohei Tokunaga 8 months ago
Hi Balaton,

> Typo: instead

Thank you for the feedback. I'll fix this in the next version of the series.