Hi,

I updated a system of us for testing the the compiler and I run into following problem:

cc -c -O -pipe -march=pentium4 -Wall \
    -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
    -Wmissing-prototypes -Wpointer-arith -Winline \
    -Wcast-qual-fformat-extensions -std=c99  -nostdinc \
    -I-  -I. -I/usr/src/sys -I/usr/src/sys/dev \
    -I/usr/src/sys/contrib/dev/acpica \
    -I/usr/src/sys/contrib/ipfilter \
    -I/usr/src/sys/contrib/dev/ath \
    -I/usr/src/sys/contrib/dev/ath/freebsd -D_KERNEL \
    -include opt_global.h -fno-common  \
    -mno-align-long-strings \
    -mpreferred-stack-boundary=2 -ffreestanding \
    /usr/src/sys/dev/ata/ata-all.c
{standard input}: Assembler messages:
{standard input}:7652: Error: invalid character '_' in mnemonic
*** Error code 1

Stop in /usr/obj/usr/src/sys/MOBY.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.

The lines around the location are:
ata_enclosure_status:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %edi
        pushl   %esi
        pushl   %ebx
        subl    $24, %esp
        movl    8(%ebp), %edi
        movl    $6, -16(%ebp)
        testb   $8, 20(%edi)
        ds ; je .L2817
        movl    (%edi), %eax
        movl    $1, 4(%esp)
        movl    %eax, (%esp)
        call    *248(%eax)
        movl    (%edi), %ecx
        movl    $0, %eax
        movl    $128, %edx
#APP
                lock ;          cmpxchgl %edx,244(%ecx) ;
setz     %al ;                   movzbl  %al,%eax ;      1:        #
atomic_cmpset_int
#NO_APP
        testl   %eax, %eax
        jne     .L2830
        movl    $0, %esi
        movl    $128, %ebx
.L2822:

The line 7652 is the "#NO_APP". After asking the current@ list
I didn't receive any answer so I assumed either noone had the
time to look over it or it's not really interesting for any
responsible. So I started some research about the '#APP'/'#NO_APP',
the code origin, etc.

The '#APP'/'#NO_APP' pair is used by the compiler to mark the
assembly section to be reformatted by the as(1) builtin preprocessor.
Because that's not the only '#APP'/'#NO_APP' pair, there must be sth.
different.

A try to reformat the assembly file produces the experience that
the error is gone when the label '1:' is placed on a new line.
The question I couldn't answer by myself is now:

is there any difference in the resulting code, if the inline assembly
of 'atomic_cmpset_int' will be written like:

static __inline int
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
{
        int res = exp;

        __asm __volatile (
        "" __XSTRING(MPLOCKED) "\n\t"
        "cmpxchgl %1,%2\n\t"
        "setz %%al\n\t"
        "movzbl %%al,%0\n\t"
        "1:\n\t"
        "# atomic_cmpset_int"
        : "+a" (res)                  /* 0 (result) */
        : "r" (src),                  /* 1 */
          "m" (*(dst))                        /* 2 */
        : "memory");                          

        return (res);
}

as it's shown in an example in
src/contrib/binutils/gas/config/tc-i386.c?

Or is the resulting code different from the original? I understood
the ';' as a instruction sepatator, so for my understanding there
will be no difference. But I think about the 'lock' instruction
which is required for SMP kernels? How works it here? Does it locks
the entire 3 instructions or just the first of them?

It would be great if someone could explain that to me.

Thanks and best regards,
Jens

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to