gtk2: force link with shm* functions from libandroid-shmem

This commit is contained in:
Leonid Pliushch 2020-01-04 23:47:27 +02:00 committed by Yaksh Bariya
parent ef7dc394e1
commit 450dc9498b
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
2 changed files with 89 additions and 1 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="GObject-based multi-platform GUI toolkit (legacy)"
TERMUX_PKG_LICENSE="LGPL-2.0"
TERMUX_PKG_MAINTAINER="Leonid Plyushch <leonid.plyushch@gmail.com>"
TERMUX_PKG_VERSION=2.24.32
TERMUX_PKG_REVISION=17
TERMUX_PKG_REVISION=18
TERMUX_PKG_SRCURL=https://github.com/GNOME/gtk/archive/${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=961678c64ad986029befd7bdd8ed3e3849e2c5e54d24affbc7d49758245c87fa
TERMUX_PKG_BUILD_IN_SRC=true

View File

@ -0,0 +1,88 @@
diff -uNr gtk-2.24.32/gdk/x11/gdkimage-x11.c gtk-2.24.32.mod/gdk/x11/gdkimage-x11.c
--- gtk-2.24.32/gdk/x11/gdkimage-x11.c 2018-01-08 23:35:39.000000000 +0200
+++ gtk-2.24.32.mod/gdk/x11/gdkimage-x11.c 2020-01-04 23:45:54.651752410 +0200
@@ -35,7 +35,83 @@
#ifdef USE_SHM
#include <sys/ipc.h>
-#include <sys/shm.h>
+#include <linux/shm.h>
+#include <dlfcn.h>
+
+#ifndef shmid_ds
+# define shmid_ds shmid64_ds
+#endif
+
+static void * (*android_shmat)(int shmid, const void *shmaddr, int shmflg) = NULL;
+static int (*android_shmdt)(const void *shmaddr) = NULL;
+static int (*android_shmget)(key_t key, size_t size, int shmflg) = NULL;
+static int (*android_shmctl)(int shmid, int cmd, struct shmid_ds *buf) = NULL;
+
+////
+
+static void * shmat(int shmid, const void *shmaddr, int shmflg) {
+ if (!android_shmat) {
+ void *handle = dlopen("@TERMUX_PREFIX@/lib/libandroid-shmem.so", RTLD_LOCAL | RTLD_LAZY);
+
+ if (!handle) {
+ abort();
+ }
+
+ android_shmat = dlsym(handle, "shmat");
+
+ dlclose(handle);
+ }
+
+ return android_shmat(shmid, shmaddr, shmflg);
+}
+
+static int shmdt(const void *shmaddr) {
+ if (!android_shmdt) {
+ void *handle = dlopen("@TERMUX_PREFIX@/lib/libandroid-shmem.so", RTLD_LOCAL | RTLD_LAZY);
+
+ if (!handle) {
+ abort();
+ }
+
+ android_shmdt = dlsym(handle, "shmdt");
+
+ dlclose(handle);
+ }
+
+ return android_shmdt(shmaddr);
+}
+
+static int shmget(key_t key, size_t size, int shmflg) {
+ if (!android_shmget) {
+ void *handle = dlopen("@TERMUX_PREFIX@/lib/libandroid-shmem.so", RTLD_LOCAL | RTLD_LAZY);
+
+ if (!handle) {
+ abort();
+ }
+
+ android_shmget = dlsym(handle, "shmget");
+
+ dlclose(handle);
+ }
+
+ return android_shmget(key, size, shmflg);
+}
+
+static int shmctl(int shmid, int cmd, struct shmid_ds *buf) {
+ if (!android_shmctl) {
+ void *handle = dlopen("@TERMUX_PREFIX@/lib/libandroid-shmem.so", RTLD_LOCAL | RTLD_LAZY);
+
+ if (!handle) {
+ abort();
+ }
+
+ android_shmctl = dlsym(handle, "shmctl");
+
+ dlclose(handle);
+ }
+
+ return android_shmctl(shmid, cmd, buf);
+}
#endif /* USE_SHM */
#include <X11/Xlib.h>