From owner-svn-src-all@FreeBSD.ORG Fri Mar 26 13:33:30 2010 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B64F41065676; Fri, 26 Mar 2010 13:33:30 +0000 (UTC) (envelope-from Petr.Salinger@seznam.cz) Received: from relay.felk.cvut.cz (relay.felk.cvut.cz [147.32.80.7]) by mx1.freebsd.org (Postfix) with ESMTP id 423698FC28; Fri, 26 Mar 2010 13:33:29 +0000 (UTC) Received: from sci.felk.cvut.cz (sci.felk.cvut.cz [147.32.83.100]) by relay.felk.cvut.cz (8.14.3/8.14.3) with ESMTP id o2QD0rPN028708; Fri, 26 Mar 2010 14:00:53 +0100 (CET) (envelope-from Petr.Salinger@seznam.cz) Date: Fri, 26 Mar 2010 16:06:31 +0100 (CET) From: Petr Salinger X-X-Sender: salinger@sci.felk.cvut.cz To: Alexander Leidinger In-Reply-To: <20100326133617.34413032k064412c@webmail.leidinger.net> Message-ID: References: <201003261143.o2QBhFhK034688@svn.freebsd.org> <20100326114925.GS2415@deviant.kiev.zoral.com.ua> <20100326133617.34413032k064412c@webmail.leidinger.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-FELK-MailScanner-Information: X-MailScanner-ID: o2QD0rPN028708 X-FELK-MailScanner: Found to be clean X-FELK-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-1.121, required 5, BAYES_00 -1.90, SPF_NEUTRAL 0.78) X-FELK-MailScanner-From: petr.salinger@seznam.cz X-FELK-MailScanner-To: kostikbel@gmail.com, netchild@freebsd.org, svn-src-all@freebsd.org X-FELK-MailScanner-Watermark: 1270213253.4867@7R+kNfAToSB+9AuXRpmRgQ X-Spam-Status: No Cc: Kostik Belousov , svn-src-all@FreeBSD.org Subject: Re: svn commit: r205683 - head/sys/compat/linprocfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2010 13:33:30 -0000 >>> --- 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