From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CBA0C072B5 for ; Fri, 24 May 2019 15:27:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A139217D7 for ; Fri, 24 May 2019 15:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389764AbfEXP07 convert rfc822-to-8bit (ORCPT ); Fri, 24 May 2019 11:26:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:41592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389079AbfEXP07 (ORCPT ); Fri, 24 May 2019 11:26:59 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 899612133D; Fri, 24 May 2019 15:26:57 +0000 (UTC) Date: Fri, 24 May 2019 11:26:56 -0400 From: Steven Rostedt To: Roger Willcocks Cc: Linus Torvalds , LKML , Ben Skeggs , David Airlie , Daniel Vetter , Leon Romanovsky , Doug Ledford , Jason Gunthorpe , "Darrick J. Wong" , linux-xfs@vger.kernel.org, dri-devel , nouveau@lists.freedesktop.org, linux-rdma , Andrew Morton Subject: Re: [RFC][PATCH] kernel.h: Add generic roundup_64() macro Message-ID: <20190524112656.5ef67c6c@gandalf.local.home> In-Reply-To: References: <20190523100013.52a8d2a6@gandalf.local.home> <20190523112740.7167aba4@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 May 2019 16:11:14 +0100 Roger Willcocks wrote: > On 23/05/2019 16:27, Steven Rostedt wrote: > > > > I haven't yet tested this, but what about something like the following: > > > > ...perhaps forget about the constant check, and just force > > the power of two check: > > > > \ > > if (!(__y & (__y >> 1))) { \ > > __x = round_up(x, y); \ > > } else { \ > > You probably want > >            if (!(__y & (__y - 1)) > > -- Yes I do. I corrected it in my next email. http://lkml.kernel.org/r/20190523133648.591f9e78@gandalf.local.home > #define roundup(x, y) ( \ > { \ > typeof(y) __y = y; \ > typeof(x) __x; \ > \ > if (__y & (__y - 1)) \ > __x = round_up(x, __y); \ > else \ > __x = (((x) + (__y - 1)) / __y) * __y; \ > __x; \ > }) -- Steve