Date: Fri, 26 Mar 2010 16:06:31 +0100 (CET) From: Petr Salinger <Petr.Salinger@seznam.cz> To: Alexander Leidinger <netchild@FreeBSD.org> Cc: Kostik Belousov <kostikbel@gmail.com>, svn-src-all@FreeBSD.org Subject: Re: svn commit: r205683 - head/sys/compat/linprocfs Message-ID: <Pine.LNX.4.62.1003261557490.19320@sci.felk.cvut.cz> In-Reply-To: <20100326133617.34413032k064412c@webmail.leidinger.net> References: <201003261143.o2QBhFhK034688@svn.freebsd.org> <20100326114925.GS2415@deviant.kiev.zoral.com.ua> <20100326133617.34413032k064412c@webmail.leidinger.net>
next in thread | previous in thread | raw e-mail | index | archive | help
>>> --- head/sys/compat/linprocfs/linprocfs.c (r205682)
>>> +++ head/sys/compat/linprocfs/linprocfs.c (r205683)
>>> @@ -110,13 +110,36 @@ __FBSDID("$FreeBSD$");
>>> /*
>>> * Various conversion macros
>>> */
>>> +
>>> +/* The LINUX_USER_HZ is assumed 100 for now */
>>> +
>>> +#if defined(__i386__) && defined(__GNUCLIKE_ASM)
>>> +/* we need intermediate result as 64 bit, otherwise it overflows too
>>> early */
>>> +#define DO64_MULDIV(v,m,d) \
>>> +({ \
>>> + unsigned long rv0; \
>>> + unsigned long rv1; \
>>> + __asm__ __volatile__( \
>>> + "mull %1\n\t" \
>>> + "divl %2\n\t" \
>>> + :"=a" (rv0), "=d" (rv1) \
>>> + :"r" (d), "0" (v), "1" (m) \
>>> + :"cc" ); \
>>> + rv0; \
>>> +})
>>
>> Why it is impossible to express the calculation in C ?
>
> You forgot to CC the submitter... CCed.
>
> What do you have in mind, (unsinged long)((uint64_t)v * (uint64_t)m /
> (uint64_t)d)? Conditionally on the architecture or not?
Or just on all architectures this:
#define T2J(x) (unsigned long)(((x) * 100ULL) / (stathz ? stathz : hz)) /* ticks to jiffies */
Petr
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.62.1003261557490.19320>
