Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp548493rdf; Tue, 21 Nov 2023 09:23:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI/U6/At8xA8ISqzVh95ww8r/xug2Oko1JzTqGGh17D2LUTPiHJgeX2ccI26z+TF/dRUtG X-Received: by 2002:a17:90b:4a8d:b0:280:a491:abff with SMTP id lp13-20020a17090b4a8d00b00280a491abffmr9480039pjb.5.1700587429101; Tue, 21 Nov 2023 09:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700587429; cv=none; d=google.com; s=arc-20160816; b=DX2UtmrR0spl+lsLaXj+ciwT85mvooI1S42DT3pKCeNPe83APsDpfJ2Bc00vBKu3Gp OJbnb56iOmRpEHcLFTU72QIvht0rNcRj7azFQw4rbkOSInE4VLNMkFcoiiNWDocum23X JAv1HjM6Se4K8dBIdWh1Dy0w4uph7T5ijmltp2ZRTA/CSH39SHn/dSqVyvR+//6p4swk NfOBMZYqBH0sE8MlP7qSkXsKxBUXz0soQfxJZRnrZT3rSJHy+x3E/KmrCJGdvBJ/90kA pvRoU3CLxnD+n2I5VMfpBHj9CTnA2Uh+oaYtbqWZEdLTEekqA3ODXMdsp6PqwnjG0vWL qhjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2/ZO4yKs3VhkhylSYQ9J7OGN/6CUEfOejASnyNs/Dbc=; fh=XUSK86dRtIDox/pL14c8+vjPo/oh20N9xTOSHzyqGEs=; b=oRX0vhuKSQRUw5OsGZWDzrNGZRvnRLovOCM01K8quli1HnQy0NBUiqdCDzBW1reAXf FCGHHWknK4hRrJH7Xgs+U7NuA8b7ztuoMQkXiWUxWgIwafy0tS+FjQ/ZNYo/jPUTQf5o qL8eME/r+8NNHPE4XN5fYYh9lpDW6k3SZ4cpMEgQSz6tIaPmCmWWrSUSCaVy0YxH/4/u 2cOvf2tp6xFNxfKdxZdjbWS9jBxdedxSQxxpdJ9yrKrTlvwK51xRxQTFuYmZXJrfZig6 vJsrUPOi5KOJhXkvXS3nbkqaj94tnwyj9hOKKPx3oxqIJ59ODithnz3REK9PfQPC5ypx Twhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=H7jCaKAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id mj12-20020a17090b368c00b00284eb6ee925si7708764pjb.92.2023.11.21.09.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 09:23:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=H7jCaKAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BD1128024072; Tue, 21 Nov 2023 09:23:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234176AbjKURXh (ORCPT + 99 others); Tue, 21 Nov 2023 12:23:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234275AbjKURXf (ORCPT ); Tue, 21 Nov 2023 12:23:35 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 003AE12A for ; Tue, 21 Nov 2023 09:23:29 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-5484ef5e3d2so6220097a12.3 for ; Tue, 21 Nov 2023 09:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1700587408; x=1701192208; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2/ZO4yKs3VhkhylSYQ9J7OGN/6CUEfOejASnyNs/Dbc=; b=H7jCaKAAc1bYxl8WhWgC1m9NA2zxATRdjcH5sEsOHVSalBGa0+CzUMkII+/M9nfweT AoUKw7PQqyO87ob24gTB2H2BhIxyZlmhgHTYkh+nymh++CgRxKriNMrQB7wPLRsR5/pF EQ8U8563bfvzb1z1QQqgwXaU58fiHCYDmoSUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700587408; x=1701192208; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2/ZO4yKs3VhkhylSYQ9J7OGN/6CUEfOejASnyNs/Dbc=; b=LWwPV6RXEvCwAqrwCCwu1jXK8gjLtKOO/hQG68DD+X7z1rJcFDzU+t8bJpRW4HBZGP d/WI+IwJdPaLKoZv2mfgQd9JfPn+P9sBpfpB1h41W3JmgyF11qB+zKwctp7VMDfj7fhE t0xv6FRVk5Lgs0TT/HdPkkJYOQFxThb4yiZH0bu/uDoROOgqhyadQmjInZD+mvt4O8PI z9r/eFCYNLw4g2dvDrZD1GMi4o9arWhOSYKN918cQffF3RunEyQgq0367eGesg54wNYj KBmC2A7p0cyMz/Yuc1OdAyschxD4OhVek3lyiF9lO+M0yVC15WVwYyhCtE9j56JtZSEc 8AAQ== X-Gm-Message-State: AOJu0YweSFWIkgJiMyzOHYWTxJv0D3neM58eZPsL/RgOLgTSlcPfpLkb vNqCYibyXC7Nh7c2n1x6pPKlVh9LwYuv2S1c+73XPA== X-Received: by 2002:aa7:d68e:0:b0:548:4774:e59c with SMTP id d14-20020aa7d68e000000b005484774e59cmr2398366edr.35.1700587408192; Tue, 21 Nov 2023 09:23:28 -0800 (PST) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com. [209.85.208.49]) by smtp.gmail.com with ESMTPSA id d16-20020aa7d5d0000000b00548aeeb1a9esm2763925eds.89.2023.11.21.09.23.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 09:23:26 -0800 (PST) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5401bab7525so8456792a12.2 for ; Tue, 21 Nov 2023 09:23:26 -0800 (PST) X-Received: by 2002:aa7:d68e:0:b0:548:4774:e59c with SMTP id d14-20020aa7d68e000000b005484774e59cmr2398277edr.35.1700587406073; Tue, 21 Nov 2023 09:23:26 -0800 (PST) MIME-Version: 1.0 References: <20231121010318.524570-1-nickrterrell@gmail.com> <20231121010318.524570-3-nickrterrell@gmail.com> In-Reply-To: <20231121010318.524570-3-nickrterrell@gmail.com> From: Linus Torvalds Date: Tue, 21 Nov 2023 09:23:08 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] zstd: Backport Huffman speed improvement from upstream To: Nick Terrell Cc: linux-kernel@vger.kernel.org, Yann Collet , Nick Terrell , Kernel Team , Giovanni Cabiddu , Nick Terrell Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 09:23:46 -0800 (PST) On Mon, 20 Nov 2023 at 16:52, Nick Terrell wrote: > > +/* Calls X(N) for each stream 0, 1, 2, 3. */ > +#define HUF_4X_FOR_EACH_STREAM(X) \ > + { \ > + X(0) \ > + X(1) \ > + X(2) \ > + X(3) \ > + } > + > +/* Calls X(N, var) for each stream 0, 1, 2, 3. */ > +#define HUF_4X_FOR_EACH_STREAM_WITH_VAR(X, var) \ > + { \ > + X(0, (var)) \ > + X(1, (var)) \ > + X(2, (var)) \ > + X(3, (var)) \ > + } > + What shitty compilers do you need to be compatible with? Because at least for Linux, the above is one single #define: #define FOUR(X,y...) do { \ X(0,##y); X(1,##y); X(2,##y); X(3,##y); \ } while (0) and it does the right thing for any number of arguments, ie FOUR(fn) FOUR(fn1,a) FOUR(fn2,a,b) expands to do { fn(0); fn(1); fn(2); fn(3); } while (0) do { fn1(0,a); fn1(1,a); fn1(2,a); fn1(3,a); } while (0) do { fn2(0,a,b); fn2(1,a,b); fn2(2,a,b); fn2(3,a,b); } while (0) so unless you need to support some completely garbage compiler upstream, please just do the single #define. Linus