Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
85edd52e
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
7
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
85edd52e
编写于
4月 15, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
!28 Fix Cpplint and improve security
Merge pull request !28 from 李鸿章/crc32_align
上级
abc9a741
d4ed948e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
23 deletion
+14
-23
build/scripts/crc32.sh
build/scripts/crc32.sh
+2
-4
mindinsight/datavisual/utils/crc32/crc32.cc
mindinsight/datavisual/utils/crc32/crc32.cc
+2
-4
mindinsight/datavisual/utils/crc32/crc32.h
mindinsight/datavisual/utils/crc32/crc32.h
+10
-15
未找到文件。
build/scripts/crc32.sh
浏览文件 @
85edd52e
...
...
@@ -63,13 +63,11 @@ build_crc32() {
rm
-f
"
$CRC32_SOURCE_DIR
/
$CRC32_SO_FILE
"
rm
-f
"
$CRC32_OUTPUT_DIR
/
$CRC32_SO_FILE
"
PYBIND11_INCLUDES
=
$(
$PYTHON
-m
pybind11
--includes
)
PYTHON_INCLUDE
=
$(
echo
"
$PYBIND11_INCLUDES
"
|
awk
'{print $1}'
|
sed
"s/^-I//g"
)
PYTHON_HEADERS
=
$(
echo
"
$PYBIND11_INCLUDES
"
|
awk
'{print $2}'
|
sed
"s/^-I//g"
)
read
-ra
PYBIND11_INCLUDES
<<<
"
$(
$PYTHON
-m
pybind11
--includes
)
"
c++
-O2
-O3
-shared
-std
=
c++11
-fPIC
-fstack-protector-all
-D_FORTIFY_SOURCE
=
2
\
-Wno-maybe-uninitialized
-Wno-unused-parameter
-Wall
-Wl
,-z,relro,-z,now,-z,noexecstack
\
-I
"
$THIRD_PARTY_DIR
"
-I
"
$DATAVISUAL_DIR
/utils"
-I
"
$PYTHON_INCLUDE
"
-I
"
$PYTHON_HEADERS
"
\
-I
"
$THIRD_PARTY_DIR
/securec/include"
"
${
PYBIND11_INCLUDES
[0]
}
"
"
${
PYBIND11_INCLUDES
[1]
}
"
\
-o
"
$CRC32_SO_FILE
"
crc32.cc
"
$BUILDDIR
/libsecurec.a"
if
[
!
-f
"
$CRC32_SO_FILE
"
]
;
then
...
...
mindinsight/datavisual/utils/crc32/crc32.cc
浏览文件 @
85edd52e
...
...
@@ -14,8 +14,7 @@
* limitations under the License.
*/
#include "crc32/crc32.h"
#include <stdint.h>
#include "crc32.h"
static
const
uint32_t
crc_table_o32
[
CRC_TABLE_SIZE
]
=
{
...
...
@@ -280,9 +279,8 @@ inline void CRC32T8(uint32_t *crc, const uint8_t **p) {
// calc the crc32c value
uint32_t
MakeCrc32c
(
uint32_t
init_crc
,
const
char
*
data
,
size_t
size
)
{
EXCEPT_CHECK_NULL
(
data
);
uint32_t
crc
=
init_crc
^
0xFFFFFFFFU
;
const
long
OFFSET
=
8
;
const
int
OFFSET
=
8
;
// Get the origin begin and end address(not alignment)
auto
*
bp
=
reinterpret_cast
<
const
uint8_t
*>
(
data
);
...
...
mindinsight/datavisual/utils/crc32/crc32.h
浏览文件 @
85edd52e
...
...
@@ -17,10 +17,10 @@
#ifndef DATAVISUAL_UTILS_CRC32_CRC32_H_
#define DATAVISUAL_UTILS_CRC32_CRC32_H_
#include "pybind11/pybind11.h"
#include "securec/include/securec.h"
#include <cstddef>
#include <cstdint>
#include "pybind11/pybind11.h"
#include "securec.h"
#define CRC_TABLE_SIZE 256
#define RIGHT_SHIFT 15
...
...
@@ -29,28 +29,19 @@
// Align n to (1 << m) byte boundary
#define MEM_ALIGN(n, m) ((n + ((1 << m) - 1)) & ~((1 << m) - 1))
// check the null point, Only log it in if(): The value is null
#define EXCEPT_CHECK_NULL(value) \
do { \
if (value == nullptr) { \
break; \
} \
} while (0)
// implement common define function
// Get the 32 bits align value
inline
uint32_t
DecodeFixed32
(
const
char
*
ptr
)
{
uint32_t
result
=
0
;
if
(
EOK
!=
memcpy_s
(
&
result
,
sizeof
(
result
),
ptr
,
sizeof
(
result
)))
{
return
result
;
if
(
EOK
!=
memcpy_s
(
&
result
,
sizeof
(
result
),
ptr
,
sizeof
(
result
)))
{
// `0` indicates that something wrong happened
return
0
;
}
return
result
;
}
// Used to fetch a naturally-aligned 32-bit word in little endian byte-order
inline
uint32_t
LE_LOAD32
(
const
uint8_t
*
p
)
{
return
DecodeFixed32
(
reinterpret_cast
<
const
char
*>
(
p
));
}
inline
uint32_t
LE_LOAD32
(
const
uint8_t
*
p
)
{
return
DecodeFixed32
(
reinterpret_cast
<
const
char
*>
(
p
));
}
// Masked for crc.
static
constexpr
uint32_t
kMaskDelta
=
0xA282EAD8U
;
...
...
@@ -62,6 +53,10 @@ uint32_t MakeCrc32c(uint32_t init_crc, const char* data, size_t size);
// A function return the crc32c value
uint32_t
GetMaskCrc32cValue
(
const
char
*
data
,
size_t
n
)
{
if
(
data
==
nullptr
&&
n
>
0
)
{
// Return early to prevent MakeCrc32c resulting in segmentfault
return
0
;
}
uint32_t
crc
=
MakeCrc32c
(
0
,
data
,
n
);
return
((
crc
>>
RIGHT_SHIFT
)
|
(
crc
<<
LEFT_SHIFT
))
+
kMaskDelta
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录