Message-Id: <200005231231.IAA05257@delorie.com> From: "Dieter Buerssner" To: Eli Zaretskii Date: Tue, 23 May 2000 14:38:03 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Bug 314 CC: djgpp-workers AT delorie DOT com References: <200005231106 DOT HAA32744 AT delorie DOT com> In-reply-to: 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