[rtems commit] Added in_cksum_sparc. h to optimize IP checksum calculations for SPARC.

Ralf Corsepius ralf.corsepius at rtems.org
Fri Jun 21 05:50:16 UTC 2013

On 06/21/2013 12:15 AM, Jiri Gaisler wrote:

>>> diff --git a/cpukit/libnetworking/netinet/in_cksum.c
>>> b/cpukit/libnetworking/netinet/in_cksum.c
>>> index ec7e49c..ff25ad6 100644
>>> --- a/cpukit/libnetworking/netinet/in_cksum.c
>>> +++ b/cpukit/libnetworking/netinet/in_cksum.c
>>> @@ -61,6 +61,10 @@
>>>    #include "in_cksum_nios2.h"
>>> +#elif (defined(__GNUC__) && defined(__sparc))
>>> +
>>> +#include "in_cksum_sparc.h"
>>> +
>>>    #else
>> I am having several issues with this patch:
>> a) Has this code been tested with/checked against sparc64-rtems4.11 toolchains?
> No, it has been tested against sparc-rtems4.11. sparc64 is a different
> architecture which requires its own implementation of in_cksum_xxx.h.

OK, in this case, the defines need to be reworked, because both
sparc-rtems4.11-gcc and sparc64-rtems4.11-gcc define __sparc__
(There currently is no __sparc64__ define), which would mean the code 
above would also be used for the sparc64.

A common way to separate the sparc from the sparc64 on the preprocessor 
level would to utilize the __LP64__ define:

#if defined(__sparc__)
... coded shared on sparc and sparc64

#if defined(__sparc__) && defined(__LP64__)
... code exclusively for the sparc64

#if defined(__sparc__) && !defined(__LP64__)
... code exclusively for the sparc

There are other defines (e.g. __arch64__) which could be candidates for 
this purpose, however __LP64__ is pretty commonly used for this purpose.


More information about the devel mailing list