mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@mindspring.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: from where comes "__moddi3"?
Date: Sat, 21 Jul 2007 15:34:21 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707211532140.8143@localhost.localdomain> (raw)
In-Reply-To: <1185046274.5652.15.camel@lappy>

On Sat, 21 Jul 2007, Peter Zijlstra wrote:

> On Sat, 2007-07-21 at 15:21 -0400, Robert P. J. Day wrote:
> > again, probably displaying my abject ignorance, but i wrote a
> > trivial module that tries to "var % 15", and i get:
> >
> >   WARNING: "__moddi3" undefined!
> >
> > and, not surprisingly, when i try to insmod:
> >
> >   insmod: error inserting 'seq.ko': -1 Unknown symbol in module
> >
> > (using 16 rather than 15 works fine, as i assume that the modulus
> > call is simply replaced by an optimized  bitwise comparison.)
> >
> >   so ... from where comes __moddi3?  i know there are places in the
> > kernel source tree that do non-power-of-2 moduli, and they work fine,
> > no?  thanks.
>
> let me guess, 32 bit kernel, and var is 64 bit?

um ... yeah.  duh.  var type is actually loff_t.  i should have
realized that.

> gcc translates that into a libgcc call, which we _explicitly_ do not
> have because 64bit divisions are expensive!
>
> use do_div().

gotcha.  thanks.

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

  reply	other threads:[~2007-07-21 19:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-21 19:21 Robert P. J. Day
2007-07-21 19:31 ` Peter Zijlstra
2007-07-21 19:34   ` Robert P. J. Day [this message]
2007-07-21 19:58   ` Jan-Benedict Glaw
2007-07-21 20:00     ` Peter Zijlstra
2007-07-21 19:33 ` Alexander Shishkin
2007-07-21 19:34   ` Jan Engelhardt
2007-07-21 20:00     ` Alexander Shishkin
2007-07-21 21:27       ` David Schwartz
2007-07-21 22:02         ` Arjan van de Ven

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=Pine.LNX.4.64.0707211532140.8143@localhost.localdomain \
    --to=rpjday@mindspring.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.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®