Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
5cfffbfa
Commit
5cfffbfa
authored
8 years ago
by
Paul A. Patience
Browse files
Options
Downloads
Patches
Plain Diff
crc64: fix error
parent
275f8988
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/crc64.h
+22
-0
22 additions, 0 deletions
include/crc64.h
libc/misc/lib_crc64.c
+7
-8
7 additions, 8 deletions
libc/misc/lib_crc64.c
with
29 additions
and
8 deletions
include/crc64.h
+
22
−
0
View file @
5cfffbfa
...
...
@@ -43,6 +43,28 @@
#include
<sys/types.h>
#include
<stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/*
* CRC64_CHECK is the CRC64 of the string "123456789" without the null byte.
*
* const uint8_t checkbuf[] =
* {
* '1', '2', '3', '4', '5', '6', '7', '8', '9'
* };
*
* assert(crc64(checkbuf, sizeof(checkbuf)) == CRC64_CHECK);
*/
/* CRC-64/WE */
#define CRC64_POLY ((uint64_t)0x42f0e1eba9ea3693)
#define CRC64_INIT ((uint64_t)0xffffffffffffffff)
#define CRC64_XOROUT ((uint64_t)0xffffffffffffffff)
#define CRC64_CHECK ((uint64_t)0x62ec59e3f1a4f00a)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
libc/misc/lib_crc64.c
+
7
−
8
View file @
5cfffbfa
...
...
@@ -54,8 +54,8 @@
* #include <stdint.h>
* #include <stdio.h>
*
* #define CRC64_POLY
NOMIAL
((uint64_t)0x42f0e1eba9ea3693)
* #define CRC64_TABLEN
((size_t)256)
* #define CRC64_POLY
((uint64_t)0x42f0e1eba9ea3693)
* #define CRC64_TABLEN ((size_t)256)
*
* int main(void)
* {
...
...
@@ -73,7 +73,7 @@
* {
* if ((crc64val & ((uint64_t)1 << 63)) != 0)
* {
* crc64val = (crc64val << 1) ^ CRC64_POLY
NOMIAL
;
* crc64val = (crc64val << 1) ^ CRC64_POLY;
* }
* else
* {
...
...
@@ -234,8 +234,6 @@ static const uint64_t crc64_tab[256] =
0x5dedc41a34bbeeb2
,
0x1f1d25f19d51d821
,
0xd80c07cd676f8394
,
0x9afce626ce85b507
};
#else
# define CRC64_POLYNOMIAL ((uint64_t)0x42f0e1eba9ea3693)
#endif
/****************************************************************************
...
...
@@ -257,7 +255,8 @@ uint64_t crc64part(FAR const uint8_t *src, size_t len, uint64_t crc64val)
for
(
i
=
0
;
i
<
len
;
i
++
)
{
crc64val
=
crc64_tab
[((
crc64val
>>
56
)
&
0xff
)
^
src
[
i
]]
^
(
crc64val
<<
8
);
crc64val
=
crc64_tab
[((
crc64val
>>
56
)
&
0xff
)
^
src
[
i
]]
^
(
crc64val
<<
8
);
}
return
crc64val
;
...
...
@@ -275,7 +274,7 @@ uint64_t crc64part(FAR const uint8_t *src, size_t len, uint64_t crc64val)
{
if
((
crc64val
&
((
uint64_t
)
1
<<
63
))
!=
0
)
{
crc64val
=
(
crc64val
<<
1
)
^
CRC64_POLY
NOMIAL
;
crc64val
=
(
crc64val
<<
1
)
^
CRC64_POLY
;
}
else
{
...
...
@@ -298,5 +297,5 @@ uint64_t crc64part(FAR const uint8_t *src, size_t len, uint64_t crc64val)
uint64_t
crc64
(
FAR
const
uint8_t
*
src
,
size_t
len
)
{
return
crc64part
(
src
,
len
,
~
(
uint64_t
)
0
)
;
return
crc64part
(
src
,
len
,
CRC64_INIT
)
^
CRC64_XOROUT
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment