From patchwork Mon Sep 15 07:30:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37410 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0B991206A5 for ; Mon, 15 Sep 2014 07:38:48 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gi9sf1916885lab.11 for ; Mon, 15 Sep 2014 00:38:46 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=ovLK2hy89zxJpDbfDgG9ZDydfAEqpYoQyxqQ5ssAEQc=; b=ckQUhXgzZGeMK3KpNKBowdVIMMfzvnqsR5YCCQosNPzMkOwQYqFkfjYjjnIBZ/22BQ FyIoDYMAswxfRlsUAFBLoUVtIcECRHgFms1eQWHgV2uyFGiNBuPiwAz/i/4Udw9tTX8f k9t2bn5rekPY3SF+vhS7CZdbYhSvbDQBsREMzgTmIfOkmpV6ghKbXfIKByP2OujbB26W Wnd/hPstaHI7PRGr0swT71ErJn5ORmdkG2wjV8o0XUa5yB3DzwnyidEFeR/tjRI/llY5 C5z8UivK/Tufs2QBmQjh0MuJV7chee+f8o6++UnbrOSFoF81wHFQmTar7WrD8MGFq1ik bnJg== X-Gm-Message-State: ALoCoQm1vr+jX4z4Y3QkaJsSR6s+oCyMrDO4nqmCKnWNhPSUn/Csdn3XPCuaVjb+8yMfkayCKwJM X-Received: by 10.112.118.8 with SMTP id ki8mr6835485lbb.4.1410766726409; Mon, 15 Sep 2014 00:38:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.229 with SMTP id h5ls353001lam.4.gmail; Mon, 15 Sep 2014 00:38:46 -0700 (PDT) X-Received: by 10.152.4.194 with SMTP id m2mr12634709lam.63.1410766726199; Mon, 15 Sep 2014 00:38:46 -0700 (PDT) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com [2a00:1450:4010:c04::22f]) by mx.google.com with ESMTPS id qj5si17572323lbb.89.2014.09.15.00.38.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Sep 2014 00:38:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) client-ip=2a00:1450:4010:c04::22f; Received: by mail-lb0-f175.google.com with SMTP id n15so285912lbi.34 for ; Mon, 15 Sep 2014 00:38:44 -0700 (PDT) X-Received: by 10.152.7.8 with SMTP id f8mr25899528laa.27.1410766724024; Mon, 15 Sep 2014 00:38:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp162399lbb; Mon, 15 Sep 2014 00:38:43 -0700 (PDT) X-Received: by 10.68.173.101 with SMTP id bj5mr24943717pbc.15.1410766722503; Mon, 15 Sep 2014 00:38:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si21323601pdm.51.2014.09.15.00.38.41 for ; Mon, 15 Sep 2014 00:38:42 -0700 (PDT) Received-SPF: none (google.com: linux-crypto-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753569AbaIOHii (ORCPT ); Mon, 15 Sep 2014 03:38:38 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:60852 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752327AbaIOHbX (ORCPT ); Mon, 15 Sep 2014 03:31:23 -0400 Received: by mail-pd0-f174.google.com with SMTP id v10so5631162pde.5 for ; Mon, 15 Sep 2014 00:31:22 -0700 (PDT) X-Received: by 10.66.186.167 with SMTP id fl7mr34753358pac.14.1410766282579; Mon, 15 Sep 2014 00:31:22 -0700 (PDT) Received: from galdor.edimax.com ([38.126.120.10]) by mx.google.com with ESMTPSA id cz1sm1011611pdb.85.2014.09.15.00.31.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Sep 2014 00:31:21 -0700 (PDT) From: behanw@converseincode.com To: agk@redhat.com, clm@fb.com, davem@davemloft.net, dm-devel@redhat.com, fabf@skynet.be, herbert@gondor.apana.org.au, jbacik@fb.com, snitzer@redhat.com, tadeusz.struk@intel.com Cc: akpm@linux-foundation.org, bruce.w.allan@intel.com, d.kasatkin@samsung.com, james.l.morris@oracle.com, john.griffin@intel.com, linux-btrfs@vger.kernel.org, linux-crypto@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, neilb@suse.de, qat-linux@intel.com, serge@hallyn.com, thomas.lendacky@amd.com, zohar@linux.vnet.ibm.com, torvalds@linux-foundation.org, Behan Webster Subject: [PATCH v3 01/12] crypto: LLVMLinux: Add macro to remove use of VLAIS in crypto code Date: Mon, 15 Sep 2014 00:30:23 -0700 Message-Id: <1410766234-1634-2-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1410766234-1634-1-git-send-email-behanw@converseincode.com> References: <1410766234-1634-1-git-send-email-behanw@converseincode.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Behan Webster Add a macro which replaces the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This macro instead allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. Signed-off-by: Behan Webster Acked-by: Herbert Xu --- include/crypto/hash.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index a391955..541125b 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -58,6 +58,11 @@ struct shash_desc { void *__ctx[] CRYPTO_MINALIGN_ATTR; }; +#define SHASH_DESC_ON_STACK(shash, tfm) \ + char __desc[sizeof(struct shash_desc) + \ + crypto_shash_descsize(tfm)] CRYPTO_MINALIGN_ATTR; \ + struct shash_desc *shash = (struct shash_desc *)__desc + struct shash_alg { int (*init)(struct shash_desc *desc); int (*update)(struct shash_desc *desc, const u8 *data,