Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2735902rda; Wed, 25 Oct 2023 10:44:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPXdkhQYiNt/4YWtjJlpR258JGEk8Yh7GIDjXhw0Sdx7yZK7OfIKLbOLDd5+nlqIHfJnfY X-Received: by 2002:a81:84d1:0:b0:5a8:204c:5c9b with SMTP id u200-20020a8184d1000000b005a8204c5c9bmr15895090ywf.18.1698255885135; Wed, 25 Oct 2023 10:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698255885; cv=none; d=google.com; s=arc-20160816; b=RzOOzaEnyBnJEMnpxIFmCNjLoQ6//N3r2kHSL4bOdRaaC639Pr8speLcZAJJVk7g6O mHVxr0c24MMslIOUTXOmtwbPJFgVhpZJiyYCM12LKQRjkAMn7ySrlMEap30bpVF90RJy jEvBwOAFomI3e+5xr2uZeSE2sXbO5a8Y/PVm8e521I/ydkB452Yv1F81HD9SZEU90XbE h1BwFZnc0ZLikZOmJqoj/iiM5g4DmwyLnCJziV1kUhH6IheMI/6mkiasHwBWW2fzKbOm g1bqbkD6lZ2/bzqHr5rgPd5JOBeAlqYfdLUvUiDz40PAFHWElkESYcNRaPevNlgAzee9 01zA== 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=KvqI5bmHaI6r/r4Bh4STYH/OzlrCkqHPpu4GTwS1+V8=; fh=/D2zUKZZ9f3bty4T38bMFmpJh1bLnR5ne0ZdGDv9cgs=; b=o8YTOCHa+8u/jGODrEagGGLIinM744q+oCgWBCuAG+KAHl+/FEaVb8rEfLsmbzL+Jz oPpfZIWNRZZDxtSy6NrAVIiBPTl11bqDsiVsVOB7X0MU/npzGjNd8jQodeRepYw/R6MK F1GV5YzdxOiDw2DlUt0QKpnOmnnplCR+shGYYCxq5Acq8KwyYwBV2OOcub7kdJdZ5AM6 cYnieXp4wlNAYvUk9Z334yxa5b3YoQFVNx/o4LQ8KSwUDxGrN7sdqecVw9DY2RltAV8L rsEwQtyAiGRCMdcK0h8BkVHZ2TN3Xhe6GElP9n3FXXDXWK1v9vyaFu5Q63JYXNE/0ej4 OAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OXVx2Du9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n131-20020a817289000000b005a825c9b92asi12073745ywc.395.2023.10.25.10.44.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OXVx2Du9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 5B576814C69D; Wed, 25 Oct 2023 10:44:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232270AbjJYRn7 (ORCPT + 99 others); Wed, 25 Oct 2023 13:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234367AbjJYRn6 (ORCPT ); Wed, 25 Oct 2023 13:43:58 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35CCC138 for ; Wed, 25 Oct 2023 10:43:56 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c518a1d83fso94985891fa.3 for ; Wed, 25 Oct 2023 10:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1698255834; x=1698860634; 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=KvqI5bmHaI6r/r4Bh4STYH/OzlrCkqHPpu4GTwS1+V8=; b=OXVx2Du9VeuoBLpGr8hGnI+yHnRo1H15KqUJ3t0u1Ue2uobLcr44mIAhhwOdukrrrg LVs3YoANZB2J4V0WXYID/6sxWRXiWImDWi3qU571wz0aHCOc2gDHgUbT8qMt/hwt8eZ9 8Bj7iWgbk7Icylx7RVQGOYetMVl+Wy3zZV5ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698255834; x=1698860634; 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=KvqI5bmHaI6r/r4Bh4STYH/OzlrCkqHPpu4GTwS1+V8=; b=HMUVeiWBwfFvPl/IO5nC4jTfxcsuEpKbtpAhTnO2xqiph2pxdyulP3fywe5OKXzrRC +uyojykCvbhW6Vy8Dwg2Gc1lwB8M745XIXzdJcYWr0H/I7d9YrL5fD170oWod9Uv7fxA rr88vAQ4tYVWpsIOx1Vl2Po0nYwI1SZ4TTJs+tEgXHVxQnSplqvhEONJXIIOgLcBZwfZ 3lW/HDf3dhRoTWTBknACFnTzUYhIFUakICIWbWnE6Q698aRt/hOLsYEyZ1OqRCoRFgjF MWuvNOttzQaPgJPzOEUCQC2h5A/WuDGLw0/4xaLaaPlvU5qUEsdwMSLDb+h2Y/Xf3GPu JoCw== X-Gm-Message-State: AOJu0YyZ2l1mgymgiL1cICQpdrOSgKZaFHxbuRV+473qTsmcevz04xkq 7EeYBMburZ4P7wlj9EU+9hCTP0K2ScEztJ3gTd0jwyOx X-Received: by 2002:ac2:43cc:0:b0:503:38fe:4590 with SMTP id u12-20020ac243cc000000b0050338fe4590mr10160671lfl.60.1698255834099; Wed, 25 Oct 2023 10:43:54 -0700 (PDT) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com. [209.85.167.52]) by smtp.gmail.com with ESMTPSA id x15-20020a19e00f000000b0050467be30ccsm2659961lfg.89.2023.10.25.10.43.52 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Oct 2023 10:43:52 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50802148be9so3615735e87.2 for ; Wed, 25 Oct 2023 10:43:52 -0700 (PDT) X-Received: by 2002:ac2:52aa:0:b0:505:6fcd:d7bf with SMTP id r10-20020ac252aa000000b005056fcdd7bfmr10111613lfm.19.1698255831687; Wed, 25 Oct 2023 10:43:51 -0700 (PDT) MIME-Version: 1.0 References: <20231024161931.78567-1-sebastian.reichel@collabora.com> <20231024161931.78567-2-sebastian.reichel@collabora.com> In-Reply-To: From: Linus Torvalds Date: Wed, 25 Oct 2023 07:43:34 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/3] math.h: add DIV_ROUND_UP_NO_OVERFLOW To: Vasily Gorbik Cc: Sebastian Reichel , Andy Shevchenko , Michael Turquette , Stephen Boyd , David Laight , 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 25 Oct 2023 10:44:13 -0700 (PDT) On Wed, 25 Oct 2023 at 05:05, Vasily Gorbik wrote: > > You probably want > > #define __div_round_up(n,d) _Generic((n)+(d), \ > unsigned long long: __div_round_up_ull, \ > long long: __div_round_up_ll, \ > unsigned long: __div_round_up_ul, \ > long: __div_round_up_l, \ > unsigned int: __div_round_up_u, \ > int: __div_round_up_i)(n,d) > > to avoid early type-checking for expressions that will be discarded > and prevent errors like: Ack. I noticed that later when I tried to do a bigger config build - the compiler would warn about the implicit truncation of the integer arguments (for the cases where they weren't used). > Plus typos fixes below passes allyesconfig for s390, 32-bit x86 and arm. Lovely. It would have been even better if somebody told me that I was stupid and there was some nice trick to it, but at least the _Generic() approach doesn't seem broken - just a few tweaks needed. Linus