aboutsummaryrefslogtreecommitdiff
path: root/emulators/qemu-devel
diff options
context:
space:
mode:
authorJuergen Lock <nox@FreeBSD.org>2014-11-08 11:48:13 +0000
committerJuergen Lock <nox@FreeBSD.org>2014-11-08 11:48:13 +0000
commitc126e97c4c4d14de02e888229e488fa64c374d8b (patch)
treede339ec4f33c51813d0272be2eecfe724a1c9bb9 /emulators/qemu-devel
parent2e8f7f1e45e5b70e4e92a0a79c909e77cffa4274 (diff)
downloadports-c126e97c4c4d14de02e888229e488fa64c374d8b.tar.gz
ports-c126e97c4c4d14de02e888229e488fa64c374d8b.zip
Notes
Diffstat (limited to 'emulators/qemu-devel')
-rw-r--r--emulators/qemu-devel/Makefile18
-rw-r--r--emulators/qemu-devel/files/extra-patch-1ebbb5b56e890741f1461662fae9728da0c76e2772
-rw-r--r--emulators/qemu-devel/files/extra-patch-22b23eb877a8a5ec251b4ae0e71e3c7ce53977211051
-rw-r--r--emulators/qemu-devel/files/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8-before1119
-rw-r--r--emulators/qemu-devel/files/extra-patch-30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b40851
-rw-r--r--emulators/qemu-devel/files/extra-patch-3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca2763
-rw-r--r--emulators/qemu-devel/files/extra-patch-5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6201
-rw-r--r--emulators/qemu-devel/files/extra-patch-72f0a64c7dd7be796dc2d8f2b0dab340309800e245
-rw-r--r--emulators/qemu-devel/files/extra-patch-93cf90cb04fee057a710be43614b033e6b2e86d1100
-rw-r--r--emulators/qemu-devel/files/extra-patch-9ed0e07e2e07791858339874eb4d20daca858c8a77
-rw-r--r--emulators/qemu-devel/files/extra-patch-a6402a4b7077af85733a1c98d63ab09f02d980ec173
-rw-r--r--emulators/qemu-devel/files/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b108
-rw-r--r--emulators/qemu-devel/files/extra-patch-ac9f83019a2059d4bfe5cedfae35ba4151d5ac88226
-rw-r--r--emulators/qemu-devel/files/extra-patch-ad225b8412847303d48d8e7852589456325e8f9b36
-rw-r--r--emulators/qemu-devel/files/extra-patch-c9c55ac786f09ce575b5f67b35241ce9452896c9224
-rw-r--r--emulators/qemu-devel/files/extra-patch-d9388715135ed1f36e12e6cdbcc1be09d1657916112
-rw-r--r--emulators/qemu-devel/files/extra-patch-f32d585446698e1faa319c95df6b4d00c16f866c81
17 files changed, 2636 insertions, 21 deletions
diff --git a/emulators/qemu-devel/Makefile b/emulators/qemu-devel/Makefile
index b34b0190928c..203b56e50f88 100644
--- a/emulators/qemu-devel/Makefile
+++ b/emulators/qemu-devel/Makefile
@@ -3,7 +3,7 @@
PORTNAME= qemu
PORTVERSION= 2.0.2
-PORTREVISION= 5
+PORTREVISION= 6
CATEGORIES= emulators
MASTER_SITES= http://wiki.qemu.org/download/:release \
LOCAL/nox:snapshot
@@ -81,7 +81,21 @@ EXTRA_PATCHES+= ${FILESDIR}/extra-patch-sysctl-hw-physmem
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-max-arg-pages
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-ad92220df37d1ab3120316fcc436071c78817561
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8
-EXTRA_PATCHES+= ${FILESDIR}/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8-before11
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-ac9f83019a2059d4bfe5cedfae35ba4151d5ac88
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-d9388715135ed1f36e12e6cdbcc1be09d1657916
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-c9c55ac786f09ce575b5f67b35241ce9452896c9
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-f32d585446698e1faa319c95df6b4d00c16f866c
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-a6402a4b7077af85733a1c98d63ab09f02d980ec
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b408
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-22b23eb877a8a5ec251b4ae0e71e3c7ce5397721
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-1ebbb5b56e890741f1461662fae9728da0c76e27
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-93cf90cb04fee057a710be43614b033e6b2e86d1
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-ad225b8412847303d48d8e7852589456325e8f9b
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca27
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-72f0a64c7dd7be796dc2d8f2b0dab340309800e2
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-9ed0e07e2e07791858339874eb4d20daca858c8a
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b
.endif
CONFIGURE_ARGS+= --extra-ldflags=-L${LOCALBASE}/lib
diff --git a/emulators/qemu-devel/files/extra-patch-1ebbb5b56e890741f1461662fae9728da0c76e27 b/emulators/qemu-devel/files/extra-patch-1ebbb5b56e890741f1461662fae9728da0c76e27
new file mode 100644
index 000000000000..2ce53dcf5d9a
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-1ebbb5b56e890741f1461662fae9728da0c76e27
@@ -0,0 +1,72 @@
+From 1ebbb5b56e890741f1461662fae9728da0c76e27 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Thu, 6 Nov 2014 22:35:01 +0000
+Subject: [PATCH] Add JHB's ioctl decoding to unknown ioctl message.
+
+---
+ bsd-user/bsd-ioctl.c | 31 ++++++++++++++++++++++++++++---
+ 1 file changed, 28 insertions(+), 3 deletions(-)
+
+diff --git a/bsd-user/bsd-ioctl.c b/bsd-user/bsd-ioctl.c
+index 95505a4..10e8e54 100644
+--- a/bsd-user/bsd-ioctl.c
++++ b/bsd-user/bsd-ioctl.c
+@@ -19,6 +19,7 @@
+
+ #include <sys/types.h>
+ #include <sys/param.h>
++#include <sys/ioccom.h>
+ #include <sys/ioctl.h>
+ #if defined(__FreeBSD_version) && __FreeBSD_version > 900000
+ #include <sys/_termios.h>
+@@ -307,6 +308,29 @@ static IOCTLEntry ioctl_entries[] = {
+ { 0, 0 },
+ };
+
++static void log_unsupported_ioctl(unsigned long cmd)
++{
++ gemu_log("cmd=0x%08lx dir=", cmd);
++ switch (cmd & IOC_DIRMASK) {
++ case IOC_VOID:
++ gemu_log("VOID ");
++ break;
++ case IOC_OUT:
++ gemu_log("OUT ");
++ break;
++ case IOC_IN:
++ gemu_log("IN ");
++ break;
++ case IOC_INOUT:
++ gemu_log("INOUT");
++ break;
++ default:
++ gemu_log("%01lx ???", (cmd & IOC_DIRMASK) >> 29);
++ break;
++ }
++ gemu_log(" '%c' %3d %lu\n", (char)IOCGROUP(cmd), (int)(cmd & 0xff), IOCPARM_LEN(cmd));
++}
++
+ abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
+ {
+ const IOCTLEntry *ie;
+@@ -319,7 +343,8 @@ abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
+ ie = ioctl_entries;
+ for (;;) {
+ if (ie->target_cmd == 0) {
+- gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd);
++ gemu_log("Qemu unsupported ioctl: ");
++ log_unsupported_ioctl(cmd);
+ return -TARGET_ENOSYS;
+ }
+ if (ie->target_cmd == cmd) {
+@@ -398,8 +423,8 @@ abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
+ break;
+
+ default:
+- gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n",
+- (long)cmd, arg_type[0]);
++ gemu_log("Qemu unknown ioctl: type=%d ", arg_type[0]);
++ log_unsupported_ioctl(cmd);
+ ret = -TARGET_ENOSYS;
+ break;
+ }
diff --git a/emulators/qemu-devel/files/extra-patch-22b23eb877a8a5ec251b4ae0e71e3c7ce5397721 b/emulators/qemu-devel/files/extra-patch-22b23eb877a8a5ec251b4ae0e71e3c7ce5397721
new file mode 100644
index 000000000000..59d262be4fcc
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-22b23eb877a8a5ec251b4ae0e71e3c7ce5397721
@@ -0,0 +1,1051 @@
+From 22b23eb877a8a5ec251b4ae0e71e3c7ce5397721 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Thu, 6 Nov 2014 20:16:28 +0000
+Subject: [PATCH] Add bsd-user/freebsd/make_syscall_nr_h.sh to generate
+ syscall_nr.h.
+
+make_syscall_nr.h.sh is added so syscall_nr.h can be generated from
+<sys/syscall.h>. Maybe this should be configure or one of the
+makefiles. Also report "qemu: unsupported syscall: #" via gemu_log
+when we try to emulate an unsupported system call.
+---
+ bsd-user/freebsd/make_syscall_nr_h.sh | 26 +
+ bsd-user/freebsd/strace.list | 2 -
+ bsd-user/freebsd/syscall_nr.h | 918 +++++++++++++++++-----------------
+ bsd-user/syscall.c | 7 +
+ 4 files changed, 495 insertions(+), 458 deletions(-)
+ create mode 100644 bsd-user/freebsd/make_syscall_nr_h.sh
+
+diff --git a/bsd-user/freebsd/make_syscall_nr_h.sh b/bsd-user/freebsd/make_syscall_nr_h.sh
+new file mode 100644
+index 0000000..cc180df
+--- /dev/null
++++ b/bsd-user/freebsd/make_syscall_nr_h.sh
+@@ -0,0 +1,26 @@
++#! /bin/sh -
++
++#
++# Usage: 'sh ./make_syscall_nr_h.sh [full path to syscall.h] [syscall_nr.h]'
++#
++
++#default input file:
++syshdr="/usr/include/sys/syscall.h"
++
++#default output file:
++sysnr="./syscall_nr.h"
++
++if [ -n "$1" ]; then
++ syshdr=$1
++fi
++
++if [ -n "$2" ]; then
++ sysnr=$2
++fi
++
++echo "/*" > $sysnr
++echo " * This file was generated from $syshdr" >> $sysnr
++echo " */" >> $sysnr
++echo "" >> $sysnr
++
++/usr/bin/sed -e 's:SYS_:TARGET_FREEBSD_NR_:' < $syshdr >> $sysnr
+diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
+index cba4afe..e09048f 100644
+--- a/bsd-user/freebsd/strace.list
++++ b/bsd-user/freebsd/strace.list
+@@ -45,10 +45,8 @@
+ { TARGET_FREEBSD_NR_cap_fcntls_get, "cap_fcntls_get", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_fcntls_limit, "cap_fcntls_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_getmode, "cap_getmode", NULL, NULL, NULL },
+-{ TARGET_FREEBSD_NR_cap_getrights, "cap_getrights", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_ioctls_get, "cap_ioctls_get", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_ioctls_limit, "cap_ioctls_limit", NULL, NULL, NULL },
+-{ TARGET_FREEBSD_NR_cap_new, "cap_new", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_rights_limit, "cap_rights_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
+ { TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL },
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index 7d6bef8..74c3135 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -1,463 +1,469 @@
+ /*
++ * This file was generated from /usr/include/sys/syscall.h
++ */
++
++/*
+ * System call numbers.
+ *
+- * created from FreeBSD: releng/9.1/sys/kern/syscalls.master 229723
+- * 2012-01-06 19:29:16Z jhb
++ * DO NOT EDIT-- this file is automatically generated.
++ * $FreeBSD$
++ * created from FreeBSD: head/sys/kern/syscalls.master 272823 2014-10-09 15:16:52Z marcel
+ */
+
+-#define TARGET_FREEBSD_NR_syscall 0
+-#define TARGET_FREEBSD_NR_exit 1
+-#define TARGET_FREEBSD_NR_fork 2
+-#define TARGET_FREEBSD_NR_read 3
+-#define TARGET_FREEBSD_NR_write 4
+-#define TARGET_FREEBSD_NR_open 5
+-#define TARGET_FREEBSD_NR_close 6
+-#define TARGET_FREEBSD_NR_wait4 7
+- /* 8 is old creat */
+-#define TARGET_FREEBSD_NR_link 9
+-#define TARGET_FREEBSD_NR_unlink 10
+- /* 11 is obsolete execv */
+-#define TARGET_FREEBSD_NR_chdir 12
+-#define TARGET_FREEBSD_NR_fchdir 13
+-#define TARGET_FREEBSD_NR_mknod 14
+-#define TARGET_FREEBSD_NR_chmod 15
+-#define TARGET_FREEBSD_NR_chown 16
+-#define TARGET_FREEBSD_NR_break 17
+-#define TARGET_FREEBSD_NR_freebsd4_getfsstat 18
+- /* 19 is old lseek */
+-#define TARGET_FREEBSD_NR_getpid 20
+-#define TARGET_FREEBSD_NR_mount 21
+-#define TARGET_FREEBSD_NR_unmount 22
+-#define TARGET_FREEBSD_NR_setuid 23
+-#define TARGET_FREEBSD_NR_getuid 24
+-#define TARGET_FREEBSD_NR_geteuid 25
+-#define TARGET_FREEBSD_NR_ptrace 26
+-#define TARGET_FREEBSD_NR_recvmsg 27
+-#define TARGET_FREEBSD_NR_sendmsg 28
+-#define TARGET_FREEBSD_NR_recvfrom 29
+-#define TARGET_FREEBSD_NR_accept 30
+-#define TARGET_FREEBSD_NR_getpeername 31
+-#define TARGET_FREEBSD_NR_getsockname 32
+-#define TARGET_FREEBSD_NR_access 33
+-#define TARGET_FREEBSD_NR_chflags 34
+-#define TARGET_FREEBSD_NR_fchflags 35
+-#define TARGET_FREEBSD_NR_sync 36
+-#define TARGET_FREEBSD_NR_kill 37
+- /* 38 is old stat */
+-#define TARGET_FREEBSD_NR_getppid 39
+- /* 40 is old lstat */
+-#define TARGET_FREEBSD_NR_dup 41
+-#define TARGET_FREEBSD_NR_pipe 42
+-#define TARGET_FREEBSD_NR_getegid 43
+-#define TARGET_FREEBSD_NR_profil 44
+-#define TARGET_FREEBSD_NR_ktrace 45
+- /* 46 is old sigaction */
+-#define TARGET_FREEBSD_NR_getgid 47
+- /* 48 is old sigprocmask */
+-#define TARGET_FREEBSD_NR_getlogin 49
+-#define TARGET_FREEBSD_NR_setlogin 50
+-#define TARGET_FREEBSD_NR_acct 51
+- /* 52 is old sigpending */
+-#define TARGET_FREEBSD_NR_sigaltstack 53
+-#define TARGET_FREEBSD_NR_ioctl 54
+-#define TARGET_FREEBSD_NR_reboot 55
+-#define TARGET_FREEBSD_NR_revoke 56
+-#define TARGET_FREEBSD_NR_symlink 57
+-#define TARGET_FREEBSD_NR_readlink 58
+-#define TARGET_FREEBSD_NR_execve 59
+-#define TARGET_FREEBSD_NR_umask 60
+-#define TARGET_FREEBSD_NR_chroot 61
+- /* 62 is old fstat */
+- /* 63 is old getkerninfo */
+- /* 64 is old getpagesize */
+-#define TARGET_FREEBSD_NR_msync 65
+-#define TARGET_FREEBSD_NR_vfork 66
+- /* 67 is obsolete vread */
+- /* 68 is obsolete vwrite */
+-#define TARGET_FREEBSD_NR_sbrk 69
+-#define TARGET_FREEBSD_NR_sstk 70
+- /* 71 is old mmap */
+-#define TARGET_FREEBSD_NR_vadvise 72
+-#define TARGET_FREEBSD_NR_munmap 73
+-#define TARGET_FREEBSD_NR_mprotect 74
+-#define TARGET_FREEBSD_NR_madvise 75
+- /* 76 is obsolete vhangup */
+- /* 77 is obsolete vlimit */
+-#define TARGET_FREEBSD_NR_mincore 78
+-#define TARGET_FREEBSD_NR_getgroups 79
+-#define TARGET_FREEBSD_NR_setgroups 80
+-#define TARGET_FREEBSD_NR_getpgrp 81
+-#define TARGET_FREEBSD_NR_setpgid 82
+-#define TARGET_FREEBSD_NR_setitimer 83
+- /* 84 is old wait */
+-#define TARGET_FREEBSD_NR_swapon 85
+-#define TARGET_FREEBSD_NR_getitimer 86
+- /* 87 is old gethostname */
+- /* 88 is old sethostname */
+-#define TARGET_FREEBSD_NR_getdtablesize 89
+-#define TARGET_FREEBSD_NR_dup2 90
+-#define TARGET_FREEBSD_NR_fcntl 92
+-#define TARGET_FREEBSD_NR_select 93
+-#define TARGET_FREEBSD_NR_fsync 95
+-#define TARGET_FREEBSD_NR_setpriority 96
+-#define TARGET_FREEBSD_NR_socket 97
+-#define TARGET_FREEBSD_NR_connect 98
+- /* 99 is old accept */
+-#define TARGET_FREEBSD_NR_getpriority 100
+- /* 101 is old send */
+- /* 102 is old recv */
+- /* 103 is old sigreturn */
+-#define TARGET_FREEBSD_NR_bind 104
+-#define TARGET_FREEBSD_NR_setsockopt 105
+-#define TARGET_FREEBSD_NR_listen 106
+- /* 107 is obsolete vtimes */
+- /* 108 is old sigvec */
+- /* 109 is old sigblock */
+- /* 110 is old sigsetmask */
+- /* 111 is old sigsuspend */
+- /* 112 is old sigstack */
+- /* 113 is old recvmsg */
+- /* 114 is old sendmsg */
+- /* 115 is obsolete vtrace */
+-#define TARGET_FREEBSD_NR_gettimeofday 116
+-#define TARGET_FREEBSD_NR_getrusage 117
+-#define TARGET_FREEBSD_NR_getsockopt 118
+-#define TARGET_FREEBSD_NR_readv 120
+-#define TARGET_FREEBSD_NR_writev 121
+-#define TARGET_FREEBSD_NR_settimeofday 122
+-#define TARGET_FREEBSD_NR_fchown 123
+-#define TARGET_FREEBSD_NR_fchmod 124
+- /* 125 is old recvfrom */
+-#define TARGET_FREEBSD_NR_setreuid 126
+-#define TARGET_FREEBSD_NR_setregid 127
+-#define TARGET_FREEBSD_NR_rename 128
+- /* 129 is old truncate */
+- /* 130 is old ftruncate */
+-#define TARGET_FREEBSD_NR_flock 131
+-#define TARGET_FREEBSD_NR_mkfifo 132
+-#define TARGET_FREEBSD_NR_sendto 133
+-#define TARGET_FREEBSD_NR_shutdown 134
+-#define TARGET_FREEBSD_NR_socketpair 135
+-#define TARGET_FREEBSD_NR_mkdir 136
+-#define TARGET_FREEBSD_NR_rmdir 137
+-#define TARGET_FREEBSD_NR_utimes 138
+- /* 139 is obsolete 4.2 sigreturn */
+-#define TARGET_FREEBSD_NR_adjtime 140
+- /* 141 is old getpeername */
+- /* 142 is old gethostid */
+- /* 143 is old sethostid */
+- /* 144 is old getrlimit */
+- /* 145 is old setrlimit */
+- /* 146 is old killpg */
+-#define TARGET_FREEBSD_NR_killpg 146 /* COMPAT */
+-#define TARGET_FREEBSD_NR_setsid 147
+-#define TARGET_FREEBSD_NR_quotactl 148
+- /* 149 is old quota */
+- /* 150 is old getsockname */
+-#define TARGET_FREEBSD_NR_nlm_syscall 154
+-#define TARGET_FREEBSD_NR_nfssvc 155
+- /* 156 is old getdirentries */
+-#define TARGET_FREEBSD_NR_freebsd4_statfs 157
+-#define TARGET_FREEBSD_NR_freebsd4_fstatfs 158
+-#define TARGET_FREEBSD_NR_lgetfh 160
+-#define TARGET_FREEBSD_NR_getfh 161
+-#define TARGET_FREEBSD_NR_freebsd4_getdomainname 162
+-#define TARGET_FREEBSD_NR_freebsd4_setdomainname 163
+-#define TARGET_FREEBSD_NR_freebsd4_uname 164
+-#define TARGET_FREEBSD_NR_sysarch 165
+-#define TARGET_FREEBSD_NR_rtprio 166
+-#define TARGET_FREEBSD_NR_semsys 169
+-#define TARGET_FREEBSD_NR_msgsys 170
+-#define TARGET_FREEBSD_NR_shmsys 171
+-#define TARGET_FREEBSD_NR_freebsd6_pread 173
+-#define TARGET_FREEBSD_NR_freebsd6_pwrite 174
+-#define TARGET_FREEBSD_NR_setfib 175
+-#define TARGET_FREEBSD_NR_ntp_adjtime 176
+-#define TARGET_FREEBSD_NR_setgid 181
+-#define TARGET_FREEBSD_NR_setegid 182
+-#define TARGET_FREEBSD_NR_seteuid 183
+-#define TARGET_FREEBSD_NR_stat 188
+-#define TARGET_FREEBSD_NR_fstat 189
+-#define TARGET_FREEBSD_NR_lstat 190
+-#define TARGET_FREEBSD_NR_pathconf 191
+-#define TARGET_FREEBSD_NR_fpathconf 192
+-#define TARGET_FREEBSD_NR_getrlimit 194
+-#define TARGET_FREEBSD_NR_setrlimit 195
+-#define TARGET_FREEBSD_NR_getdirentries 196
+-#define TARGET_FREEBSD_NR_freebsd6_mmap 197
+-#define TARGET_FREEBSD_NR___syscall 198
+-#define TARGET_FREEBSD_NR_freebsd6_lseek 199
+-#define TARGET_FREEBSD_NR_freebsd6_truncate 200
+-#define TARGET_FREEBSD_NR_freebsd6_ftruncate 201
+-#define TARGET_FREEBSD_NR___sysctl 202
+-#define TARGET_FREEBSD_NR_mlock 203
+-#define TARGET_FREEBSD_NR_munlock 204
+-#define TARGET_FREEBSD_NR_undelete 205
+-#define TARGET_FREEBSD_NR_futimes 206
+-#define TARGET_FREEBSD_NR_getpgid 207
+-#define TARGET_FREEBSD_NR_poll 209
+-#define TARGET_FREEBSD_NR_freebsd7___semctl 220
+-#define TARGET_FREEBSD_NR_semget 221
+-#define TARGET_FREEBSD_NR_semop 222
+-#define TARGET_FREEBSD_NR_freebsd7_msgctl 224
+-#define TARGET_FREEBSD_NR_msgget 225
+-#define TARGET_FREEBSD_NR_msgsnd 226
+-#define TARGET_FREEBSD_NR_msgrcv 227
+-#define TARGET_FREEBSD_NR_shmat 228
+-#define TARGET_FREEBSD_NR_freebsd7_shmctl 229
+-#define TARGET_FREEBSD_NR_shmdt 230
+-#define TARGET_FREEBSD_NR_shmget 231
+-#define TARGET_FREEBSD_NR_clock_gettime 232
+-#define TARGET_FREEBSD_NR_clock_settime 233
+-#define TARGET_FREEBSD_NR_clock_getres 234
+-#define TARGET_FREEBSD_NR_ktimer_create 235
+-#define TARGET_FREEBSD_NR_ktimer_delete 236
+-#define TARGET_FREEBSD_NR_ktimer_settime 237
+-#define TARGET_FREEBSD_NR_ktimer_gettime 238
+-#define TARGET_FREEBSD_NR_ktimer_getoverrun 239
+-#define TARGET_FREEBSD_NR_nanosleep 240
+-#define TARGET_FREEBSD_NR_ntp_gettime 248
+-#define TARGET_FREEBSD_NR_minherit 250
+-#define TARGET_FREEBSD_NR_rfork 251
+-#define TARGET_FREEBSD_NR_openbsd_poll 252
+-#define TARGET_FREEBSD_NR_issetugid 253
+-#define TARGET_FREEBSD_NR_lchown 254
+-#define TARGET_FREEBSD_NR_aio_read 255
+-#define TARGET_FREEBSD_NR_aio_write 256
+-#define TARGET_FREEBSD_NR_lio_listio 257
+-#define TARGET_FREEBSD_NR_getdents 272
+-#define TARGET_FREEBSD_NR_lchmod 274
+-#define TARGET_FREEBSD_NR_netbsd_lchown 275
+-#define TARGET_FREEBSD_NR_lutimes 276
+-#define TARGET_FREEBSD_NR_netbsd_msync 277
+-#define TARGET_FREEBSD_NR_nstat 278
+-#define TARGET_FREEBSD_NR_nfstat 279
+-#define TARGET_FREEBSD_NR_nlstat 280
+-#define TARGET_FREEBSD_NR_preadv 289
+-#define TARGET_FREEBSD_NR_pwritev 290
+-#define TARGET_FREEBSD_NR_freebsd4_fhstatfs 297
+-#define TARGET_FREEBSD_NR_fhopen 298
+-#define TARGET_FREEBSD_NR_fhstat 299
+-#define TARGET_FREEBSD_NR_modnext 300
+-#define TARGET_FREEBSD_NR_modstat 301
+-#define TARGET_FREEBSD_NR_modfnext 302
+-#define TARGET_FREEBSD_NR_modfind 303
+-#define TARGET_FREEBSD_NR_kldload 304
+-#define TARGET_FREEBSD_NR_kldunload 305
+-#define TARGET_FREEBSD_NR_kldfind 306
+-#define TARGET_FREEBSD_NR_kldnext 307
+-#define TARGET_FREEBSD_NR_kldstat 308
+-#define TARGET_FREEBSD_NR_kldfirstmod 309
+-#define TARGET_FREEBSD_NR_getsid 310
+-#define TARGET_FREEBSD_NR_setresuid 311
+-#define TARGET_FREEBSD_NR_setresgid 312
+- /* 313 is obsolete signanosleep */
+-#define TARGET_FREEBSD_NR_aio_return 314
+-#define TARGET_FREEBSD_NR_aio_suspend 315
+-#define TARGET_FREEBSD_NR_aio_cancel 316
+-#define TARGET_FREEBSD_NR_aio_error 317
+-#define TARGET_FREEBSD_NR_oaio_read 318
+-#define TARGET_FREEBSD_NR_oaio_write 319
+-#define TARGET_FREEBSD_NR_olio_listio 320
+-#define TARGET_FREEBSD_NR_yield 321
+- /* 322 is obsolete thr_sleep */
+- /* 323 is obsolete thr_wakeup */
+-#define TARGET_FREEBSD_NR_mlockall 324
+-#define TARGET_FREEBSD_NR_munlockall 325
+-#define TARGET_FREEBSD_NR___getcwd 326
+-#define TARGET_FREEBSD_NR_sched_setparam 327
+-#define TARGET_FREEBSD_NR_sched_getparam 328
+-#define TARGET_FREEBSD_NR_sched_setscheduler 329
+-#define TARGET_FREEBSD_NR_sched_getscheduler 330
+-#define TARGET_FREEBSD_NR_sched_yield 331
+-#define TARGET_FREEBSD_NR_sched_get_priority_max 332
+-#define TARGET_FREEBSD_NR_sched_get_priority_min 333
+-#define TARGET_FREEBSD_NR_sched_rr_get_interval 334
+-#define TARGET_FREEBSD_NR_utrace 335
+-#define TARGET_FREEBSD_NR_freebsd4_sendfile 336
+-#define TARGET_FREEBSD_NR_kldsym 337
+-#define TARGET_FREEBSD_NR_jail 338
+-#define TARGET_FREEBSD_NR_nnpfs_syscall 339
+-#define TARGET_FREEBSD_NR_sigprocmask 340
+-#define TARGET_FREEBSD_NR_sigsuspend 341
+-#define TARGET_FREEBSD_NR_freebsd4_sigaction 342
+-#define TARGET_FREEBSD_NR_sigpending 343
+-#define TARGET_FREEBSD_NR_freebsd4_sigreturn 344
+-#define TARGET_FREEBSD_NR_sigtimedwait 345
+-#define TARGET_FREEBSD_NR_sigwaitinfo 346
+-#define TARGET_FREEBSD_NR___acl_get_file 347
+-#define TARGET_FREEBSD_NR___acl_set_file 348
+-#define TARGET_FREEBSD_NR___acl_get_fd 349
+-#define TARGET_FREEBSD_NR___acl_set_fd 350
+-#define TARGET_FREEBSD_NR___acl_delete_file 351
+-#define TARGET_FREEBSD_NR___acl_delete_fd 352
+-#define TARGET_FREEBSD_NR___acl_aclcheck_file 353
+-#define TARGET_FREEBSD_NR___acl_aclcheck_fd 354
+-#define TARGET_FREEBSD_NR_extattrctl 355
+-#define TARGET_FREEBSD_NR_extattr_set_file 356
+-#define TARGET_FREEBSD_NR_extattr_get_file 357
+-#define TARGET_FREEBSD_NR_extattr_delete_file 358
+-#define TARGET_FREEBSD_NR_aio_waitcomplete 359
+-#define TARGET_FREEBSD_NR_getresuid 360
+-#define TARGET_FREEBSD_NR_getresgid 361
+-#define TARGET_FREEBSD_NR_kqueue 362
+-#define TARGET_FREEBSD_NR_kevent 363
+-#define TARGET_FREEBSD_NR_extattr_set_fd 371
+-#define TARGET_FREEBSD_NR_extattr_get_fd 372
+-#define TARGET_FREEBSD_NR_extattr_delete_fd 373
+-#define TARGET_FREEBSD_NR___setugid 374
+-#define TARGET_FREEBSD_NR_eaccess 376
+-#define TARGET_FREEBSD_NR_afs3_syscall 377
+-#define TARGET_FREEBSD_NR_nmount 378
+-#define TARGET_FREEBSD_NR___mac_get_proc 384
+-#define TARGET_FREEBSD_NR___mac_set_proc 385
+-#define TARGET_FREEBSD_NR___mac_get_fd 386
+-#define TARGET_FREEBSD_NR___mac_get_file 387
+-#define TARGET_FREEBSD_NR___mac_set_fd 388
+-#define TARGET_FREEBSD_NR___mac_set_file 389
+-#define TARGET_FREEBSD_NR_kenv 390
+-#define TARGET_FREEBSD_NR_lchflags 391
+-#define TARGET_FREEBSD_NR_uuidgen 392
+-#define TARGET_FREEBSD_NR_sendfile 393
+-#define TARGET_FREEBSD_NR_mac_syscall 394
+-#define TARGET_FREEBSD_NR_getfsstat 395
+-#define TARGET_FREEBSD_NR_statfs 396
+-#define TARGET_FREEBSD_NR_fstatfs 397
+-#define TARGET_FREEBSD_NR_fhstatfs 398
+-#define TARGET_FREEBSD_NR_ksem_close 400
+-#define TARGET_FREEBSD_NR_ksem_post 401
+-#define TARGET_FREEBSD_NR_ksem_wait 402
+-#define TARGET_FREEBSD_NR_ksem_trywait 403
+-#define TARGET_FREEBSD_NR_ksem_init 404
+-#define TARGET_FREEBSD_NR_ksem_open 405
+-#define TARGET_FREEBSD_NR_ksem_unlink 406
+-#define TARGET_FREEBSD_NR_ksem_getvalue 407
+-#define TARGET_FREEBSD_NR_ksem_destroy 408
+-#define TARGET_FREEBSD_NR___mac_get_pid 409
+-#define TARGET_FREEBSD_NR___mac_get_link 410
+-#define TARGET_FREEBSD_NR___mac_set_link 411
+-#define TARGET_FREEBSD_NR_extattr_set_link 412
+-#define TARGET_FREEBSD_NR_extattr_get_link 413
+-#define TARGET_FREEBSD_NR_extattr_delete_link 414
+-#define TARGET_FREEBSD_NR___mac_execve 415
+-#define TARGET_FREEBSD_NR_sigaction 416
+-#define TARGET_FREEBSD_NR_sigreturn 417
+-#define TARGET_FREEBSD_NR_getcontext 421
+-#define TARGET_FREEBSD_NR_setcontext 422
+-#define TARGET_FREEBSD_NR_swapcontext 423
+-#define TARGET_FREEBSD_NR_swapoff 424
+-#define TARGET_FREEBSD_NR___acl_get_link 425
+-#define TARGET_FREEBSD_NR___acl_set_link 426
+-#define TARGET_FREEBSD_NR___acl_delete_link 427
+-#define TARGET_FREEBSD_NR___acl_aclcheck_link 428
+-#define TARGET_FREEBSD_NR_sigwait 429
+-#define TARGET_FREEBSD_NR_thr_create 430
+-#define TARGET_FREEBSD_NR_thr_exit 431
+-#define TARGET_FREEBSD_NR_thr_self 432
+-#define TARGET_FREEBSD_NR_thr_kill 433
+-#define TARGET_FREEBSD_NR__umtx_lock 434
+-#define TARGET_FREEBSD_NR__umtx_unlock 435
+-#define TARGET_FREEBSD_NR_jail_attach 436
+-#define TARGET_FREEBSD_NR_extattr_list_fd 437
+-#define TARGET_FREEBSD_NR_extattr_list_file 438
+-#define TARGET_FREEBSD_NR_extattr_list_link 439
+-#define TARGET_FREEBSD_NR_ksem_timedwait 441
+-#define TARGET_FREEBSD_NR_thr_suspend 442
+-#define TARGET_FREEBSD_NR_thr_wake 443
+-#define TARGET_FREEBSD_NR_kldunloadf 444
+-#define TARGET_FREEBSD_NR_audit 445
+-#define TARGET_FREEBSD_NR_auditon 446
+-#define TARGET_FREEBSD_NR_getauid 447
+-#define TARGET_FREEBSD_NR_setauid 448
+-#define TARGET_FREEBSD_NR_getaudit 449
+-#define TARGET_FREEBSD_NR_setaudit 450
+-#define TARGET_FREEBSD_NR_getaudit_addr 451
+-#define TARGET_FREEBSD_NR_setaudit_addr 452
+-#define TARGET_FREEBSD_NR_auditctl 453
+-#define TARGET_FREEBSD_NR__umtx_op 454
+-#define TARGET_FREEBSD_NR_thr_new 455
+-#define TARGET_FREEBSD_NR_sigqueue 456
+-#define TARGET_FREEBSD_NR_kmq_open 457
+-#define TARGET_FREEBSD_NR_kmq_setattr 458
+-#define TARGET_FREEBSD_NR_kmq_timedreceive 459
+-#define TARGET_FREEBSD_NR_kmq_timedsend 460
+-#define TARGET_FREEBSD_NR_kmq_notify 461
+-#define TARGET_FREEBSD_NR_kmq_unlink 462
+-#define TARGET_FREEBSD_NR_abort2 463
+-#define TARGET_FREEBSD_NR_thr_set_name 464
+-#define TARGET_FREEBSD_NR_aio_fsync 465
+-#define TARGET_FREEBSD_NR_rtprio_thread 466
+-#define TARGET_FREEBSD_NR_sctp_peeloff 471
+-#define TARGET_FREEBSD_NR_sctp_generic_sendmsg 472
+-#define TARGET_FREEBSD_NR_sctp_generic_sendmsg_iov 473
+-#define TARGET_FREEBSD_NR_sctp_generic_recvmsg 474
+-#define TARGET_FREEBSD_NR_pread 475
+-#define TARGET_FREEBSD_NR_pwrite 476
+-#define TARGET_FREEBSD_NR_mmap 477
+-#define TARGET_FREEBSD_NR_lseek 478
+-#define TARGET_FREEBSD_NR_truncate 479
+-#define TARGET_FREEBSD_NR_ftruncate 480
+-#define TARGET_FREEBSD_NR_thr_kill2 481
+-#define TARGET_FREEBSD_NR_shm_open 482
+-#define TARGET_FREEBSD_NR_shm_unlink 483
+-#define TARGET_FREEBSD_NR_cpuset 484
+-#define TARGET_FREEBSD_NR_cpuset_setid 485
+-#define TARGET_FREEBSD_NR_cpuset_getid 486
+-#define TARGET_FREEBSD_NR_cpuset_getaffinity 487
+-#define TARGET_FREEBSD_NR_cpuset_setaffinity 488
+-#define TARGET_FREEBSD_NR_faccessat 489
+-#define TARGET_FREEBSD_NR_fchmodat 490
+-#define TARGET_FREEBSD_NR_fchownat 491
+-#define TARGET_FREEBSD_NR_fexecve 492
+-#define TARGET_FREEBSD_NR_fstatat 493
+-#define TARGET_FREEBSD_NR_futimesat 494
+-#define TARGET_FREEBSD_NR_linkat 495
+-#define TARGET_FREEBSD_NR_mkdirat 496
+-#define TARGET_FREEBSD_NR_mkfifoat 497
+-#define TARGET_FREEBSD_NR_mknodat 498
+-#define TARGET_FREEBSD_NR_openat 499
+-#define TARGET_FREEBSD_NR_readlinkat 500
+-#define TARGET_FREEBSD_NR_renameat 501
+-#define TARGET_FREEBSD_NR_symlinkat 502
+-#define TARGET_FREEBSD_NR_unlinkat 503
+-#define TARGET_FREEBSD_NR_posix_openpt 504
+-#define TARGET_FREEBSD_NR_gssd_syscall 505
+-#define TARGET_FREEBSD_NR_jail_get 506
+-#define TARGET_FREEBSD_NR_jail_set 507
+-#define TARGET_FREEBSD_NR_jail_remove 508
+-#define TARGET_FREEBSD_NR_closefrom 509
+-#define TARGET_FREEBSD_NR___semctl 510
+-#define TARGET_FREEBSD_NR_msgctl 511
+-#define TARGET_FREEBSD_NR_shmctl 512
+-#define TARGET_FREEBSD_NR_lpathconf 513
+-#define TARGET_FREEBSD_NR_cap_new 514
+-#define TARGET_FREEBSD_NR_cap_getrights 515
+-#define TARGET_FREEBSD_NR_cap_enter 516
+-#define TARGET_FREEBSD_NR_cap_getmode 517
+-#define TARGET_FREEBSD_NR_pdfork 518
+-#define TARGET_FREEBSD_NR_pdkill 519
+-#define TARGET_FREEBSD_NR_pdgetpid 520
+-#define TARGET_FREEBSD_NR_pselect 522
+-#define TARGET_FREEBSD_NR_getloginclass 523
+-#define TARGET_FREEBSD_NR_setloginclass 524
+-#define TARGET_FREEBSD_NR_rctl_get_racct 525
+-#define TARGET_FREEBSD_NR_rctl_get_rules 526
+-#define TARGET_FREEBSD_NR_rctl_get_limits 527
+-#define TARGET_FREEBSD_NR_rctl_add_rule 528
+-#define TARGET_FREEBSD_NR_rctl_remove_rule 529
+-#define TARGET_FREEBSD_NR_posix_fallocate 530
+-#define TARGET_FREEBSD_NR_posix_fadvise 531
+-#define TARGET_FREEBSD_NR_wait6 532
+-#define TARGET_FREEBSD_NR_cap_rights_limit 533
+-#define TARGET_FREEBSD_NR_cap_ioctls_limit 534
+-#define TARGET_FREEBSD_NR_cap_ioctls_get 535
+-#define TARGET_FREEBSD_NR_cap_fcntls_limit 536
+-#define TARGET_FREEBSD_NR_cap_fcntls_get 537
+-#define TARGET_FREEBSD_NR_bindat 538
+-#define TARGET_FREEBSD_NR_connectat 539
+-#define TARGET_FREEBSD_NR_chflagsat 540
+-#define TARGET_FREEBSD_NR_accept4 541
+-#define TARGET_FREEBSD_NR_pipe2 542
++#define TARGET_FREEBSD_NR_syscall 0
++#define TARGET_FREEBSD_NR_exit 1
++#define TARGET_FREEBSD_NR_fork 2
++#define TARGET_FREEBSD_NR_read 3
++#define TARGET_FREEBSD_NR_write 4
++#define TARGET_FREEBSD_NR_open 5
++#define TARGET_FREEBSD_NR_close 6
++#define TARGET_FREEBSD_NR_wait4 7
++ /* 8 is old creat */
++#define TARGET_FREEBSD_NR_link 9
++#define TARGET_FREEBSD_NR_unlink 10
++ /* 11 is obsolete execv */
++#define TARGET_FREEBSD_NR_chdir 12
++#define TARGET_FREEBSD_NR_fchdir 13
++#define TARGET_FREEBSD_NR_mknod 14
++#define TARGET_FREEBSD_NR_chmod 15
++#define TARGET_FREEBSD_NR_chown 16
++#define TARGET_FREEBSD_NR_break 17
++#define TARGET_FREEBSD_NR_freebsd4_getfsstat 18
++ /* 19 is old lseek */
++#define TARGET_FREEBSD_NR_getpid 20
++#define TARGET_FREEBSD_NR_mount 21
++#define TARGET_FREEBSD_NR_unmount 22
++#define TARGET_FREEBSD_NR_setuid 23
++#define TARGET_FREEBSD_NR_getuid 24
++#define TARGET_FREEBSD_NR_geteuid 25
++#define TARGET_FREEBSD_NR_ptrace 26
++#define TARGET_FREEBSD_NR_recvmsg 27
++#define TARGET_FREEBSD_NR_sendmsg 28
++#define TARGET_FREEBSD_NR_recvfrom 29
++#define TARGET_FREEBSD_NR_accept 30
++#define TARGET_FREEBSD_NR_getpeername 31
++#define TARGET_FREEBSD_NR_getsockname 32
++#define TARGET_FREEBSD_NR_access 33
++#define TARGET_FREEBSD_NR_chflags 34
++#define TARGET_FREEBSD_NR_fchflags 35
++#define TARGET_FREEBSD_NR_sync 36
++#define TARGET_FREEBSD_NR_kill 37
++ /* 38 is old stat */
++#define TARGET_FREEBSD_NR_getppid 39
++ /* 40 is old lstat */
++#define TARGET_FREEBSD_NR_dup 41
++#define TARGET_FREEBSD_NR_pipe 42
++#define TARGET_FREEBSD_NR_getegid 43
++#define TARGET_FREEBSD_NR_profil 44
++#define TARGET_FREEBSD_NR_ktrace 45
++ /* 46 is old sigaction */
++#define TARGET_FREEBSD_NR_getgid 47
++ /* 48 is old sigprocmask */
++#define TARGET_FREEBSD_NR_getlogin 49
++#define TARGET_FREEBSD_NR_setlogin 50
++#define TARGET_FREEBSD_NR_acct 51
++ /* 52 is old sigpending */
++#define TARGET_FREEBSD_NR_sigaltstack 53
++#define TARGET_FREEBSD_NR_ioctl 54
++#define TARGET_FREEBSD_NR_reboot 55
++#define TARGET_FREEBSD_NR_revoke 56
++#define TARGET_FREEBSD_NR_symlink 57
++#define TARGET_FREEBSD_NR_readlink 58
++#define TARGET_FREEBSD_NR_execve 59
++#define TARGET_FREEBSD_NR_umask 60
++#define TARGET_FREEBSD_NR_chroot 61
++ /* 62 is old fstat */
++ /* 63 is old getkerninfo */
++ /* 64 is old getpagesize */
++#define TARGET_FREEBSD_NR_msync 65
++#define TARGET_FREEBSD_NR_vfork 66
++ /* 67 is obsolete vread */
++ /* 68 is obsolete vwrite */
++#define TARGET_FREEBSD_NR_sbrk 69
++#define TARGET_FREEBSD_NR_sstk 70
++ /* 71 is old mmap */
++#define TARGET_FREEBSD_NR_vadvise 72
++#define TARGET_FREEBSD_NR_munmap 73
++#define TARGET_FREEBSD_NR_mprotect 74
++#define TARGET_FREEBSD_NR_madvise 75
++ /* 76 is obsolete vhangup */
++ /* 77 is obsolete vlimit */
++#define TARGET_FREEBSD_NR_mincore 78
++#define TARGET_FREEBSD_NR_getgroups 79
++#define TARGET_FREEBSD_NR_setgroups 80
++#define TARGET_FREEBSD_NR_getpgrp 81
++#define TARGET_FREEBSD_NR_setpgid 82
++#define TARGET_FREEBSD_NR_setitimer 83
++ /* 84 is old wait */
++#define TARGET_FREEBSD_NR_swapon 85
++#define TARGET_FREEBSD_NR_getitimer 86
++ /* 87 is old gethostname */
++ /* 88 is old sethostname */
++#define TARGET_FREEBSD_NR_getdtablesize 89
++#define TARGET_FREEBSD_NR_dup2 90
++#define TARGET_FREEBSD_NR_fcntl 92
++#define TARGET_FREEBSD_NR_select 93
++#define TARGET_FREEBSD_NR_fsync 95
++#define TARGET_FREEBSD_NR_setpriority 96
++#define TARGET_FREEBSD_NR_socket 97
++#define TARGET_FREEBSD_NR_connect 98
++ /* 99 is old accept */
++#define TARGET_FREEBSD_NR_getpriority 100
++ /* 101 is old send */
++ /* 102 is old recv */
++ /* 103 is old sigreturn */
++#define TARGET_FREEBSD_NR_bind 104
++#define TARGET_FREEBSD_NR_setsockopt 105
++#define TARGET_FREEBSD_NR_listen 106
++ /* 107 is obsolete vtimes */
++ /* 108 is old sigvec */
++ /* 109 is old sigblock */
++ /* 110 is old sigsetmask */
++ /* 111 is old sigsuspend */
++ /* 112 is old sigstack */
++ /* 113 is old recvmsg */
++ /* 114 is old sendmsg */
++ /* 115 is obsolete vtrace */
++#define TARGET_FREEBSD_NR_gettimeofday 116
++#define TARGET_FREEBSD_NR_getrusage 117
++#define TARGET_FREEBSD_NR_getsockopt 118
++#define TARGET_FREEBSD_NR_readv 120
++#define TARGET_FREEBSD_NR_writev 121
++#define TARGET_FREEBSD_NR_settimeofday 122
++#define TARGET_FREEBSD_NR_fchown 123
++#define TARGET_FREEBSD_NR_fchmod 124
++ /* 125 is old recvfrom */
++#define TARGET_FREEBSD_NR_setreuid 126
++#define TARGET_FREEBSD_NR_setregid 127
++#define TARGET_FREEBSD_NR_rename 128
++ /* 129 is old truncate */
++ /* 130 is old ftruncate */
++#define TARGET_FREEBSD_NR_flock 131
++#define TARGET_FREEBSD_NR_mkfifo 132
++#define TARGET_FREEBSD_NR_sendto 133
++#define TARGET_FREEBSD_NR_shutdown 134
++#define TARGET_FREEBSD_NR_socketpair 135
++#define TARGET_FREEBSD_NR_mkdir 136
++#define TARGET_FREEBSD_NR_rmdir 137
++#define TARGET_FREEBSD_NR_utimes 138
++ /* 139 is obsolete 4.2 sigreturn */
++#define TARGET_FREEBSD_NR_adjtime 140
++ /* 141 is old getpeername */
++ /* 142 is old gethostid */
++ /* 143 is old sethostid */
++ /* 144 is old getrlimit */
++ /* 145 is old setrlimit */
++ /* 146 is old killpg */
++#define TARGET_FREEBSD_NR_setsid 147
++#define TARGET_FREEBSD_NR_quotactl 148
++ /* 149 is old quota */
++ /* 150 is old getsockname */
++#define TARGET_FREEBSD_NR_nlm_syscall 154
++#define TARGET_FREEBSD_NR_nfssvc 155
++ /* 156 is old getdirentries */
++#define TARGET_FREEBSD_NR_freebsd4_statfs 157
++#define TARGET_FREEBSD_NR_freebsd4_fstatfs 158
++#define TARGET_FREEBSD_NR_lgetfh 160
++#define TARGET_FREEBSD_NR_getfh 161
++#define TARGET_FREEBSD_NR_freebsd4_getdomainname 162
++#define TARGET_FREEBSD_NR_freebsd4_setdomainname 163
++#define TARGET_FREEBSD_NR_freebsd4_uname 164
++#define TARGET_FREEBSD_NR_sysarch 165
++#define TARGET_FREEBSD_NR_rtprio 166
++#define TARGET_FREEBSD_NR_semsys 169
++#define TARGET_FREEBSD_NR_msgsys 170
++#define TARGET_FREEBSD_NR_shmsys 171
++#define TARGET_FREEBSD_NR_freebsd6_pread 173
++#define TARGET_FREEBSD_NR_freebsd6_pwrite 174
++#define TARGET_FREEBSD_NR_setfib 175
++#define TARGET_FREEBSD_NR_ntp_adjtime 176
++#define TARGET_FREEBSD_NR_setgid 181
++#define TARGET_FREEBSD_NR_setegid 182
++#define TARGET_FREEBSD_NR_seteuid 183
++#define TARGET_FREEBSD_NR_stat 188
++#define TARGET_FREEBSD_NR_fstat 189
++#define TARGET_FREEBSD_NR_lstat 190
++#define TARGET_FREEBSD_NR_pathconf 191
++#define TARGET_FREEBSD_NR_fpathconf 192
++#define TARGET_FREEBSD_NR_getrlimit 194
++#define TARGET_FREEBSD_NR_setrlimit 195
++#define TARGET_FREEBSD_NR_getdirentries 196
++#define TARGET_FREEBSD_NR_freebsd6_mmap 197
++#define TARGET_FREEBSD_NR___syscall 198
++#define TARGET_FREEBSD_NR_freebsd6_lseek 199
++#define TARGET_FREEBSD_NR_freebsd6_truncate 200
++#define TARGET_FREEBSD_NR_freebsd6_ftruncate 201
++#define TARGET_FREEBSD_NR___sysctl 202
++#define TARGET_FREEBSD_NR_mlock 203
++#define TARGET_FREEBSD_NR_munlock 204
++#define TARGET_FREEBSD_NR_undelete 205
++#define TARGET_FREEBSD_NR_futimes 206
++#define TARGET_FREEBSD_NR_getpgid 207
++#define TARGET_FREEBSD_NR_poll 209
++#define TARGET_FREEBSD_NR_freebsd7___semctl 220
++#define TARGET_FREEBSD_NR_semget 221
++#define TARGET_FREEBSD_NR_semop 222
++#define TARGET_FREEBSD_NR_freebsd7_msgctl 224
++#define TARGET_FREEBSD_NR_msgget 225
++#define TARGET_FREEBSD_NR_msgsnd 226
++#define TARGET_FREEBSD_NR_msgrcv 227
++#define TARGET_FREEBSD_NR_shmat 228
++#define TARGET_FREEBSD_NR_freebsd7_shmctl 229
++#define TARGET_FREEBSD_NR_shmdt 230
++#define TARGET_FREEBSD_NR_shmget 231
++#define TARGET_FREEBSD_NR_clock_gettime 232
++#define TARGET_FREEBSD_NR_clock_settime 233
++#define TARGET_FREEBSD_NR_clock_getres 234
++#define TARGET_FREEBSD_NR_ktimer_create 235
++#define TARGET_FREEBSD_NR_ktimer_delete 236
++#define TARGET_FREEBSD_NR_ktimer_settime 237
++#define TARGET_FREEBSD_NR_ktimer_gettime 238
++#define TARGET_FREEBSD_NR_ktimer_getoverrun 239
++#define TARGET_FREEBSD_NR_nanosleep 240
++#define TARGET_FREEBSD_NR_ffclock_getcounter 241
++#define TARGET_FREEBSD_NR_ffclock_setestimate 242
++#define TARGET_FREEBSD_NR_ffclock_getestimate 243
++#define TARGET_FREEBSD_NR_clock_getcpuclockid2 247
++#define TARGET_FREEBSD_NR_ntp_gettime 248
++#define TARGET_FREEBSD_NR_minherit 250
++#define TARGET_FREEBSD_NR_rfork 251
++#define TARGET_FREEBSD_NR_openbsd_poll 252
++#define TARGET_FREEBSD_NR_issetugid 253
++#define TARGET_FREEBSD_NR_lchown 254
++#define TARGET_FREEBSD_NR_aio_read 255
++#define TARGET_FREEBSD_NR_aio_write 256
++#define TARGET_FREEBSD_NR_lio_listio 257
++#define TARGET_FREEBSD_NR_getdents 272
++#define TARGET_FREEBSD_NR_lchmod 274
++#define TARGET_FREEBSD_NR_netbsd_lchown 275
++#define TARGET_FREEBSD_NR_lutimes 276
++#define TARGET_FREEBSD_NR_netbsd_msync 277
++#define TARGET_FREEBSD_NR_nstat 278
++#define TARGET_FREEBSD_NR_nfstat 279
++#define TARGET_FREEBSD_NR_nlstat 280
++#define TARGET_FREEBSD_NR_preadv 289
++#define TARGET_FREEBSD_NR_pwritev 290
++#define TARGET_FREEBSD_NR_freebsd4_fhstatfs 297
++#define TARGET_FREEBSD_NR_fhopen 298
++#define TARGET_FREEBSD_NR_fhstat 299
++#define TARGET_FREEBSD_NR_modnext 300
++#define TARGET_FREEBSD_NR_modstat 301
++#define TARGET_FREEBSD_NR_modfnext 302
++#define TARGET_FREEBSD_NR_modfind 303
++#define TARGET_FREEBSD_NR_kldload 304
++#define TARGET_FREEBSD_NR_kldunload 305
++#define TARGET_FREEBSD_NR_kldfind 306
++#define TARGET_FREEBSD_NR_kldnext 307
++#define TARGET_FREEBSD_NR_kldstat 308
++#define TARGET_FREEBSD_NR_kldfirstmod 309
++#define TARGET_FREEBSD_NR_getsid 310
++#define TARGET_FREEBSD_NR_setresuid 311
++#define TARGET_FREEBSD_NR_setresgid 312
++ /* 313 is obsolete signanosleep */
++#define TARGET_FREEBSD_NR_aio_return 314
++#define TARGET_FREEBSD_NR_aio_suspend 315
++#define TARGET_FREEBSD_NR_aio_cancel 316
++#define TARGET_FREEBSD_NR_aio_error 317
++#define TARGET_FREEBSD_NR_oaio_read 318
++#define TARGET_FREEBSD_NR_oaio_write 319
++#define TARGET_FREEBSD_NR_olio_listio 320
++#define TARGET_FREEBSD_NR_yield 321
++ /* 322 is obsolete thr_sleep */
++ /* 323 is obsolete thr_wakeup */
++#define TARGET_FREEBSD_NR_mlockall 324
++#define TARGET_FREEBSD_NR_munlockall 325
++#define TARGET_FREEBSD_NR___getcwd 326
++#define TARGET_FREEBSD_NR_sched_setparam 327
++#define TARGET_FREEBSD_NR_sched_getparam 328
++#define TARGET_FREEBSD_NR_sched_setscheduler 329
++#define TARGET_FREEBSD_NR_sched_getscheduler 330
++#define TARGET_FREEBSD_NR_sched_yield 331
++#define TARGET_FREEBSD_NR_sched_get_priority_max 332
++#define TARGET_FREEBSD_NR_sched_get_priority_min 333
++#define TARGET_FREEBSD_NR_sched_rr_get_interval 334
++#define TARGET_FREEBSD_NR_utrace 335
++#define TARGET_FREEBSD_NR_freebsd4_sendfile 336
++#define TARGET_FREEBSD_NR_kldsym 337
++#define TARGET_FREEBSD_NR_jail 338
++#define TARGET_FREEBSD_NR_nnpfs_syscall 339
++#define TARGET_FREEBSD_NR_sigprocmask 340
++#define TARGET_FREEBSD_NR_sigsuspend 341
++#define TARGET_FREEBSD_NR_freebsd4_sigaction 342
++#define TARGET_FREEBSD_NR_sigpending 343
++#define TARGET_FREEBSD_NR_freebsd4_sigreturn 344
++#define TARGET_FREEBSD_NR_sigtimedwait 345
++#define TARGET_FREEBSD_NR_sigwaitinfo 346
++#define TARGET_FREEBSD_NR___acl_get_file 347
++#define TARGET_FREEBSD_NR___acl_set_file 348
++#define TARGET_FREEBSD_NR___acl_get_fd 349
++#define TARGET_FREEBSD_NR___acl_set_fd 350
++#define TARGET_FREEBSD_NR___acl_delete_file 351
++#define TARGET_FREEBSD_NR___acl_delete_fd 352
++#define TARGET_FREEBSD_NR___acl_aclcheck_file 353
++#define TARGET_FREEBSD_NR___acl_aclcheck_fd 354
++#define TARGET_FREEBSD_NR_extattrctl 355
++#define TARGET_FREEBSD_NR_extattr_set_file 356
++#define TARGET_FREEBSD_NR_extattr_get_file 357
++#define TARGET_FREEBSD_NR_extattr_delete_file 358
++#define TARGET_FREEBSD_NR_aio_waitcomplete 359
++#define TARGET_FREEBSD_NR_getresuid 360
++#define TARGET_FREEBSD_NR_getresgid 361
++#define TARGET_FREEBSD_NR_kqueue 362
++#define TARGET_FREEBSD_NR_kevent 363
++#define TARGET_FREEBSD_NR_extattr_set_fd 371
++#define TARGET_FREEBSD_NR_extattr_get_fd 372
++#define TARGET_FREEBSD_NR_extattr_delete_fd 373
++#define TARGET_FREEBSD_NR___setugid 374
++#define TARGET_FREEBSD_NR_eaccess 376
++#define TARGET_FREEBSD_NR_afs3_syscall 377
++#define TARGET_FREEBSD_NR_nmount 378
++#define TARGET_FREEBSD_NR___mac_get_proc 384
++#define TARGET_FREEBSD_NR___mac_set_proc 385
++#define TARGET_FREEBSD_NR___mac_get_fd 386
++#define TARGET_FREEBSD_NR___mac_get_file 387
++#define TARGET_FREEBSD_NR___mac_set_fd 388
++#define TARGET_FREEBSD_NR___mac_set_file 389
++#define TARGET_FREEBSD_NR_kenv 390
++#define TARGET_FREEBSD_NR_lchflags 391
++#define TARGET_FREEBSD_NR_uuidgen 392
++#define TARGET_FREEBSD_NR_sendfile 393
++#define TARGET_FREEBSD_NR_mac_syscall 394
++#define TARGET_FREEBSD_NR_getfsstat 395
++#define TARGET_FREEBSD_NR_statfs 396
++#define TARGET_FREEBSD_NR_fstatfs 397
++#define TARGET_FREEBSD_NR_fhstatfs 398
++#define TARGET_FREEBSD_NR_ksem_close 400
++#define TARGET_FREEBSD_NR_ksem_post 401
++#define TARGET_FREEBSD_NR_ksem_wait 402
++#define TARGET_FREEBSD_NR_ksem_trywait 403
++#define TARGET_FREEBSD_NR_ksem_init 404
++#define TARGET_FREEBSD_NR_ksem_open 405
++#define TARGET_FREEBSD_NR_ksem_unlink 406
++#define TARGET_FREEBSD_NR_ksem_getvalue 407
++#define TARGET_FREEBSD_NR_ksem_destroy 408
++#define TARGET_FREEBSD_NR___mac_get_pid 409
++#define TARGET_FREEBSD_NR___mac_get_link 410
++#define TARGET_FREEBSD_NR___mac_set_link 411
++#define TARGET_FREEBSD_NR_extattr_set_link 412
++#define TARGET_FREEBSD_NR_extattr_get_link 413
++#define TARGET_FREEBSD_NR_extattr_delete_link 414
++#define TARGET_FREEBSD_NR___mac_execve 415
++#define TARGET_FREEBSD_NR_sigaction 416
++#define TARGET_FREEBSD_NR_sigreturn 417
++#define TARGET_FREEBSD_NR_getcontext 421
++#define TARGET_FREEBSD_NR_setcontext 422
++#define TARGET_FREEBSD_NR_swapcontext 423
++#define TARGET_FREEBSD_NR_swapoff 424
++#define TARGET_FREEBSD_NR___acl_get_link 425
++#define TARGET_FREEBSD_NR___acl_set_link 426
++#define TARGET_FREEBSD_NR___acl_delete_link 427
++#define TARGET_FREEBSD_NR___acl_aclcheck_link 428
++#define TARGET_FREEBSD_NR_sigwait 429
++#define TARGET_FREEBSD_NR_thr_create 430
++#define TARGET_FREEBSD_NR_thr_exit 431
++#define TARGET_FREEBSD_NR_thr_self 432
++#define TARGET_FREEBSD_NR_thr_kill 433
++#define TARGET_FREEBSD_NR_jail_attach 436
++#define TARGET_FREEBSD_NR_extattr_list_fd 437
++#define TARGET_FREEBSD_NR_extattr_list_file 438
++#define TARGET_FREEBSD_NR_extattr_list_link 439
++#define TARGET_FREEBSD_NR_ksem_timedwait 441
++#define TARGET_FREEBSD_NR_thr_suspend 442
++#define TARGET_FREEBSD_NR_thr_wake 443
++#define TARGET_FREEBSD_NR_kldunloadf 444
++#define TARGET_FREEBSD_NR_audit 445
++#define TARGET_FREEBSD_NR_auditon 446
++#define TARGET_FREEBSD_NR_getauid 447
++#define TARGET_FREEBSD_NR_setauid 448
++#define TARGET_FREEBSD_NR_getaudit 449
++#define TARGET_FREEBSD_NR_setaudit 450
++#define TARGET_FREEBSD_NR_getaudit_addr 451
++#define TARGET_FREEBSD_NR_setaudit_addr 452
++#define TARGET_FREEBSD_NR_auditctl 453
++#define TARGET_FREEBSD_NR__umtx_op 454
++#define TARGET_FREEBSD_NR_thr_new 455
++#define TARGET_FREEBSD_NR_sigqueue 456
++#define TARGET_FREEBSD_NR_kmq_open 457
++#define TARGET_FREEBSD_NR_kmq_setattr 458
++#define TARGET_FREEBSD_NR_kmq_timedreceive 459
++#define TARGET_FREEBSD_NR_kmq_timedsend 460
++#define TARGET_FREEBSD_NR_kmq_notify 461
++#define TARGET_FREEBSD_NR_kmq_unlink 462
++#define TARGET_FREEBSD_NR_abort2 463
++#define TARGET_FREEBSD_NR_thr_set_name 464
++#define TARGET_FREEBSD_NR_aio_fsync 465
++#define TARGET_FREEBSD_NR_rtprio_thread 466
++#define TARGET_FREEBSD_NR_sctp_peeloff 471
++#define TARGET_FREEBSD_NR_sctp_generic_sendmsg 472
++#define TARGET_FREEBSD_NR_sctp_generic_sendmsg_iov 473
++#define TARGET_FREEBSD_NR_sctp_generic_recvmsg 474
++#define TARGET_FREEBSD_NR_pread 475
++#define TARGET_FREEBSD_NR_pwrite 476
++#define TARGET_FREEBSD_NR_mmap 477
++#define TARGET_FREEBSD_NR_lseek 478
++#define TARGET_FREEBSD_NR_truncate 479
++#define TARGET_FREEBSD_NR_ftruncate 480
++#define TARGET_FREEBSD_NR_thr_kill2 481
++#define TARGET_FREEBSD_NR_shm_open 482
++#define TARGET_FREEBSD_NR_shm_unlink 483
++#define TARGET_FREEBSD_NR_cpuset 484
++#define TARGET_FREEBSD_NR_cpuset_setid 485
++#define TARGET_FREEBSD_NR_cpuset_getid 486
++#define TARGET_FREEBSD_NR_cpuset_getaffinity 487
++#define TARGET_FREEBSD_NR_cpuset_setaffinity 488
++#define TARGET_FREEBSD_NR_faccessat 489
++#define TARGET_FREEBSD_NR_fchmodat 490
++#define TARGET_FREEBSD_NR_fchownat 491
++#define TARGET_FREEBSD_NR_fexecve 492
++#define TARGET_FREEBSD_NR_fstatat 493
++#define TARGET_FREEBSD_NR_futimesat 494
++#define TARGET_FREEBSD_NR_linkat 495
++#define TARGET_FREEBSD_NR_mkdirat 496
++#define TARGET_FREEBSD_NR_mkfifoat 497
++#define TARGET_FREEBSD_NR_mknodat 498
++#define TARGET_FREEBSD_NR_openat 499
++#define TARGET_FREEBSD_NR_readlinkat 500
++#define TARGET_FREEBSD_NR_renameat 501
++#define TARGET_FREEBSD_NR_symlinkat 502
++#define TARGET_FREEBSD_NR_unlinkat 503
++#define TARGET_FREEBSD_NR_posix_openpt 504
++#define TARGET_FREEBSD_NR_gssd_syscall 505
++#define TARGET_FREEBSD_NR_jail_get 506
++#define TARGET_FREEBSD_NR_jail_set 507
++#define TARGET_FREEBSD_NR_jail_remove 508
++#define TARGET_FREEBSD_NR_closefrom 509
++#define TARGET_FREEBSD_NR___semctl 510
++#define TARGET_FREEBSD_NR_msgctl 511
++#define TARGET_FREEBSD_NR_shmctl 512
++#define TARGET_FREEBSD_NR_lpathconf 513
++ /* 514 is obsolete cap_new */
++#define TARGET_FREEBSD_NR___cap_rights_get 515
++#define TARGET_FREEBSD_NR_cap_enter 516
++#define TARGET_FREEBSD_NR_cap_getmode 517
++#define TARGET_FREEBSD_NR_pdfork 518
++#define TARGET_FREEBSD_NR_pdkill 519
++#define TARGET_FREEBSD_NR_pdgetpid 520
++#define TARGET_FREEBSD_NR_pselect 522
++#define TARGET_FREEBSD_NR_getloginclass 523
++#define TARGET_FREEBSD_NR_setloginclass 524
++#define TARGET_FREEBSD_NR_rctl_get_racct 525
++#define TARGET_FREEBSD_NR_rctl_get_rules 526
++#define TARGET_FREEBSD_NR_rctl_get_limits 527
++#define TARGET_FREEBSD_NR_rctl_add_rule 528
++#define TARGET_FREEBSD_NR_rctl_remove_rule 529
++#define TARGET_FREEBSD_NR_posix_fallocate 530
++#define TARGET_FREEBSD_NR_posix_fadvise 531
++#define TARGET_FREEBSD_NR_wait6 532
++#define TARGET_FREEBSD_NR_cap_rights_limit 533
++#define TARGET_FREEBSD_NR_cap_ioctls_limit 534
++#define TARGET_FREEBSD_NR_cap_ioctls_get 535
++#define TARGET_FREEBSD_NR_cap_fcntls_limit 536
++#define TARGET_FREEBSD_NR_cap_fcntls_get 537
++#define TARGET_FREEBSD_NR_bindat 538
++#define TARGET_FREEBSD_NR_connectat 539
++#define TARGET_FREEBSD_NR_chflagsat 540
++#define TARGET_FREEBSD_NR_accept4 541
++#define TARGET_FREEBSD_NR_pipe2 542
+ #define TARGET_FREEBSD_NR_aio_mlock 543
+ #define TARGET_FREEBSD_NR_procctl 544
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 545
++#define TARGET_FREEBSD_NR_MAXSYSCALL 545
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 2ad63e5..4a743e8 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -356,6 +356,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_freebsd_cap_enter();
+ break;
+
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
+ case TARGET_FREEBSD_NR_cap_new: /* cap_new(2) */
+ ret = do_freebsd_cap_new(arg1, arg2);
+ break;
+@@ -363,6 +364,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ case TARGET_FREEBSD_NR_cap_getrights: /* cap_getrights(2) */
+ ret = do_freebsd_cap_getrights(arg1, arg2);
+ break;
++#endif /* __FreeBSD_version < 1000000 */
+
+ case TARGET_FREEBSD_NR_cap_getmode: /* cap_getmode(2) */
+ ret = do_freebsd_cap_getmode(arg1);
+@@ -1052,9 +1054,11 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_kill(arg1, arg2);
+ break;
+
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
+ case TARGET_FREEBSD_NR_killpg: /* killpg(2) */
+ ret = do_bsd_killpg(arg1, arg2);
+ break;
++#endif
+
+ case TARGET_FREEBSD_NR_pdkill: /* pdkill(2) */
+ ret = do_freebsd_pdkill(arg1, arg2);
+@@ -1218,6 +1222,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_freebsd_swapcontext(cpu_env, arg1, arg2);
+ break;
+
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
+ case TARGET_FREEBSD_NR__umtx_lock: /* undocumented */
+ ret = do_freebsd__umtx_lock(arg1);
+ break;
+@@ -1225,6 +1230,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ case TARGET_FREEBSD_NR__umtx_unlock: /* undocumented */
+ ret = do_freebsd__umtx_unlock(arg1);
+ break;
++#endif
+
+ case TARGET_FREEBSD_NR__umtx_op: /* undocumented */
+ ret = do_freebsd__umtx_op(arg1, arg2, arg3, arg4, arg5);
+@@ -1628,6 +1634,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ break;
+
+ default:
++ gemu_log("qemu: unsupported syscall: %d (calling anyway)\n", num);
+ ret = get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
+ arg8));
+ break;
diff --git a/emulators/qemu-devel/files/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8-before11 b/emulators/qemu-devel/files/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8-before11
deleted file mode 100644
index d0746ba545b2..000000000000
--- a/emulators/qemu-devel/files/extra-patch-2478a4e4a33d0523cc436eabb4a27b258b4358b8-before11
+++ /dev/null
@@ -1,19 +0,0 @@
---- a/bsd-user/freebsd/os-thread.c
-+++ b/bsd-user/freebsd/os-thread.c
-@@ -241,8 +241,6 @@ abi_long freebsd_umtx_sem_wake(abi_ulong
-
- return get_errno(_umtx_op(g2h(obj), UMTX_OP_SEM2_WAKE, val, NULL, NULL));
- }
--#endif
--
- #else
- abi_long freebsd_umtx_sem_wait(abi_ulong obj, struct timespec *timeout)
- {
-@@ -260,6 +258,7 @@ abi_long freebsd_umtx_sem_wake(abi_ulong
- return get_errno(_umtx_op(g2h(obj), UMTX_OP_SEM_WAKE, val, NULL, NULL));
- }
- #endif
-+#endif
-
- abi_long t2h_freebsd_rtprio(struct rtprio *host_rtp, abi_ulong target_addr)
- {
diff --git a/emulators/qemu-devel/files/extra-patch-30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b408 b/emulators/qemu-devel/files/extra-patch-30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b408
new file mode 100644
index 000000000000..1228f51a067f
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b408
@@ -0,0 +1,51 @@
+From 30c8ccb41e2c9e1ddda7e3f8a8ac1eb5dab8b408 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Wed, 5 Nov 2014 22:52:17 +0000
+Subject: [PATCH] Add stub for the new procctl(2) system call.
+
+---
+ bsd-user/freebsd/os-proc.h | 10 ++++++++++
+ bsd-user/syscall.c | 4 +++-
+ 2 files changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
+index 612a5fd..193e1fc 100644
+--- a/bsd-user/freebsd/os-proc.h
++++ b/bsd-user/freebsd/os-proc.h
+@@ -21,6 +21,7 @@
+ #define __FREEBSD_PROC_H_
+
+ #if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
++#include <sys/procctl.h>
+ #include <sys/signal.h>
+ #endif
+ #include <sys/types.h>
+@@ -520,4 +521,13 @@ static inline abi_long do_freebsd_auditctl(abi_ulong arg1)
+ return -TARGET_ENOSYS;
+ }
+
++/* procctl(2) */
++static inline abi_long do_freebsd_procctl(__unused int idtype, __unused int id,
++ __unused int cmd, __unused abi_ulong arg)
++{
++
++ qemu_log("qemu: Unsupported syscall procctl()\n");
++ return -TARGET_ENOSYS;
++}
++
+ #endif /* ! __FREEBSD_PROC_H_ */
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 30dc2f3..2ad63e5 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -432,7 +432,9 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_setpriority(arg1, arg2, arg3);
+ break;
+
+-
++ case TARGET_FREEBSD_NR_procctl: /* procctl(2) */
++ ret = do_freebsd_procctl(arg1, arg2, arg3, arg4);
++ break;
+
+ /*
+ * File system calls.
diff --git a/emulators/qemu-devel/files/extra-patch-3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca27 b/emulators/qemu-devel/files/extra-patch-3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca27
new file mode 100644
index 000000000000..aa0cca202ecf
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca27
@@ -0,0 +1,63 @@
+From 3ed485b9b4ef8d8ba916760aec0cdf9dbce8ca27 Mon Sep 17 00:00:00 2001
+From: Sean Bruno <sbruno@crack.ysv.freebsd.org>
+Date: Fri, 7 Nov 2014 19:19:38 +0000
+Subject: [PATCH] Now that the kernel image activators can be run
+ independantly, there's no need for qemu itself to do this. This allows
+ /bin/sh to be used as a static amd64 binary on my poudriere jails.
+
+---
+ bsd-user/freebsd/os-proc.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c
+index 24b8d27..b185439 100644
+--- a/bsd-user/freebsd/os-proc.c
++++ b/bsd-user/freebsd/os-proc.c
+@@ -82,6 +82,7 @@ get_filename_from_fd(pid_t pid, int fd, char *filename, size_t len)
+ return ret;
+ }
+
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
+ static int
+ is_target_shell_script(int fd, char *interp, size_t size, char **interp_args)
+ {
+@@ -143,6 +144,7 @@ is_target_shell_script(int fd, char *interp, size_t size, char **interp_args)
+
+ return 0;
+ }
++#endif
+
+ /*
+ * execve/fexecve
+@@ -257,6 +259,7 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ ret = -TARGET_EBADF;
+ goto execve_end;
+ }
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
+ } else if (is_target_shell_script((int)path_or_fd, execpath,
+ sizeof(execpath), &scriptargs) != 0) {
+ char scriptpath[PATH_MAX];
+@@ -282,6 +285,7 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ ret = -TARGET_EBADF;
+ goto execve_end;
+ }
++#endif
+ } else {
+ ret = get_errno(fexecve((int)path_or_fd, argp, envp));
+ }
+@@ -310,6 +314,7 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ *qarg1++ = (char *)interp_prefix;
+ #endif
+ ret = get_errno(execve(qemu_proc_pathname, qargp, envp));
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
+ } else if (is_target_shell_script(fd, execpath,
+ sizeof(execpath), &scriptargs) != 0) {
+ close(fd);
+@@ -328,6 +333,7 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ *qarg1 = scriptargs;
+ }
+ ret = get_errno(execve(qemu_proc_pathname, qarg0, envp));
++#endif
+ } else {
+ close(fd);
+ /* Execve() as a host native binary. */
diff --git a/emulators/qemu-devel/files/extra-patch-5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6 b/emulators/qemu-devel/files/extra-patch-5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6
new file mode 100644
index 000000000000..193a6e4e8751
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6
@@ -0,0 +1,201 @@
+From 5f81caf45c0d0eb2b4b852f8580a1938fb3d12c6 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Wed, 5 Nov 2014 20:28:13 +0000
+Subject: [PATCH] Add support for pipe2(2) and chflagsat(2) system calls.
+
+This change adds support for newly added pipe2(2) and chflagsat(2)
+system calls. It also fixes what obviously looks like a bug with the
+pipe(2) call emulation. The pipe descriptors were not written back.
+---
+ bsd-user/bsd-file.h | 8 +++-
+ bsd-user/freebsd/os-file.h | 86 +++++++++++++++++++++++++++++++++++++++++++
+ bsd-user/freebsd/strace.list | 2 +
+ bsd-user/freebsd/syscall_nr.h | 3 +-
+ bsd-user/syscall.c | 9 +++++
+ 5 files changed, 105 insertions(+), 3 deletions(-)
+ create mode 100644 bsd-user/freebsd/os-file.h
+
+diff --git a/bsd-user/bsd-file.h b/bsd-user/bsd-file.h
+index 5d8a347..f697eac 100644
+--- a/bsd-user/bsd-file.h
++++ b/bsd-user/bsd-file.h
+@@ -1013,7 +1013,7 @@ static abi_long do_bsd_lseek(void *cpu_env, abi_long arg1, abi_long arg2,
+ }
+
+ /* pipe(2) */
+-static abi_long do_bsd_pipe(void *cpu_env, abi_long arg1)
++static abi_long do_bsd_pipe(void *cpu_env, abi_ulong pipedes)
+ {
+ abi_long ret;
+ int host_pipe[2];
+@@ -1022,8 +1022,12 @@ static abi_long do_bsd_pipe(void *cpu_env, abi_long arg1)
+ if (host_ret != -1) {
+ set_second_rval(cpu_env, host_pipe[1]);
+ ret = host_pipe[0];
++ if (put_user_s32(host_pipe[0], pipedes) ||
++ put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
++ return -TARGET_EFAULT;
++ }
+ } else {
+- ret = get_errno(host_ret);
++ ret = get_errno(host_ret);
+ }
+ return ret;
+ }
+diff --git a/bsd-user/freebsd/os-file.h b/bsd-user/freebsd/os-file.h
+new file mode 100644
+index 0000000..2c6bc24
+--- /dev/null
++++ b/bsd-user/freebsd/os-file.h
+@@ -0,0 +1,86 @@
++/*
++ * FreeBSD file related system call shims and definitions
++ *
++ * Copyright (c) 2014 Stacey D. Son
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef __FREEBSD_OS_FILE_H_
++#define __FREEBSD_OS_FILE_H_
++
++#include <sys/stat.h>
++#include <unistd.h>
++
++#include "qemu-os.h"
++
++
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
++/* pipe2(2) */
++static abi_long do_bsd_pipe2(void *cpu_env, abi_ulong pipedes, int flags)
++{
++ abi_long ret;
++ int host_pipe[2];
++ int host_ret = pipe2(host_pipe, flags);
++
++ if (is_error(host_ret)) {
++ return get_errno(host_ret);
++ }
++ if (host_ret != -1) {
++ set_second_rval(cpu_env, host_pipe[1]);
++ ret = host_pipe[0];
++ if (put_user_s32(host_pipe[0], pipedes) ||
++ put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
++ return -TARGET_EFAULT;
++ }
++ } else {
++ ret = get_errno(host_ret);
++ }
++ return ret;
++}
++
++/* chflagsat(2) */
++static inline abi_long do_bsd_chflagsat(int fd, abi_ulong path,
++ abi_ulong flags, int atflags)
++{
++ abi_long ret;
++ void *p;
++
++ LOCK_PATH(p, path);
++ ret = get_errno(chflagsat(fd, p, flags, atflags)); /* XXX path(p)? */
++ UNLOCK_PATH(p, path);
++
++ return ret;
++}
++
++#else /* ! __FreeBSD_version > 1000000 */
++
++static abi_long do_bsd_pipe2(__unused void *cpu_env, __unused abi_long arg1,
++ __unused int flags)
++{
++
++ qemu_log("qemu: Unsupported syscall pipe2()\n");
++ return -TARGET_ENOSYS;
++}
++
++static inline abi_long do_bsd_chflagsat(__unused int fd,
++ __unused abi_ulong path, __unused abi_ulong flags, int atflags)
++{
++
++ qemu_log("qemu: Unsupported syscall chflagsat()\n");
++ return -TARGET_ENOSYS;
++}
++
++#endif /* ! __FreeBSD_version >= 1000000 */
++#endif /* __FREEBSD_OS_FILE_H_ */
+diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
+index 991cbe2..cba4afe 100644
+--- a/bsd-user/freebsd/strace.list
++++ b/bsd-user/freebsd/strace.list
+@@ -52,6 +52,7 @@
+ { TARGET_FREEBSD_NR_cap_rights_limit, "cap_rights_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
+ { TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_chflagsat, "chflagsat", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
+ { TARGET_FREEBSD_NR_chown, "chown", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chroot, "chroot", NULL, NULL, NULL },
+@@ -160,6 +161,7 @@
+ { TARGET_FREEBSD_NR_openat, "openat", "%s(%d, \"%s\",%#x,%#o)", NULL, NULL },
+ { TARGET_FREEBSD_NR_pathconf, "pathconf", "%s(\"%s\", %d)", NULL, NULL },
+ { TARGET_FREEBSD_NR_pipe, "pipe", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_pipe2, "pipe2", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_poll, "poll", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_pread, "pread", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_preadv, "preadv", NULL, NULL, NULL },
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index 260fd82..b44545b 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -457,4 +457,5 @@
+ #define TARGET_FREEBSD_NR_connectat 539
+ #define TARGET_FREEBSD_NR_chflagsat 540
+ #define TARGET_FREEBSD_NR_accept4 541
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 542
++#define TARGET_FREEBSD_NR_pipe2 542
++#define TARGET_FREEBSD_NR_MAXSYSCALL 543
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index e043396..0a2ab88 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -44,6 +44,7 @@
+
+ /* *BSD dependent syscall shims */
+ #include "os-extattr.h"
++#include "os-file.h"
+ #include "os-time.h"
+ #include "os-misc.h"
+ #include "os-proc.h"
+@@ -646,6 +647,10 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_chflags(arg1, arg2);
+ break;
+
++ case TARGET_FREEBSD_NR_chflagsat: /* chflagsat(2) */
++ ret = do_bsd_chflagsat(arg1, arg2, arg3, arg4);
++ break;
++
+ case TARGET_FREEBSD_NR_lchflags: /* lchflags(2) */
+ ret = do_bsd_lchflags(arg1, arg2);
+ break;
+@@ -702,6 +707,10 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_pipe(cpu_env, arg1);
+ break;
+
++ case TARGET_FREEBSD_NR_pipe2: /* pipe2(2) */
++ ret = do_bsd_pipe2(cpu_env, arg1, arg2);
++ break;
++
+ case TARGET_FREEBSD_NR_swapon: /* swapon(2) */
+ ret = do_bsd_swapon(arg1);
+ break;
diff --git a/emulators/qemu-devel/files/extra-patch-72f0a64c7dd7be796dc2d8f2b0dab340309800e2 b/emulators/qemu-devel/files/extra-patch-72f0a64c7dd7be796dc2d8f2b0dab340309800e2
new file mode 100644
index 000000000000..57c54b994595
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-72f0a64c7dd7be796dc2d8f2b0dab340309800e2
@@ -0,0 +1,45 @@
+From 72f0a64c7dd7be796dc2d8f2b0dab340309800e2 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Fri, 7 Nov 2014 20:48:56 +0000
+Subject: [PATCH] struct __wrusage is not available until FreeBSD 10.0.
+
+---
+ bsd-user/bsd-proc.c | 2 ++
+ bsd-user/qemu-bsd.h | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
+index 7f0b21c..503e928 100644
+--- a/bsd-user/bsd-proc.c
++++ b/bsd-user/bsd-proc.c
+@@ -147,6 +147,7 @@ abi_long host_to_target_rusage(abi_ulong target_addr,
+ return 0;
+ }
+
++:#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ abi_long host_to_target_wrusage(abi_ulong target_addr,
+ const struct __wrusage *wrusage)
+ {
+@@ -161,6 +162,7 @@ abi_long host_to_target_wrusage(abi_ulong target_addr,
+
+ return 0;
+ }
++#endif /* ! __FreeBSD_version >= 1000000 */
+
+ /*
+ * wait status conversion.
+diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h
+index e58fdd7..0c0d1e3 100644
+--- a/bsd-user/qemu-bsd.h
++++ b/bsd-user/qemu-bsd.h
+@@ -48,8 +48,10 @@ rlim_t target_to_host_rlim(abi_ulong target_rlim);
+ abi_ulong host_to_target_rlim(rlim_t rlim);
+ abi_long host_to_target_rusage(abi_ulong target_addr,
+ const struct rusage *rusage);
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ abi_long host_to_target_wrusage(abi_ulong target_addr,
+ const struct __wrusage *wrusage);
++#endif /* __FreeBSD_version >= 1000000 */
+ int host_to_target_waitstatus(int status);
+
+ /* bsd-socket.c */
diff --git a/emulators/qemu-devel/files/extra-patch-93cf90cb04fee057a710be43614b033e6b2e86d1 b/emulators/qemu-devel/files/extra-patch-93cf90cb04fee057a710be43614b033e6b2e86d1
new file mode 100644
index 000000000000..da4f6ccd35f8
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-93cf90cb04fee057a710be43614b033e6b2e86d1
@@ -0,0 +1,100 @@
+From 93cf90cb04fee057a710be43614b033e6b2e86d1 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Fri, 7 Nov 2014 05:35:17 +0000
+Subject: [PATCH] Add support for legacy system calls.
+
+This change adds support for some legacy system calls so qemu bsd
+user-mode will still work on older versions of FreeBSD (i.e. 9.X).
+---
+ bsd-user/freebsd/make_syscall_nr_h.sh | 19 +++++++++++++++++++
+ bsd-user/freebsd/strace.list | 11 +++++++++++
+ bsd-user/freebsd/syscall_nr.h | 16 ++++++++++++++++
+ 3 files changed, 46 insertions(+)
+
+diff --git a/bsd-user/freebsd/make_syscall_nr_h.sh b/bsd-user/freebsd/make_syscall_nr_h.sh
+index cc180df..f73dfc9 100644
+--- a/bsd-user/freebsd/make_syscall_nr_h.sh
++++ b/bsd-user/freebsd/make_syscall_nr_h.sh
+@@ -24,3 +24,22 @@ echo " */" >> $sysnr
+ echo "" >> $sysnr
+
+ /usr/bin/sed -e 's:SYS_:TARGET_FREEBSD_NR_:' < $syshdr >> $sysnr
++
++cat << _EOF >> $sysnr
++/* Legacy system calls. */
++#ifndef TARGET_FREEBSD_NR_killpg
++#define TARGET_FREEBSD_NR_killpg 146
++#endif
++#ifndef TARGET_FREEBSD_NR__umtx_lock
++#define TARGET_FREEBSD_NR__umtx_lock 434
++#endif
++#ifndef TARGET_FREEBSD_NR__umtx_unlock
++#define TARGET_FREEBSD_NR__umtx_unlock 435
++#endif
++#ifndef TARGET_FREEBSD_NR_cap_new
++#define TARGET_FREEBSD_NR_cap_new 514
++#endif
++#ifndef TARGET_FREEBSD_NR_cap_getrights
++#define TARGET_FREEBSD_NR_cap_getrights 515
++#endif
++_EOF
+diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
+index e09048f..6202790 100644
+--- a/bsd-user/freebsd/strace.list
++++ b/bsd-user/freebsd/strace.list
+@@ -33,6 +33,10 @@
+ { TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
+ { TARGET_FREEBSD_NR__umtx_op, "_umtx_op", "%s(%#x, %d, %d, %#x, %#x)", NULL, NULL },
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
++{ TARGET_FREEBSD_NR__umtx_lock, "__umtx_lock", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR__umtx_unlock, "__umtx_unlock", NULL, NULL, NULL },
++#endif
+ { TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
+ { TARGET_FREEBSD_NR_accept4, "accept4", "%s(%d,%d,%#x,%#x)", NULL, NULL },
+ { TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
+@@ -45,6 +49,10 @@
+ { TARGET_FREEBSD_NR_cap_fcntls_get, "cap_fcntls_get", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_fcntls_limit, "cap_fcntls_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_getmode, "cap_getmode", NULL, NULL, NULL },
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
++{ TARGET_FREEBSD_NR_cap_getrights, "cap_getrights", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_new, "cap_new", NULL, NULL, NULL },
++#endif
+ { TARGET_FREEBSD_NR_cap_ioctls_get, "cap_ioctls_get", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_ioctls_limit, "cap_ioctls_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_cap_rights_limit, "cap_rights_limit", NULL, NULL, NULL },
+@@ -126,6 +134,9 @@
+ { TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL },
+ { TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL },
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1000000
++{ TARGET_FREEBSD_NR_killpg, "killpg", NULL, NULL, NULL },
++#endif
+ { TARGET_FREEBSD_NR_kqueue, "kqueue", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_ktrace, "ktrace", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_lchown, "lchown", NULL, NULL, NULL },
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index 74c3135..dd3cb4f 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -467,3 +467,19 @@
+ #define TARGET_FREEBSD_NR_aio_mlock 543
+ #define TARGET_FREEBSD_NR_procctl 544
+ #define TARGET_FREEBSD_NR_MAXSYSCALL 545
++/* Legacy system calls. */
++#ifndef TARGET_FREEBSD_NR_killpg
++#define TARGET_FREEBSD_NR_killpg 146
++#endif
++#ifndef TARGET_FREEBSD_NR__umtx_lock
++#define TARGET_FREEBSD_NR__umtx_lock 434
++#endif
++#ifndef TARGET_FREEBSD_NR__umtx_unlock
++#define TARGET_FREEBSD_NR__umtx_unlock 435
++#endif
++#ifndef TARGET_FREEBSD_NR_cap_new
++#define TARGET_FREEBSD_NR_cap_new 514
++#endif
++#ifndef TARGET_FREEBSD_NR_cap_getrights
++#define TARGET_FREEBSD_NR_cap_getrights 515
++#endif
diff --git a/emulators/qemu-devel/files/extra-patch-9ed0e07e2e07791858339874eb4d20daca858c8a b/emulators/qemu-devel/files/extra-patch-9ed0e07e2e07791858339874eb4d20daca858c8a
new file mode 100644
index 000000000000..f2561fe3ff4e
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-9ed0e07e2e07791858339874eb4d20daca858c8a
@@ -0,0 +1,77 @@
+From 9ed0e07e2e07791858339874eb4d20daca858c8a Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Fri, 7 Nov 2014 22:17:58 +0000
+Subject: [PATCH] Fix typo and some other build issues.
+
+---
+ bsd-user/bsd-proc.c | 5 +++--
+ bsd-user/freebsd/os-proc.c | 4 ++++
+ bsd-user/freebsd/os-proc.h | 1 +
+ 3 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
+index 503e928..248bcfb 100644
+--- a/bsd-user/bsd-proc.c
++++ b/bsd-user/bsd-proc.c
+@@ -17,6 +17,7 @@
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
++#include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/resource.h>
+ #include <sys/wait.h>
+@@ -147,7 +148,7 @@ abi_long host_to_target_rusage(abi_ulong target_addr,
+ return 0;
+ }
+
+-:#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ abi_long host_to_target_wrusage(abi_ulong target_addr,
+ const struct __wrusage *wrusage)
+ {
+@@ -162,7 +163,7 @@ abi_long host_to_target_wrusage(abi_ulong target_addr,
+
+ return 0;
+ }
+-#endif /* ! __FreeBSD_version >= 1000000 */
++#endif /* __FreeBSD_version >= 1000000 */
+
+ /*
+ * wait status conversion.
+diff --git a/bsd-user/freebsd/os-proc.c b/bsd-user/freebsd/os-proc.c
+index b185439..fd0b64f 100644
+--- a/bsd-user/freebsd/os-proc.c
++++ b/bsd-user/freebsd/os-proc.c
+@@ -234,7 +234,9 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ }
+
+ if (do_fexec) {
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
+ char execpath[PATH_MAX], *scriptargs;
++#endif /* __FreeBSD_version < 1100000 */
+
+ if (((int)path_or_fd > 0 &&
+ is_target_elf_binary((int)path_or_fd)) == 1) {
+@@ -291,7 +293,9 @@ abi_long freebsd_exec_common(abi_ulong path_or_fd, abi_ulong guest_argp,
+ }
+ } else {
+ int fd;
++#if defined(__FreeBSD_version) && __FreeBSD_version < 1100000
+ char execpath[PATH_MAX], *scriptargs;
++#endif
+
+ p = lock_user_string(path_or_fd);
+ if (p == NULL) {
+diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
+index 193e1fc..487aef3 100644
+--- a/bsd-user/freebsd/os-proc.h
++++ b/bsd-user/freebsd/os-proc.h
+@@ -20,6 +20,7 @@
+ #ifndef __FREEBSD_PROC_H_
+ #define __FREEBSD_PROC_H_
+
++#include <sys/param.h>
+ #if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ #include <sys/procctl.h>
+ #include <sys/signal.h>
diff --git a/emulators/qemu-devel/files/extra-patch-a6402a4b7077af85733a1c98d63ab09f02d980ec b/emulators/qemu-devel/files/extra-patch-a6402a4b7077af85733a1c98d63ab09f02d980ec
new file mode 100644
index 000000000000..372aabe74f55
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-a6402a4b7077af85733a1c98d63ab09f02d980ec
@@ -0,0 +1,173 @@
+From a6402a4b7077af85733a1c98d63ab09f02d980ec Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Wed, 5 Nov 2014 22:35:23 +0000
+Subject: [PATCH] Add stubs for the new aio_*() system calls.
+
+This change adds stubs for the asynchronous I/O system calls including:
+aio_cancel(2), aio_error(2), aio_return(2), aio_read(2), aio_write(2),
+aio_syspend(2), aio_waitcomplete(2), aio_fsync(2), and aio_mlock(2).
+---
+ bsd-user/freebsd/os-file.h | 78 +++++++++++++++++++++++++++++++++++++++++++
+ bsd-user/freebsd/syscall_nr.h | 4 ++-
+ bsd-user/syscall.c | 43 ++++++++++++++++++++++++
+ 3 files changed, 124 insertions(+), 1 deletion(-)
+
+diff --git a/bsd-user/freebsd/os-file.h b/bsd-user/freebsd/os-file.h
+index 2c6bc24..0b3e8c5 100644
+--- a/bsd-user/freebsd/os-file.h
++++ b/bsd-user/freebsd/os-file.h
+@@ -21,10 +21,88 @@
+ #define __FREEBSD_OS_FILE_H_
+
+ #include <sys/stat.h>
++#include <aio.h>
+ #include <unistd.h>
+
+ #include "qemu-os.h"
+
++/*
++ * Asynchronous I/O.
++ */
++
++/* aio_read(2) */
++static abi_long do_freebsd_aio_read(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_read()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_write(2) */
++static abi_long do_freebsd_aio_write(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_write()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_suspend(2) */
++static abi_long do_freebsd_aio_suspend(__unused abi_ulong iocbs,
++ __unused int niocb, __unused abi_ulong timeout)
++{
++ qemu_log("qemu: Unsupported syscall aio_suspend()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_cancel(2) */
++static abi_long do_freebsd_aio_cancel(__unused int fildes,
++ __unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_cancel()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_error(2) */
++static abi_long do_freebsd_aio_error(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_error()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* oaio_read(2) */
++static abi_long do_freebsd_oaio_read(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall oaio_read()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* oaio_write(2) */
++static abi_long do_freebsd_oaio_write(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall oaio_write()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_waitcomplete(2) */
++static abi_long do_freebsd_aio_waitcomplete(__unused abi_ulong iocbp,
++ __unused abi_ulong timeout)
++{
++ qemu_log("qemu: Unsupported syscall aio_waitcomplete()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_fsync(2) */
++static abi_long do_freebsd_aio_fsync(__unused int op,
++ __unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_fsync()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* aio_mlock(2) */
++static abi_long do_freebsd_aio_mlock(__unused abi_ulong iocb)
++{
++ qemu_log("qemu: Unsupported syscall aio_mlock()\n");
++ return -TARGET_ENOSYS;
++}
+
+ #if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ /* pipe2(2) */
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index b44545b..7d6bef8 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -458,4 +458,6 @@
+ #define TARGET_FREEBSD_NR_chflagsat 540
+ #define TARGET_FREEBSD_NR_accept4 541
+ #define TARGET_FREEBSD_NR_pipe2 542
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 543
++#define TARGET_FREEBSD_NR_aio_mlock 543
++#define TARGET_FREEBSD_NR_procctl 544
++#define TARGET_FREEBSD_NR_MAXSYSCALL 545
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 0a2ab88..30dc2f3 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -1582,6 +1582,49 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_obreak(arg1);
+ break;
+
++ /*
++ * Asynchronous I/O
++ */
++ case TARGET_FREEBSD_NR_aio_read: /* aio_read(2) */
++ ret = do_freebsd_aio_read(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_write: /* aio_write(2) */
++ ret = do_freebsd_aio_write(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_suspend: /* aio_suspend(2) */
++ ret = do_freebsd_aio_suspend(arg1, arg2, arg3);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_cancel: /* aio_cancel(2) */
++ ret = do_freebsd_aio_cancel(arg1, arg2);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_error: /* aio_error(2) */
++ ret = do_freebsd_aio_error(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_oaio_read: /* oaio_read(2) */
++ ret = do_freebsd_oaio_read(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_oaio_write: /* oaio_write(2) */
++ ret = do_freebsd_oaio_write(arg1);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_waitcomplete: /* aio_waitcomplete(2) */
++ ret = do_freebsd_aio_waitcomplete(arg1, arg2);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_fsync: /* aio_fsync(2) */
++ ret = do_freebsd_aio_fsync(arg1, arg2);
++ break;
++
++ case TARGET_FREEBSD_NR_aio_mlock: /* aio_mlock(2) */
++ ret = do_freebsd_aio_mlock(arg1);
++ break;
++
+ default:
+ ret = get_errno(syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
+ arg8));
diff --git a/emulators/qemu-devel/files/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b b/emulators/qemu-devel/files/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b
new file mode 100644
index 000000000000..322dc7e823fe
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b
@@ -0,0 +1,108 @@
+From a8dc4de7f73bc6f8363c0fc81c4c6e53733c444b Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Fri, 7 Nov 2014 22:24:56 +0000
+Subject: [PATCH] Make bindat(2), connectat(2) and accept4(2) syscall handlers
+ consistent.
+
+The stubs for bindat(2) and connectat(2) didn't have the correct number of
+arguments. Also, since bindat, connectat and accept4 are freebsd-only
+system calls the handlers should be do_freebsd_* instead of do_bsd_*.
+---
+ bsd-user/freebsd/os-socket.h | 18 ++++++++++--------
+ bsd-user/syscall.c | 6 +++---
+ 2 files changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/bsd-user/freebsd/os-socket.h b/bsd-user/freebsd/os-socket.h
+index 4212f0a..31bd1b3 100644
+--- a/bsd-user/freebsd/os-socket.h
++++ b/bsd-user/freebsd/os-socket.h
+@@ -559,8 +559,8 @@ static inline abi_long do_freebsd_sendfile(abi_long fd, abi_long s,
+
+ #if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ /* bindat(2) */
+-static inline abi_long do_bsd_bindat(int fd, int sockfd, abi_ulong target_addr,
+- socklen_t addrlen)
++static inline abi_long do_freebsd_bindat(int fd, int sockfd,
++ abi_ulong target_addr, socklen_t addrlen)
+ {
+ abi_long ret;
+ void *addr;
+@@ -579,7 +579,7 @@ static inline abi_long do_bsd_bindat(int fd, int sockfd, abi_ulong target_addr,
+ }
+
+ /* connectat(2) */
+-static inline abi_long do_bsd_connectat(int fd, int sockfd,
++static inline abi_long do_freebsd_connectat(int fd, int sockfd,
+ abi_ulong target_addr, socklen_t addrlen)
+ {
+ abi_long ret;
+@@ -600,7 +600,7 @@ static inline abi_long do_bsd_connectat(int fd, int sockfd,
+ }
+
+ /* accept4(2) */
+-static inline abi_long do_bsd_accept4(int fd, abi_ulong target_addr,
++static inline abi_long do_freebsd_accept4(int fd, abi_ulong target_addr,
+ abi_ulong target_addrlen_addr, int flags)
+ {
+ socklen_t addrlen;
+@@ -635,7 +635,7 @@ static inline abi_long do_bsd_accept4(int fd, abi_ulong target_addr,
+ #else /* ! __FreeBSD_version >= 1000000 */
+
+ /* bindat(2) */
+-static inline abi_long do_bsd_bindat(__unused int sockfd,
++static inline abi_long do_freebsd_bindat(__unused int fd, __unused int sockfd,
+ __unused abi_ulong target_addr, __unused socklen_t addrlen)
+ {
+
+@@ -644,15 +644,17 @@ static inline abi_long do_bsd_bindat(__unused int sockfd,
+ }
+
+ /* connectat(2) */
+-static inline abi_long do_bsd_connectat(__unused int sockfd,
+- __unused abi_ulong target_addr, __unused socklen_t addrlen)
++static inline abi_long do_freebsd_connectat(__unused int fd,
++ __unused int sockfd, __unused abi_ulong target_addr,
++ __unused socklen_t addrlen)
+ {
+
+ qemu_log("qemu: Unsupported syscall connectat()\n");
+ return -TARGET_ENOSYS;
+ }
+
+-static inline abi_long do_bsd_accept4(__unused int fd,
++/* accept4(2) */
++static inline abi_long do_freebsd_accept4(__unused int fd,
+ __unused abi_ulong target_addr, __unused abi_ulong target_addrlen_addr,
+ __unused int flags)
+ {
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 4a743e8..243eb13 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -1072,7 +1072,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ break;
+
+ case TARGET_FREEBSD_NR_accept4: /* accept4(2) */
+- ret = do_bsd_accept4(arg1, arg2, arg3, arg4);
++ ret = do_freebsd_accept4(arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_bind: /* bind(2) */
+@@ -1080,7 +1080,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ break;
+
+ case TARGET_FREEBSD_NR_bindat: /* bindat(2) */
+- ret = do_bsd_bindat(arg1, arg2, arg3, arg4);
++ ret = do_freebsd_bindat(arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_connect: /* connect(2) */
+@@ -1088,7 +1088,7 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ break;
+
+ case TARGET_FREEBSD_NR_connectat: /* connectat(2) */
+- ret = do_bsd_connectat(arg1, arg2, arg3, arg4);
++ ret = do_freebsd_connectat(arg1, arg2, arg3, arg4);
+ break;
+
+ case TARGET_FREEBSD_NR_getpeername: /* getpeername(2) */
diff --git a/emulators/qemu-devel/files/extra-patch-ac9f83019a2059d4bfe5cedfae35ba4151d5ac88 b/emulators/qemu-devel/files/extra-patch-ac9f83019a2059d4bfe5cedfae35ba4151d5ac88
new file mode 100644
index 000000000000..20be77475efa
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-ac9f83019a2059d4bfe5cedfae35ba4151d5ac88
@@ -0,0 +1,226 @@
+From ac9f83019a2059d4bfe5cedfae35ba4151d5ac88 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 4 Nov 2014 21:34:25 +0000
+Subject: [PATCH] Add support for the wait6(2) system call.
+
+---
+ bsd-user/bsd-proc.c | 37 ++++++++++++++++++++++-------
+ bsd-user/freebsd/os-proc.h | 55 ++++++++++++++++++++++++++++++++++++++++++-
+ bsd-user/freebsd/syscall_nr.h | 3 ++-
+ bsd-user/qemu-bsd.h | 2 ++
+ bsd-user/syscall.c | 6 ++++-
+ bsd-user/syscall_defs.h | 5 ++++
+ 6 files changed, 97 insertions(+), 11 deletions(-)
+
+diff --git a/bsd-user/bsd-proc.c b/bsd-user/bsd-proc.c
+index a4bcdc8..7f0b21c 100644
+--- a/bsd-user/bsd-proc.c
++++ b/bsd-user/bsd-proc.c
+@@ -1,7 +1,7 @@
+ /*
+ * BSD process related system call helpers
+ *
+- * Copyright (c) 2013 Stacey D. Son
++ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -108,14 +108,9 @@ abi_ulong host_to_target_rlim(rlim_t rlim)
+ return result;
+ }
+
+-abi_long host_to_target_rusage(abi_ulong target_addr,
+- const struct rusage *rusage)
++static void h2t_rusage(const struct rusage *rusage,
++ struct target_freebsd_rusage *target_rusage)
+ {
+- struct target_freebsd_rusage *target_rusage;
+-
+- if (!lock_user_struct(VERIFY_WRITE, target_rusage, target_addr, 0)) {
+- return -TARGET_EFAULT;
+- }
+ __put_user(rusage->ru_utime.tv_sec, &target_rusage->ru_utime.tv_sec);
+ __put_user(rusage->ru_utime.tv_usec, &target_rusage->ru_utime.tv_usec);
+
+@@ -136,11 +131,37 @@ abi_long host_to_target_rusage(abi_ulong target_addr,
+ __put_user(rusage->ru_nsignals, &target_rusage->ru_nsignals);
+ __put_user(rusage->ru_nvcsw, &target_rusage->ru_nvcsw);
+ __put_user(rusage->ru_nivcsw, &target_rusage->ru_nivcsw);
++}
++
++abi_long host_to_target_rusage(abi_ulong target_addr,
++ const struct rusage *rusage)
++{
++ struct target_freebsd_rusage *target_rusage;
++
++ if (!lock_user_struct(VERIFY_WRITE, target_rusage, target_addr, 0)) {
++ return -TARGET_EFAULT;
++ }
++ h2t_rusage(rusage, target_rusage);
+ unlock_user_struct(target_rusage, target_addr, 1);
+
+ return 0;
+ }
+
++abi_long host_to_target_wrusage(abi_ulong target_addr,
++ const struct __wrusage *wrusage)
++{
++ struct target_freebsd__wrusage *target_wrusage;
++
++ if (!lock_user_struct(VERIFY_WRITE, target_wrusage, target_addr, 0)) {
++ return -TARGET_EFAULT;
++ }
++ h2t_rusage(&wrusage->wru_self, &target_wrusage->wru_self);
++ h2t_rusage(&wrusage->wru_children, &target_wrusage->wru_children);
++ unlock_user_struct(target_wrusage, target_addr, 1);
++
++ return 0;
++}
++
+ /*
+ * wait status conversion.
+ *
+diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
+index b31f7c4..8e28f04 100644
+--- a/bsd-user/freebsd/os-proc.h
++++ b/bsd-user/freebsd/os-proc.h
+@@ -1,7 +1,7 @@
+ /*
+ * process related system call shims and definitions
+ *
+- * Copyright (c) 2013 Stacey D. Son
++ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -20,6 +20,9 @@
+ #ifndef __FREEBSD_PROC_H_
+ #define __FREEBSD_PROC_H_
+
++#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++#include <sys/signal.h>
++#endif
+ #include <sys/types.h>
+ #if defined(__FreeBSD_version) && __FreeBSD_version > 900000
+ #include <sys/procdesc.h>
+@@ -72,6 +75,56 @@ static inline abi_long do_freebsd_wait4(abi_long arg1, abi_ulong target_status,
+ return ret;
+ }
+
++#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++/* wait6(2) */
++static inline abi_long do_freebsd_wait6(abi_long idtype, abi_long id,
++ abi_ulong target_status, abi_long options, abi_ulong target_wrusage,
++ abi_ulong target_infop)
++{
++ abi_long ret;
++ int status;
++ struct __wrusage wrusage, *wrusage_ptr = NULL;
++ siginfo_t info;
++ void *p;
++
++ if (target_wrusage) {
++ wrusage_ptr = &wrusage;
++ }
++ ret = get_errno(wait6(idtype, id, &status, options, wrusage_ptr, &info));
++ if (!is_error(ret)) {
++ status = host_to_target_waitstatus(status);
++ if (put_user_s32(status, target_status) != 0) {
++ return -TARGET_EFAULT;
++ }
++ if (target_wrusage != 0) {
++ host_to_target_wrusage(target_wrusage, &wrusage);
++ }
++ if (target_infop != 0) {
++ p = lock_user(VERIFY_WRITE, target_infop, sizeof(target_siginfo_t),
++ 0);
++ if (p == NULL) {
++ return -TARGET_EFAULT;
++ }
++ host_to_target_siginfo(p, &info);
++ unlock_user(p, target_infop, sizeof(target_siginfo_t));
++ }
++ }
++ return ret;
++}
++
++#else /* ! __FreeBSD_version > 1100000 */
++
++static inline abi_long do_freebsd_wait6( __unused abi_long idtype,
++ __unused abi_long id, __unused abi_ulong target_status,
++ __unused abi_long options, __unused abi_ulong target_wrusage,
++ __unused abi_ulong target_infop)
++{
++
++ qemu_log("qemu: Unsupported syscall wait6()\n");
++ return -TARGET_ENOSYS;
++}
++#endif /* __FreeBSD_version > 1100000 */
++
+ #if defined(__FreeBSD_version) && __FreeBSD_version > 900000
+ /* setloginclass(2) */
+ static inline abi_long do_freebsd_setloginclass(abi_ulong arg1)
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index d849024..779e192 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -447,4 +447,5 @@
+ #define TARGET_FREEBSD_NR_rctl_remove_rule 529
+ #define TARGET_FREEBSD_NR_posix_fallocate 530
+ #define TARGET_FREEBSD_NR_posix_fadvise 531
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 532
++#define TARGET_FREEBSD_NR_wait6 532
++#define TARGET_FREEBSD_NR_MAXSYSCALL 533
+diff --git a/bsd-user/qemu-bsd.h b/bsd-user/qemu-bsd.h
+index 771245d..e58fdd7 100644
+--- a/bsd-user/qemu-bsd.h
++++ b/bsd-user/qemu-bsd.h
+@@ -48,6 +48,8 @@ rlim_t target_to_host_rlim(abi_ulong target_rlim);
+ abi_ulong host_to_target_rlim(rlim_t rlim);
+ abi_long host_to_target_rusage(abi_ulong target_addr,
+ const struct rusage *rusage);
++abi_long host_to_target_wrusage(abi_ulong target_addr,
++ const struct __wrusage *wrusage);
+ int host_to_target_waitstatus(int status);
+
+ /* bsd-socket.c */
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index ac27584..4f5a008 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -2,7 +2,7 @@
+ * BSD syscalls
+ *
+ * Copyright (c) 2003 - 2008 Fabrice Bellard
+- * Copyright (c) 2013 Stacey D. Son
++ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -189,6 +189,10 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_freebsd_wait4(arg1, arg2, arg3, arg4);
+ break;
+
++ case TARGET_FREEBSD_NR_wait6: /* wait6(2) */
++ ret = do_freebsd_wait6(arg1, arg2, arg3, arg4, arg5, arg6);
++ break;
++
+ case TARGET_FREEBSD_NR_exit: /* exit(2) */
+ ret = do_bsd_exit(cpu_env, arg1);
+ break;
+diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h
+index d02476c..1af31da 100644
+--- a/bsd-user/syscall_defs.h
++++ b/bsd-user/syscall_defs.h
+@@ -281,6 +281,11 @@ struct target_freebsd_rusage {
+ abi_long ru_nivcsw; /* involuntary context switches */
+ };
+
++struct target_freebsd__wrusage {
++ struct target_freebsd_rusage wru_self;
++ struct target_freebsd_rusage wru_children;
++};
++
+ /*
+ * sys/socket.h
+ */
diff --git a/emulators/qemu-devel/files/extra-patch-ad225b8412847303d48d8e7852589456325e8f9b b/emulators/qemu-devel/files/extra-patch-ad225b8412847303d48d8e7852589456325e8f9b
new file mode 100644
index 000000000000..1c4dcf552384
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-ad225b8412847303d48d8e7852589456325e8f9b
@@ -0,0 +1,36 @@
+From ad225b8412847303d48d8e7852589456325e8f9b Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Fri, 7 Nov 2014 16:07:27 +0000
+Subject: [PATCH] Correctly deal with new sem_wait2 and sem_wake2 _umtx ops for
+ 9.x builds.
+
+---
+ bsd-user/freebsd/os-thread.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/bsd-user/freebsd/os-thread.c b/bsd-user/freebsd/os-thread.c
+index cca46cf..baec878 100644
+--- a/bsd-user/freebsd/os-thread.c
++++ b/bsd-user/freebsd/os-thread.c
+@@ -241,9 +241,9 @@ abi_long freebsd_umtx_sem_wake(abi_ulong obj, uint32_t val)
+
+ return get_errno(_umtx_op(g2h(obj), UMTX_OP_SEM2_WAKE, val, NULL, NULL));
+ }
+-#endif
+
+-#else
++#else /* ! __FreeBSD_version > 1100000 */
++
+ abi_long freebsd_umtx_sem_wait(abi_ulong obj, struct timespec *timeout)
+ {
+
+@@ -259,7 +259,8 @@ abi_long freebsd_umtx_sem_wake(abi_ulong obj, uint32_t val)
+
+ return get_errno(_umtx_op(g2h(obj), UMTX_OP_SEM_WAKE, val, NULL, NULL));
+ }
+-#endif
++#endif /* ! __FreeBSD_version > 110000 */
++#endif /* ! __FreeBSD_version > 900000 */
+
+ abi_long t2h_freebsd_rtprio(struct rtprio *host_rtp, abi_ulong target_addr)
+ {
diff --git a/emulators/qemu-devel/files/extra-patch-c9c55ac786f09ce575b5f67b35241ce9452896c9 b/emulators/qemu-devel/files/extra-patch-c9c55ac786f09ce575b5f67b35241ce9452896c9
new file mode 100644
index 000000000000..315b99e258b8
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-c9c55ac786f09ce575b5f67b35241ce9452896c9
@@ -0,0 +1,224 @@
+From c9c55ac786f09ce575b5f67b35241ce9452896c9 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 4 Nov 2014 23:38:38 +0000
+Subject: [PATCH] Add support for new socket system calls.
+
+This change adds support for bindat(2), connectat(2), and accept4(2)
+system calls.
+---
+ bsd-user/freebsd/os-socket.h | 106 +++++++++++++++++++++++++++++++++++++++++-
+ bsd-user/freebsd/strace.list | 13 ++++++
+ bsd-user/freebsd/syscall_nr.h | 6 ++-
+ bsd-user/syscall.c | 12 +++++
+ 4 files changed, 135 insertions(+), 2 deletions(-)
+
+diff --git a/bsd-user/freebsd/os-socket.h b/bsd-user/freebsd/os-socket.h
+index 6530a07..61e3440 100644
+--- a/bsd-user/freebsd/os-socket.h
++++ b/bsd-user/freebsd/os-socket.h
+@@ -1,7 +1,7 @@
+ /*
+ * FreeBSD socket related system call shims
+ *
+- * Copyright (c) 2013 Stacey D. Son
++ * Copyright (c) 2013-14 Stacey D. Son
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -557,4 +557,108 @@ static inline abi_long do_freebsd_sendfile(abi_long fd, abi_long s,
+ return -TARGET_ENOSYS;
+ }
+
++#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++/* bindat(2) */
++static inline abi_long do_bsd_bindat(int fd, int sockfd, abi_ulong target_addr,
++ socklen_t addrlen)
++{
++ abi_long ret;
++ void *addr;
++
++ if ((int)addrlen < 0) {
++ return -TARGET_EINVAL;
++ }
++
++ addr = alloca(addrlen + 1);
++ ret = target_to_host_sockaddr(addr, target_addr, addrlen);
++ if (is_error(ret)) {
++ return ret;
++ }
++
++ return get_errno(bindat(fd, sockfd, addr, addrlen));
++}
++
++/* connectat(2) */
++static inline abi_long do_bsd_connectat(int fd, int sockfd,
++ abi_ulong target_addr, socklen_t addrlen)
++{
++ abi_long ret;
++ void *addr;
++
++ if ((int)addrlen < 0) {
++ return -TARGET_EINVAL;
++ }
++ addr = alloca(addrlen);
++
++ ret = target_to_host_sockaddr(addr, target_addr, addrlen);
++
++ if (is_error(ret)) {
++ return ret;
++ }
++
++ return get_errno(connectat(fd, sockfd, addr, addrlen));
++}
++
++/* accept4(2) */
++static inline abi_long do_bsd_accept4(int fd, abi_ulong target_addr,
++ abi_ulong target_addrlen_addr, int flags)
++{
++ socklen_t addrlen;
++ void *addr;
++ abi_long ret;
++
++ if (target_addr == 0) {
++ return get_errno(accept(fd, NULL, NULL));
++ }
++ /* return EINVAL if addrlen pointer is invalid */
++ if (get_user_u32(addrlen, target_addrlen_addr)) {
++ return -TARGET_EINVAL;
++ }
++ if ((int)addrlen < 0) {
++ return -TARGET_EINVAL;
++ }
++ if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) {
++ return -TARGET_EINVAL;
++ }
++ addr = alloca(addrlen);
++
++ ret = get_errno(accept4(fd, addr, &addrlen, flags));
++ if (!is_error(ret)) {
++ host_to_target_sockaddr(target_addr, addr, addrlen);
++ if (put_user_u32(addrlen, target_addrlen_addr)) {
++ ret = -TARGET_EFAULT;
++ }
++ }
++ return ret;
++}
++
++#else /* ! __FreeBSD_version > 1100000 */
++
++/* bindat(2) */
++static inline abi_long do_bsd_bindat(__unused int sockfd,
++ __unused abi_ulong target_addr, __unused socklen_t addrlen)
++{
++
++ qemu_log("qemu: Unsupported syscall bindat()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* connectat(2) */
++static inline abi_long do_bsd_connectat(__unused int sockfd,
++ __unused abi_ulong target_addr, __unused socklen_t addrlen)
++{
++
++ qemu_log("qemu: Unsupported syscall connectat()\n");
++ return -TARGET_ENOSYS;
++}
++
++static inline abi_long do_bsd_accept4(__unused int fd,
++ __unused abi_ulong target_addr, __unused abi_ulong target_addrlen_addr,
++ __unused int flags)
++{
++
++ qemu_log("qemu: Unsupported syscall accept4()\n");
++ return -TARGET_ENOSYS;
++}
++#endif /* ! __FreeBSD_version > 1100000 */
+ #endif /* !__FREEBSD_SOCKET_H_ */
+diff --git a/bsd-user/freebsd/strace.list b/bsd-user/freebsd/strace.list
+index f8858aa..991cbe2 100644
+--- a/bsd-user/freebsd/strace.list
++++ b/bsd-user/freebsd/strace.list
+@@ -34,11 +34,22 @@
+ { TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, print_sysctl, NULL },
+ { TARGET_FREEBSD_NR__umtx_op, "_umtx_op", "%s(%#x, %d, %d, %#x, %#x)", NULL, NULL },
+ { TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL },
++{ TARGET_FREEBSD_NR_accept4, "accept4", "%s(%d,%d,%#x,%#x)", NULL, NULL },
+ { TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL },
+ { TARGET_FREEBSD_NR_acct, "acct", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_adjtime, "adjtime", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_bind, "bind", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_bindat, "bindat", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_break, "break", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_enter, "cap_enter", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_fcntls_get, "cap_fcntls_get", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_fcntls_limit, "cap_fcntls_limit", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_getmode, "cap_getmode", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_getrights, "cap_getrights", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_ioctls_get, "cap_ioctls_get", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_ioctls_limit, "cap_ioctls_limit", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_new, "cap_new", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_cap_rights_limit, "cap_rights_limit", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL },
+ { TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL },
+@@ -49,6 +60,7 @@
+ { TARGET_FREEBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_close, "close", "%s(%d)", NULL, NULL },
+ { TARGET_FREEBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL },
++{ TARGET_FREEBSD_NR_connectat, "connectat", "%s(%d,%d,%#x,%d)", NULL, NULL },
+ { TARGET_FREEBSD_NR_dup, "dup", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_dup2, "dup2", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_eaccess, "eaccess", "%s(\"%s\",%#x)", NULL, NULL },
+@@ -228,6 +240,7 @@
+ { TARGET_FREEBSD_NR_utimes, "utimes", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_vfork, "vfork", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_wait4, "wait4", NULL, NULL, NULL },
++{ TARGET_FREEBSD_NR_wait6, "wait6", NULL, NULL, NULL },
+ { TARGET_FREEBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL },
+ { TARGET_FREEBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL },
+ { TARGET_FREEBSD_NR_posix_openpt, "posix_openpt", "%s(%d)", NULL, NULL },
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index 2ab3e1e..260fd82 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -453,4 +453,8 @@
+ #define TARGET_FREEBSD_NR_cap_ioctls_get 535
+ #define TARGET_FREEBSD_NR_cap_fcntls_limit 536
+ #define TARGET_FREEBSD_NR_cap_fcntls_get 537
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 538
++#define TARGET_FREEBSD_NR_bindat 538
++#define TARGET_FREEBSD_NR_connectat 539
++#define TARGET_FREEBSD_NR_chflagsat 540
++#define TARGET_FREEBSD_NR_accept4 541
++#define TARGET_FREEBSD_NR_MAXSYSCALL 542
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index c615bb8..e043396 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -1056,14 +1056,26 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_bsd_accept(arg1, arg2, arg3);
+ break;
+
++ case TARGET_FREEBSD_NR_accept4: /* accept4(2) */
++ ret = do_bsd_accept4(arg1, arg2, arg3, arg4);
++ break;
++
+ case TARGET_FREEBSD_NR_bind: /* bind(2) */
+ ret = do_bsd_bind(arg1, arg2, arg3);
+ break;
+
++ case TARGET_FREEBSD_NR_bindat: /* bindat(2) */
++ ret = do_bsd_bindat(arg1, arg2, arg3, arg4);
++ break;
++
+ case TARGET_FREEBSD_NR_connect: /* connect(2) */
+ ret = do_bsd_connect(arg1, arg2, arg3);
+ break;
+
++ case TARGET_FREEBSD_NR_connectat: /* connectat(2) */
++ ret = do_bsd_connectat(arg1, arg2, arg3, arg4);
++ break;
++
+ case TARGET_FREEBSD_NR_getpeername: /* getpeername(2) */
+ ret = do_bsd_getpeername(arg1, arg2, arg3);
+ break;
diff --git a/emulators/qemu-devel/files/extra-patch-d9388715135ed1f36e12e6cdbcc1be09d1657916 b/emulators/qemu-devel/files/extra-patch-d9388715135ed1f36e12e6cdbcc1be09d1657916
new file mode 100644
index 000000000000..9b84e18ec838
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-d9388715135ed1f36e12e6cdbcc1be09d1657916
@@ -0,0 +1,112 @@
+From d9388715135ed1f36e12e6cdbcc1be09d1657916 Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Tue, 4 Nov 2014 22:14:50 +0000
+Subject: [PATCH] Add stubs for the new cap_*() system calls.
+
+This change adds stubs for cap_right_limit(2), cap_ioctls_limit(2),
+cap_ioctls_get(2), cap_fcntls_limit(2), and cap_fcntls_get(2) system calls.
+---
+ bsd-user/freebsd/os-proc.h | 42 ++++++++++++++++++++++++++++++++++++++++++
+ bsd-user/freebsd/syscall_nr.h | 7 ++++++-
+ bsd-user/syscall.c | 20 ++++++++++++++++++++
+ 3 files changed, 68 insertions(+), 1 deletion(-)
+
+diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
+index 8e28f04..cd05e96 100644
+--- a/bsd-user/freebsd/os-proc.h
++++ b/bsd-user/freebsd/os-proc.h
+@@ -419,6 +419,48 @@ static inline abi_long do_freebsd_cap_getmode(abi_ulong arg1)
+ return -TARGET_ENOSYS;
+ }
+
++/* cap_rights_limit(2) */
++static inline abi_long do_freebsd_cap_rights_limit(int arg1, abi_ulong arg2)
++{
++
++ qemu_log("qemu: Unsupported syscall cap_rights_limit()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* cap_ioctls_limit(2) */
++static inline abi_long do_freebsd_cap_ioctls_limit(int arg1, abi_ulong arg2,
++ abi_ulong arg3)
++{
++
++ qemu_log("qemu: Unsupported syscall cap_ioctls_limit()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* cap_ioctls_get(2) */
++static inline abi_long do_freebsd_cap_ioctls_get(int arg1, abi_ulong arg2,
++ abi_ulong arg3)
++{
++
++ qemu_log("qemu: Unsupported syscall cap_ioctls_limit()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* cap_fcntls_limit(2) */
++static inline abi_long do_freebsd_cap_fcntls_limit(int arg1, abi_ulong arg2)
++{
++
++ qemu_log("qemu: Unsupported syscall cap_fcntls_limit()\n");
++ return -TARGET_ENOSYS;
++}
++
++/* cap_fcntls_get(2) */
++static inline abi_long do_freebsd_cap_fcntls_get(int arg1, abi_ulong arg2)
++{
++
++ qemu_log("qemu: Unsupported syscall cap_fcntls_get()\n");
++ return -TARGET_ENOSYS;
++}
++
+ /* audit(2) */
+ static inline abi_long do_freebsd_audit(abi_ulong arg1, abi_ulong arg2)
+ {
+diff --git a/bsd-user/freebsd/syscall_nr.h b/bsd-user/freebsd/syscall_nr.h
+index 779e192..2ab3e1e 100644
+--- a/bsd-user/freebsd/syscall_nr.h
++++ b/bsd-user/freebsd/syscall_nr.h
+@@ -448,4 +448,9 @@
+ #define TARGET_FREEBSD_NR_posix_fallocate 530
+ #define TARGET_FREEBSD_NR_posix_fadvise 531
+ #define TARGET_FREEBSD_NR_wait6 532
+-#define TARGET_FREEBSD_NR_MAXSYSCALL 533
++#define TARGET_FREEBSD_NR_cap_rights_limit 533
++#define TARGET_FREEBSD_NR_cap_ioctls_limit 534
++#define TARGET_FREEBSD_NR_cap_ioctls_get 535
++#define TARGET_FREEBSD_NR_cap_fcntls_limit 536
++#define TARGET_FREEBSD_NR_cap_fcntls_get 537
++#define TARGET_FREEBSD_NR_MAXSYSCALL 538
+diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
+index 4f5a008..c615bb8 100644
+--- a/bsd-user/syscall.c
++++ b/bsd-user/syscall.c
+@@ -367,6 +367,26 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
+ ret = do_freebsd_cap_getmode(arg1);
+ break;
+
++ case TARGET_FREEBSD_NR_cap_rights_limit: /* cap_rights_limit(2) */
++ ret = do_freebsd_cap_rights_limit(arg1, arg2);
++ break;
++
++ case TARGET_FREEBSD_NR_cap_ioctls_limit: /* cap_ioctls_limit(2) */
++ ret = do_freebsd_cap_ioctls_limit(arg1, arg2, arg3);
++ break;
++
++ case TARGET_FREEBSD_NR_cap_ioctls_get: /* cap_ioctls_get(2) */
++ ret = do_freebsd_cap_ioctls_get(arg1, arg2, arg3);
++ break;
++
++ case TARGET_FREEBSD_NR_cap_fcntls_limit: /* cap_fcntls_limit(2) */
++ ret = do_freebsd_cap_fcntls_limit(arg1, arg2);
++ break;
++
++ case TARGET_FREEBSD_NR_cap_fcntls_get: /* cap_fcntls_get(2) */
++ ret = do_freebsd_cap_fcntls_get(arg1, arg2);
++ break;
++
+ case TARGET_FREEBSD_NR_audit: /* audit(2) */
+ ret = do_freebsd_audit(arg1, arg2);
+ break;
diff --git a/emulators/qemu-devel/files/extra-patch-f32d585446698e1faa319c95df6b4d00c16f866c b/emulators/qemu-devel/files/extra-patch-f32d585446698e1faa319c95df6b4d00c16f866c
new file mode 100644
index 000000000000..dddad5432bcf
--- /dev/null
+++ b/emulators/qemu-devel/files/extra-patch-f32d585446698e1faa319c95df6b4d00c16f866c
@@ -0,0 +1,81 @@
+From f32d585446698e1faa319c95df6b4d00c16f866c Mon Sep 17 00:00:00 2001
+From: Stacey Son <sson@FreeBSD.org>
+Date: Wed, 5 Nov 2014 20:55:35 +0000
+Subject: [PATCH] The new system calls were actually added in 10.0.
+
+This change fixes when cap_*[_limit, _get](2), bindat(2), connectat(2),
+and wait6(2) were actually added to the FreeBSD kernel.
+---
+ bsd-user/freebsd/os-proc.h | 8 ++++----
+ bsd-user/freebsd/os-socket.h | 6 +++---
+ 2 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/bsd-user/freebsd/os-proc.h b/bsd-user/freebsd/os-proc.h
+index cd05e96..612a5fd 100644
+--- a/bsd-user/freebsd/os-proc.h
++++ b/bsd-user/freebsd/os-proc.h
+@@ -20,7 +20,7 @@
+ #ifndef __FREEBSD_PROC_H_
+ #define __FREEBSD_PROC_H_
+
+-#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ #include <sys/signal.h>
+ #endif
+ #include <sys/types.h>
+@@ -75,7 +75,7 @@ static inline abi_long do_freebsd_wait4(abi_long arg1, abi_ulong target_status,
+ return ret;
+ }
+
+-#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ /* wait6(2) */
+ static inline abi_long do_freebsd_wait6(abi_long idtype, abi_long id,
+ abi_ulong target_status, abi_long options, abi_ulong target_wrusage,
+@@ -112,7 +112,7 @@ static inline abi_long do_freebsd_wait6(abi_long idtype, abi_long id,
+ return ret;
+ }
+
+-#else /* ! __FreeBSD_version > 1100000 */
++#else /* ! __FreeBSD_version >= 1000000 */
+
+ static inline abi_long do_freebsd_wait6( __unused abi_long idtype,
+ __unused abi_long id, __unused abi_ulong target_status,
+@@ -123,7 +123,7 @@ static inline abi_long do_freebsd_wait6( __unused abi_long idtype,
+ qemu_log("qemu: Unsupported syscall wait6()\n");
+ return -TARGET_ENOSYS;
+ }
+-#endif /* __FreeBSD_version > 1100000 */
++#endif /* __FreeBSD_version >= 1000000 */
+
+ #if defined(__FreeBSD_version) && __FreeBSD_version > 900000
+ /* setloginclass(2) */
+diff --git a/bsd-user/freebsd/os-socket.h b/bsd-user/freebsd/os-socket.h
+index 61e3440..4212f0a 100644
+--- a/bsd-user/freebsd/os-socket.h
++++ b/bsd-user/freebsd/os-socket.h
+@@ -557,7 +557,7 @@ static inline abi_long do_freebsd_sendfile(abi_long fd, abi_long s,
+ return -TARGET_ENOSYS;
+ }
+
+-#if defined(__FreeBSD_version) && __FreeBSD_version > 1100000
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
+ /* bindat(2) */
+ static inline abi_long do_bsd_bindat(int fd, int sockfd, abi_ulong target_addr,
+ socklen_t addrlen)
+@@ -632,7 +632,7 @@ static inline abi_long do_bsd_accept4(int fd, abi_ulong target_addr,
+ return ret;
+ }
+
+-#else /* ! __FreeBSD_version > 1100000 */
++#else /* ! __FreeBSD_version >= 1000000 */
+
+ /* bindat(2) */
+ static inline abi_long do_bsd_bindat(__unused int sockfd,
+@@ -660,5 +660,5 @@ static inline abi_long do_bsd_accept4(__unused int fd,
+ qemu_log("qemu: Unsupported syscall accept4()\n");
+ return -TARGET_ENOSYS;
+ }
+-#endif /* ! __FreeBSD_version > 1100000 */
++#endif /* ! __FreeBSD_version >= 1000000 */
+ #endif /* !__FREEBSD_SOCKET_H_ */