From patchwork Fri Sep 8 12:46:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 9943891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 37CC860224 for ; Fri, 8 Sep 2017 12:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A9D1286E1 for ; Fri, 8 Sep 2017 12:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F74B286E3; Fri, 8 Sep 2017 12:47:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67698286E1 for ; Fri, 8 Sep 2017 12:47:37 +0000 (UTC) Received: from localhost ([::1]:45293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqIh6-0001mK-WA for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Sep 2017 08:47:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqIgH-0001hG-4M for qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:46:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqIgC-0007bP-VQ for qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:46:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqIgC-0007a2-Mn for qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:46:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92F8280460; Fri, 8 Sep 2017 12:46:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 92F8280460 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=david@redhat.com Received: from [10.36.117.121] (ovpn-117-121.ams2.redhat.com [10.36.117.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 199A7610B0; Fri, 8 Sep 2017 12:46:36 +0000 (UTC) To: Thomas Huth , qemu-devel@nongnu.org References: <20170907201335.13956-1-david@redhat.com> <20170907201335.13956-9-david@redhat.com> <1603f6bf-f481-13c2-c7eb-ac155c5a14cc@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Fri, 8 Sep 2017 14:46:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1603f6bf-f481-13c2-c7eb-ac155c5a14cc@redhat.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 08 Sep 2017 12:46:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH v3 08/21] s390x: move sclp_service_call() to sclp.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthew Rosato , Eduardo Habkost , cohuck@redhat.com, Richard Henderson , Alexander Graf , Markus Armbruster , borntraeger@de.ibm.com, Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 08.09.2017 06:21, Thomas Huth wrote: > On 07.09.2017 22:13, David Hildenbrand wrote: >> Implemented in sclp.c, so let's move it to the right include file. >> Fix up one include. Do a forward declaration of CPUS390XState to fix the >> two sclp consoles complaining. >> >> Signed-off-by: David Hildenbrand >> --- >> include/hw/s390x/sclp.h | 2 ++ >> target/s390x/cpu.h | 1 - >> target/s390x/misc_helper.c | 1 + >> 3 files changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h >> index a72d096081..4b86a8a293 100644 >> --- a/include/hw/s390x/sclp.h >> +++ b/include/hw/s390x/sclp.h >> @@ -242,5 +242,7 @@ sclpMemoryHotplugDev *init_sclp_memory_hotplug_dev(void); >> sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void); >> void sclp_service_interrupt(uint32_t sccb); >> void raise_irq_cpu_hotplug(void); >> +typedef struct CPUS390XState CPUS390XState; >> +int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code); > > That's dangerous and likely does not work with certain versions of GCC. > You can't do a "forward declaration" with typedef in C, I'm afraid. See > for example: > > https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg01454.html > https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg03337.html > https://stackoverflow.com/questions/8367646/redefinition-of-typedef > > All this typedef'ing in QEMU is pretty bad ... we run into this problem > again and again. include/qemu/typedefs.h is just a work-around for this. > I know people like typedefs for some reasons (I used to do that, too, > before I realized the trouble with them), but IMHO we should rather > adopt the typedef-related rules from the kernel coding conventions instead: > > https://www.kernel.org/doc/html/v4.13/process/coding-style.html#typedefs > > Thomas > Yes, this is really nasty. And I wasn't aware of the involved issues. This seems to be the only feasible solution (including cpu.h sounds wrong and will require a bunch of other includes): Opinions? diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index a72d096081..ce80915a02 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -242,5 +242,7 @@ sclpMemoryHotplugDev *init_sclp_memory_hotplug_dev(void); sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void); void sclp_service_interrupt(uint32_t sccb); void raise_irq_cpu_hotplug(void); +struct CPUS390XState; +int sclp_service_call(struct CPUS390XState *env, uint64_t sccb, uint32_t code); #endif diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 3aa2e46aac..032d1de2e8 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -721,6 +721,5 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf, /* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); -int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code); #endif diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index b142db71c6..8b07535b02 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -35,6 +35,7 @@ #include "sysemu/sysemu.h" #include "hw/s390x/ebcdic.h" #include "hw/s390x/s390-virtio-hcall.h" +#include "hw/s390x/sclp.h" #endif /* #define DEBUG_HELPER */