termux-packages/x11-packages/qemu-common/android-5/0008-fix-syscalls-android5.patch

210 lines
6.2 KiB
Diff
Raw Normal View History

2019-05-27 16:34:58 +02:00
diff -uNr qemu-4.0.0/linux-user/syscall.c qemu-4.0.0.mod/linux-user/syscall.c
--- qemu-4.0.0/linux-user/syscall.c 2019-05-01 02:55:06.401703214 +0300
+++ qemu-4.0.0.mod/linux-user/syscall.c 2019-05-01 02:56:06.894984667 +0300
2018-09-17 13:27:14 +02:00
@@ -42,7 +42,7 @@
#include <poll.h>
#include <sys/times.h>
#include <sys/shm.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
#include <sys/statfs.h>
#include <utime.h>
#include <sys/sysinfo.h>
2019-05-27 16:34:58 +02:00
@@ -76,12 +76,17 @@
2018-09-17 13:27:14 +02:00
#endif
#define termios host_termios
+#define termios2 host_termios2
+#define ktermios host_ktermios
#define winsize host_winsize
#define termio host_termio
#define sgttyb host_sgttyb /* same as target */
#define tchars host_tchars /* same as target */
#define ltchars host_ltchars /* same as target */
2019-05-27 16:34:58 +02:00
+#undef __ASM_GENERIC_TERMBITS_H
2018-09-17 13:27:14 +02:00
+#include <asm/termbits.h>
2019-05-27 16:34:58 +02:00
+
2018-09-17 13:27:14 +02:00
#include <linux/termios.h>
#include <linux/unistd.h>
#include <linux/cdrom.h>
2019-05-27 16:34:58 +02:00
@@ -244,6 +249,61 @@
2018-10-26 15:19:03 +02:00
#define __NR__llseek __NR_lseek
2018-09-17 13:27:14 +02:00
#endif
+_syscall0(int, vhangup)
+#ifdef __NR_msgctl
+_syscall3(int, msgctl, int, msqid, int, cmd, struct msqid_ds *, buf)
+#else
+static int
+msgctl (int msqid, int cmd, struct msqid_ds *buf)
+{
2018-10-26 15:19:03 +02:00
+ return syscall (__NR_ipc, IPCOP_msgctl, msqid, cmd | 0x100, 0, buf);
2018-09-17 13:27:14 +02:00
+}
+#endif
2018-10-26 15:19:03 +02:00
+
2018-09-17 13:27:14 +02:00
+#ifdef __NR_semget
+_syscall3(int, semget, key_t, key, int, nsems, int, semflg)
+#else
+static int
2018-10-26 15:19:03 +02:00
+semget (key_t key, int nsems, int semflg)
2018-09-17 13:27:14 +02:00
+{
2019-05-27 16:34:58 +02:00
+ return syscall (__NR_ipc, IPCOP_semget, key, nsems, semflg, NULL);
2018-09-17 13:27:14 +02:00
+}
+#endif
2018-10-26 15:19:03 +02:00
+
2018-09-17 13:27:14 +02:00
+_syscall1(int, adjtimex, struct timex *, buf)
+_syscall2(int, sethostname, const char *, name, size_t, len)
+_syscall2(int, setdomainname, const char *, name, size_t, len)
+#ifdef __NR_msgget
+_syscall2(int, msgget, key_t, key, int, msgflg)
+#else
+static int
2018-10-26 15:19:03 +02:00
+msgget (key_t key, int msgflg)
2018-09-17 13:27:14 +02:00
+{
2018-10-26 15:19:03 +02:00
+ return syscall(__NR_ipc, 5, IPCOP_msgget, key, msgflg, 0, NULL);
2018-09-17 13:27:14 +02:00
+}
+#endif
+
+#ifdef _NSIG_WORDS
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ for (i = 0; i < _NSIG_WORDS; i++)
+ dest->sig[i] = a->sig[i] | b->sig[i];
+ return 0;
+}
+#else
+static int sigorset(sigset_t *dest, const sigset_t *a, const sigset_t *b)
+{
+ int i;
+ if (!dest || !a || !b)
+ return -1;
+ *dest = *a | *b;
+ return 0;
+}
+#endif
+
2018-10-26 15:19:03 +02:00
/* Newer kernel ports have llseek() instead of _llseek() */
#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek)
#define TARGET_NR__llseek TARGET_NR_llseek
2019-05-27 16:34:58 +02:00
@@ -806,6 +866,9 @@
2018-09-17 13:27:14 +02:00
size_t, len, unsigned, prio, const struct timespec *, timeout)
safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr,
size_t, len, unsigned *, prio, const struct timespec *, timeout)
+_syscall1(int, mq_unlink, const char *, name)
+_syscall4(__kernel_mqd_t, mq_open, const char *, name, int, oflag, mode_t, mode,
+ struct mq_attr *, attr)
#endif
/* We do ioctl like this rather than via safe_syscall3 to preserve the
* "third argument might be integer or pointer or not present" behaviour of
2019-05-27 16:34:58 +02:00
@@ -1184,7 +1247,7 @@
2018-09-17 13:27:14 +02:00
}
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
-#include <mqueue.h>
+#include <linux/mqueue.h>
static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr,
abi_ulong target_mq_attr_addr)
2019-05-27 16:34:58 +02:00
@@ -3231,6 +3294,8 @@
2018-09-17 13:27:14 +02:00
return 0;
}
+#define semid_ds __kernel_legacy_semid_ds
+
static inline abi_long target_to_host_semid_ds(struct semid_ds *host_sd,
abi_ulong target_addr)
{
2019-05-27 16:34:58 +02:00
@@ -3310,6 +3375,16 @@
2018-09-17 13:27:14 +02:00
abi_ulong __buf;
};
+#ifdef __NR_semctl
+_syscall4(int, semctl, int, semid, int, semnum, int, cmd, union semun, arg4)
+#else
+static int semctl(int semid, int semnum, int cmd, union semun arg4)
+{
+ return syscall(__NR_ipc, IPCOP_semctl, semid, semnum, cmd | 0x100,
2018-10-26 15:19:03 +02:00
+ arg4.__buf);
2018-09-17 13:27:14 +02:00
+}
+#endif
+
static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,
abi_ulong target_addr)
{
2019-05-27 16:34:58 +02:00
@@ -3440,7 +3515,7 @@
2018-09-17 13:27:14 +02:00
case GETPID:
case GETNCNT:
case GETZCNT:
- ret = get_errno(semctl(semid, semnum, cmd, NULL));
+ ret = get_errno(semctl(semid, semnum, cmd, (union semun) {.buf = NULL}));
break;
}
2019-05-27 16:34:58 +02:00
@@ -3522,7 +3597,7 @@
2018-09-17 13:27:14 +02:00
host_md->msg_stime = tswapal(target_md->msg_stime);
host_md->msg_rtime = tswapal(target_md->msg_rtime);
host_md->msg_ctime = tswapal(target_md->msg_ctime);
- host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes);
+ host_md->msg_cbytes = tswapal(target_md->__msg_cbytes);
host_md->msg_qnum = tswapal(target_md->msg_qnum);
host_md->msg_qbytes = tswapal(target_md->msg_qbytes);
host_md->msg_lspid = tswapal(target_md->msg_lspid);
2019-05-27 16:34:58 +02:00
@@ -3543,7 +3618,7 @@
2018-09-17 13:27:14 +02:00
target_md->msg_stime = tswapal(host_md->msg_stime);
target_md->msg_rtime = tswapal(host_md->msg_rtime);
target_md->msg_ctime = tswapal(host_md->msg_ctime);
- target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes);
+ target_md->__msg_cbytes = tswapal(host_md->msg_cbytes);
target_md->msg_qnum = tswapal(host_md->msg_qnum);
target_md->msg_qbytes = tswapal(host_md->msg_qbytes);
target_md->msg_lspid = tswapal(host_md->msg_lspid);
2019-05-27 16:34:58 +02:00
@@ -4799,6 +4874,9 @@
2018-09-17 13:27:14 +02:00
}
#endif
+#undef winsize
+#undef termio
+
static IOCTLEntry ioctl_entries[] = {
#define IOCTL(cmd, access, ...) \
{ TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
2019-05-27 16:34:58 +02:00
@@ -7378,7 +7456,7 @@
2018-09-17 13:27:14 +02:00
unlock_user(p, arg1, 0);
return ret;
2018-09-17 13:27:14 +02:00
#endif
-#ifdef TARGET_NR_stime /* not on alpha */
2018-10-26 15:19:03 +02:00
+#if 0 //def TARGET_NR_stime /* not on alpha */
2018-09-17 13:27:14 +02:00
case TARGET_NR_stime:
{
time_t host_time;
2019-05-27 16:34:58 +02:00
@@ -7440,7 +7518,7 @@
2018-09-17 13:27:14 +02:00
}
return ret;
2018-09-17 13:27:14 +02:00
#endif
-#if defined(TARGET_NR_futimesat)
+#if 0 && defined(TARGET_NR_futimesat)
case TARGET_NR_futimesat:
{
struct timeval *tvp, tv[2];
2019-05-27 16:34:58 +02:00
@@ -11056,7 +11134,7 @@
/* Not implemented for now... */
2018-09-17 13:27:14 +02:00
/* case TARGET_NR_mq_notify: */
/* break; */
2019-05-27 16:34:58 +02:00
-
2018-09-17 13:27:14 +02:00
+#if 0
case TARGET_NR_mq_getsetattr:
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
2019-05-27 16:34:58 +02:00
@@ -11074,6 +11152,7 @@
2018-09-17 13:27:14 +02:00
}
return ret;
2018-09-17 13:27:14 +02:00
#endif
+#endif
#ifdef CONFIG_SPLICE
#ifdef TARGET_NR_tee