Re: Opteron bug

Jakub Jelinek
2004-06-21T05:47:19Z

On Mon, Jun 21, 2004 at 02:54:53AM +0300, Denis Vlasenko wrote:
> On Sunday 20 June 2004 15:02, Jakub Jelinek wrote:
> > On Sun, Jun 20, 2004 at 01:47:17PM +0200, R. J. Wysocki wrote:
> > > Well, is there any case in which the gcc can produce such stuff?
> >
> > GCC doesn't ever generate std instruction (only cld), though users
> > can use it in inline assembly or assembly source file.
> > AFAIK x86_64 glibc doesn't use it at all either.
>
> glibc-2.3/sysdeps/i386/memcopy.h:
>
> #define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
> do \
> { \
> int __d0; \
> asm volatile(/* Set the direction flag, so copying goes backwards. */ \
> "std\n" \
> /* Copy bytes. */ \
> "rep\n" \
> "movsb\n" \
> /* Clear the dir flag. Convention says it should be 0. */ \
> "cld" : \
> "=D" (dst_ep), "=S" (src_ep), "=c" (__d0) : \
> "0" (dst_ep - 1), "1" (src_ep - 1), "2" (nbytes) : \
> "memory"); \
> dst_ep += 1; \
> src_ep += 1; \
> } while (0)
>
> WORD_COPY_BWD also does this

I know, but I said x86_64 glibc, which doesn't do this.

Jakub