Deleted Added
sdiff udiff text old ( 54882 ) new ( 58698 )
full compact
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from tahoe: in_cksum.c 1.2 86/01/05
34 * from: @(#)in_cksum.c 1.3 (Berkeley) 1/19/91
35 * $FreeBSD: head/sys/i386/i386/in_cksum.c 54882 1999-12-20 12:11:34Z sheldonh $
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/mbuf.h>
41
42#include <netinet/in.h>
43#include <netinet/in_systm.h>

--- 8 unchanged lines hidden (view full) ---

52 * code and should be modified for each CPU to be as fast as possible.
53 *
54 * This implementation is 386 version.
55 */
56
57#undef ADDCARRY
58#define ADDCARRY(x) if ((x) > 0xffff) (x) -= 0xffff
59#define REDUCE {sum = (sum & 0xffff) + (sum >> 16); ADDCARRY(sum);}
60
61/*
62 * Thanks to gcc we don't have to guess
63 * which registers contain sum & w.
64 */
65#define ADD(n) __asm __volatile \
66 ("addl " #n "(%2), %0" : "=r" (sum) : "0" (sum), "r" (w))
67#define ADDC(n) __asm __volatile \

--- 173 unchanged lines hidden (view full) ---

241 standard (the odd byte is shifted left by 8 bits) */
242 su.c[1] = 0;
243 sum += su.s;
244 }
245 REDUCE;
246 return (~sum & 0xffff);
247}
248
249/*
250 * This is the exact same algorithm as above with a few exceptions:
251 * (1) it is designed to operate on buffers, not mbufs
252 * (2) it returns an intermediate form of the sum which has to be
253 * explicitly finalized (but this can be delayed)
254 * (3) it accepts an intermediate sum
255 *
256 * This is particularly useful when building packets quickly,

--- 159 unchanged lines hidden ---