rewrite src/sys/i386/i386/in_cksum.c

zhouyi zhou zhouzhouyi at FreeBSD.org
Mon Jul 9 03:14:13 UTC 2007


Sorry, previously send the preprocessed version of in_cksum.c:
What really needs to be replaced is for example:
408                 if (mlen >= 16) {
409                         ADD(0);
410                         ADDC(4);
411                         ADDC(8);
412                         ADDC(12);
413                         MOP;
414                         w += 8;
415                         mlen -= 16;
416                 }
On Mon, 9 Jul 2007 10:55:47 +0800
zhouyi zhou <zhouzhouyi at FreeBSD.org> wrote:

> Hey,
>   Since FreeBSD update gcc from 3.4.x to 4.2.0, the FreeBSD gdb remote debugger in i386 platform
> will find the TCP/UPD checksum will not be computed right, when calling macro in_cksum
> which calls in_cksum_skip in src/sys/i386/i386/in_cksum.c in case of getting rid of -O flag
> supplied to gcc when compiling(The optimize will interfere with comfortable gdb debugging).
> 
>   The reason is for example in src/sys/i386/i386/in_cksum.c:
>     126   if (mlen >= 16) {
>     127    __asm volatile ("addl %1, %0" : "+r" (sum) : "g" (((const unsigned int *)w)[0 / 4]));
>     128    __asm volatile ("adcl %1, %0" : "+r" (sum) : "g" (((const unsigned int *)w)[4 / 4]));
>     129    __asm volatile ("adcl %1, %0" : "+r" (sum) : "g" (((const unsigned int *)w)[8 / 4]));
>     130    __asm volatile ("adcl %1, %0" : "+r" (sum) : "g" (((const unsigned int *)w)[12 / 4]));
>     131    __asm volatile ("adcl         $0, %0" : "+r" (sum));
>     132    w += 8;
>     133    mlen -= 16;
>     134   }
>


More information about the freebsd-hackers mailing list