25 Apr
2010
25 Apr
'10
9:41 a.m.
Gcc does not recognize z + (z < sum) as an "add with carry" However, x86 recognizes if (z < x) z++ as an "add with carry" operation so lets use that instead. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> --- lib/checksum.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lib/checksum.c b/lib/checksum.c index 33cb386..bf70cab 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -26,7 +26,9 @@ static u32 add32(u32 sum, u32 x) { u32 z = sum + x; - return z + (z < sum); + if (z < x) + z++; + return z; } static u16 -- 1.6.4.4