Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp581084rdh; Thu, 26 Oct 2023 09:55:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSrHjNFL7wk1bZkSVrAoTf6oNeEwuJHgUOhEYnAO408ogq2tqGewkn+Uixem09hCnjhKRR X-Received: by 2002:a25:dc0c:0:b0:da0:b36c:1af1 with SMTP id y12-20020a25dc0c000000b00da0b36c1af1mr2380288ybe.62.1698339329861; Thu, 26 Oct 2023 09:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698339329; cv=none; d=google.com; s=arc-20160816; b=q180EEG9FjQyQhPLaecY4JNaYMplzHpQBTOat7Hl2OqhZRSoN3GhAwusHTG6JX7mpD CXEVsk43mIUxuECeQjvl7c5jVB6t26WYppU8O32sCLrLJIiZB9bTgp8WO7MILiD1Hufk urmIYVL/NcEuM0Jo0lFT5P9XbLvzZRrKuHpJOYfRHVTAEjXDoUQ80zSPVhtoeeJegJZG imq0KWAdF59TzlnHlq0eE02v7QbjK3Zw0hbuYR7L29lEGXouit8WERyjQDbxFo2AfK+V ecAi5tOoUE6mfiRMqogISRPuRDorBhCCH1+L2McEM9uTJY16QWYPQJUKQfKk2A8Gbf4W sM+g== 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=Ant3aW5o4UfJ9+pGAMWn3sv1qIYaJ3ZE24ECRvWTTJY=; fh=kwz8SaMJF9hL1NqdptspTA3XjeK+IK6NQrYH0CtFd34=; b=FrNMsiKGPDdrrFzFJ+gU9cpruAkbikCyL+PX4hfTsURo/BumsH2ukHEGrg8SSVSvrH smc7HkzNuexJnyVF6m4iLjz9H/nDL9rtSpZd930bbR1fF3t1+qBEj43wg4W0PBQOUvpv u9NvO3HBA4daM+sW2Y2LzE7DaT1RbGJ4BvxZNBwZ2PDlbs3lt8vVlIFOMNyqimPmVBis F5fgchpjK4kRF3sgcrZiwBDLPGx78p8MVM45yaC/thEfHPbk/UON0j0PP8nuHDZXme/W 7757jb6DuNk7adLdeXEQ7K7VjCDo71GEgeATFBBHAsq0Q7svNHbEQncVB8cPkuIn2U7y vQfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RampxnR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id q6-20020a056902150600b00d7b9fad2573si20102476ybu.213.2023.10.26.09.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 09:55:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=RampxnR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 44F1A818D509; Thu, 26 Oct 2023 09:55:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345164AbjJZQyf (ORCPT + 99 others); Thu, 26 Oct 2023 12:54:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231710AbjJZQya (ORCPT ); Thu, 26 Oct 2023 12:54:30 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F7E187 for ; Thu, 26 Oct 2023 09:54:27 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-52bd9ddb741so1950942a12.0 for ; Thu, 26 Oct 2023 09:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1698339266; x=1698944066; 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=Ant3aW5o4UfJ9+pGAMWn3sv1qIYaJ3ZE24ECRvWTTJY=; b=RampxnR4KBqfIh3i/GkpCQ4mSOOYVRkDhFLjkxsvIqZ7EvRa/6SCmJYCCKBu81dgvb +TseekiscFTBC+7lee+ymiWvP2MATt7qMOTyFnbSGCvOjQYjvCR021d+eBZDilgUXeO/ ilxa6oOy/rh81nBbHRg4tPAo7Yvko3gz568tc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698339266; x=1698944066; 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=Ant3aW5o4UfJ9+pGAMWn3sv1qIYaJ3ZE24ECRvWTTJY=; b=n1Oc1aMLbHHmxeKprdau0787K+HUFMu1hzRITlTR7fuf6JBMbarcgh4XpoDMKhkPq3 8bO+Y9RMDdWtChWYMwygJxZxSfkSItkkdvKAv+C4gsFXDCZ81C/Hw9zQyVNfOHvCBaGt cAp9Q6cJdvk4B+kHAX5cXTTUINPuhYaSoNbpmIUlFeGHhLgSxOdJK4UI/wuzXx44OwRd hU5x8Iiy6rz7uGqHzb/whbOW2XVw48lMefruCzL69c6qzebJOECDdKoaT33je912+Z2d OtFLEREerulGClf3tEbPjdOzwISPuvPV1jBxNxRlaqA/KGLV/Q824G88wNwofBaAePGr yZHw== X-Gm-Message-State: AOJu0Yw1TUKLdGTZ4LCRDAObAwHPgPERrd0z6cxZ0ARiCr6mITaSBzvO H5EStli6gKMhikfE90TqNdBF0XDpcMWK6Tfo31VJBJz0 X-Received: by 2002:a50:ab12:0:b0:53f:ba2a:2aa9 with SMTP id s18-20020a50ab12000000b0053fba2a2aa9mr333739edc.1.1698339266100; Thu, 26 Oct 2023 09:54:26 -0700 (PDT) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com. [209.85.208.41]) by smtp.gmail.com with ESMTPSA id 22-20020a508756000000b00532eba07773sm11754965edv.25.2023.10.26.09.54.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Oct 2023 09:54:25 -0700 (PDT) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5230a22cfd1so1936744a12.1 for ; Thu, 26 Oct 2023 09:54:25 -0700 (PDT) X-Received: by 2002:a05:6402:3586:b0:538:a47:89d3 with SMTP id y6-20020a056402358600b005380a4789d3mr295557edc.21.1698339264715; Thu, 26 Oct 2023 09:54:24 -0700 (PDT) MIME-Version: 1.0 References: <20231024161931.78567-1-sebastian.reichel@collabora.com> <20231024161931.78567-2-sebastian.reichel@collabora.com> <055dd714f98f4e45b2add561b7663378@AcuMS.aculab.com> In-Reply-To: <055dd714f98f4e45b2add561b7663378@AcuMS.aculab.com> From: Linus Torvalds Date: Thu, 26 Oct 2023 06:54:07 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/3] math.h: add DIV_ROUND_UP_NO_OVERFLOW To: David Laight Cc: Vasily Gorbik , Sebastian Reichel , Andy Shevchenko , Michael Turquette , Stephen Boyd , "linux-clk@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Niklas Schnelle , "kernel@collabora.com" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 26 Oct 2023 09:55:03 -0700 (PDT) On Wed, 25 Oct 2023 at 22:57, David Laight wrote: > > Doesn't that version end up calling inline functions? > So won't be usable in static initialisers - the same as statement functions. David, please either read what I write, or actually test things out, instead of just adding noise. It is not a problem to have a _Generic() - or a __builtin_chooise_expr() - that has an inline function that doesn't get used. The compiler will remove it. The problem is literally that you can't use "__auto_type", because *STATEMENT EXPRESSIONS* do not work outside of function definitions, because gcc won't even *parse* them, and just says error: braced-group within expression allowed only inside a function exactly like I explained in the comment of the patch that does the _Generic(). Which is why my solution ended up using those inline functions, and splitting manually by type, instead of an expression statement and __auto_type. Whether you then split into different expressions with _Generic() or by using __builtin_choose_expr() is irrelevant, although once you do "split by type", _Generic() ends up being much more convenient because that's what it's designed for (and you don't end up trying to figure out the size with sizeof() and typeof tricks). Linus