Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/810094/?format=api
{ "id": 810094, "url": "http://patchwork.ozlabs.org/api/1.2/patches/810094/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1504613972-15847-1-git-send-email-peter.maydell@linaro.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.2/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504613972-15847-1-git-send-email-peter.maydell@linaro.org>", "list_archive_url": null, "date": "2017-09-05T12:19:32", "name": "util/qemu-thread-posix.c: Replace OS ifdefs with CONFIG_HAVE_SEM_TIMEDWAIT", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "98799d39a93addda13f4c1474617a7afd7abc0f8", "submitter": { "id": 5111, "url": "http://patchwork.ozlabs.org/api/1.2/people/5111/?format=api", "name": "Peter Maydell", "email": "peter.maydell@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1504613972-15847-1-git-send-email-peter.maydell@linaro.org/mbox/", "series": [ { "id": 1563, "url": "http://patchwork.ozlabs.org/api/1.2/series/1563/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1563", "date": "2017-09-05T12:19:32", "name": "util/qemu-thread-posix.c: Replace OS ifdefs with CONFIG_HAVE_SEM_TIMEDWAIT", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1563/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/810094/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/810094/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmm4V5gbQz9sRV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 5 Sep 2017 22:19:54 +1000 (AEST)", "from localhost ([::1]:58612 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dpCpc-0002u9-UC\n\tfor incoming@patchwork.ozlabs.org; Tue, 05 Sep 2017 08:19:52 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:45069)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pm215@archaic.org.uk>) id 1dpCp8-0002ts-BR\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 08:19:27 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pm215@archaic.org.uk>) id 1dpCp3-0001Sx-HV\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 08:19:22 -0400", "from orth.archaic.org.uk ([2001:8b0:1d0::2]:37156)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pm215@archaic.org.uk>)\n\tid 1dpCp3-0001Ry-9r; Tue, 05 Sep 2017 08:19:17 -0400", "from pm215 by orth.archaic.org.uk with local (Exim 4.89)\n\t(envelope-from <pm215@archaic.org.uk>)\n\tid 1dpCp0-0006zf-CH; Tue, 05 Sep 2017 13:19:14 +0100" ], "From": "Peter Maydell <peter.maydell@linaro.org>", "To": "qemu-devel@nongnu.org,\n\tqemu-trivial@nongnu.org", "Date": "Tue, 5 Sep 2017 13:19:32 +0100", "Message-Id": "<1504613972-15847-1-git-send-email-peter.maydell@linaro.org>", "X-Mailer": "git-send-email 2.7.4", "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.", "X-Received-From": "2001:8b0:1d0::2", "Subject": "[Qemu-devel] [PATCH] util/qemu-thread-posix.c: Replace OS ifdefs\n\twith CONFIG_HAVE_SEM_TIMEDWAIT", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "patches@linaro.org", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "In qemu-thread-posix.c we have two implementations of the\nvarious qemu_sem_* functions, one of which uses native POSIX\nsem_* and the other of which emulates them with pthread conditions.\nThis is necessary because not all our host OSes support\nsem_timedwait().\n\nInstead of a hard-coded list of OSes which don't implement\nsem_timedwait(), which gets out of date, make configure\ntest for the presence of the function and set a new\nCONFIG_HAVE_SEM_TIMEDWAIT appropriately.\n\nIn particular, newer NetBSDs have sem_timedwait(), so this\ncommit will switch them over to using it. OSX still does\nnot have an implementation.\n\nSigned-off-by: Peter Maydell <peter.maydell@linaro.org>\n---\nIt would be nice to gradually reduce the number of places\nwe do per-OS ifdeffery in favour of checking for the specific\nfeature we care about in each case...\nTested on Linux, NetBSD, OSX.\n\n configure | 15 +++++++++++++++\n include/qemu/thread-posix.h | 2 +-\n util/qemu-thread-posix.c | 10 +++++-----\n 3 files changed, 21 insertions(+), 6 deletions(-)", "diff": "diff --git a/configure b/configure\nindex fb7e34a..aa8d4d9 100755\n--- a/configure\n+++ b/configure\n@@ -4448,6 +4448,18 @@ if compile_prog \"\" \"\" ; then\n fi\n \n ##########################################\n+# check if we have sem_timedwait\n+\n+sem_timedwait=no\n+cat > $TMPC << EOF\n+#include <semaphore.h>\n+int main(void) { return sem_timedwait(0, 0); }\n+EOF\n+if compile_prog \"\" \"\" ; then\n+ sem_timedwait=yes\n+fi\n+\n+##########################################\n # check if trace backend exists\n \n $python \"$source_path/scripts/tracetool.py\" \"--backends=$trace_backends\" --check-backends > /dev/null 2> /dev/null\n@@ -5680,6 +5692,9 @@ fi\n if test \"$inotify1\" = \"yes\" ; then\n echo \"CONFIG_INOTIFY1=y\" >> $config_host_mak\n fi\n+if test \"$sem_timedwait\" = \"yes\" ; then\n+ echo \"CONFIG_SEM_TIMEDWAIT=y\" >> $config_host_mak\n+fi\n if test \"$byteswap_h\" = \"yes\" ; then\n echo \"CONFIG_BYTESWAP_H=y\" >> $config_host_mak\n fi\ndiff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h\nindex e5e3a0f..f4296d3 100644\n--- a/include/qemu/thread-posix.h\n+++ b/include/qemu/thread-posix.h\n@@ -21,7 +21,7 @@ struct QemuCond {\n };\n \n struct QemuSemaphore {\n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n pthread_mutex_t lock;\n pthread_cond_t cond;\n unsigned int count;\ndiff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c\nindex 4e95d27..7306475 100644\n--- a/util/qemu-thread-posix.c\n+++ b/util/qemu-thread-posix.c\n@@ -168,7 +168,7 @@ void qemu_sem_init(QemuSemaphore *sem, int init)\n {\n int rc;\n \n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n rc = pthread_mutex_init(&sem->lock, NULL);\n if (rc != 0) {\n error_exit(rc, __func__);\n@@ -196,7 +196,7 @@ void qemu_sem_destroy(QemuSemaphore *sem)\n \n assert(sem->initialized);\n sem->initialized = false;\n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n rc = pthread_cond_destroy(&sem->cond);\n if (rc < 0) {\n error_exit(rc, __func__);\n@@ -218,7 +218,7 @@ void qemu_sem_post(QemuSemaphore *sem)\n int rc;\n \n assert(sem->initialized);\n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n pthread_mutex_lock(&sem->lock);\n if (sem->count == UINT_MAX) {\n rc = EINVAL;\n@@ -256,7 +256,7 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)\n struct timespec ts;\n \n assert(sem->initialized);\n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n rc = 0;\n compute_abs_deadline(&ts, ms);\n pthread_mutex_lock(&sem->lock);\n@@ -304,7 +304,7 @@ void qemu_sem_wait(QemuSemaphore *sem)\n int rc;\n \n assert(sem->initialized);\n-#if defined(__APPLE__) || defined(__NetBSD__)\n+#ifndef CONFIG_SEM_TIMEDWAIT\n pthread_mutex_lock(&sem->lock);\n while (sem->count == 0) {\n rc = pthread_cond_wait(&sem->cond, &sem->lock);\n", "prefixes": [] }