All of lore.kernel.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Joel Stanley <joel@jms.id.au>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	linux-fbdev@vger.kernel.org, kvm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	Paul Mackerras <paulus@samba.org>,
	alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
Date: Tue, 21 Apr 2020 10:55:16 -0500	[thread overview]
Message-ID: <20200421155516.GT26902@gate.crashing.org> (raw)
In-Reply-To: <CACPK8XfqnqgkXcBzp=nqd=AJX1MK05eTNiyOdaEuRu3_6RsXSQ@mail.gmail.com>

Hi!

On Tue, Apr 21, 2020 at 01:04:05AM +0000, Joel Stanley wrote:
> On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > _ALIGN_DOWN() is specific to powerpc
> > ALIGN_DOWN() is generic and does the same
> >
> > Replace _ALIGN_DOWN() by ALIGN_DOWN()
> 
> This one is a bit less obvious. It becomes (leaving the typeof's alone
> for clarity):
> 
> -((addr)&(~((typeof(addr))(size)-1)))
> +((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
> ~((typeof(addr))(size)-1))
> 
> Which I assume the compiler will sort out?

[ This is line-wrapped, something in your mailer?  Took me a bit to figure
  out the - and + are diff -u things :-) ]

In the common case where size is a constant integer power of two, the
compiler will have no problem with this.  But why do so complicated?

Why are the casts there, btw?


Segher

WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Joel Stanley <joel@jms.id.au>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	linux-fbdev@vger.kernel.org, kvm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	Paul Mackerras <paulus@samba.org>,
	alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
Date: Tue, 21 Apr 2020 15:55:16 +0000	[thread overview]
Message-ID: <20200421155516.GT26902@gate.crashing.org> (raw)
In-Reply-To: <CACPK8XfqnqgkXcBzp=nqd=AJX1MK05eTNiyOdaEuRu3_6RsXSQ@mail.gmail.com>

Hi!

On Tue, Apr 21, 2020 at 01:04:05AM +0000, Joel Stanley wrote:
> On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > _ALIGN_DOWN() is specific to powerpc
> > ALIGN_DOWN() is generic and does the same
> >
> > Replace _ALIGN_DOWN() by ALIGN_DOWN()
> 
> This one is a bit less obvious. It becomes (leaving the typeof's alone
> for clarity):
> 
> -((addr)&(~((typeof(addr))(size)-1)))
> +((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
> ~((typeof(addr))(size)-1))
> 
> Which I assume the compiler will sort out?

[ This is line-wrapped, something in your mailer?  Took me a bit to figure
  out the - and + are diff -u things :-) ]

In the common case where size is a constant integer power of two, the
compiler will have no problem with this.  But why do so complicated?

Why are the casts there, btw?


Segher

WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Joel Stanley <joel@jms.id.au>
Cc: linux-fbdev@vger.kernel.org, kvm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	Paul Mackerras <paulus@samba.org>,
	alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
Date: Tue, 21 Apr 2020 10:55:16 -0500	[thread overview]
Message-ID: <20200421155516.GT26902@gate.crashing.org> (raw)
In-Reply-To: <CACPK8XfqnqgkXcBzp=nqd=AJX1MK05eTNiyOdaEuRu3_6RsXSQ@mail.gmail.com>

Hi!

On Tue, Apr 21, 2020 at 01:04:05AM +0000, Joel Stanley wrote:
> On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > _ALIGN_DOWN() is specific to powerpc
> > ALIGN_DOWN() is generic and does the same
> >
> > Replace _ALIGN_DOWN() by ALIGN_DOWN()
> 
> This one is a bit less obvious. It becomes (leaving the typeof's alone
> for clarity):
> 
> -((addr)&(~((typeof(addr))(size)-1)))
> +((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
> ~((typeof(addr))(size)-1))
> 
> Which I assume the compiler will sort out?

[ This is line-wrapped, something in your mailer?  Took me a bit to figure
  out the - and + are diff -u things :-) ]

In the common case where size is a constant integer power of two, the
compiler will have no problem with this.  But why do so complicated?

Why are the casts there, btw?


Segher

WARNING: multiple messages have this Message-ID (diff)
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Joel Stanley <joel@jms.id.au>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	linux-fbdev@vger.kernel.org, kvm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	Paul Mackerras <paulus@samba.org>,
	alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN()
Date: Tue, 21 Apr 2020 10:55:16 -0500	[thread overview]
Message-ID: <20200421155516.GT26902@gate.crashing.org> (raw)
In-Reply-To: <CACPK8XfqnqgkXcBzp=nqd=AJX1MK05eTNiyOdaEuRu3_6RsXSQ@mail.gmail.com>

Hi!

On Tue, Apr 21, 2020 at 01:04:05AM +0000, Joel Stanley wrote:
> On Mon, 20 Apr 2020 at 18:38, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > _ALIGN_DOWN() is specific to powerpc
> > ALIGN_DOWN() is generic and does the same
> >
> > Replace _ALIGN_DOWN() by ALIGN_DOWN()
> 
> This one is a bit less obvious. It becomes (leaving the typeof's alone
> for clarity):
> 
> -((addr)&(~((typeof(addr))(size)-1)))
> +((((addr) - ((size) - 1)) + ((typeof(addr))(size) - 1)) &
> ~((typeof(addr))(size)-1))
> 
> Which I assume the compiler will sort out?

[ This is line-wrapped, something in your mailer?  Took me a bit to figure
  out the - and + are diff -u things :-) ]

In the common case where size is a constant integer power of two, the
compiler will have no problem with this.  But why do so complicated?

Why are the casts there, btw?


Segher
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-04-21 15:56 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 18:36 [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-20 18:36 ` Christophe Leroy
2020-04-20 18:36 ` Christophe Leroy
2020-04-20 18:36 ` Christophe Leroy
2020-04-20 18:36 ` [PATCH 2/5] powerpc: Replace _ALIGN_DOWN() by ALIGN_DOWN() Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-21  1:04   ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21 15:55     ` Segher Boessenkool [this message]
2020-04-21 15:55       ` Segher Boessenkool
2020-04-21 15:55       ` Segher Boessenkool
2020-04-21 15:55       ` Segher Boessenkool
2020-04-20 18:36 ` [PATCH 3/5] powerpc: Replace _ALIGN_UP() by ALIGN() Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-21  1:04   ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-20 18:36 ` [PATCH 4/5] powerpc: Replace _ALIGN() " Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-21  1:11   ` Joel Stanley
2020-04-21  1:11     ` Joel Stanley
2020-04-21  1:11     ` Joel Stanley
2020-04-21  1:11     ` Joel Stanley
2020-04-20 18:36 ` [PATCH 5/5] powerpc: Remove _ALIGN_UP(), _ALIGN_DOWN() and _ALIGN() Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-20 18:36   ` Christophe Leroy
2020-04-21  1:04   ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  1:04     ` Joel Stanley
2020-04-21  0:49 ` [PATCH 1/5] drivers/powerpc: Replace _ALIGN_UP() by ALIGN() Joel Stanley
2020-04-21  0:49   ` Joel Stanley
2020-04-21  0:49   ` Joel Stanley
2020-04-21  0:49   ` Joel Stanley
2020-05-20 10:59 ` Michael Ellerman
2020-05-20 10:59   ` Michael Ellerman
2020-05-20 10:59   ` Michael Ellerman
2020-05-20 10:59   ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200421155516.GT26902@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=joel@jms.id.au \
    --cc=kvm@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.