login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
November
»
11
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do division with rounding
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Andrew Morton
Subject:
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do division with rounding
Date: Tuesday, November 11, 2008 - 4:20 pm
On Tue, 11 Nov 2008 15:05:02 -0800 (PST) Trent Piepho <tpiepho@freescale.com> wrote:
quoted text
> On Mon, 10 Nov 2008, Darrick J. Wong wrote: > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > > index fba141d..fb02266 100644 > > --- a/include/linux/kernel.h > > +++ b/include/linux/kernel.h > > @@ -48,6 +48,12 @@ extern const char linux_proc_banner[]; > > #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) > > #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > > #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) > > +#define DIV_ROUND_CLOSEST(x, divisor)( \ > > +{ \ > > + typeof(divisor) __divisor = divisor; \ > > + (((x) + ((__divisor) / 2)) / (__divisor)); \ > > +} \ > > +) > > Maybe you can do away with the statement-expression extension? I've seen > cases where it cases gcc to generate worse code. It seems like it > shouldn't, but it does. I know DIV_ROUND_CLOSEST (maybe DIV_ROUND_NEAR?) > uses divisor twice, but all the also divide macros do that too, so why does > this one need to be different?
The others need fixing too.
quoted text
> Note that if divisor is a signed variable, divisor/2 generates worse code > than divisor>>1.
yup. I wonder why the compiler doesn't do that for itself - is there a case where it will generate a different result? --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do divisio ...
, Darrick J. Wong
, (Mon Nov 10, 6:01 pm)
[PATCH 2/2] adt74{62, 70, 73}: Use DIV_ROUND_CLOSEST for r ...
, Darrick J. Wong
, (Mon Nov 10, 6:01 pm)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Jean Delvare
, (Tue Nov 11, 3:04 am)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Andrew Morton
, (Tue Nov 11, 10:07 am)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Jean Delvare
, (Tue Nov 11, 10:11 am)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Joe Perches
, (Tue Nov 11, 11:51 am)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Trent Piepho
, (Tue Nov 11, 4:05 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Andrew Morton
, (Tue Nov 11, 4:20 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Trent Piepho
, (Tue Nov 11, 4:42 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Jochen Voß
, (Tue Nov 11, 4:50 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Andrew Morton
, (Tue Nov 11, 5:08 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Trent Piepho
, (Fri Nov 14, 2:46 pm)
Re: [lm-sensors] [PATCH 1/2] Create a DIV_ROUND_CLOSEST ma ...
, Andrew Morton
, (Fri Nov 14, 3:24 pm)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Peter Zijlstra
, (Mon Aug 3, 4:57 am)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Jean Delvare
, (Mon Aug 3, 5:21 am)
Re: [PATCH 1/2] Create a DIV_ROUND_CLOSEST macro to do div ...
, Peter Zijlstra
, (Mon Aug 3, 5:27 am)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
FUJITA Tomonori
Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel
Rafael J. Wysocki
[Bug #11287] Regression in 2.6.27-rc2 in acpi_processor_init()
Ingo Molnar
Re: [GIT PULL] time.c - respin
Ingo Molnar
Re: [PATCH] x86: silence section mismatch warning - uv_cpu_init
Rafael J. Wysocki
[Bug #11380] lockdep warning: cpu_add_remove_lock at:cpu_maps_update_begin+0x14/0x16
git
:
Mark Junker
git on MacOSX and files with decomposed utf-8 file names
Junio C Hamano
Re: git-svnimport
Junio C Hamano
Re: [PATCH] Detached HEAD (experimental)
Johannes Schindelin
Re: [PATCH] Fix approxidate("never") to always return 0
A Large Angry SCM
Re: [RFC] origin link for cherry-pick and revert
linux-netdev
:
Arnaldo Carvalho de Melo
Re: [PATCH 06/37] dccp: Limit feature negotiation to connection setup phase
Gerrit Renker
[PATCH 1/5] dccp: Initialisation framework for feature negotiation
Daniel Lezcano
getsockopt(TCP_DEFER_ACCEPT) value change
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Gerrit Renker
[PATCH 37/37] dccp: Debugging functions for feature negotiation
git-commits-head
:
Linux Kernel Mailing List
ath9k_htc: Allocate URBs properly
Linux Kernel Mailing List
timer: Try to survive timer callback preempt_count leak
Linux Kernel Mailing List
powerpc/kexec: Add support for FSL-BookE
Linux Kernel Mailing List
V4L/DVB (8976): af9015: Add USB ID for AVerMedia A309
Linux Kernel Mailing List
ARM: 5670/1: bcmring: add default configuration for bcmring arch
openbsd-misc
:
Stephen J. Bevan
GRE over IPsec
Christophe Rioux
Implementation example of snmp
Nick Holland
Re: booting openbsd on eee without cd-rom
Guido Tschakert
Re: what exactly is enc0?
Darrin Chandler
Re: strange output on openbsd C code
Colocation donated by:
Syndicate