mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Matthew Wilcox <willy@debian.org>
Cc: bernie@develer.com, akpm@zip.com.au, linux-kernel@vger.kernel.org
Subject: Re: do_div vs sector_t
Date: Fri, 11 Jul 2003 15:34:15 -0700	[thread overview]
Message-ID: <20030711153415.6776a680.akpm@osdl.org> (raw)
In-Reply-To: <20030711223359.GP20424@parcelfarce.linux.theplanet.co.uk>

Matthew Wilcox <willy@debian.org> wrote:
>
> This almost works (the warning is harmless since gcc optimises away the call)
> 
> # define do_div(n,base) ({                                              \
>         uint32_t __base = (base);                                       \
>         uint32_t __rem;                                                 \
>         if ((sizeof(n) < 8) || (likely(((n) >> 32) == 0))) {            \
>                 __rem = (uint32_t)(n) % __base;                         \
>                 (n) = (uint32_t)(n) / __base;                           \
>         } else                                                          \
>                 __rem = __div64_32(&(n), __base);                       \
>         __rem;                                                          \
>  })

Could we just do:

diff -puN include/asm-generic/div64.h~do_div-fix-43 include/asm-generic/div64.h
--- 25/include/asm-generic/div64.h~do_div-fix-43	Fri Jul 11 15:32:33 2003
+++ 25-akpm/include/asm-generic/div64.h	Fri Jul 11 15:33:26 2003
@@ -34,7 +34,8 @@
 
 extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
 
-# define do_div(n,base) ({				\
+# define do_div(_n,base) ({				\
+	uint64_t n = _n;				\
 	uint32_t __base = (base);			\
 	uint32_t __rem;					\
 	if (likely(((n) >> 32) == 0)) {			\
@@ -42,6 +43,7 @@ extern uint32_t __div64_32(uint64_t *div
 		(n) = (uint32_t)(n) / __base;		\
 	} else 						\
 		__rem = __div64_32(&(n), __base);	\
+	_n = n;						\
 	__rem;						\
  })
 

_




  reply	other threads:[~2003-07-11 22:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-11 22:33 Matthew Wilcox
2003-07-11 22:34 ` Andrew Morton [this message]
2003-07-11 22:42 ` Neil Brown
2003-07-12  0:14   ` do_div vs sector_t (patch) Nick Piggin
2003-07-12  6:52 ` do_div vs sector_t Christoph Hellwig
2003-07-12  6:58   ` Andrew Morton
2003-07-13 17:26 ` Richard Henderson
2003-07-13 17:39   ` Russell King
2003-07-13 19:14   ` Bernardo Innocenti
2003-07-13 20:04     ` Matthew Wilcox
2003-07-14  4:07 ` Peter Chubb
2003-07-13 18:40 linux

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=20030711153415.6776a680.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=akpm@zip.com.au \
    --cc=bernie@develer.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@debian.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®