linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Anzinger <george@mvista.com>
To: andersen@codepoet.org
Cc: Andrew Morton <akpm@osdl.org>,
	"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
	torvalds@osdl.org, linux-kernel@vger.kernel.org,
	jun.nakajima@intel.com
Subject: Re: [PATCHSET][2.6-test4][0/6]Support for HPET based timer - Take 2
Date: Fri, 05 Sep 2003 15:19:09 -0700	[thread overview]
Message-ID: <3F590BDD.9010902@mvista.com> (raw)
In-Reply-To: <20030829210335.GA3150@codepoet.org>

Erik Andersen wrote:
> On Fri Aug 29, 2003 at 11:23:47AM -0700, Andrew Morton wrote:
> 
>>"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com> wrote:
>>
>>>Resending the patch.
>>
>>Thanks, I'll include these in the next -mm kernel.
>>
>>Reading the code, the only thing which leaps out is:
>>
>>+/* Use our own asm for 64 bit multiply/divide */
>>+#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) 			\
>>+		__asm__ __volatile__("mull %2" 				\
>>+				:"=a" (eax_out), "=d" (edx_out) 	\
>>+				:"r" (reg_in), "0" (eax_in))

This can be done in standard C.  If you want an inline, how about 
(from .../kernel/posix-timers.c):

static inline u64  mpy_l_X_l_ll(unsigned long mpy1,unsigned long mpy2)
{
	return (u64)mpy1 * mpy2;
}


>>+
>>+#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) 		\
>>+		__asm__ __volatile__("divl %2" 				\
>>+				:"=a" (eax_out), "=d" (edx_out) 	\
>>+				:"r" (reg_in), "0" (eax_in), "1" (edx_in))

This appears to be the same as (from .../include/asm-i386/div64.h):

#define div_long_long_rem(a,b,c) div_ll_X_l_rem(a,b,c)

extern inline long
div_ll_X_l_rem(long long divs, long div, long *rem)
{
	long dum2;
       __asm__("divl %2":"=a"(dum2), "=d"(*rem)
       :	"rm"(div), "A"(divs));

	return dum2;

}

-g

>>
>>We seem to keep on proliferating home-grown x86 64-bit math functions.
>>
>>Do you really need these?  Is it possible to use do_div() and the C 64x64
>>`*' operator instead?
> 
> 
> 
> The fundamental reason these are proliferating is that given
> some random bit of code such as:
> 
>     u64 foo=9, bar=3, baz;
>     baz = foo / bar;
>     baz = foo % bar;
> 
> gcc then generates code calling __udivdi3 and __umoddi3.  Since
> the kernel does not provide these, people keep reinventing them.
> Perhaps it is time to kill off do_div and all its little friends
> and simply copy __udivdi3 and __umoddi3 from libgcc.....
> 
>  -Erik
> 
> --
> Erik B. Andersen             http://codepoet-consulting.com/
> --This message was written using 73% post-consumer electrons--
> -
> 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/
> 

-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml


  parent reply	other threads:[~2003-09-05 22:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-28 23:41 [PATCHSET][2.6-test4][0/6]Support for HPET based timer - Take 2 Pallipadi, Venkatesh
2003-08-29 18:23 ` Andrew Morton
2003-08-29 21:03   ` Erik Andersen
2003-08-31 21:05     ` Linus Torvalds
2003-08-31 22:24       ` Erik Andersen
2003-08-31 22:48         ` Linus Torvalds
2003-09-05 22:19     ` George Anzinger [this message]
     [not found] <pEGJ.73p.5@gated-at.bofh.it>
2003-08-29  3:40 ` David Mosberger-Tang
2003-08-29 16:12 Pallipadi, Venkatesh
2003-08-30  4:59 ` David Mosberger-Tang
2003-08-29 23:58 Pallipadi, Venkatesh
2003-09-05 22:26 ` George Anzinger
2003-08-30 16:26 Pallipadi, Venkatesh
2003-09-06 19:04 Pallipadi, Venkatesh
2003-09-07 17:57 ` George Anzinger

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=3F590BDD.9010902@mvista.com \
    --to=george@mvista.com \
    --cc=akpm@osdl.org \
    --cc=andersen@codepoet.org \
    --cc=jun.nakajima@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=venkatesh.pallipadi@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).