GNATS-1110: in_cksum_hdr error in PC386 BSP

Eric Norum norume at aps.anl.gov
Wed Jun 28 13:47:48 UTC 2006


danilliu at 163.com reported:
I changed the defination of function in_cksum_hdr() in \cpukit 
\libnetworking\machine\in_cksum.h from macro assemble to C language  
as below. Then it's running OK.

static __inline u_int
in_cksum_hdr(const struct ip *ip)
{
register u_int sum = 0;
register u_int16_t *ipdat;

ipdat=(u_int16_t *)ip;
sum=ipdat[0]+ipdat[1]+ipdat[2]+ipdat[3]+ipdat[4]+ipdat[5]+ipdat[6] 
+ipdat[7]+ipdat[8]+ipdat[9];

sum = (sum & 0xffff) + (sum >> 16);
return ~((sum>0xffff) ? (sum-0xffff) : sum) & 0xffff;
}
================================================================

This seems like a reasonable fix, but I wonder why the old code quit  
working.  Is this an indication of an error in the newer versions of  
gcc or was the old inline assembly wrong?
The checksum routines are very heavily used so it's really important  
that they be as fast as possible.  Do you have an estimate of the  
relative times of the old and new versions of this code?

If there are no objections in the next little while I'll commit the  
above change.  Joel has been asking for someone to fix the qemu  
problem for a long time.  Thank you very much for looking into this.
-- 
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793





More information about the users mailing list