2016-06-10 23:03:50 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/crc64.h
|
|
|
|
*
|
2021-09-28 17:44:33 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2016-06-10 23:03:50 +08:00
|
|
|
*
|
2021-09-28 17:44:33 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-06-10 23:03:50 +08:00
|
|
|
*
|
2021-09-28 17:44:33 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-06-10 23:03:50 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_CRC64_H
|
|
|
|
#define __INCLUDE_CRC64_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-10-01 05:28:04 +08:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2016-06-10 23:03:50 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-10-01 05:28:04 +08:00
|
|
|
#ifdef CONFIG_HAVE_LONG_LONG
|
|
|
|
|
2016-06-10 23:41:11 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-02-03 16:42:38 +08:00
|
|
|
/* CRC64_CHECK is the CRC64 of the string "123456789" without the null byte.
|
2016-06-10 23:41:11 +08:00
|
|
|
*
|
|
|
|
* const uint8_t checkbuf[] =
|
|
|
|
* {
|
|
|
|
* '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* assert(crc64(checkbuf, sizeof(checkbuf)) == CRC64_CHECK);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* CRC-64/WE */
|
|
|
|
|
2018-08-27 19:47:59 +08:00
|
|
|
#define CRC64_POLY ((uint64_t)0x42f0e1eba9ea3693ull)
|
|
|
|
#define CRC64_INIT ((uint64_t)0xffffffffffffffffull)
|
|
|
|
#define CRC64_XOROUT ((uint64_t)0xffffffffffffffffull)
|
|
|
|
#define CRC64_CHECK ((uint64_t)0x62ec59e3f1a4f00aull)
|
2016-06-10 23:41:11 +08:00
|
|
|
|
2016-06-10 23:03:50 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: crc64part
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Continue CRC calculation on a part of the buffer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint64_t crc64part(FAR const uint8_t *src, size_t len, uint64_t crc64val);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: crc64
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return a 64-bit CRC of the contents of the 'src' buffer, length 'len'.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
uint64_t crc64(FAR const uint8_t *src, size_t len);
|
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-10-01 05:28:04 +08:00
|
|
|
#endif /* CONFIG_HAVE_LONG_LONG */
|
2016-06-10 23:03:50 +08:00
|
|
|
#endif /* __INCLUDE_CRC64_H */
|