delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/23/08:32:49

Message-Id: <200005231231.IAA05257@delorie.com>
From: "Dieter Buerssner" <buers AT gmx DOT de>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Date: Tue, 23 May 2000 14:38:03 +0200
MIME-Version: 1.0
Subject: Re: Bug 314
CC: djgpp-workers AT delorie DOT com
References: <200005231106 DOT HAA32744 AT delorie DOT com>
In-reply-to: <Pine.SUN.3.91.1000523144730.5702E-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.12b)
Reply-To: djgpp-workers AT delorie DOT com

On 23 May 00, Eli Zaretskii wrote:
 
> On Tue, 23 May 2000, Dieter Buerssner wrote:
> > On 23 May 00, at 12:06, Eli Zaretskii wrote:
> > > The code seems consistent with C9X draft, as far as I could see, but
> > > isn't it better to replace it with inline asm that does this in a
> > > single instruction?
> > 
> > Gcc will usually produce only one idiv instruction for n/d; n%d pairs 
> > for integer types smaller long long.
>
> First, I meant the long long version as well. 

It would be a rather difficult task, to write the long long version 
with inline assembly. You have to take into account, that the 
demoniator is > 32 bits. There is no upcode for this. Even, when the 
demoniator is smaller 32 bits, idiv won't be enough, because the 
result can overflow. I think, one has just to live with the fact, 
that long long / long long and long long % long long will be a rather 
slow operation with x86.

> And second, I was thinking
> about putting a fast inline version into stdlib.h as a macro, and making
> the function versions use that macro as their body.  We do that for getc 
> and putc, for example.

While it might be a good idea, to use an inline version,I don't see 
any need, to use inline assembly for it.

As a side note, I think these functions will loose importance. In 
C99, % and / are well defined for negative numbers. This was not the 
case in C90.

Regards,
Dieter

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019