linux-mips
[Top] [All Lists]

Re: gcc warning in my trace_benchmark() code

To: David Daney <ddaney.cavm@gmail.com>
Subject: Re: gcc warning in my trace_benchmark() code
From: Steven Rostedt <rostedt@goodmis.org>
Date: Thu, 5 Jun 2014 18:17:08 -0400
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
In-reply-to: <5390E788.2030702@gmail.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20140605121204.18ee5f2d@gandalf.local.home> <5390A4F0.3000601@gmail.com> <20140605133500.190eb31d@gandalf.local.home> <5390BA9D.3090402@gmail.com> <20140605145339.57c5be79@gandalf.local.home> <5390E788.2030702@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
On Thu, 05 Jun 2014 14:56:24 -0700
David Daney <ddaney.cavm@gmail.com> wrote:

 
> Evidently it is.
> 
> The top of asm-generic/div64.h has:
> 
> .
> .
> .
>   * The semantics of do_div() are:
>   *
>   * uint32_t do_div(uint64_t *n, uint32_t base)
>   * {

That's somewhat lacking. Does this mean that we have no consistent way
to divide a s64 number?

> .
> .
> .
> 
> do_div() really passes the first parameter by reference, and C doesn't 
> have by reference parameters, so the example is not quite right.  But it 
> does seem to imply the thing should be an *unsigned* 64-bit wide variable.
> 
> It has been like this since the beginning of the git epoch.
> 
> > Where is that documented.
> 
> The code is the documentation.
> 
> > I don't
> > see it in the comments, and I don't see anything in the Documentation
> > directory. It only states that n must be 64bit. It doesn't say unsigned
> > 64 bit.
> 
> The handful of call sites I examined, seem to all use u64 or unsigned 
> long long.

and u64 and unsigned long long are usually the standard type to use for
64 bits.

> 
> I get:
> 
>    $ grep -r do_div Documentation | wc
>        0       0       0
> 
> So it would seem that most of the do_div() documentation actually is the 
> code.
> 

Which means there isn't documentation for it.

Anyway, this probably can be safely converted to an unsigned. As I'm
not sure standard deviation can ever be negative.

-- Steve

<Prev in Thread] Current Thread [Next in Thread>