From patchwork Sun Jan 13 16:35:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 211639 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 53E4C2C010A for ; Mon, 14 Jan 2013 03:36:27 +1100 (EST) Received: from localhost ([::1]:50355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuQXp-0004BK-AA for incoming@patchwork.ozlabs.org; Sun, 13 Jan 2013 11:36:25 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuQXc-0004A9-Ao for qemu-devel@nongnu.org; Sun, 13 Jan 2013 11:36:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuQXV-0006Df-2z for qemu-devel@nongnu.org; Sun, 13 Jan 2013 11:36:12 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:42122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuQXU-0006D9-Qx for qemu-devel@nongnu.org; Sun, 13 Jan 2013 11:36:04 -0500 Received: by mail-lb0-f174.google.com with SMTP id gi11so2412039lbb.19 for ; Sun, 13 Jan 2013 08:36:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=i7r2hJjAfqAK17AIQsrNDznwzA5kInoEoEwoIV4OINQ=; b=LLu/Ds2Mo/2nhzBmLxKJRaIJ5P7x/BPi9UVBAs3e9xPvoR5FpluT6pQKh4MAiN0aBm Q7WrwI44eLemutGvFakRnAPxVnt7O12NS18d1qKK8XgRgvD1Jkw9NB8mCwXFdUIcejL1 TbSvuE70x8jV+JN8ph90meNMbp4dt1L64YGfsFwvaAlS/yM6kr/h+HTt5FPKS2eezzOG UUUTA1YJ5hvFuSpa0SdqQB1UC/7Z/qky9gIBRzYiRlMNh+nk1gbYZAKP09T2jYJfu0Km mGL/V/BpYnF9YJNCyNDlywViTQXSsv7KljzV7MiOdVR3xHJiw4ZjzyVhM/CEuRECYc4l Rxiw== X-Received: by 10.152.47.75 with SMTP id b11mr77819679lan.14.1358094963261; Sun, 13 Jan 2013 08:36:03 -0800 (PST) Received: from localhost.localdomain (blueswirl.broker.freenet6.net. [2001:5c0:1000:b::b867]) by mx.google.com with ESMTPS id fb1sm4233049lbb.15.2013.01.13.08.35.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 13 Jan 2013 08:36:01 -0800 (PST) From: Blue Swirl To: qemu-devel@nongnu.org Date: Sun, 13 Jan 2013 16:35:41 +0000 Message-Id: <1309ac93ff943931eb213dd87cd3570910b23926.1358094930.git.blauwirbel@gmail.com> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.217.174 Cc: blauwirbel@gmail.com, rth@twiddle.net Subject: [Qemu-devel] [PATCH] bswap: improve gluing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org OpenBSD system compiler (gcc 4.2.1) has problems with concatenation of macro arguments in macro functions: CC aes.o In file included from /src/qemu/include/qemu-common.h:126, from /src/qemu/aes.c:30: /src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu': /src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS' /src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS' Function leul_to_cpu() is only used in kvm-all.c, so the warnings are not fatal on OpenBSD without -Werror. Fix by applying glue(). Also add do {} while(0) wrapping and fix semicolon use while at it. Signed-off-by: Blue Swirl Reviewed-by: Richard Henderson Tested-by: Andreas Färber Reviewed-by: David Gibson --- include/qemu/bswap.h | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index be9b035..e6d4798 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -72,45 +72,45 @@ static inline void bswap64s(uint64_t *s) #if defined(HOST_WORDS_BIGENDIAN) #define be_bswap(v, size) (v) -#define le_bswap(v, size) bswap ## size(v) +#define le_bswap(v, size) glue(bswap, size)(v) #define be_bswaps(v, size) -#define le_bswaps(p, size) *p = bswap ## size(*p); +#define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) #else #define le_bswap(v, size) (v) -#define be_bswap(v, size) bswap ## size(v) +#define be_bswap(v, size) glue(bswap, size)(v) #define le_bswaps(v, size) -#define be_bswaps(p, size) *p = bswap ## size(*p); +#define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) #endif #define CPU_CONVERT(endian, size, type)\ static inline type endian ## size ## _to_cpu(type v)\ {\ - return endian ## _bswap(v, size);\ + return glue(endian, _bswap)(v, size);\ }\ \ static inline type cpu_to_ ## endian ## size(type v)\ {\ - return endian ## _bswap(v, size);\ + return glue(endian, _bswap)(v, size);\ }\ \ static inline void endian ## size ## _to_cpus(type *p)\ {\ - endian ## _bswaps(p, size)\ + glue(endian, _bswaps)(p, size);\ }\ \ static inline void cpu_to_ ## endian ## size ## s(type *p)\ {\ - endian ## _bswaps(p, size)\ + glue(endian, _bswaps)(p, size);\ }\ \ static inline type endian ## size ## _to_cpup(const type *p)\ {\ - return endian ## size ## _to_cpu(*p);\ + return glue(glue(endian, size), _to_cpu)(*p);\ }\ \ static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ {\ - *p = cpu_to_ ## endian ## size(v);\ + *p = glue(glue(cpu_to_, endian), size)(v);\ } CPU_CONVERT(be, 16, uint16_t)