File: checksum.h

package info (click to toggle)
linux 3.16.51-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-updates
  • size: 755,292 kB
  • sloc: ansic: 12,235,573; asm: 277,597; perl: 53,071; xml: 47,771; makefile: 30,539; sh: 7,977; python: 6,697; cpp: 5,131; yacc: 4,254; lex: 2,215; awk: 741; pascal: 231; lisp: 218; sed: 30
file content (42 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright 2010 Tilera Corporation. All Rights Reserved.
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation, version 2.
 *
 *   This program is distributed in the hope that it will be useful, but
 *   WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 *   NON INFRINGEMENT.  See the GNU General Public License for
 *   more details.
 */

#ifndef _ASM_TILE_CHECKSUM_H
#define _ASM_TILE_CHECKSUM_H

#include <asm-generic/checksum.h>

/* Allow us to provide a more optimized do_csum(). */
__wsum do_csum(const unsigned char *buff, int len);
#define do_csum do_csum

/*
 * Return the sum of all the 16-bit subwords in a long.
 * This sums two subwords on a 32-bit machine, and four on 64 bits.
 * The implementation does two vector adds to capture any overflow.
 */
static inline unsigned int csum_long(unsigned long x)
{
	unsigned long ret;
#ifdef __tilegx__
	ret = __insn_v2sadu(x, 0);
	ret = __insn_v2sadu(ret, 0);
#else
	ret = __insn_sadh_u(x, 0);
	ret = __insn_sadh_u(ret, 0);
#endif
	return ret;
}

#endif /* _ASM_TILE_CHECKSUM_H */