From patchwork Wed Jul 22 16:44:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 51369 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id A9D6A228EF for ; Wed, 22 Jul 2015 16:44:32 +0000 (UTC) Received: by laah7 with SMTP id h7sf33534801laa.2 for ; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=cc4BP/YoVIIt04tMDjBSzXRSpVhqxBPjBLywz3yE5b0=; b=hpAp/OipJcYmdV8LI+9rzC/xwnFQD3b1MQw/9Sr+cS5OoXrQBOOVU2R70PbzjXRQwl TQWPlY84LHXfVxmnnJM/aBlMDo5gGaAT9fQckTHdtyF61r3KQ5VXUuZC/dnn7S5MGpPQ r8Mn6ECveL83GXC1hQLaAT/2iEF31YJHkvK6Z2FaNVXTZcSp8fJAfk4bWz/w8rJy8JaX lIrkfjCg0O8MjhVVKhtO3VANkPklRdbndsscJHzNIcM4WdVuOY9KV2wpcWzzfiz3BMeW Fj2VqcQPFw0G5IfVDLcFHpIHTGuyzqEcNiE9faC7RBKZ2abX6Ar6SUlDwLb6s3411b2H //oA== X-Gm-Message-State: ALoCoQn8UArFZaMqs+YhhcrShAppYGDjGrDWo39ytY3NQxEljNUxsqTmf2HdaUHDKPr7BVVYY+Mc X-Received: by 10.112.181.37 with SMTP id dt5mr1604647lbc.10.1437583471634; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.65 with SMTP id r1ls115340lag.61.gmail; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) X-Received: by 10.112.202.234 with SMTP id kl10mr3237617lbc.51.1437583471424; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id t18si1631712laz.137.2015.07.22.09.44.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jul 2015 09:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laah7 with SMTP id h7so10217022laa.0 for ; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr3213312lbc.112.1437583471325; Wed, 22 Jul 2015 09:44:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp46317lba; Wed, 22 Jul 2015 09:44:30 -0700 (PDT) X-Received: by 10.70.56.4 with SMTP id w4mr7824589pdp.148.1437583458955; Wed, 22 Jul 2015 09:44:18 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id qy7si5143804pab.12.2015.07.22.09.44.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 22 Jul 2015 09:44:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1ZHx7r-0002Wj-IP; Wed, 22 Jul 2015 17:44:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 03/12] osdep.h: Move some compiler-specific things to compiler.h Date: Wed, 22 Jul 2015 17:44:02 +0100 Message-Id: <1437583451-9677-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437583451-9677-1-git-send-email-peter.maydell@linaro.org> References: <1437583451-9677-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , osdep.h has a few things which are really compiler specific; move them to compiler.h, and include compiler.h from osdep.h. Signed-off-by: Peter Maydell --- include/qemu/compiler.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ include/qemu/osdep.h | 48 +----------------------------------------------- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index df9dd51..bdc9a60 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -42,6 +42,53 @@ # define QEMU_PACKED __attribute__((packed)) #endif +#ifndef glue +#define xglue(x, y) x ## y +#define glue(x, y) xglue(x, y) +#define stringify(s) tostring(s) +#define tostring(s) #s +#endif + +#ifndef likely +#if __GNUC__ < 3 +#define __builtin_expect(x, n) (x) +#endif + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif + +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char __attribute__((unused)) offset_must_be_zero[ \ + -offsetof(type, field)]; \ + container_of(dev, type, field);})) +#else +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) +#endif + +#define typeof_field(type, field) typeof(((type *)0)->field) +#define type_check(t1,t2) ((t1*)0 - (t2*)0) + +#ifndef always_inline +#if !((__GNUC__ < 3) || defined(__APPLE__)) +#ifdef __OPTIMIZE__ +#undef inline +#define inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#else +#undef inline +#define inline always_inline +#endif + #define cat(x,y) x ## y #define cat2(x,y) cat(x,y) #define QEMU_BUILD_BUG_ON(x) \ diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index e9b8b92..4ae2c64 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -2,6 +2,7 @@ #define QEMU_OSDEP_H #include "config-host.h" +#include "qemu/compiler.h" #include #include #include @@ -27,41 +28,6 @@ typedef unsigned int uint_fast16_t; typedef signed int int_fast16_t; #endif -#ifndef glue -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) -#define stringify(s) tostring(s) -#define tostring(s) #s -#endif - -#ifndef likely -#if __GNUC__ < 3 -#define __builtin_expect(x, n) (x) -#endif - -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - offsetof(type, member));}) -#endif - -/* Convert from a base type to a parent type, with compile time checking. */ -#ifdef __GNUC__ -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ - char __attribute__((unused)) offset_must_be_zero[ \ - -offsetof(type, field)]; \ - container_of(dev, type, field);})) -#else -#define DO_UPCAST(type, field, dev) container_of(dev, type, field) -#endif - -#define typeof_field(type, field) typeof(((type *)0)->field) -#define type_check(t1,t2) ((t1*)0 - (t2*)0) - #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif @@ -87,18 +53,6 @@ typedef signed int int_fast16_t; #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif -#ifndef always_inline -#if !((__GNUC__ < 3) || defined(__APPLE__)) -#ifdef __OPTIMIZE__ -#undef inline -#define inline __attribute__ (( always_inline )) __inline__ -#endif -#endif -#else -#undef inline -#define inline always_inline -#endif - int qemu_daemon(int nochdir, int noclose); void *qemu_try_memalign(size_t alignment, size_t size); void *qemu_memalign(size_t alignment, size_t size);