0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-04 18:45:52 +00:00
termux-packages/packages/mesa/0006-wsi-no-pthread_cancel.patch
2024-10-30 15:22:21 +02:00

86 lines
2.1 KiB
Diff

+++ ./src/vulkan/wsi/wsi_common_display.c
@@ -176,6 +176,12 @@
static uint64_t fence_sequence;
+#ifdef __ANDROID__
+static void thread_signal_handler (int signum) {
+ pthread_exit (0);
+}
+#endif
+
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_mode, VkDisplayModeKHR)
ICD_DEFINE_NONDISP_HANDLE_CASTS(wsi_display_connector, VkDisplayKHR)
@@ -1341,7 +1347,9 @@
.events = POLLIN
};
+#ifndef __ANDROID__
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif
for (;;) {
int ret = poll(&pollfd, 1, -1);
if (ret > 0) {
@@ -1369,9 +1377,22 @@
static void
wsi_display_stop_wait_thread(struct wsi_display *wsi)
{
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset (&actions, 0, sizeof (actions));
+ sigemptyset (&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction (SIGUSR2, &actions, NULL);
+#endif
+
mtx_lock(&wsi->wait_mutex);
if (wsi->wait_thread) {
+#ifndef __ANDROID__
pthread_cancel(wsi->wait_thread);
+#else
+ pthread_kill(wsi->wait_thread, SIGUSR2);
+#endif
pthread_join(wsi->wait_thread, NULL);
wsi->wait_thread = 0;
}
@@ -2215,7 +2236,9 @@
int udev_fd = udev_monitor_get_fd(mon);
+#ifndef __ANDROID__
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+#endif
for (;;) {
nfds_t nfds = 1;
@@ -2340,6 +2363,15 @@
struct wsi_display *wsi =
(struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset (&actions, 0, sizeof (actions));
+ sigemptyset (&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction (SIGUSR2, &actions, NULL);
+#endif
+
if (wsi) {
wsi_for_each_connector(connector, wsi) {
wsi_for_each_display_mode(mode, connector) {
@@ -2351,7 +2383,11 @@
wsi_display_stop_wait_thread(wsi);
if (wsi->hotplug_thread) {
+#ifndef __ANDROID__
pthread_cancel(wsi->hotplug_thread);
+#else
+ pthread_kill(wsi->hotplug_thread, SIGUSR2);
+#endif
pthread_join(wsi->hotplug_thread, NULL);
}