From patchwork Tue Dec 27 15:36:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 89105 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp5039645qgi; Tue, 27 Dec 2016 07:36:29 -0800 (PST) X-Received: by 10.194.203.135 with SMTP id kq7mr34725541wjc.26.1482852989795; Tue, 27 Dec 2016 07:36:29 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id kp4si17063190wjb.217.2016.12.27.07.36.28; Tue, 27 Dec 2016 07:36:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59E8CB38CE; Tue, 27 Dec 2016 16:36:28 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8G50mX2fNUMj; Tue, 27 Dec 2016 16:36:28 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 312ACA766D; Tue, 27 Dec 2016 16:36:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B495A767D for ; Tue, 27 Dec 2016 16:36:23 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tsri-eMl8GL0 for ; Tue, 27 Dec 2016 16:36:22 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by theia.denx.de (Postfix) with ESMTPS id 519F2A766D for ; Tue, 27 Dec 2016 16:36:18 +0100 (CET) Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-12.nifty.com with ESMTP id uBRFa5RJ030807; Wed, 28 Dec 2016 00:36:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com uBRFa5RJ030807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1482852973; bh=bmq3PRXbWm3YuZmjiamd8aggqLiHCvWc9dUk0MFIbyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wwk68/EtSKzwt6SydIlzh3GAzMNGBUNfQ2t46GDQCeUn0eGs8pNesnQ+ENINdxSGG hz9BTRi7lgd0idelv+ZBNatf8h4pePJ7TudKoSR4lVCyr/rAAlNyL8p1iSyPwU2A1u 32H0ei84eI5MpbvXA7ewr/3SWLg+4D1f3as8fSD8tFt1MakQGk0LAgku47BNJLpmCA ais32/SqOvBMs9FdbhMVSz3M0fAjvGl5QjoIOsXm0XuZHg727KQ/B+w2jHFFthAOlm Pl+tm5oMAMLx3SzLuESQQywLu6r5Yt3Sr5+bguwS6Qxh75XTBj3JY31tBtmkz6hb3b 1AhcdYrj2rX4A== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 28 Dec 2016 00:36:01 +0900 Message-Id: <1482852963-6887-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482852963-6887-1-git-send-email-yamada.masahiro@socionext.com> References: <1482852963-6887-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH v2 3/5] typecheck: import include/linux/typecheck.h from Linux 4.9 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Copied from Linux 4.9. Signed-off-by: Masahiro Yamada --- Changes in v2: None include/linux/typecheck.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 include/linux/typecheck.h -- 2.7.4 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/include/linux/typecheck.h b/include/linux/typecheck.h new file mode 100644 index 0000000..eb5b74a --- /dev/null +++ b/include/linux/typecheck.h @@ -0,0 +1,24 @@ +#ifndef TYPECHECK_H_INCLUDED +#define TYPECHECK_H_INCLUDED + +/* + * Check at compile time that something is of a particular type. + * Always evaluates to 1 so you may use it easily in comparisons. + */ +#define typecheck(type,x) \ +({ type __dummy; \ + typeof(x) __dummy2; \ + (void)(&__dummy == &__dummy2); \ + 1; \ +}) + +/* + * Check at compile time that 'function' is a certain type, or is a pointer + * to that type (needs to use typedef for the function type.) + */ +#define typecheck_fn(type,function) \ +({ typeof(type) __tmp = function; \ + (void)__tmp; \ +}) + +#endif /* TYPECHECK_H_INCLUDED */