Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
15c06a2f
Commit
15c06a2f
authored
Sep 15, 2009
by
Stephen Rothwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit 'asm-generic/next'
parents
0c13b48a
428bc597
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
lib/checksum.c
lib/checksum.c
+8
-6
No files found.
lib/checksum.c
View file @
15c06a2f
...
@@ -37,7 +37,8 @@
...
@@ -37,7 +37,8 @@
#include <asm/byteorder.h>
#include <asm/byteorder.h>
static
inline
unsigned
short
from32to16
(
unsigned
long
x
)
#ifndef do_csum
static
inline
unsigned
short
from32to16
(
unsigned
int
x
)
{
{
/* add up 16-bit and 16-bit for 16+c bit */
/* add up 16-bit and 16-bit for 16+c bit */
x
=
(
x
&
0xffff
)
+
(
x
>>
16
);
x
=
(
x
&
0xffff
)
+
(
x
>>
16
);
...
@@ -49,16 +50,16 @@ static inline unsigned short from32to16(unsigned long x)
...
@@ -49,16 +50,16 @@ static inline unsigned short from32to16(unsigned long x)
static
unsigned
int
do_csum
(
const
unsigned
char
*
buff
,
int
len
)
static
unsigned
int
do_csum
(
const
unsigned
char
*
buff
,
int
len
)
{
{
int
odd
,
count
;
int
odd
,
count
;
unsigned
long
result
=
0
;
unsigned
int
result
=
0
;
if
(
len
<=
0
)
if
(
len
<=
0
)
goto
out
;
goto
out
;
odd
=
1
&
(
unsigned
long
)
buff
;
odd
=
1
&
(
unsigned
long
)
buff
;
if
(
odd
)
{
if
(
odd
)
{
#ifdef __LITTLE_ENDIAN
#ifdef __LITTLE_ENDIAN
result
=
*
buff
;
#else
result
+=
(
*
buff
<<
8
);
result
+=
(
*
buff
<<
8
);
#else
result
=
*
buff
;
#endif
#endif
len
--
;
len
--
;
buff
++
;
buff
++
;
...
@@ -73,9 +74,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
...
@@ -73,9 +74,9 @@ static unsigned int do_csum(const unsigned char *buff, int len)
}
}
count
>>=
1
;
/* nr of 32-bit words.. */
count
>>=
1
;
/* nr of 32-bit words.. */
if
(
count
)
{
if
(
count
)
{
unsigned
long
carry
=
0
;
unsigned
int
carry
=
0
;
do
{
do
{
unsigned
long
w
=
*
(
unsigned
int
*
)
buff
;
unsigned
int
w
=
*
(
unsigned
int
*
)
buff
;
count
--
;
count
--
;
buff
+=
4
;
buff
+=
4
;
result
+=
carry
;
result
+=
carry
;
...
@@ -102,6 +103,7 @@ static unsigned int do_csum(const unsigned char *buff, int len)
...
@@ -102,6 +103,7 @@ static unsigned int do_csum(const unsigned char *buff, int len)
out:
out:
return
result
;
return
result
;
}
}
#endif
/*
/*
* This is a version of ip_compute_csum() optimized for IP headers,
* This is a version of ip_compute_csum() optimized for IP headers,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment