Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cnnhP-000327-M7 for mharc-qemu-trivial@gnu.org; Tue, 14 Mar 2017 10:45:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnnhM-0002zc-MH for qemu-trivial@nongnu.org; Tue, 14 Mar 2017 10:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnnhJ-0007HI-Fn for qemu-trivial@nongnu.org; Tue, 14 Mar 2017 10:45:16 -0400 Received: from www145.your-server.de ([78.47.15.66]:34904) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnnhJ-0007Fv-6e; Tue, 14 Mar 2017 10:45:13 -0400 Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by www145.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1cnnhH-0006IA-HH; Tue, 14 Mar 2017 15:45:11 +0100 Received: from [141.89.226.146] (helo=parabola-pocket.hpi.uni-potsdam.de) by sslproxy03.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cnnhH-0007SJ-4B; Tue, 14 Mar 2017 15:45:11 +0100 From: Andreas Grapentin To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Andreas Grapentin Date: Tue, 14 Mar 2017 15:44:52 +0100 Message-Id: <20170314144453.5027-1-andreas@grapentin.org> X-Mailer: git-send-email 2.12.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: andreas@grapentin.org X-Virus-Scanned: Clear (ClamAV 0.99.2/23203/Tue Mar 14 13:13:21 2017) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 78.47.15.66 Subject: [Qemu-trivial] [PATCH 0/1] Developer Conveniences - check for _Static_assert and use in QEMU_BUILD_BUG_ON X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Mar 2017 14:45:18 -0000 (as taken from here: http://wiki.qemu-project.org/Contribute/BiteSizedTasks) I added a configure check for C11's _Static_assert, and based on the outcome, QEMU_BUILD_BUG_ON will now produce slightly more readable results on failures. Systems without C11 conforming compilers will still have the old messages, as verified by intentionally breaking the configure check. the following example output was generated by inverting the condition in QEMU_BUILD_BUG_ON: without _Static_assert: > In file included from /home/andi/research/qemu-shared-memory/qemu/include/qemu/osdep.h:36:0, > from /home/andi/research/qemu-shared-memory/qemu/qga/commands.c:13: > /home/andi/research/qemu-shared-memory/qemu/qga/commands.c: In function ‘qmp_guest_exec_status’: > /home/andi/research/qemu-shared-memory/qemu/include/qemu/compiler.h:89:12: error: negative width in bit-field ‘’ > struct { \ > ^ > /home/andi/research/qemu-shared-memory/qemu/include/qemu/compiler.h:96:38: note: in expansion of macro QEMU_BUILD_BUG_ON_STRUCT’ > #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \ > ^~~~~~~~~~~~~~~~~~~~~~~~ > /home/andi/research/qemu-shared-memory/qemu/include/qemu/atomic.h:146:5: note: in expansion of macro ‘QEMU_BUILD_BUG_ON’ > QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ > ^~~~~~~~~~~~~~~~~ > /home/andi/research/qemu-shared-memory/qemu/include/qemu/atomic.h:417:5: note: in expansion of macro ‘atomic_load_acquire’ > atomic_load_acquire(ptr) > ^~~~~~~~~~~~~~~~~~~ > /home/andi/research/qemu-shared-memory/qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’ > bool finished = atomic_mb_read(&gei->finished); > ^~~~~~~~~~~~~~ with _Static_assert: > In file included from /home/andi/research/qemu-shared-memory/qemu/include/qemu/osdep.h:36:0, > from /home/andi/research/qemu-shared-memory/qemu/qga/commands.c:13: > /home/andi/research/qemu-shared-memory/qemu/qga/commands.c: In function ‘qmp_guest_exec_status’: > /home/andi/research/qemu-shared-memory/qemu/include/qemu/compiler.h:94:30: error: static assertion failed: "sizeof(*&gei->finished) > sizeof(void *)" > #define QEMU_BUILD_BUG_ON(x) _Static_assert((x), #x) > ^ > /home/andi/research/qemu-shared-memory/qemu/include/qemu/atomic.h:146:5: note: in expansion of macro ‘QEMU_BUILD_BUG_ON’ > QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *)); \ > ^~~~~~~~~~~~~~~~~ > /home/andi/research/qemu-shared-memory/qemu/include/qemu/atomic.h:417:5: note: in expansion of macro ‘atomic_load_acquire’ > atomic_load_acquire(ptr) > ^~~~~~~~~~~~~~~~~~~ > /home/andi/research/qemu-shared-memory/qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’ > bool finished = atomic_mb_read(&gei->finished); > ^~~~~~~~~~~~~~ Andreas Grapentin (1): added configure check for _Static_assert and updated QEMU_BUILD_BUG_ON(...) accordingly configure | 18 ++++++++++++++++++ include/qemu/compiler.h | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) -- 2.12.0