1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Smorkalov 76eff34bdc Enable KleidiCV for Android aarch64 by default. 2024-07-04 10:38:29 +03:00
1988 changed files with 95596 additions and 124607 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
-14
View File
@@ -1,14 +0,0 @@
name: 4.x
on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:
jobs:
CodeQL:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-CodeQL.yaml@main
with:
target_branch: '4.x'
workflow_branch: main
+23 -13
View File
@@ -6,30 +6,37 @@ on:
- 4.x
jobs:
Linux:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Linux.yaml@main
with:
workflow_branch: main
Windows:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-Windows.yaml@main
with:
workflow_branch: main
Ubuntu2404-ARM64:
Ubuntu2004-ARM64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-ARM64.yaml@main
Ubuntu2404-ARM64-Debug:
Ubuntu2004-ARM64-Debug:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-ARM64-Debug.yaml@main
Ubuntu2004-x64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-U20.yaml@main
Ubuntu2004-x64-OpenVINO:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-U20-OpenVINO.yaml@main
Ubuntu2204-x64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-U22.yaml@main
Ubuntu2404-x64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-U24.yaml@main
Ubuntu2004-x64-CUDA:
if: "${{ contains(github.event.pull_request.labels.*.name, 'category: dnn') }} || ${{ contains(github.event.pull_request.labels.*.name, 'category: dnn (onnx)') }}"
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-U20-Cuda.yaml@main
Windows10-x64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-W10.yaml@main
Windows10-ARM64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-W10-ARM64.yaml@main
Windows10-x64-Vulkan:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-W10-Vulkan.yaml@main
macOS-ARM64:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-macOS-ARM64.yaml@main
@@ -45,6 +52,9 @@ jobs:
Android-SDK:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-4.x-Android-SDK.yaml@main
Android-Test:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-PR-4.x-Android-Test.yaml@main
TIM-VX:
uses: opencv/ci-gha-workflow/.github/workflows/OCV-timvx-backend-tests-4.x.yml@main
@@ -42,11 +42,15 @@ endif()
if(WITH_NEON)
target_compile_definitions(carotene_objs PRIVATE "-DWITH_NEON")
if(NOT DEFINED CAROTENE_NEON_ARCH )
elseif(CAROTENE_NEON_ARCH EQUAL 8)
target_compile_definitions(carotene_objs PRIVATE "-DCAROTENE_NEON_ARCH=8")
elseif(CAROTENE_NEON_ARCH EQUAL 7)
target_compile_definitions(carotene_objs PRIVATE "-DCAROTENE_NEON_ARCH=7")
else()
target_compile_definitions(carotene_objs PRIVATE "-DCAROTENE_NEON_ARCH=0")
endif()
endif()
if(MINGW)
target_compile_definitions(carotene_objs PRIVATE "-D_USE_MATH_DEFINES=1")
endif()
# we add dummy file to fix XCode build
add_library(carotene STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} "$<TARGET_OBJECTS:carotene_objs>" "${CAROTENE_SOURCE_DIR}/dummy.cpp")
@@ -119,7 +119,7 @@ private: \
#define TEGRA_BINARYOP(type, op, src1, sz1, src2, sz2, dst, sz, w, h) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_##op##_Invoker<const type, type>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -154,7 +154,7 @@ TegraUnaryOp_Invoker(bitwiseNot, bitwiseNot)
#define TEGRA_UNARYOP(type, op, src1, sz1, dst, sz, w, h) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_##op##_Invoker<const type, type>(src1, sz1, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -254,32 +254,32 @@ TegraGenOp_Invoker(cmpLE, cmpGE, 2, 1, 0, RANGE_DATA(ST, src2_data, src2_step),
( \
CAROTENE_NS::isSupportedConfiguration() ? \
((op) == cv::CMP_EQ) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpEQ_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
((op) == cv::CMP_NE) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpNE_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
((op) == cv::CMP_GT) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpGT_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
((op) == cv::CMP_GE) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpGE_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
((op) == cv::CMP_LT) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpLT_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
((op) == cv::CMP_LE) ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_cmpLE_Invoker<const type, CAROTENE_NS::u8>(src1, sz1, src2, sz2, dst, sz, w, h), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
@@ -310,7 +310,7 @@ TegraGenOp_Invoker(cmpLE, cmpGE, 2, 1, 0, RANGE_DATA(ST, src2_data, src2_step),
#define TEGRA_BINARYOPSCALE(type, op, src1, sz1, src2, sz2, dst, sz, w, h, scales) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_##op##_Invoker<const type, type>(src1, sz1, src2, sz2, dst, sz, w, h, scales), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -332,7 +332,7 @@ TegraBinaryOpScale_Invoker(divf, div, 1, scale)
#define TEGRA_UNARYOPSCALE(type, op, src1, sz1, dst, sz, w, h, scales) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, h), \
parallel_for_(Range(0, h), \
TegraGenOp_##op##_Invoker<const type, type>(src1, sz1, dst, sz, w, h, scales), \
(w * h) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -928,17 +928,17 @@ TegraRowOp_Invoker(split4, split4, 1, 4, 0, RANGE_DATA(ST, src1_data, 4*sizeof(S
( \
CAROTENE_NS::isSupportedConfiguration() ? \
cn == 2 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_split2_Invoker<const type, type>(src, dst[0], dst[1]), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
cn == 3 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_split3_Invoker<const type, type>(src, dst[0], dst[1], dst[2]), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
cn == 4 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_split4_Invoker<const type, type>(src, dst[0], dst[1], dst[2], dst[3]), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
@@ -990,17 +990,17 @@ TegraRowOp_Invoker(combine4, combine4, 4, 1, 0, RANGE_DATA(ST, src1_data, sizeof
( \
CAROTENE_NS::isSupportedConfiguration() ? \
cn == 2 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_combine2_Invoker<const type, type>(src[0], src[1], dst), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
cn == 3 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_combine3_Invoker<const type, type>(src[0], src[1], src[2], dst), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
cn == 4 ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_combine4_Invoker<const type, type>(src[0], src[1], src[2], src[3], dst), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
@@ -1033,7 +1033,7 @@ TegraRowOp_Invoker(phase, phase, 2, 1, 1, RANGE_DATA(ST, src1_data, sizeof(CAROT
#define TEGRA_FASTATAN(y, x, dst, len, angleInDegrees) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_phase_Invoker<const CAROTENE_NS::f32, CAROTENE_NS::f32>(x, y, dst, angleInDegrees ? 1.0f : M_PI/180), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -1049,7 +1049,7 @@ TegraRowOp_Invoker(magnitude, magnitude, 2, 1, 0, RANGE_DATA(ST, src1_data, size
#define TEGRA_MAGNITUDE(x, y, dst, len) \
( \
CAROTENE_NS::isSupportedConfiguration() ? \
parallel_for_(cv::Range(0, len), \
parallel_for_(Range(0, len), \
TegraRowOp_magnitude_Invoker<const CAROTENE_NS::f32, CAROTENE_NS::f32>(x, y, dst), \
(len) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK \
@@ -1286,6 +1286,7 @@ inline int TEGRA_SEPFILTERFREE(cvhalFilter2D *context)
#undef cv_hal_sepFilterFree
#define cv_hal_sepFilterFree TEGRA_SEPFILTERFREE
struct MorphCtx
{
int operation;
@@ -1563,17 +1564,17 @@ TegraCvtColor_Invoker(rgbx2bgrx, rgbx2bgrx, src_data + static_cast<size_t>(range
scn == 3 ? \
dcn == 3 ? \
swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2bgr_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
CV_HAL_ERROR_NOT_IMPLEMENTED : \
dcn == 4 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2bgrx_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2rgbx_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
@@ -1581,16 +1582,16 @@ TegraCvtColor_Invoker(rgbx2bgrx, rgbx2bgrx, src_data + static_cast<size_t>(range
scn == 4 ? \
dcn == 3 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2bgr_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2rgb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
dcn == 4 ? \
swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2bgrx_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
@@ -1613,19 +1614,19 @@ TegraCvtColor_Invoker(rgbx2rgb565, rgbx2rgb565, src_data + static_cast<size_t>(r
greenBits == 6 && CAROTENE_NS::isSupportedConfiguration() ? \
scn == 3 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2bgr565_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2rgb565_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
scn == 4 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2bgr565_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2rgb565_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
@@ -1646,19 +1647,19 @@ TegraCvtColor_Invoker(bgrx2gray, bgrx2gray, CAROTENE_NS::COLOR_SPACE_BT601, src_
depth == CV_8U && CAROTENE_NS::isSupportedConfiguration() ? \
scn == 3 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2gray_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgr2gray_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
scn == 4 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2gray_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgrx2gray_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
@@ -1674,12 +1675,12 @@ TegraCvtColor_Invoker(gray2rgbx, gray2rgbx, src_data + static_cast<size_t>(range
( \
depth == CV_8U && CAROTENE_NS::isSupportedConfiguration() ? \
dcn == 3 ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_gray2rgb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
dcn == 4 ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_gray2rgbx_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)), \
CV_HAL_ERROR_OK : \
@@ -1700,19 +1701,19 @@ TegraCvtColor_Invoker(bgrx2ycrcb, bgrx2ycrcb, src_data + static_cast<size_t>(ran
isCbCr && depth == CV_8U && CAROTENE_NS::isSupportedConfiguration() ? \
scn == 3 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2ycrcb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgr2ycrcb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
scn == 4 ? \
(swapBlue ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2ycrcb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgrx2ycrcb_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
@@ -1742,34 +1743,34 @@ TegraCvtColor_Invoker(bgrx2hsvf, bgrx2hsv, src_data + static_cast<size_t>(range.
scn == 3 ? \
(swapBlue ? \
isFullRange ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2hsvf_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgb2hsv_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
isFullRange ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgr2hsvf_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgr2hsv_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
scn == 4 ? \
(swapBlue ? \
isFullRange ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2hsvf_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_rgbx2hsv_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
isFullRange ? \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgrx2hsvf_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) : \
parallel_for_(cv::Range(0, height), \
parallel_for_(Range(0, height), \
TegraCvtColor_bgrx2hsv_Invoker(src_data, src_step, dst_data, dst_step, width, height), \
(width * height) / static_cast<double>(1<<16)) ), \
CV_HAL_ERROR_OK : \
@@ -1856,126 +1857,6 @@ TegraCvtColor_Invoker(bgrx2hsvf, bgrx2hsv, src_data + static_cast<size_t>(range.
#define cv_hal_cvtTwoPlaneYUVtoBGREx TEGRA_CVT2PYUVTOBGR_EX
#endif
// The optimized branch was developed for old armv7 processors and leads to perf degradation on armv8
#if defined(__ARM_ARCH) && (__ARM_ARCH == 7)
inline CAROTENE_NS::BORDER_MODE borderCV2Carotene(int borderType)
{
switch(borderType)
{
case CV_HAL_BORDER_CONSTANT:
return CAROTENE_NS::BORDER_MODE_CONSTANT;
case CV_HAL_BORDER_REPLICATE:
return CAROTENE_NS::BORDER_MODE_REPLICATE;
case CV_HAL_BORDER_REFLECT:
return CAROTENE_NS::BORDER_MODE_REFLECT;
case CV_HAL_BORDER_WRAP:
return CAROTENE_NS::BORDER_MODE_WRAP;
case CV_HAL_BORDER_REFLECT_101:
return CAROTENE_NS::BORDER_MODE_REFLECT101;
}
return CAROTENE_NS::BORDER_MODE_UNDEFINED;
}
inline int TEGRA_GaussianBlurBinomial(const uchar* src_data, size_t src_step, uchar* dst_data, size_t dst_step,
int width, int height, int depth, int cn, size_t margin_left, size_t margin_top,
size_t margin_right, size_t margin_bottom, size_t ksize, int border_type)
{
CAROTENE_NS::Size2D sz(width, height);
CAROTENE_NS::BORDER_MODE border = borderCV2Carotene(border_type);
CAROTENE_NS::Margin mg(margin_left, margin_right, margin_top, margin_bottom);
if (ksize == 3)
{
if ((depth != CV_8U) || (cn != 1))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (CAROTENE_NS::isGaussianBlur3x3MarginSupported(sz, border, mg))
{
CAROTENE_NS::gaussianBlur3x3Margin(sz, src_data, src_step, dst_data, dst_step,
border, 0, mg);
return CV_HAL_ERROR_OK;
}
}
else if (ksize == 5)
{
if (!CAROTENE_NS::isGaussianBlur5x5Supported(sz, cn, border))
return CV_HAL_ERROR_NOT_IMPLEMENTED;
if (depth == CV_8U)
{
CAROTENE_NS::gaussianBlur5x5(sz, cn, (uint8_t*)src_data, src_step,
(uint8_t*)dst_data, dst_step, border, 0, mg);
return CV_HAL_ERROR_OK;
}
else if (depth == CV_16U)
{
CAROTENE_NS::gaussianBlur5x5(sz, cn, (uint16_t*)src_data, src_step,
(uint16_t*)dst_data, dst_step, border, 0, mg);
return CV_HAL_ERROR_OK;
}
else if (depth == CV_16S)
{
CAROTENE_NS::gaussianBlur5x5(sz, cn, (int16_t*)src_data, src_step,
(int16_t*)dst_data, dst_step, border, 0, mg);
return CV_HAL_ERROR_OK;
}
}
return CV_HAL_ERROR_NOT_IMPLEMENTED;
}
#undef cv_hal_gaussianBlurBinomial
#define cv_hal_gaussianBlurBinomial TEGRA_GaussianBlurBinomial
#endif // __ARM_ARCH=7
#endif // OPENCV_IMGPROC_HAL_INTERFACE_H
// The optimized branch was developed for old armv7 processors
#if defined(__ARM_ARCH) && (__ARM_ARCH == 7)
inline int TEGRA_LKOpticalFlowLevel(const uchar *prev_data, size_t prev_data_step,
const short* prev_deriv_data, size_t prev_deriv_step,
const uchar* next_data, size_t next_step,
int width, int height, int cn,
const float *prev_points, float *next_points, size_t point_count,
uchar *status, float *err,
const int win_width, const int win_height,
int termination_count, double termination_epsilon,
bool get_min_eigen_vals,
float min_eigen_vals_threshold)
{
if (!CAROTENE_NS::isSupportedConfiguration())
return CV_HAL_ERROR_NOT_IMPLEMENTED;
CAROTENE_NS::pyrLKOptFlowLevel(CAROTENE_NS::Size2D(width, height), cn,
prev_data, prev_data_step, prev_deriv_data, prev_deriv_step,
next_data, next_step,
point_count, prev_points, next_points,
status, err, CAROTENE_NS::Size2D(win_width, win_height),
termination_count, termination_epsilon,
get_min_eigen_vals, min_eigen_vals_threshold);
return CV_HAL_ERROR_OK;
}
#undef cv_hal_LKOpticalFlowLevel
#define cv_hal_LKOpticalFlowLevel TEGRA_LKOpticalFlowLevel
#endif // __ARM_ARCH=7
#if 0 // OpenCV provides fater parallel implementation
inline int TEGRA_ScharrDeriv(const uchar* src_data, size_t src_step,
short* dst_data, size_t dst_step,
int width, int height, int cn)
{
if (!CAROTENE_NS::isSupportedConfiguration())
return CV_HAL_ERROR_NOT_IMPLEMENTED;
CAROTENE_NS::ScharrDeriv(CAROTENE_NS::Size2D(width, height), cn, src_data, src_step, dst_data, dst_step);
return CV_HAL_ERROR_OK;
}
#undef cv_hal_ScharrDeriv
#define cv_hal_ScharrDeriv TEGRA_ScharrDeriv
#endif
#endif
@@ -359,7 +359,7 @@ namespace CAROTENE_NS {
/*
For each point `p` within `size`, do:
dst[p] = src0[p] * scale / src1[p]
dst[p] = src0[p] * scale / src1[p]
NOTE: ROUND_TO_ZERO convert policy is used
*/
@@ -420,7 +420,7 @@ namespace CAROTENE_NS {
/*
For each point `p` within `size`, do:
dst[p] = scale / src[p]
dst[p] = scale / src[p]
NOTE: ROUND_TO_ZERO convert policy is used
*/
@@ -1040,7 +1040,7 @@ namespace CAROTENE_NS {
s32 maxVal, size_t * maxLocPtr, s32 & maxLocCount, s32 maxLocCapacity);
/*
Among each pixel `p` within `src` find min and max values and its first occurrences
Among each pixel `p` within `src` find min and max values and its first occurences
*/
void minMaxLoc(const Size2D &size,
const s8 * srcBase, ptrdiff_t srcStride,
@@ -2485,7 +2485,7 @@ namespace CAROTENE_NS {
u8 *status, f32 *err,
const Size2D &winSize,
u32 terminationCount, f64 terminationEpsilon,
bool getMinEigenVals,
u32 level, u32 maxLevel, bool useInitialFlow, bool getMinEigenVals,
f32 minEigThreshold);
}
@@ -378,7 +378,7 @@ void extract4(const Size2D &size,
vst1q_##sgn##bits(dst1 + d1j, vals.v4.val[3]); \
}
#endif
#endif
#define SPLIT4ALPHA(sgn,bits) void split4(const Size2D &_size, \
const sgn##bits * srcBase, ptrdiff_t srcStride, \
@@ -58,6 +58,17 @@
namespace CAROTENE_NS { namespace internal {
#ifndef CAROTENE_NEON_ARCH
# if defined(__aarch64__) || defined(__aarch32__)
# define CAROTENE_NEON_ARCH 8
# else
# define CAROTENE_NEON_ARCH 7
# endif
#endif
#if ( !defined(__aarch64__) && !defined(__aarch32__) ) && (CAROTENE_NEON_ARCH == 8 )
# error("ARMv7 doen't support A32/A64 Neon instructions")
#endif
inline void prefetch(const void *ptr, size_t offset = 32*10)
{
#if defined __GNUC__
@@ -58,7 +58,7 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
u8 *status, f32 *err,
const Size2D &winSize,
u32 terminationCount, f64 terminationEpsilon,
bool getMinEigenVals,
u32 level, u32 maxLevel, bool useInitialFlow, bool getMinEigenVals,
f32 minEigThreshold)
{
internal::assertSupportedConfiguration();
@@ -74,11 +74,32 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
for( u32 ptidx = 0; ptidx < ptCount; ptidx++ )
{
f32 levscale = (1./(1 << level));
u32 ptref = ptidx << 1;
f32 prevPtX = prevPts[ptref+0];
f32 prevPtY = prevPts[ptref+1];
f32 nextPtX = nextPts[ptref+0];
f32 nextPtY = nextPts[ptref+1];
f32 prevPtX = prevPts[ptref+0]*levscale;
f32 prevPtY = prevPts[ptref+1]*levscale;
f32 nextPtX;
f32 nextPtY;
if( level == maxLevel )
{
if( useInitialFlow )
{
nextPtX = nextPts[ptref+0]*levscale;
nextPtY = nextPts[ptref+1]*levscale;
}
else
{
nextPtX = prevPtX;
nextPtY = prevPtY;
}
}
else
{
nextPtX = nextPts[ptref+0]*2.f;
nextPtY = nextPts[ptref+1]*2.f;
}
nextPts[ptref+0] = nextPtX;
nextPts[ptref+1] = nextPtY;
s32 iprevPtX, iprevPtY;
s32 inextPtX, inextPtY;
@@ -90,10 +111,13 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
if( iprevPtX < -(s32)winSize.width || iprevPtX >= (s32)size.width ||
iprevPtY < -(s32)winSize.height || iprevPtY >= (s32)size.height )
{
if( status )
status[ptidx] = false;
if( err )
err[ptidx] = 0;
if( level == 0 )
{
if( status )
status[ptidx] = false;
if( err )
err[ptidx] = 0;
}
continue;
}
@@ -309,7 +333,7 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
if( minEig < minEigThreshold || D < FLT_EPSILON )
{
if( status )
if( level == 0 && status )
status[ptidx] = false;
continue;
}
@@ -329,7 +353,7 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
if( inextPtX < -(s32)winSize.width || inextPtX >= (s32)size.width ||
inextPtY < -(s32)winSize.height || inextPtY >= (s32)size.height )
{
if( status )
if( level == 0 && status )
status[ptidx] = false;
break;
}
@@ -445,7 +469,8 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
prevDeltaX = deltaX;
prevDeltaY = deltaY;
}
if( status && status[ptidx] && err && !getMinEigenVals )
if( status && status[ptidx] && err && level == 0 && !getMinEigenVals )
{
f32 nextPointX = nextPts[ptref+0] - halfWinX;
f32 nextPointY = nextPts[ptref+1] - halfWinY;
@@ -501,6 +526,9 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
(void)winSize;
(void)terminationCount;
(void)terminationEpsilon;
(void)level;
(void)maxLevel;
(void)useInitialFlow;
(void)getMinEigenVals;
(void)minEigThreshold;
(void)ptCount;
@@ -508,3 +536,4 @@ void pyrLKOptFlowLevel(const Size2D &size, s32 cn,
}
}//CAROTENE_NS
@@ -57,7 +57,7 @@ namespace CAROTENE_NS { namespace internal {
inline uint32x4_t vroundq_u32_f32(const float32x4_t val)
{
#if defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
#if CAROTENE_NEON_ARCH >= 8 /* get ready for ARMv9 */
return vcvtnq_u32_f32(val);
#else
const float32x4_t delta = vdupq_n_f32(CAROTENE_ROUND_DELTA);
@@ -67,7 +67,7 @@ inline uint32x4_t vroundq_u32_f32(const float32x4_t val)
inline uint32x2_t vround_u32_f32(const float32x2_t val)
{
#if defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
#if CAROTENE_NEON_ARCH >= 8 /* get ready for ARMv9 */
return vcvtn_u32_f32(val);
#else
const float32x2_t delta = vdup_n_f32(CAROTENE_ROUND_DELTA);
@@ -77,7 +77,7 @@ inline uint32x2_t vround_u32_f32(const float32x2_t val)
inline int32x4_t vroundq_s32_f32(const float32x4_t val)
{
#if defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
#if CAROTENE_NEON_ARCH >= 8 /* get ready for ARMv9 */
return vcvtnq_s32_f32(val);
#else
const float32x4_t delta = vdupq_n_f32(CAROTENE_ROUND_DELTA);
@@ -87,7 +87,7 @@ inline int32x4_t vroundq_s32_f32(const float32x4_t val)
inline int32x2_t vround_s32_f32(const float32x2_t val)
{
#if defined(__ARM_ARCH) && (__ARM_ARCH >= 8)
#if CAROTENE_NEON_ARCH >= 8 /* get ready for ARMv9 */
return vcvtn_s32_f32(val);
#else
const float32x2_t delta = vdup_n_f32(CAROTENE_ROUND_DELTA);
-201
View File
@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2017 by Contributors
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
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.
-366
View File
@@ -1,366 +0,0 @@
/*!
* Copyright (c) 2017 by Contributors
* \file dlpack.h
* \brief The common header of DLPack.
*/
#ifndef DLPACK_DLPACK_H_
#define DLPACK_DLPACK_H_
/**
* \brief Compatibility with C++
*/
#ifdef __cplusplus
#define DLPACK_EXTERN_C extern "C"
#else
#define DLPACK_EXTERN_C
#endif
/*! \brief The current major version of dlpack */
#define DLPACK_MAJOR_VERSION 1
/*! \brief The current minor version of dlpack */
#define DLPACK_MINOR_VERSION 1
/*! \brief DLPACK_DLL prefix for windows */
#ifdef _WIN32
#ifdef DLPACK_EXPORTS
#define DLPACK_DLL __declspec(dllexport)
#else
#define DLPACK_DLL __declspec(dllimport)
#endif
#else
#define DLPACK_DLL
#endif
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
* \brief The DLPack version.
*
* A change in major version indicates that we have changed the
* data layout of the ABI - DLManagedTensorVersioned.
*
* A change in minor version indicates that we have added new
* code, such as a new device type, but the ABI is kept the same.
*
* If an obtained DLPack tensor has a major version that disagrees
* with the version number specified in this header file
* (i.e. major != DLPACK_MAJOR_VERSION), the consumer must call the deleter
* (and it is safe to do so). It is not safe to access any other fields
* as the memory layout will have changed.
*
* In the case of a minor version mismatch, the tensor can be safely used as
* long as the consumer knows how to interpret all fields. Minor version
* updates indicate the addition of enumeration values.
*/
typedef struct {
/*! \brief DLPack major version. */
uint32_t major;
/*! \brief DLPack minor version. */
uint32_t minor;
} DLPackVersion;
/*!
* \brief The device type in DLDevice.
*/
#ifdef __cplusplus
typedef enum : int32_t {
#else
typedef enum {
#endif
/*! \brief CPU device */
kDLCPU = 1,
/*! \brief CUDA GPU device */
kDLCUDA = 2,
/*!
* \brief Pinned CUDA CPU memory by cudaMallocHost
*/
kDLCUDAHost = 3,
/*! \brief OpenCL devices. */
kDLOpenCL = 4,
/*! \brief Vulkan buffer for next generation graphics. */
kDLVulkan = 7,
/*! \brief Metal for Apple GPU. */
kDLMetal = 8,
/*! \brief Verilog simulator buffer */
kDLVPI = 9,
/*! \brief ROCm GPUs for AMD GPUs */
kDLROCM = 10,
/*!
* \brief Pinned ROCm CPU memory allocated by hipMallocHost
*/
kDLROCMHost = 11,
/*!
* \brief Reserved extension device type,
* used for quickly test extension device
* The semantics can differ depending on the implementation.
*/
kDLExtDev = 12,
/*!
* \brief CUDA managed/unified memory allocated by cudaMallocManaged
*/
kDLCUDAManaged = 13,
/*!
* \brief Unified shared memory allocated on a oneAPI non-partititioned
* device. Call to oneAPI runtime is required to determine the device
* type, the USM allocation type and the sycl context it is bound to.
*
*/
kDLOneAPI = 14,
/*! \brief GPU support for next generation WebGPU standard. */
kDLWebGPU = 15,
/*! \brief Qualcomm Hexagon DSP */
kDLHexagon = 16,
/*! \brief Microsoft MAIA devices */
kDLMAIA = 17,
} DLDeviceType;
/*!
* \brief A Device for Tensor and operator.
*/
typedef struct {
/*! \brief The device type used in the device. */
DLDeviceType device_type;
/*!
* \brief The device index.
* For vanilla CPU memory, pinned memory, or managed memory, this is set to 0.
*/
int32_t device_id;
} DLDevice;
/*!
* \brief The type code options DLDataType.
*/
typedef enum {
/*! \brief signed integer */
kDLInt = 0U,
/*! \brief unsigned integer */
kDLUInt = 1U,
/*! \brief IEEE floating point */
kDLFloat = 2U,
/*!
* \brief Opaque handle type, reserved for testing purposes.
* Frameworks need to agree on the handle data type for the exchange to be well-defined.
*/
kDLOpaqueHandle = 3U,
/*! \brief bfloat16 */
kDLBfloat = 4U,
/*!
* \brief complex number
* (C/C++/Python layout: compact struct per complex number)
*/
kDLComplex = 5U,
/*! \brief boolean */
kDLBool = 6U,
/*! \brief FP8 data types */
kDLFloat8_e3m4 = 7U,
kDLFloat8_e4m3 = 8U,
kDLFloat8_e4m3b11fnuz = 9U,
kDLFloat8_e4m3fn = 10U,
kDLFloat8_e4m3fnuz = 11U,
kDLFloat8_e5m2 = 12U,
kDLFloat8_e5m2fnuz = 13U,
kDLFloat8_e8m0fnu = 14U,
/*! \brief FP6 data types
* Setting bits != 6 is currently unspecified, and the producer must ensure it is set
* while the consumer must stop importing if the value is unexpected.
*/
kDLFloat6_e2m3fn = 15U,
kDLFloat6_e3m2fn = 16U,
/*! \brief FP4 data types
* Setting bits != 4 is currently unspecified, and the producer must ensure it is set
* while the consumer must stop importing if the value is unexpected.
*/
kDLFloat4_e2m1fn = 17U,
} DLDataTypeCode;
/*!
* \brief The data type the tensor can hold. The data type is assumed to follow the
* native endian-ness. An explicit error message should be raised when attempting to
* export an array with non-native endianness
*
* Examples
* - float: type_code = 2, bits = 32, lanes = 1
* - float4(vectorized 4 float): type_code = 2, bits = 32, lanes = 4
* - int8: type_code = 0, bits = 8, lanes = 1
* - std::complex<float>: type_code = 5, bits = 64, lanes = 1
* - bool: type_code = 6, bits = 8, lanes = 1 (as per common array library convention, the underlying storage size of bool is 8 bits)
* - float8_e4m3: type_code = 8, bits = 8, lanes = 1 (packed in memory)
* - float6_e3m2fn: type_code = 16, bits = 6, lanes = 1 (packed in memory)
* - float4_e2m1fn: type_code = 17, bits = 4, lanes = 1 (packed in memory)
*
* When a sub-byte type is packed, DLPack requires the data to be in little bit-endian, i.e.,
* for a packed data set D ((D >> (i * bits)) && bit_mask) stores the i-th element.
*/
typedef struct {
/*!
* \brief Type code of base types.
* We keep it uint8_t instead of DLDataTypeCode for minimal memory
* footprint, but the value should be one of DLDataTypeCode enum values.
* */
uint8_t code;
/*!
* \brief Number of bits, common choices are 8, 16, 32.
*/
uint8_t bits;
/*! \brief Number of lanes in the type, used for vector types. */
uint16_t lanes;
} DLDataType;
/*!
* \brief Plain C Tensor object, does not manage memory.
*/
typedef struct {
/*!
* \brief The data pointer points to the allocated data. This will be CUDA
* device pointer or cl_mem handle in OpenCL. It may be opaque on some device
* types. This pointer is always aligned to 256 bytes as in CUDA. The
* `byte_offset` field should be used to point to the beginning of the data.
*
* Note that as of Nov 2021, multiply libraries (CuPy, PyTorch, TensorFlow,
* TVM, perhaps others) do not adhere to this 256 byte aligment requirement
* on CPU/CUDA/ROCm, and always use `byte_offset=0`. This must be fixed
* (after which this note will be updated); at the moment it is recommended
* to not rely on the data pointer being correctly aligned.
*
* For given DLTensor, the size of memory required to store the contents of
* data is calculated as follows:
*
* \code{.c}
* static inline size_t GetDataSize(const DLTensor* t) {
* size_t size = 1;
* for (tvm_index_t i = 0; i < t->ndim; ++i) {
* size *= t->shape[i];
* }
* size *= (t->dtype.bits * t->dtype.lanes + 7) / 8;
* return size;
* }
* \endcode
*
* Note that if the tensor is of size zero, then the data pointer should be
* set to `NULL`.
*/
void* data;
/*! \brief The device of the tensor */
DLDevice device;
/*! \brief Number of dimensions */
int32_t ndim;
/*! \brief The data type of the pointer*/
DLDataType dtype;
/*! \brief The shape of the tensor */
int64_t* shape;
/*!
* \brief strides of the tensor (in number of elements, not bytes)
* can be NULL, indicating tensor is compact and row-majored.
*/
int64_t* strides;
/*! \brief The offset in bytes to the beginning pointer to data */
uint64_t byte_offset;
} DLTensor;
/*!
* \brief C Tensor object, manage memory of DLTensor. This data structure is
* intended to facilitate the borrowing of DLTensor by another framework. It is
* not meant to transfer the tensor. When the borrowing framework doesn't need
* the tensor, it should call the deleter to notify the host that the resource
* is no longer needed.
*
* \note This data structure is used as Legacy DLManagedTensor
* in DLPack exchange and is deprecated after DLPack v0.8
* Use DLManagedTensorVersioned instead.
* This data structure may get renamed or deleted in future versions.
*
* \sa DLManagedTensorVersioned
*/
typedef struct DLManagedTensor {
/*! \brief DLTensor which is being memory managed */
DLTensor dl_tensor;
/*! \brief the context of the original host framework of DLManagedTensor in
* which DLManagedTensor is used in the framework. It can also be NULL.
*/
void * manager_ctx;
/*!
* \brief Destructor - this should be called
* to destruct the manager_ctx which backs the DLManagedTensor. It can be
* NULL if there is no way for the caller to provide a reasonable destructor.
* The destructor deletes the argument self as well.
*/
void (*deleter)(struct DLManagedTensor * self);
} DLManagedTensor;
// bit masks used in in the DLManagedTensorVersioned
/*! \brief bit mask to indicate that the tensor is read only. */
#define DLPACK_FLAG_BITMASK_READ_ONLY (1UL << 0UL)
/*!
* \brief bit mask to indicate that the tensor is a copy made by the producer.
*
* If set, the tensor is considered solely owned throughout its lifetime by the
* consumer, until the producer-provided deleter is invoked.
*/
#define DLPACK_FLAG_BITMASK_IS_COPIED (1UL << 1UL)
/*
* \brief bit mask to indicate that whether a sub-byte type is packed or padded.
*
* The default for sub-byte types (ex: fp4/fp6) is assumed packed. This flag can
* be set by the producer to signal that a tensor of sub-byte type is padded.
*/
#define DLPACK_FLAG_BITMASK_IS_SUBBYTE_TYPE_PADDED (1UL << 2UL)
/*!
* \brief A versioned and managed C Tensor object, manage memory of DLTensor.
*
* This data structure is intended to facilitate the borrowing of DLTensor by
* another framework. It is not meant to transfer the tensor. When the borrowing
* framework doesn't need the tensor, it should call the deleter to notify the
* host that the resource is no longer needed.
*
* \note This is the current standard DLPack exchange data structure.
*/
struct DLManagedTensorVersioned {
/*!
* \brief The API and ABI version of the current managed Tensor
*/
DLPackVersion version;
/*!
* \brief the context of the original host framework.
*
* Stores DLManagedTensorVersioned is used in the
* framework. It can also be NULL.
*/
void *manager_ctx;
/*!
* \brief Destructor.
*
* This should be called to destruct manager_ctx which holds the DLManagedTensorVersioned.
* It can be NULL if there is no way for the caller to provide a reasonable
* destructor. The destructor deletes the argument self as well.
*/
void (*deleter)(struct DLManagedTensorVersioned *self);
/*!
* \brief Additional bitmask flags information about the tensor.
*
* By default the flags should be set to 0.
*
* \note Future ABI changes should keep everything until this field
* stable, to ensure that deleter can be correctly called.
*
* \sa DLPACK_FLAG_BITMASK_READ_ONLY
* \sa DLPACK_FLAG_BITMASK_IS_COPIED
*/
uint64_t flags;
/*! \brief DLTensor which is being memory managed */
DLTensor dl_tensor;
};
#ifdef __cplusplus
} // DLPACK_EXTERN_C
#endif
#endif // DLPACK_DLPACK_H_
-44
View File
@@ -1,44 +0,0 @@
function(download_fastcv root_dir)
# Commit SHA in the opencv_3rdparty repo
set(FASTCV_COMMIT "9e8d42b6d7e769548d70b2e5674e263b056de8b4")
# Define actual FastCV versions
if(ANDROID)
if(AARCH64)
message(STATUS "Download FastCV for Android aarch64")
set(FCV_PACKAGE_NAME "fastcv_android_aarch64_2025_07_09.tgz")
set(FCV_PACKAGE_HASH "8b9497858cf3c3502a0be4369d06ebf8")
else()
message(STATUS "Download FastCV for Android armv7")
set(FCV_PACKAGE_NAME "fastcv_android_arm32_2025_07_09.tgz")
set(FCV_PACKAGE_HASH "e0e6009c9f2f2b96140cd6a639c7383f")
endif()
elseif(UNIX AND NOT APPLE AND NOT IOS AND NOT XROS)
if(AARCH64)
set(FCV_PACKAGE_NAME "fastcv_linux_aarch64_2025_07_09.tgz")
set(FCV_PACKAGE_HASH "05e254e0eb3c13fa23eb7213f0fe6d82")
else()
message("FastCV: fastcv lib for 32-bit Linux is not supported for now!")
endif()
endif(ANDROID)
# Download Package
set(OPENCV_FASTCV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FASTCV_COMMIT}/fastcv/")
ocv_download( FILENAME ${FCV_PACKAGE_NAME}
HASH ${FCV_PACKAGE_HASH}
URL ${OPENCV_FASTCV_URL}
DESTINATION_DIR ${root_dir}
ID FASTCV
STATUS res
UNPACK
RELATIVE_URL)
if(res)
set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status")
else()
message(WARNING "FastCV: package download failed!")
endif()
endfunction()
+5 -5
View File
@@ -1,8 +1,8 @@
# Binaries branch name: ffmpeg/4.x_20251226
# Binaries were created for OpenCV: cff7581175d2abfc6aef2e4f04f482e258b5c864
ocv_update(FFMPEG_BINARIES_COMMIT "d82ad9a54a7b42a1648a9cae8fed5c2f20ea396c")
ocv_update(FFMPEG_FILE_HASH_BIN32 "47730de2286110b0d1250ff9cf50ce56")
ocv_update(FFMPEG_FILE_HASH_BIN64 "3248b4663ffef770cdb54ec8b9d16a28")
# Binaries branch name: ffmpeg/4.x_20240522
# Binaries were created for OpenCV: 8393885a39dac1e650bf5d0aaff84c04ad8bcdd3
ocv_update(FFMPEG_BINARIES_COMMIT "394dca6ceb3085c979415e6385996b6570e94153")
ocv_update(FFMPEG_FILE_HASH_BIN32 "bdfbd1efb295f3e54c07d2cb7a843bf9")
ocv_update(FFMPEG_FILE_HASH_BIN64 "bfef029900f788480a363d6dc05c4f0e")
ocv_update(FFMPEG_FILE_HASH_CMAKE "8862c87496e2e8c375965e1277dee1c7")
function(download_win_ffmpeg script_var)
+1 -1
View File
@@ -1 +1 @@
Origin: https://github.com/google/flatbuffers/tree/v25.9.23
Origin: https://github.com/google/flatbuffers/tree/v23.5.9
+5 -5
View File
@@ -28,21 +28,21 @@ class Allocator {
virtual ~Allocator() {}
// Allocate `size` bytes of memory.
virtual uint8_t* allocate(size_t size) = 0;
virtual uint8_t *allocate(size_t size) = 0;
// Deallocate `size` bytes of memory at `p` allocated by this allocator.
virtual void deallocate(uint8_t* p, size_t size) = 0;
virtual void deallocate(uint8_t *p, size_t size) = 0;
// Reallocate `new_size` bytes of memory, replacing the old region of size
// `old_size` at `p`. In contrast to a normal realloc, this grows downwards,
// and is intended specifcally for `vector_downward` use.
// `in_use_back` and `in_use_front` indicate how much of `old_size` is
// actually in use at each end, and needs to be copied.
virtual uint8_t* reallocate_downward(uint8_t* old_p, size_t old_size,
virtual uint8_t *reallocate_downward(uint8_t *old_p, size_t old_size,
size_t new_size, size_t in_use_back,
size_t in_use_front) {
FLATBUFFERS_ASSERT(new_size > old_size); // vector_downward only grows
uint8_t* new_p = allocate(new_size);
uint8_t *new_p = allocate(new_size);
memcpy_downward(old_p, old_size, new_p, new_size, in_use_back,
in_use_front);
deallocate(old_p, old_size);
@@ -54,7 +54,7 @@ class Allocator {
// to `new_p` of `new_size`. Only memory of size `in_use_front` and
// `in_use_back` will be copied from the front and back of the old memory
// allocation.
void memcpy_downward(uint8_t* old_p, size_t old_size, uint8_t* new_p,
void memcpy_downward(uint8_t *old_p, size_t old_size, uint8_t *new_p,
size_t new_size, size_t in_use_back,
size_t in_use_front) {
memcpy(new_p + new_size - in_use_back, old_p + old_size - in_use_back,
+48 -49
View File
@@ -27,15 +27,17 @@
namespace flatbuffers {
// This is used as a helper type for accessing arrays.
template <typename T, uint16_t length>
class Array {
template<typename T, uint16_t length> class Array {
// Array<T> can carry only POD data types (scalars or structs).
typedef typename flatbuffers::bool_constant<flatbuffers::is_scalar<T>::value>
scalar_tag;
typedef
typename flatbuffers::conditional<scalar_tag::value, T, const T *>::type
IndirectHelperType;
public:
typedef uint16_t size_type;
typedef typename IndirectHelper<T>::return_type return_type;
typedef typename IndirectHelper<IndirectHelperType>::return_type return_type;
typedef VectorConstIterator<T, return_type, uoffset_t> const_iterator;
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
@@ -48,7 +50,7 @@ class Array {
return_type Get(uoffset_t i) const {
FLATBUFFERS_ASSERT(i < size());
return IndirectHelper<T>::Read(Data(), i);
return IndirectHelper<IndirectHelperType>::Read(Data(), i);
}
return_type operator[](uoffset_t i) const { return Get(i); }
@@ -56,8 +58,7 @@ class Array {
// If this is a Vector of enums, T will be its storage type, not the enum
// type. This function makes it convenient to retrieve value with enum
// type E.
template <typename E>
E GetEnum(uoffset_t i) const {
template<typename E> E GetEnum(uoffset_t i) const {
return static_cast<E>(Get(i));
}
@@ -82,28 +83,28 @@ class Array {
// operation. For primitive types use @p Mutate directly.
// @warning Assignments and reads to/from the dereferenced pointer are not
// automatically converted to the correct endianness.
typename flatbuffers::conditional<scalar_tag::value, void, T*>::type
typename flatbuffers::conditional<scalar_tag::value, void, T *>::type
GetMutablePointer(uoffset_t i) const {
FLATBUFFERS_ASSERT(i < size());
return const_cast<T*>(&data()[i]);
return const_cast<T *>(&data()[i]);
}
// Change elements if you have a non-const pointer to this object.
void Mutate(uoffset_t i, const T& val) { MutateImpl(scalar_tag(), i, val); }
void Mutate(uoffset_t i, const T &val) { MutateImpl(scalar_tag(), i, val); }
// The raw data in little endian format. Use with care.
const uint8_t* Data() const { return data_; }
const uint8_t *Data() const { return data_; }
uint8_t* Data() { return data_; }
uint8_t *Data() { return data_; }
// Similarly, but typed, much like std::vector::data
const T* data() const { return reinterpret_cast<const T*>(Data()); }
T* data() { return reinterpret_cast<T*>(Data()); }
const T *data() const { return reinterpret_cast<const T *>(Data()); }
T *data() { return reinterpret_cast<T *>(Data()); }
// Copy data from a span with endian conversion.
// If this Array and the span overlap, the behavior is undefined.
void CopyFromSpan(flatbuffers::span<const T, length> src) {
const auto p1 = reinterpret_cast<const uint8_t*>(src.data());
const auto p1 = reinterpret_cast<const uint8_t *>(src.data());
const auto p2 = Data();
FLATBUFFERS_ASSERT(!(p1 >= p2 && p1 < (p2 + length)) &&
!(p2 >= p1 && p2 < (p1 + length)));
@@ -113,12 +114,12 @@ class Array {
}
protected:
void MutateImpl(flatbuffers::true_type, uoffset_t i, const T& val) {
void MutateImpl(flatbuffers::true_type, uoffset_t i, const T &val) {
FLATBUFFERS_ASSERT(i < size());
WriteScalar(data() + i, val);
}
void MutateImpl(flatbuffers::false_type, uoffset_t i, const T& val) {
void MutateImpl(flatbuffers::false_type, uoffset_t i, const T &val) {
*(GetMutablePointer(i)) = val;
}
@@ -133,9 +134,7 @@ class Array {
// Copy data from flatbuffers::span with endian conversion.
void CopyFromSpanImpl(flatbuffers::false_type,
flatbuffers::span<const T, length> src) {
for (size_type k = 0; k < length; k++) {
Mutate(k, src[k]);
}
for (size_type k = 0; k < length; k++) { Mutate(k, src[k]); }
}
// This class is only used to access pre-existing data. Don't ever
@@ -154,21 +153,21 @@ class Array {
private:
// This class is a pointer. Copying will therefore create an invalid object.
// Private and unimplemented copy constructor.
Array(const Array&);
Array& operator=(const Array&);
Array(const Array &);
Array &operator=(const Array &);
};
// Specialization for Array[struct] with access using Offset<void> pointer.
// This specialization used by idl_gen_text.cpp.
template <typename T, uint16_t length, template <typename> class OffsetT>
template<typename T, uint16_t length, template<typename> class OffsetT>
class Array<OffsetT<T>, length> {
static_assert(flatbuffers::is_same<T, void>::value, "unexpected type T");
public:
typedef const void* return_type;
typedef const void *return_type;
typedef uint16_t size_type;
const uint8_t* Data() const { return data_; }
const uint8_t *Data() const { return data_; }
// Make idl_gen_text.cpp::PrintContainer happy.
return_type operator[](uoffset_t) const {
@@ -179,14 +178,14 @@ class Array<OffsetT<T>, length> {
private:
// This class is only used to access pre-existing data.
Array();
Array(const Array&);
Array& operator=(const Array&);
Array(const Array &);
Array &operator=(const Array &);
uint8_t data_[1];
};
template <class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U, N> make_span(Array<U, N>& arr)
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U, N> make_span(Array<U, N> &arr)
FLATBUFFERS_NOEXCEPT {
static_assert(
Array<U, N>::is_span_observable,
@@ -194,26 +193,26 @@ FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U, N> make_span(Array<U, N>& arr)
return span<U, N>(arr.data(), N);
}
template <class U, uint16_t N>
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U, N> make_span(
const Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
const Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(
Array<U, N>::is_span_observable,
"wrong type U, only plain struct, LE-scalar, or byte types are allowed");
return span<const U, N>(arr.data(), N);
}
template <class U, uint16_t N>
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t, sizeof(U) * N>
make_bytes_span(Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
make_bytes_span(Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(Array<U, N>::is_span_observable,
"internal error, Array<T> might hold only scalars or structs");
return span<uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
}
template <class U, uint16_t N>
template<class U, uint16_t N>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t, sizeof(U) * N>
make_bytes_span(const Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
make_bytes_span(const Array<U, N> &arr) FLATBUFFERS_NOEXCEPT {
static_assert(Array<U, N>::is_span_observable,
"internal error, Array<T> might hold only scalars or structs");
return span<const uint8_t, sizeof(U) * N>(arr.Data(), sizeof(U) * N);
@@ -222,31 +221,31 @@ make_bytes_span(const Array<U, N>& arr) FLATBUFFERS_NOEXCEPT {
// Cast a raw T[length] to a raw flatbuffers::Array<T, length>
// without endian conversion. Use with care.
// TODO: move these Cast-methods to `internal` namespace.
template <typename T, uint16_t length>
Array<T, length>& CastToArray(T (&arr)[length]) {
return *reinterpret_cast<Array<T, length>*>(arr);
template<typename T, uint16_t length>
Array<T, length> &CastToArray(T (&arr)[length]) {
return *reinterpret_cast<Array<T, length> *>(arr);
}
template <typename T, uint16_t length>
const Array<T, length>& CastToArray(const T (&arr)[length]) {
return *reinterpret_cast<const Array<T, length>*>(arr);
template<typename T, uint16_t length>
const Array<T, length> &CastToArray(const T (&arr)[length]) {
return *reinterpret_cast<const Array<T, length> *>(arr);
}
template <typename E, typename T, uint16_t length>
Array<E, length>& CastToArrayOfEnum(T (&arr)[length]) {
template<typename E, typename T, uint16_t length>
Array<E, length> &CastToArrayOfEnum(T (&arr)[length]) {
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
return *reinterpret_cast<Array<E, length>*>(arr);
return *reinterpret_cast<Array<E, length> *>(arr);
}
template <typename E, typename T, uint16_t length>
const Array<E, length>& CastToArrayOfEnum(const T (&arr)[length]) {
template<typename E, typename T, uint16_t length>
const Array<E, length> &CastToArrayOfEnum(const T (&arr)[length]) {
static_assert(sizeof(E) == sizeof(T), "invalid enum type E");
return *reinterpret_cast<const Array<E, length>*>(arr);
return *reinterpret_cast<const Array<E, length> *>(arr);
}
template <typename T, uint16_t length>
bool operator==(const Array<T, length>& lhs,
const Array<T, length>& rhs) noexcept {
template<typename T, uint16_t length>
bool operator==(const Array<T, length> &lhs,
const Array<T, length> &rhs) noexcept {
return std::addressof(lhs) == std::addressof(rhs) ||
(lhs.size() == rhs.size() &&
std::memcmp(lhs.Data(), rhs.Data(), rhs.size() * sizeof(T)) == 0);
+22 -30
View File
@@ -139,9 +139,9 @@
#endif
#endif // !defined(FLATBUFFERS_LITTLEENDIAN)
#define FLATBUFFERS_VERSION_MAJOR 25
#define FLATBUFFERS_VERSION_MINOR 9
#define FLATBUFFERS_VERSION_REVISION 23
#define FLATBUFFERS_VERSION_MAJOR 23
#define FLATBUFFERS_VERSION_MINOR 5
#define FLATBUFFERS_VERSION_REVISION 9
#define FLATBUFFERS_STRING_EXPAND(X) #X
#define FLATBUFFERS_STRING(X) FLATBUFFERS_STRING_EXPAND(X)
namespace flatbuffers {
@@ -155,7 +155,7 @@ namespace flatbuffers {
#define FLATBUFFERS_FINAL_CLASS final
#define FLATBUFFERS_OVERRIDE override
#define FLATBUFFERS_EXPLICIT_CPP11 explicit
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : ::flatbuffers::voffset_t
#define FLATBUFFERS_VTABLE_UNDERLYING_TYPE : flatbuffers::voffset_t
#else
#define FLATBUFFERS_FINAL_CLASS
#define FLATBUFFERS_OVERRIDE
@@ -279,22 +279,20 @@ namespace flatbuffers {
#endif // !FLATBUFFERS_LOCALE_INDEPENDENT
// Suppress Undefined Behavior Sanitizer (recoverable only). Usage:
// - FLATBUFFERS_SUPPRESS_UBSAN("undefined")
// - FLATBUFFERS_SUPPRESS_UBSAN("signed-integer-overflow")
// - __suppress_ubsan__("undefined")
// - __suppress_ubsan__("signed-integer-overflow")
#if defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >=7))
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize(type)))
#define __suppress_ubsan__(type) __attribute__((no_sanitize(type)))
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 409)
#define FLATBUFFERS_SUPPRESS_UBSAN(type) __attribute__((no_sanitize_undefined))
#define __suppress_ubsan__(type) __attribute__((no_sanitize_undefined))
#else
#define FLATBUFFERS_SUPPRESS_UBSAN(type)
#define __suppress_ubsan__(type)
#endif
namespace flatbuffers {
// This is constexpr function used for checking compile-time constants.
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
return !!t;
}
// This is constexpr function used for checking compile-time constants.
// Avoid `#pragma warning(disable: 4127) // C4127: expression is constant`.
template<typename T> FLATBUFFERS_CONSTEXPR inline bool IsConstTrue(T t) {
return !!t;
}
// Enable C++ attribute [[]] if std:c++17 or higher.
@@ -339,15 +337,15 @@ typedef uint16_t voffset_t;
typedef uintmax_t largest_scalar_t;
// In 32bits, this evaluates to 2GB - 1
#define FLATBUFFERS_MAX_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset_t>::max)()
#define FLATBUFFERS_MAX_64_BUFFER_SIZE (std::numeric_limits<::flatbuffers::soffset64_t>::max)()
#define FLATBUFFERS_MAX_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset_t>::max()
#define FLATBUFFERS_MAX_64_BUFFER_SIZE std::numeric_limits<::flatbuffers::soffset64_t>::max()
// The minimum size buffer that can be a valid flatbuffer.
// Includes the offset to the root table (uoffset_t), the offset to the vtable
// of the root table (soffset_t), the size of the vtable (uint16_t), and the
// size of the referring table (uint16_t).
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(::flatbuffers::uoffset_t) + \
sizeof(::flatbuffers::soffset_t) + sizeof(uint16_t) + sizeof(uint16_t)
#define FLATBUFFERS_MIN_BUFFER_SIZE sizeof(uoffset_t) + sizeof(soffset_t) + \
sizeof(uint16_t) + sizeof(uint16_t)
// We support aligning the contents of buffers up to this size.
#ifndef FLATBUFFERS_MAX_ALIGNMENT
@@ -363,6 +361,7 @@ inline bool VerifyAlignmentRequirements(size_t align, size_t min_align = 1) {
}
#if defined(_MSC_VER)
#pragma warning(disable: 4351) // C4351: new behavior: elements of array ... will be default initialized
#pragma warning(push)
#pragma warning(disable: 4127) // C4127: conditional expression is constant
#endif
@@ -423,7 +422,7 @@ template<typename T> T EndianScalar(T t) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
__suppress_ubsan__("alignment")
T ReadScalar(const void *p) {
return EndianScalar(*reinterpret_cast<const T *>(p));
}
@@ -437,13 +436,13 @@ T ReadScalar(const void *p) {
template<typename T>
// UBSAN: C++ aliasing type rules, see std::bit_cast<> for details.
FLATBUFFERS_SUPPRESS_UBSAN("alignment")
__suppress_ubsan__("alignment")
void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(void *p, Offset<T> t) {
template<typename T> __suppress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
@@ -454,22 +453,15 @@ template<typename T> FLATBUFFERS_SUPPRESS_UBSAN("alignment") void WriteScalar(vo
// Computes how many bytes you'd have to pad to be able to write an
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
// memory).
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
__suppress_ubsan__("unsigned-integer-overflow")
inline size_t PaddingBytes(size_t buf_size, size_t scalar_size) {
return ((~buf_size) + 1) & (scalar_size - 1);
}
#if !defined(_MSC_VER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
// Generic 'operator==' with conditional specialisations.
// T e - new value of a scalar field.
// T def - default of scalar (is known at compile-time).
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }
#if !defined(_MSC_VER)
#pragma GCC diagnostic pop
#endif
#if defined(FLATBUFFERS_NAN_DEFAULTS) && \
defined(FLATBUFFERS_HAS_NEW_STRTOD) && (FLATBUFFERS_HAS_NEW_STRTOD > 0)
+39 -65
View File
@@ -20,14 +20,12 @@
#include <algorithm>
#include "flatbuffers/base.h"
#include "flatbuffers/stl_emulation.h"
namespace flatbuffers {
// Wrapper for uoffset_t to allow safe template specialization.
// Value is allowed to be 0 to indicate a null object (see e.g. AddOffset).
template <typename T = void>
struct Offset {
template<typename T = void> struct Offset {
// The type of offset to use.
typedef uoffset_t offset_type;
@@ -38,14 +36,8 @@ struct Offset {
bool IsNull() const { return !o; }
};
template <typename T>
struct is_specialisation_of_Offset : false_type {};
template <typename T>
struct is_specialisation_of_Offset<Offset<T>> : true_type {};
// Wrapper for uoffset64_t Offsets.
template <typename T = void>
struct Offset64 {
template<typename T = void> struct Offset64 {
// The type of offset to use.
typedef uoffset64_t offset_type;
@@ -56,11 +48,6 @@ struct Offset64 {
bool IsNull() const { return !o; }
};
template <typename T>
struct is_specialisation_of_Offset64 : false_type {};
template <typename T>
struct is_specialisation_of_Offset64<Offset64<T>> : true_type {};
// Litmus check for ensuring the Offsets are the expected size.
static_assert(sizeof(Offset<>) == 4, "Offset has wrong size");
static_assert(sizeof(Offset64<>) == 8, "Offset64 has wrong size");
@@ -68,13 +55,12 @@ static_assert(sizeof(Offset64<>) == 8, "Offset64 has wrong size");
inline void EndianCheck() {
int endiantest = 1;
// If this fails, see FLATBUFFERS_LITTLEENDIAN above.
FLATBUFFERS_ASSERT(*reinterpret_cast<char*>(&endiantest) ==
FLATBUFFERS_ASSERT(*reinterpret_cast<char *>(&endiantest) ==
FLATBUFFERS_LITTLEENDIAN);
(void)endiantest;
}
template <typename T>
FLATBUFFERS_CONSTEXPR size_t AlignOf() {
template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() {
// clang-format off
#ifdef _MSC_VER
return __alignof(T);
@@ -90,8 +76,8 @@ FLATBUFFERS_CONSTEXPR size_t AlignOf() {
// Lexicographically compare two strings (possibly containing nulls), and
// return true if the first is less than the second.
static inline bool StringLessThan(const char* a_data, uoffset_t a_size,
const char* b_data, uoffset_t b_size) {
static inline bool StringLessThan(const char *a_data, uoffset_t a_size,
const char *b_data, uoffset_t b_size) {
const auto cmp = memcmp(a_data, b_data, (std::min)(a_size, b_size));
return cmp == 0 ? a_size < b_size : cmp < 0;
}
@@ -104,43 +90,42 @@ static inline bool StringLessThan(const char* a_data, uoffset_t a_size,
// return type like this.
// The typedef is for the convenience of callers of this function
// (avoiding the need for a trailing return decltype)
template <typename T, typename Enable = void>
struct IndirectHelper {
template<typename T> struct IndirectHelper {
typedef T return_type;
typedef T mutable_return_type;
static const size_t element_stride = sizeof(T);
static return_type Read(const uint8_t* p, const size_t i) {
return EndianScalar((reinterpret_cast<const T*>(p))[i]);
static return_type Read(const uint8_t *p, const size_t i) {
return EndianScalar((reinterpret_cast<const T *>(p))[i]);
}
static mutable_return_type Read(uint8_t* p, const size_t i) {
static mutable_return_type Read(uint8_t *p, const size_t i) {
return reinterpret_cast<mutable_return_type>(
Read(const_cast<const uint8_t*>(p), i));
Read(const_cast<const uint8_t *>(p), i));
}
};
// For vector of Offsets.
template <typename T, template <typename> class OffsetT>
template<typename T, template<typename> class OffsetT>
struct IndirectHelper<OffsetT<T>> {
typedef const T* return_type;
typedef T* mutable_return_type;
typedef const T *return_type;
typedef T *mutable_return_type;
typedef typename OffsetT<T>::offset_type offset_type;
static const offset_type element_stride = sizeof(offset_type);
static return_type Read(const uint8_t* const p, const offset_type i) {
static return_type Read(const uint8_t *const p, const offset_type i) {
// Offsets are relative to themselves, so first update the pointer to
// point to the offset location.
const uint8_t* const offset_location = p + i * element_stride;
const uint8_t *const offset_location = p + i * element_stride;
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
// then determine the relative location from the offset location.
return reinterpret_cast<return_type>(
offset_location + ReadScalar<offset_type>(offset_location));
}
static mutable_return_type Read(uint8_t* const p, const offset_type i) {
static mutable_return_type Read(uint8_t *const p, const offset_type i) {
// Offsets are relative to themselves, so first update the pointer to
// point to the offset location.
uint8_t* const offset_location = p + i * element_stride;
uint8_t *const offset_location = p + i * element_stride;
// Then read the scalar value of the offset (which may be 32 or 64-bits) and
// then determine the relative location from the offset location.
@@ -150,26 +135,16 @@ struct IndirectHelper<OffsetT<T>> {
};
// For vector of structs.
template <typename T>
struct IndirectHelper<
T, typename std::enable_if<
!std::is_scalar<typename std::remove_pointer<T>::type>::value &&
!is_specialisation_of_Offset<T>::value &&
!is_specialisation_of_Offset64<T>::value>::type> {
private:
typedef typename std::remove_pointer<typename std::remove_cv<T>::type>::type
pointee_type;
template<typename T> struct IndirectHelper<const T *> {
typedef const T *return_type;
typedef T *mutable_return_type;
static const size_t element_stride = sizeof(T);
public:
typedef const pointee_type* return_type;
typedef pointee_type* mutable_return_type;
static const size_t element_stride = sizeof(pointee_type);
static return_type Read(const uint8_t* const p, const size_t i) {
static return_type Read(const uint8_t *const p, const size_t i) {
// Structs are stored inline, relative to the first struct pointer.
return reinterpret_cast<return_type>(p + i * element_stride);
}
static mutable_return_type Read(uint8_t* const p, const size_t i) {
static mutable_return_type Read(uint8_t *const p, const size_t i) {
// Structs are stored inline, relative to the first struct pointer.
return reinterpret_cast<mutable_return_type>(p + i * element_stride);
}
@@ -182,14 +157,14 @@ struct IndirectHelper<
/// This function is UNDEFINED for FlatBuffers whose schema does not include
/// a file_identifier (likely points at padding or the start of a the root
/// vtable).
inline const char* GetBufferIdentifier(const void* buf,
inline const char *GetBufferIdentifier(const void *buf,
bool size_prefixed = false) {
return reinterpret_cast<const char*>(buf) +
return reinterpret_cast<const char *>(buf) +
((size_prefixed) ? 2 * sizeof(uoffset_t) : sizeof(uoffset_t));
}
// Helper to see if the identifier in a buffer has the expected value.
inline bool BufferHasIdentifier(const void* buf, const char* identifier,
inline bool BufferHasIdentifier(const void *buf, const char *identifier,
bool size_prefixed = false) {
return strncmp(GetBufferIdentifier(buf, size_prefixed), identifier,
flatbuffers::kFileIdentifierLength) == 0;
@@ -197,27 +172,26 @@ inline bool BufferHasIdentifier(const void* buf, const char* identifier,
/// @cond FLATBUFFERS_INTERNAL
// Helpers to get a typed pointer to the root object contained in the buffer.
template <typename T>
T* GetMutableRoot(void* buf) {
template<typename T> T *GetMutableRoot(void *buf) {
if (!buf) return nullptr;
EndianCheck();
return reinterpret_cast<T*>(reinterpret_cast<uint8_t*>(buf) +
EndianScalar(*reinterpret_cast<uoffset_t*>(buf)));
return reinterpret_cast<T *>(
reinterpret_cast<uint8_t *>(buf) +
EndianScalar(*reinterpret_cast<uoffset_t *>(buf)));
}
template <typename T, typename SizeT = uoffset_t>
T* GetMutableSizePrefixedRoot(void* buf) {
return GetMutableRoot<T>(reinterpret_cast<uint8_t*>(buf) + sizeof(SizeT));
template<typename T, typename SizeT = uoffset_t>
T *GetMutableSizePrefixedRoot(void *buf) {
return GetMutableRoot<T>(reinterpret_cast<uint8_t *>(buf) + sizeof(SizeT));
}
template <typename T>
const T* GetRoot(const void* buf) {
return GetMutableRoot<T>(const_cast<void*>(buf));
template<typename T> const T *GetRoot(const void *buf) {
return GetMutableRoot<T>(const_cast<void *>(buf));
}
template <typename T, typename SizeT = uoffset_t>
const T* GetSizePrefixedRoot(const void* buf) {
return GetRoot<T>(reinterpret_cast<const uint8_t*>(buf) + sizeof(SizeT));
template<typename T, typename SizeT = uoffset_t>
const T *GetSizePrefixedRoot(const void *buf) {
return GetRoot<T>(reinterpret_cast<const uint8_t *>(buf) + sizeof(SizeT));
}
} // namespace flatbuffers
+4 -5
View File
@@ -27,24 +27,23 @@ namespace flatbuffers {
// A BufferRef does not own its buffer.
struct BufferRefBase {}; // for std::is_base_of
template <typename T>
struct BufferRef : BufferRefBase {
template<typename T> struct BufferRef : BufferRefBase {
BufferRef() : buf(nullptr), len(0), must_free(false) {}
BufferRef(uint8_t* _buf, uoffset_t _len)
BufferRef(uint8_t *_buf, uoffset_t _len)
: buf(_buf), len(_len), must_free(false) {}
~BufferRef() {
if (must_free) free(buf);
}
const T* GetRoot() const { return flatbuffers::GetRoot<T>(buf); }
const T *GetRoot() const { return flatbuffers::GetRoot<T>(buf); }
bool Verify() {
Verifier verifier(buf, len);
return verifier.VerifyBuffer<T>(nullptr);
}
uint8_t* buf;
uint8_t *buf;
uoffset_t len;
bool must_free;
};
@@ -25,32 +25,32 @@ namespace flatbuffers {
// DefaultAllocator uses new/delete to allocate memory regions
class DefaultAllocator : public Allocator {
public:
uint8_t* allocate(size_t size) FLATBUFFERS_OVERRIDE {
uint8_t *allocate(size_t size) FLATBUFFERS_OVERRIDE {
return new uint8_t[size];
}
void deallocate(uint8_t* p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; }
void deallocate(uint8_t *p, size_t) FLATBUFFERS_OVERRIDE { delete[] p; }
static void dealloc(void* p, size_t) { delete[] static_cast<uint8_t*>(p); }
static void dealloc(void *p, size_t) { delete[] static_cast<uint8_t *>(p); }
};
// These functions allow for a null allocator to mean use the default allocator,
// as used by DetachedBuffer and vector_downward below.
// This is to avoid having a statically or dynamically allocated default
// allocator, or having to move it between the classes that may own it.
inline uint8_t* Allocate(Allocator* allocator, size_t size) {
inline uint8_t *Allocate(Allocator *allocator, size_t size) {
return allocator ? allocator->allocate(size)
: DefaultAllocator().allocate(size);
}
inline void Deallocate(Allocator* allocator, uint8_t* p, size_t size) {
inline void Deallocate(Allocator *allocator, uint8_t *p, size_t size) {
if (allocator)
allocator->deallocate(p, size);
else
DefaultAllocator().deallocate(p, size);
}
inline uint8_t* ReallocateDownward(Allocator* allocator, uint8_t* old_p,
inline uint8_t *ReallocateDownward(Allocator *allocator, uint8_t *old_p,
size_t old_size, size_t new_size,
size_t in_use_back, size_t in_use_front) {
return allocator ? allocator->reallocate_downward(old_p, old_size, new_size,
+12 -19
View File
@@ -36,8 +36,8 @@ class DetachedBuffer {
cur_(nullptr),
size_(0) {}
DetachedBuffer(Allocator* allocator, bool own_allocator, uint8_t* buf,
size_t reserved, uint8_t* cur, size_t sz)
DetachedBuffer(Allocator *allocator, bool own_allocator, uint8_t *buf,
size_t reserved, uint8_t *cur, size_t sz)
: allocator_(allocator),
own_allocator_(own_allocator),
buf_(buf),
@@ -45,7 +45,7 @@ class DetachedBuffer {
cur_(cur),
size_(sz) {}
DetachedBuffer(DetachedBuffer&& other) noexcept
DetachedBuffer(DetachedBuffer &&other) noexcept
: allocator_(other.allocator_),
own_allocator_(other.own_allocator_),
buf_(other.buf_),
@@ -55,7 +55,7 @@ class DetachedBuffer {
other.reset();
}
DetachedBuffer& operator=(DetachedBuffer&& other) noexcept {
DetachedBuffer &operator=(DetachedBuffer &&other) noexcept {
if (this == &other) return *this;
destroy();
@@ -74,35 +74,28 @@ class DetachedBuffer {
~DetachedBuffer() { destroy(); }
const uint8_t* data() const { return cur_; }
const uint8_t *data() const { return cur_; }
uint8_t* data() { return cur_; }
uint8_t *data() { return cur_; }
size_t size() const { return size_; }
uint8_t* begin() { return data(); }
const uint8_t* begin() const { return data(); }
uint8_t* end() { return data() + size(); }
const uint8_t* end() const { return data() + size(); }
// These may change access mode, leave these at end of public section
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer& other));
FLATBUFFERS_DELETE_FUNC(DetachedBuffer(const DetachedBuffer &other));
FLATBUFFERS_DELETE_FUNC(
DetachedBuffer& operator=(const DetachedBuffer& other));
DetachedBuffer &operator=(const DetachedBuffer &other));
protected:
Allocator* allocator_;
Allocator *allocator_;
bool own_allocator_;
uint8_t* buf_;
uint8_t *buf_;
size_t reserved_;
uint8_t* cur_;
uint8_t *cur_;
size_t size_;
inline void destroy() {
if (buf_) Deallocate(allocator_, buf_, reserved_);
if (own_allocator_ && allocator_) {
delete allocator_;
}
if (own_allocator_ && allocator_) { delete allocator_; }
reset();
}
File diff suppressed because it is too large Load Diff
+30 -41
View File
@@ -41,14 +41,14 @@ namespace flatbuffers {
/// it is the opposite transformation of GetRoot().
/// This may be useful if you want to pass on a root and have the recipient
/// delete the buffer afterwards.
inline const uint8_t* GetBufferStartFromRootPointer(const void* root) {
auto table = reinterpret_cast<const Table*>(root);
inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
auto table = reinterpret_cast<const Table *>(root);
auto vtable = table->GetVTable();
// Either the vtable is before the root or after the root.
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t*>(root));
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root));
// Align to at least sizeof(uoffset_t).
start = reinterpret_cast<const uint8_t*>(reinterpret_cast<uintptr_t>(start) &
~(sizeof(uoffset_t) - 1));
start = reinterpret_cast<const uint8_t *>(reinterpret_cast<uintptr_t>(start) &
~(sizeof(uoffset_t) - 1));
// Additionally, there may be a file_identifier in the buffer, and the root
// offset. The buffer may have been aligned to any size between
// sizeof(uoffset_t) and FLATBUFFERS_MAX_ALIGNMENT (see "force_align").
@@ -64,7 +64,7 @@ inline const uint8_t* GetBufferStartFromRootPointer(const void* root) {
possible_roots; possible_roots--) {
start -= sizeof(uoffset_t);
if (ReadScalar<uoffset_t>(start) + start ==
reinterpret_cast<const uint8_t*>(root))
reinterpret_cast<const uint8_t *>(root))
return start;
}
// We didn't find the root, either the "root" passed isn't really a root,
@@ -76,22 +76,11 @@ inline const uint8_t* GetBufferStartFromRootPointer(const void* root) {
}
/// @brief This return the prefixed size of a FlatBuffer.
template <typename SizeT = uoffset_t>
inline SizeT GetPrefixedSize(const uint8_t* buf) {
template<typename SizeT = uoffset_t>
inline SizeT GetPrefixedSize(const uint8_t *buf) {
return ReadScalar<SizeT>(buf);
}
// Gets the total length of the buffer given a sized prefixed FlatBuffer.
//
// This includes the size of the prefix as well as the buffer:
//
// [size prefix][flatbuffer]
// |---------length--------|
template <typename SizeT = uoffset_t>
inline SizeT GetSizePrefixedBufferLength(const uint8_t* const buf) {
return ReadScalar<SizeT>(buf) + sizeof(SizeT);
}
// Base class for native objects (FlatBuffer data de-serialized into native
// C++ data structures).
// Contains no functionality, purely documentative.
@@ -106,9 +95,9 @@ struct NativeTable {};
/// if you wish. The resolver does the opposite lookup, for when the object
/// is being serialized again.
typedef uint64_t hash_value_t;
typedef std::function<void(void** pointer_adr, hash_value_t hash)>
typedef std::function<void(void **pointer_adr, hash_value_t hash)>
resolver_function_t;
typedef std::function<hash_value_t(void* pointer)> rehasher_function_t;
typedef std::function<hash_value_t(void *pointer)> rehasher_function_t;
// Helper function to test if a field is present, using any of the field
// enums in the generated code.
@@ -117,18 +106,18 @@ typedef std::function<hash_value_t(void* pointer)> rehasher_function_t;
// Note: this function will return false for fields equal to the default
// value, since they're not stored in the buffer (unless force_defaults was
// used).
template <typename T>
bool IsFieldPresent(const T* table, typename T::FlatBuffersVTableOffset field) {
template<typename T>
bool IsFieldPresent(const T *table, typename T::FlatBuffersVTableOffset field) {
// Cast, since Table is a private baseclass of any table types.
return reinterpret_cast<const Table*>(table)->CheckField(
return reinterpret_cast<const Table *>(table)->CheckField(
static_cast<voffset_t>(field));
}
// Utility function for reverse lookups on the EnumNames*() functions
// (in the generated C++ code)
// names must be NULL terminated.
inline int LookupEnum(const char** names, const char* name) {
for (const char** p = names; *p; p++)
inline int LookupEnum(const char **names, const char *name) {
for (const char **p = names; *p; p++)
if (!strcmp(*p, name)) return static_cast<int>(p - names);
return -1;
}
@@ -227,20 +216,20 @@ static_assert(sizeof(TypeCode) == 2, "TypeCode");
struct TypeTable;
// Signature of the static method present in each type.
typedef const TypeTable* (*TypeFunction)();
typedef const TypeTable *(*TypeFunction)();
struct TypeTable {
SequenceType st;
size_t num_elems; // of type_codes, values, names (but not type_refs).
const TypeCode* type_codes; // num_elems count
const TypeFunction* type_refs; // less than num_elems entries (see TypeCode).
const int16_t* array_sizes; // less than num_elems entries (see TypeCode).
const int64_t* values; // Only set for non-consecutive enum/union or structs.
const char* const* names; // Only set if compiled with --reflect-names.
const TypeCode *type_codes; // num_elems count
const TypeFunction *type_refs; // less than num_elems entries (see TypeCode).
const int16_t *array_sizes; // less than num_elems entries (see TypeCode).
const int64_t *values; // Only set for non-consecutive enum/union or structs.
const char *const *names; // Only set if compiled with --reflect-names.
};
// String which identifies the current version of FlatBuffers.
inline const char* flatbuffers_version_string() {
inline const char *flatbuffers_version_string() {
return "FlatBuffers " FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MAJOR) "."
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_MINOR) "."
FLATBUFFERS_STRING(FLATBUFFERS_VERSION_REVISION);
@@ -248,31 +237,31 @@ inline const char* flatbuffers_version_string() {
// clang-format off
#define FLATBUFFERS_DEFINE_BITMASK_OPERATORS(E, T)\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator | (E lhs, E rhs){\
inline E operator | (E lhs, E rhs){\
return E(T(lhs) | T(rhs));\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator & (E lhs, E rhs){\
inline E operator & (E lhs, E rhs){\
return E(T(lhs) & T(rhs));\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^ (E lhs, E rhs){\
inline E operator ^ (E lhs, E rhs){\
return E(T(lhs) ^ T(rhs));\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ~ (E lhs){\
inline E operator ~ (E lhs){\
return E(~T(lhs));\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator |= (E &lhs, E rhs){\
inline E operator |= (E &lhs, E rhs){\
lhs = lhs | rhs;\
return lhs;\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator &= (E &lhs, E rhs){\
inline E operator &= (E &lhs, E rhs){\
lhs = lhs & rhs;\
return lhs;\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 E operator ^= (E &lhs, E rhs){\
inline E operator ^= (E &lhs, E rhs){\
lhs = lhs ^ rhs;\
return lhs;\
}\
inline FLATBUFFERS_CONSTEXPR_CPP11 bool operator !(E rhs) \
inline bool operator !(E rhs) \
{\
return !bool(T(rhs)); \
}
+2 -3
View File
@@ -45,8 +45,7 @@
// Testing __cpp_lib_span requires including either <version> or <span>,
// both of which were added in C++20.
// See: https://en.cppreference.com/w/cpp/utility/feature_test
#if defined(__cplusplus) && __cplusplus >= 202002L \
|| (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
#if defined(__cplusplus) && __cplusplus >= 202002L
#define FLATBUFFERS_USE_STD_SPAN 1
#endif
#endif // FLATBUFFERS_USE_STD_SPAN
@@ -273,7 +272,7 @@ template<class T, class U>
FLATBUFFERS_CONSTEXPR_CPP11 bool operator==(const Optional<T>& lhs, const Optional<U>& rhs) FLATBUFFERS_NOEXCEPT {
return static_cast<bool>(lhs) != static_cast<bool>(rhs)
? false
: !static_cast<bool>(lhs) ? true : (*lhs == *rhs);
: !static_cast<bool>(lhs) ? false : (*lhs == *rhs);
}
#endif // FLATBUFFERS_USE_STD_OPTIONAL
+5 -10
View File
@@ -23,7 +23,7 @@
namespace flatbuffers {
struct String : public Vector<char> {
const char* c_str() const { return reinterpret_cast<const char*>(Data()); }
const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
std::string str() const { return std::string(c_str(), size()); }
// clang-format off
@@ -31,35 +31,30 @@ struct String : public Vector<char> {
flatbuffers::string_view string_view() const {
return flatbuffers::string_view(c_str(), size());
}
/* implicit */
operator flatbuffers::string_view() const {
return flatbuffers::string_view(c_str(), size());
}
#endif // FLATBUFFERS_HAS_STRING_VIEW
// clang-format on
bool operator<(const String& o) const {
bool operator<(const String &o) const {
return StringLessThan(this->data(), this->size(), o.data(), o.size());
}
};
// Convenience function to get std::string from a String returning an empty
// string on null pointer.
static inline std::string GetString(const String* str) {
static inline std::string GetString(const String *str) {
return str ? str->str() : "";
}
// Convenience function to get char* from a String returning an empty string on
// null pointer.
static inline const char* GetCstring(const String* str) {
static inline const char *GetCstring(const String *str) {
return str ? str->c_str() : "";
}
#ifdef FLATBUFFERS_HAS_STRING_VIEW
// Convenience function to get string_view from a String returning an empty
// string_view on null pointer.
static inline flatbuffers::string_view GetStringView(const String* str) {
static inline flatbuffers::string_view GetStringView(const String *str) {
return str ? str->string_view() : flatbuffers::string_view();
}
#endif // FLATBUFFERS_HAS_STRING_VIEW
+6 -8
View File
@@ -27,25 +27,23 @@ namespace flatbuffers {
class Struct FLATBUFFERS_FINAL_CLASS {
public:
template <typename T>
T GetField(uoffset_t o) const {
template<typename T> T GetField(uoffset_t o) const {
return ReadScalar<T>(&data_[o]);
}
template <typename T>
T GetStruct(uoffset_t o) const {
template<typename T> T GetStruct(uoffset_t o) const {
return reinterpret_cast<T>(&data_[o]);
}
const uint8_t* GetAddressOf(uoffset_t o) const { return &data_[o]; }
uint8_t* GetAddressOf(uoffset_t o) { return &data_[o]; }
const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; }
uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; }
private:
// private constructor & copy constructor: you obtain instances of this
// class by pointing to existing data only
Struct();
Struct(const Struct&);
Struct& operator=(const Struct&);
Struct(const Struct &);
Struct &operator=(const Struct &);
uint8_t data_[1];
};
+31 -37
View File
@@ -26,7 +26,7 @@ namespace flatbuffers {
// omitted and added at will, but uses an extra indirection to read.
class Table {
public:
const uint8_t* GetVTable() const {
const uint8_t *GetVTable() const {
return data_ - ReadScalar<soffset_t>(data_);
}
@@ -42,42 +42,38 @@ class Table {
return field < vtsize ? ReadScalar<voffset_t>(vtable + field) : 0;
}
template <typename T>
T GetField(voffset_t field, T defaultval) const {
template<typename T> T GetField(voffset_t field, T defaultval) const {
auto field_offset = GetOptionalFieldOffset(field);
return field_offset ? ReadScalar<T>(data_ + field_offset) : defaultval;
}
template <typename P, typename OffsetSize = uoffset_t>
template<typename P, typename OffsetSize = uoffset_t>
P GetPointer(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
: nullptr;
}
template <typename P, typename OffsetSize = uoffset_t>
template<typename P, typename OffsetSize = uoffset_t>
P GetPointer(voffset_t field) const {
return const_cast<Table*>(this)->GetPointer<P, OffsetSize>(field);
return const_cast<Table *>(this)->GetPointer<P, OffsetSize>(field);
}
template <typename P>
P GetPointer64(voffset_t field) {
template<typename P> P GetPointer64(voffset_t field) {
return GetPointer<P, uoffset64_t>(field);
}
template <typename P>
P GetPointer64(voffset_t field) const {
template<typename P> P GetPointer64(voffset_t field) const {
return GetPointer<P, uoffset64_t>(field);
}
template <typename P>
P GetStruct(voffset_t field) const {
template<typename P> P GetStruct(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = const_cast<uint8_t*>(data_ + field_offset);
auto p = const_cast<uint8_t *>(data_ + field_offset);
return field_offset ? reinterpret_cast<P>(p) : nullptr;
}
template <typename Raw, typename Face>
template<typename Raw, typename Face>
flatbuffers::Optional<Face> GetOptional(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
@@ -85,22 +81,20 @@ class Table {
: Optional<Face>();
}
template <typename T>
bool SetField(voffset_t field, T val, T def) {
template<typename T> bool SetField(voffset_t field, T val, T def) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return IsTheSameAs(val, def);
WriteScalar(data_ + field_offset, val);
return true;
}
template <typename T>
bool SetField(voffset_t field, T val) {
template<typename T> bool SetField(voffset_t field, T val) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return false;
WriteScalar(data_ + field_offset, val);
return true;
}
bool SetPointer(voffset_t field, const uint8_t* val) {
bool SetPointer(voffset_t field, const uint8_t *val) {
auto field_offset = GetOptionalFieldOffset(field);
if (!field_offset) return false;
WriteScalar(data_ + field_offset,
@@ -108,12 +102,12 @@ class Table {
return true;
}
uint8_t* GetAddressOf(voffset_t field) {
uint8_t *GetAddressOf(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
return field_offset ? data_ + field_offset : nullptr;
}
const uint8_t* GetAddressOf(voffset_t field) const {
return const_cast<Table*>(this)->GetAddressOf(field);
const uint8_t *GetAddressOf(voffset_t field) const {
return const_cast<Table *>(this)->GetAddressOf(field);
}
bool CheckField(voffset_t field) const {
@@ -122,13 +116,13 @@ class Table {
// Verify the vtable of this table.
// Call this once per table, followed by VerifyField once per field.
bool VerifyTableStart(Verifier& verifier) const {
bool VerifyTableStart(Verifier &verifier) const {
return verifier.VerifyTableStart(data_);
}
// Verify a particular field.
template <typename T>
bool VerifyField(const Verifier& verifier, voffset_t field,
template<typename T>
bool VerifyField(const Verifier &verifier, voffset_t field,
size_t align) const {
// Calling GetOptionalFieldOffset should be safe now thanks to
// VerifyTable().
@@ -138,8 +132,8 @@ class Table {
}
// VerifyField for required fields.
template <typename T>
bool VerifyFieldRequired(const Verifier& verifier, voffset_t field,
template<typename T>
bool VerifyFieldRequired(const Verifier &verifier, voffset_t field,
size_t align) const {
auto field_offset = GetOptionalFieldOffset(field);
return verifier.Check(field_offset != 0) &&
@@ -147,24 +141,24 @@ class Table {
}
// Versions for offsets.
template <typename OffsetT = uoffset_t>
bool VerifyOffset(const Verifier& verifier, voffset_t field) const {
template<typename OffsetT = uoffset_t>
bool VerifyOffset(const Verifier &verifier, voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
return !field_offset || verifier.VerifyOffset<OffsetT>(data_, field_offset);
}
template <typename OffsetT = uoffset_t>
bool VerifyOffsetRequired(const Verifier& verifier, voffset_t field) const {
template<typename OffsetT = uoffset_t>
bool VerifyOffsetRequired(const Verifier &verifier, voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
return verifier.Check(field_offset != 0) &&
verifier.VerifyOffset<OffsetT>(data_, field_offset);
}
bool VerifyOffset64(const Verifier& verifier, voffset_t field) const {
bool VerifyOffset64(const Verifier &verifier, voffset_t field) const {
return VerifyOffset<uoffset64_t>(verifier, field);
}
bool VerifyOffset64Required(const Verifier& verifier, voffset_t field) const {
bool VerifyOffset64Required(const Verifier &verifier, voffset_t field) const {
return VerifyOffsetRequired<uoffset64_t>(verifier, field);
}
@@ -172,15 +166,15 @@ class Table {
// private constructor & copy constructor: you obtain instances of this
// class by pointing to existing data only
Table();
Table(const Table& other);
Table& operator=(const Table&);
Table(const Table &other);
Table &operator=(const Table &);
uint8_t data_[1];
};
// This specialization allows avoiding warnings like:
// MSVC C4800: type: forcing value to bool 'true' or 'false'.
template <>
template<>
inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>(
voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
+77 -99
View File
@@ -27,56 +27,44 @@ struct String;
// An STL compatible iterator implementation for Vector below, effectively
// calling Get() for every element.
template <typename T, typename IT, typename Data = uint8_t*,
typename SizeT = uoffset_t>
template<typename T, typename IT, typename Data = uint8_t *,
typename SizeT = uoffset_t>
struct VectorIterator {
typedef std::random_access_iterator_tag iterator_category;
typedef IT value_type;
typedef ptrdiff_t difference_type;
typedef IT* pointer;
typedef IT& reference;
typedef IT *pointer;
typedef IT &reference;
static const SizeT element_stride = IndirectHelper<T>::element_stride;
VectorIterator(Data data, SizeT i) : data_(data + element_stride * i) {}
VectorIterator(const VectorIterator& other) : data_(other.data_) {}
VectorIterator(const VectorIterator &other) : data_(other.data_) {}
VectorIterator() : data_(nullptr) {}
VectorIterator& operator=(const VectorIterator& other) {
VectorIterator &operator=(const VectorIterator &other) {
data_ = other.data_;
return *this;
}
VectorIterator& operator=(VectorIterator&& other) {
VectorIterator &operator=(VectorIterator &&other) {
data_ = other.data_;
return *this;
}
bool operator==(const VectorIterator& other) const {
bool operator==(const VectorIterator &other) const {
return data_ == other.data_;
}
bool operator!=(const VectorIterator& other) const {
return data_ != other.data_;
}
bool operator<(const VectorIterator& other) const {
bool operator<(const VectorIterator &other) const {
return data_ < other.data_;
}
bool operator>(const VectorIterator& other) const {
return data_ > other.data_;
bool operator!=(const VectorIterator &other) const {
return data_ != other.data_;
}
bool operator<=(const VectorIterator& other) const {
return !(data_ > other.data_);
}
bool operator>=(const VectorIterator& other) const {
return !(data_ < other.data_);
}
difference_type operator-(const VectorIterator& other) const {
difference_type operator-(const VectorIterator &other) const {
return (data_ - other.data_) / element_stride;
}
@@ -88,7 +76,7 @@ struct VectorIterator {
// `pointer operator->()`.
IT operator->() const { return IndirectHelper<T>::Read(data_, 0); }
VectorIterator& operator++() {
VectorIterator &operator++() {
data_ += element_stride;
return *this;
}
@@ -99,16 +87,16 @@ struct VectorIterator {
return temp;
}
VectorIterator operator+(const SizeT& offset) const {
VectorIterator operator+(const SizeT &offset) const {
return VectorIterator(data_ + offset * element_stride, 0);
}
VectorIterator& operator+=(const SizeT& offset) {
VectorIterator &operator+=(const SizeT &offset) {
data_ += offset * element_stride;
return *this;
}
VectorIterator& operator--() {
VectorIterator &operator--() {
data_ -= element_stride;
return *this;
}
@@ -119,11 +107,11 @@ struct VectorIterator {
return temp;
}
VectorIterator operator-(const SizeT& offset) const {
VectorIterator operator-(const SizeT &offset) const {
return VectorIterator(data_ - offset * element_stride, 0);
}
VectorIterator& operator-=(const SizeT& offset) {
VectorIterator &operator-=(const SizeT &offset) {
data_ -= offset * element_stride;
return *this;
}
@@ -132,10 +120,10 @@ struct VectorIterator {
Data data_;
};
template <typename T, typename IT, typename SizeT = uoffset_t>
using VectorConstIterator = VectorIterator<T, IT, const uint8_t*, SizeT>;
template<typename T, typename IT, typename SizeT = uoffset_t>
using VectorConstIterator = VectorIterator<T, IT, const uint8_t *, SizeT>;
template <typename Iterator>
template<typename Iterator>
struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
explicit VectorReverseIterator(Iterator iter)
: std::reverse_iterator<Iterator>(iter) {}
@@ -157,13 +145,14 @@ struct VectorReverseIterator : public std::reverse_iterator<Iterator> {
// This is used as a helper type for accessing vectors.
// Vector::data() assumes the vector elements start after the length field.
template <typename T, typename SizeT = uoffset_t>
class Vector {
template<typename T, typename SizeT = uoffset_t> class Vector {
public:
typedef VectorIterator<T, typename IndirectHelper<T>::mutable_return_type,
uint8_t*, SizeT>
typedef VectorIterator<T,
typename IndirectHelper<T>::mutable_return_type,
uint8_t *, SizeT>
iterator;
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type, SizeT>
typedef VectorConstIterator<T, typename IndirectHelper<T>::return_type,
SizeT>
const_iterator;
typedef VectorReverseIterator<iterator> reverse_iterator;
typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
@@ -176,18 +165,14 @@ class Vector {
SizeT size() const { return EndianScalar(length_); }
// Returns true if the vector is empty.
//
// This just provides another standardized method that is expected of vectors.
bool empty() const { return size() == 0; }
// Deprecated: use size(). Here for backwards compatibility.
FLATBUFFERS_ATTRIBUTE([[deprecated("use size() instead")]])
SizeT Length() const { return size(); }
typedef SizeT size_type;
typedef typename IndirectHelper<T>::return_type return_type;
typedef typename IndirectHelper<T>::mutable_return_type mutable_return_type;
typedef typename IndirectHelper<T>::mutable_return_type
mutable_return_type;
typedef return_type value_type;
return_type Get(SizeT i) const {
@@ -200,26 +185,24 @@ class Vector {
// If this is a Vector of enums, T will be its storage type, not the enum
// type. This function makes it convenient to retrieve value with enum
// type E.
template <typename E>
E GetEnum(SizeT i) const {
template<typename E> E GetEnum(SizeT i) const {
return static_cast<E>(Get(i));
}
// If this a vector of unions, this does the cast for you. There's no check
// to make sure this is the right type!
template <typename U>
const U* GetAs(SizeT i) const {
return reinterpret_cast<const U*>(Get(i));
template<typename U> const U *GetAs(SizeT i) const {
return reinterpret_cast<const U *>(Get(i));
}
// If this a vector of unions, this does the cast for you. There's no check
// to make sure this is actually a string!
const String* GetAsString(SizeT i) const {
return reinterpret_cast<const String*>(Get(i));
const String *GetAsString(SizeT i) const {
return reinterpret_cast<const String *>(Get(i));
}
const void* GetStructFromOffset(size_t o) const {
return reinterpret_cast<const void*>(Data() + o);
const void *GetStructFromOffset(size_t o) const {
return reinterpret_cast<const void *>(Data() + o);
}
iterator begin() { return iterator(Data(), 0); }
@@ -248,7 +231,7 @@ class Vector {
// Change elements if you have a non-const pointer to this object.
// Scalars only. See reflection.h, and the documentation.
void Mutate(SizeT i, const T& val) {
void Mutate(SizeT i, const T &val) {
FLATBUFFERS_ASSERT(i < size());
WriteScalar(data() + i, val);
}
@@ -256,7 +239,7 @@ class Vector {
// Change an element of a vector of tables (or strings).
// "val" points to the new table/string, as you can obtain from
// e.g. reflection::AddFlatBuffer().
void MutateOffset(SizeT i, const uint8_t* val) {
void MutateOffset(SizeT i, const uint8_t *val) {
FLATBUFFERS_ASSERT(i < size());
static_assert(sizeof(T) == sizeof(SizeT), "Unrelated types");
WriteScalar(data() + i,
@@ -270,32 +253,30 @@ class Vector {
}
// The raw data in little endian format. Use with care.
const uint8_t* Data() const {
return reinterpret_cast<const uint8_t*>(&length_ + 1);
const uint8_t *Data() const {
return reinterpret_cast<const uint8_t *>(&length_ + 1);
}
uint8_t* Data() { return reinterpret_cast<uint8_t*>(&length_ + 1); }
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
// Similarly, but typed, much like std::vector::data
const T* data() const { return reinterpret_cast<const T*>(Data()); }
T* data() { return reinterpret_cast<T*>(Data()); }
const T *data() const { return reinterpret_cast<const T *>(Data()); }
T *data() { return reinterpret_cast<T *>(Data()); }
template <typename K>
return_type LookupByKey(K key) const {
void* search_result = std::bsearch(
template<typename K> return_type LookupByKey(K key) const {
void *search_result = std::bsearch(
&key, Data(), size(), IndirectHelper<T>::element_stride, KeyCompare<K>);
if (!search_result) {
return nullptr; // Key not found.
}
const uint8_t* element = reinterpret_cast<const uint8_t*>(search_result);
const uint8_t *element = reinterpret_cast<const uint8_t *>(search_result);
return IndirectHelper<T>::Read(element, 0);
}
template <typename K>
mutable_return_type MutableLookupByKey(K key) {
template<typename K> mutable_return_type MutableLookupByKey(K key) {
return const_cast<mutable_return_type>(LookupByKey(key));
}
@@ -309,13 +290,12 @@ class Vector {
private:
// This class is a pointer. Copying will therefore create an invalid object.
// Private and unimplemented copy constructor.
Vector(const Vector&);
Vector& operator=(const Vector&);
Vector(const Vector &);
Vector &operator=(const Vector &);
template <typename K>
static int KeyCompare(const void* ap, const void* bp) {
const K* key = reinterpret_cast<const K*>(ap);
const uint8_t* data = reinterpret_cast<const uint8_t*>(bp);
template<typename K> static int KeyCompare(const void *ap, const void *bp) {
const K *key = reinterpret_cast<const K *>(ap);
const uint8_t *data = reinterpret_cast<const uint8_t *>(bp);
auto table = IndirectHelper<T>::Read(data, 0);
// std::bsearch compares with the operands transposed, so we negate the
@@ -324,36 +304,35 @@ class Vector {
}
};
template <typename T>
using Vector64 = Vector<T, uoffset64_t>;
template<typename T> using Vector64 = Vector<T, uoffset64_t>;
template <class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U>& vec)
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> &vec)
FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<U>(vec.data(), vec.size());
}
template <class U>
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
const Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<const U>(vec.data(), vec.size());
}
template <class U>
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<uint8_t> make_bytes_span(
Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::scalar_tag::value,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<uint8_t>(vec.Data(), vec.size() * sizeof(U));
}
template <class U>
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
const Vector<U>& vec) FLATBUFFERS_NOEXCEPT {
const Vector<U> &vec) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::scalar_tag::value,
"wrong type U, only LE-scalar, or byte types are allowed");
return span<const uint8_t>(vec.Data(), vec.size() * sizeof(U));
@@ -361,17 +340,17 @@ FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const uint8_t> make_bytes_span(
// Convenient helper functions to get a span of any vector, regardless
// of whether it is null or not (the field is not set).
template <class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U>* ptr)
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<U> make_span(Vector<U> *ptr)
FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return ptr ? make_span(*ptr) : span<U>();
}
template <class U>
template<class U>
FLATBUFFERS_CONSTEXPR_CPP11 flatbuffers::span<const U> make_span(
const Vector<U>* ptr) FLATBUFFERS_NOEXCEPT {
const Vector<U> *ptr) FLATBUFFERS_NOEXCEPT {
static_assert(Vector<U>::is_span_observable,
"wrong type U, only LE-scalar, or byte types are allowed");
return ptr ? make_span(*ptr) : span<const U>();
@@ -383,10 +362,10 @@ class VectorOfAny {
public:
uoffset_t size() const { return EndianScalar(length_); }
const uint8_t* Data() const {
return reinterpret_cast<const uint8_t*>(&length_ + 1);
const uint8_t *Data() const {
return reinterpret_cast<const uint8_t *>(&length_ + 1);
}
uint8_t* Data() { return reinterpret_cast<uint8_t*>(&length_ + 1); }
uint8_t *Data() { return reinterpret_cast<uint8_t *>(&length_ + 1); }
protected:
VectorOfAny();
@@ -394,26 +373,25 @@ class VectorOfAny {
uoffset_t length_;
private:
VectorOfAny(const VectorOfAny&);
VectorOfAny& operator=(const VectorOfAny&);
VectorOfAny(const VectorOfAny &);
VectorOfAny &operator=(const VectorOfAny &);
};
template <typename T, typename U>
Vector<Offset<T>>* VectorCast(Vector<Offset<U>>* ptr) {
template<typename T, typename U>
Vector<Offset<T>> *VectorCast(Vector<Offset<U>> *ptr) {
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
return reinterpret_cast<Vector<Offset<T>>*>(ptr);
return reinterpret_cast<Vector<Offset<T>> *>(ptr);
}
template <typename T, typename U>
const Vector<Offset<T>>* VectorCast(const Vector<Offset<U>>* ptr) {
template<typename T, typename U>
const Vector<Offset<T>> *VectorCast(const Vector<Offset<U>> *ptr) {
static_assert(std::is_base_of<T, U>::value, "Unrelated types");
return reinterpret_cast<const Vector<Offset<T>>*>(ptr);
return reinterpret_cast<const Vector<Offset<T>> *>(ptr);
}
// Convenient helper function to get the length of any vector, regardless
// of whether it is null or not (the field is not set).
template <typename T>
static inline size_t VectorLength(const Vector<T>* v) {
template<typename T> static inline size_t VectorLength(const Vector<T> *v) {
return v ? v->size() : 0;
}
+31 -41
View File
@@ -17,9 +17,10 @@
#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_
#define FLATBUFFERS_VECTOR_DOWNWARD_H_
#include <algorithm>
#include <cstdint>
#include <algorithm>
#include "flatbuffers/base.h"
#include "flatbuffers/default_allocator.h"
#include "flatbuffers/detached_buffer.h"
@@ -32,10 +33,9 @@ namespace flatbuffers {
// Since this vector leaves the lower part unused, we support a "scratch-pad"
// that can be stored there for temporary data, to share the allocated space.
// Essentially, this supports 2 std::vectors in a single buffer.
template <typename SizeT = uoffset_t>
class vector_downward {
template<typename SizeT = uoffset_t> class vector_downward {
public:
explicit vector_downward(size_t initial_size, Allocator* allocator,
explicit vector_downward(size_t initial_size, Allocator *allocator,
bool own_allocator, size_t buffer_minalign,
const SizeT max_size = FLATBUFFERS_MAX_BUFFER_SIZE)
: allocator_(allocator),
@@ -49,7 +49,7 @@ class vector_downward {
cur_(nullptr),
scratch_(nullptr) {}
vector_downward(vector_downward&& other) noexcept
vector_downward(vector_downward &&other) noexcept
// clang-format on
: allocator_(other.allocator_),
own_allocator_(other.own_allocator_),
@@ -71,7 +71,7 @@ class vector_downward {
other.scratch_ = nullptr;
}
vector_downward& operator=(vector_downward&& other) noexcept {
vector_downward &operator=(vector_downward &&other) noexcept {
// Move construct a temporary and swap idiom
vector_downward temp(std::move(other));
swap(temp);
@@ -102,9 +102,7 @@ class vector_downward {
void clear_scratch() { scratch_ = buf_; }
void clear_allocator() {
if (own_allocator_ && allocator_) {
delete allocator_;
}
if (own_allocator_ && allocator_) { delete allocator_; }
allocator_ = nullptr;
own_allocator_ = false;
}
@@ -115,8 +113,8 @@ class vector_downward {
}
// Relinquish the pointer to the caller.
uint8_t* release_raw(size_t& allocated_bytes, size_t& offset) {
auto* buf = buf_;
uint8_t *release_raw(size_t &allocated_bytes, size_t &offset) {
auto *buf = buf_;
allocated_bytes = reserved_;
offset = vector_downward::offset();
@@ -145,14 +143,12 @@ class vector_downward {
FLATBUFFERS_ASSERT(cur_ >= scratch_ && scratch_ >= buf_);
// If the length is larger than the unused part of the buffer, we need to
// grow.
if (len > unused_buffer_size()) {
reallocate(len);
}
if (len > unused_buffer_size()) { reallocate(len); }
FLATBUFFERS_ASSERT(size() < max_size_);
return len;
}
inline uint8_t* make_space(size_t len) {
inline uint8_t *make_space(size_t len) {
if (len) {
ensure_space(len);
cur_ -= len;
@@ -162,7 +158,7 @@ class vector_downward {
}
// Returns nullptr if using the DefaultAllocator.
Allocator* get_custom_allocator() { return allocator_; }
Allocator *get_custom_allocator() { return allocator_; }
// The current offset into the buffer.
size_t offset() const { return cur_ - buf_; }
@@ -171,49 +167,43 @@ class vector_downward {
inline SizeT size() const { return size_; }
// The size of the buffer part of the vector that is currently unused.
SizeT unused_buffer_size() const {
return static_cast<SizeT>(cur_ - scratch_);
}
SizeT unused_buffer_size() const { return static_cast<SizeT>(cur_ - scratch_); }
// The size of the scratch part of the vector.
SizeT scratch_size() const { return static_cast<SizeT>(scratch_ - buf_); }
size_t capacity() const { return reserved_; }
uint8_t* data() const {
uint8_t *data() const {
FLATBUFFERS_ASSERT(cur_);
return cur_;
}
uint8_t* scratch_data() const {
uint8_t *scratch_data() const {
FLATBUFFERS_ASSERT(buf_);
return buf_;
}
uint8_t* scratch_end() const {
uint8_t *scratch_end() const {
FLATBUFFERS_ASSERT(scratch_);
return scratch_;
}
uint8_t* data_at(size_t offset) const { return buf_ + reserved_ - offset; }
uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; }
void push(const uint8_t* bytes, size_t num) {
if (num > 0) {
memcpy(make_space(num), bytes, num);
}
void push(const uint8_t *bytes, size_t num) {
if (num > 0) { memcpy(make_space(num), bytes, num); }
}
// Specialized version of push() that avoids memcpy call for small data.
template <typename T>
void push_small(const T& little_endian_t) {
template<typename T> void push_small(const T &little_endian_t) {
make_space(sizeof(T));
*reinterpret_cast<T*>(cur_) = little_endian_t;
*reinterpret_cast<T *>(cur_) = little_endian_t;
}
template <typename T>
void scratch_push_small(const T& t) {
template<typename T> void scratch_push_small(const T &t) {
ensure_space(sizeof(T));
*reinterpret_cast<T*>(scratch_) = t;
*reinterpret_cast<T *>(scratch_) = t;
scratch_ += sizeof(T);
}
@@ -237,7 +227,7 @@ class vector_downward {
void scratch_pop(size_t bytes_to_remove) { scratch_ -= bytes_to_remove; }
void swap(vector_downward& other) {
void swap(vector_downward &other) {
using std::swap;
swap(allocator_, other.allocator_);
swap(own_allocator_, other.own_allocator_);
@@ -251,7 +241,7 @@ class vector_downward {
swap(scratch_, other.scratch_);
}
void swap_allocator(vector_downward& other) {
void swap_allocator(vector_downward &other) {
using std::swap;
swap(allocator_, other.allocator_);
swap(own_allocator_, other.own_allocator_);
@@ -259,10 +249,10 @@ class vector_downward {
private:
// You shouldn't really be copying instances of this class.
FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward&));
FLATBUFFERS_DELETE_FUNC(vector_downward& operator=(const vector_downward&));
FLATBUFFERS_DELETE_FUNC(vector_downward(const vector_downward &));
FLATBUFFERS_DELETE_FUNC(vector_downward &operator=(const vector_downward &));
Allocator* allocator_;
Allocator *allocator_;
bool own_allocator_;
size_t initial_size_;
@@ -271,9 +261,9 @@ class vector_downward {
size_t buffer_minalign_;
size_t reserved_;
SizeT size_;
uint8_t* buf_;
uint8_t* cur_; // Points at location between empty (below) and used (above).
uint8_t* scratch_; // Points to the end of the scratchpad in use.
uint8_t *buf_;
uint8_t *cur_; // Points at location between empty (below) and used (above).
uint8_t *scratch_; // Points to the end of the scratchpad in use.
void reallocate(size_t len) {
auto old_reserved = reserved_;
+80 -120
View File
@@ -23,8 +23,7 @@
namespace flatbuffers {
// Helper class to verify the integrity of a FlatBuffer
template <bool TrackVerifierBufferSize>
class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
class Verifier FLATBUFFERS_FINAL_CLASS {
public:
struct Options {
// The maximum nesting of tables and vectors before we call it invalid.
@@ -41,18 +40,17 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
bool assert = false;
};
explicit VerifierTemplate(const uint8_t* const buf, const size_t buf_len,
const Options& opts)
explicit Verifier(const uint8_t *const buf, const size_t buf_len,
const Options &opts)
: buf_(buf), size_(buf_len), opts_(opts) {
FLATBUFFERS_ASSERT(size_ < opts.max_size);
}
// Deprecated API, please construct with VerifierTemplate::Options.
VerifierTemplate(const uint8_t* const buf, const size_t buf_len,
const uoffset_t max_depth = 64,
const uoffset_t max_tables = 1000000,
const bool check_alignment = true)
: VerifierTemplate(buf, buf_len, [&] {
// Deprecated API, please construct with Verifier::Options.
Verifier(const uint8_t *const buf, const size_t buf_len,
const uoffset_t max_depth = 64, const uoffset_t max_tables = 1000000,
const bool check_alignment = true)
: Verifier(buf, buf_len, [&] {
Options opts;
opts.max_depth = max_depth;
opts.max_tables = max_tables;
@@ -64,25 +62,25 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
bool Check(const bool ok) const {
// clang-format off
#ifdef FLATBUFFERS_DEBUG_VERIFICATION_FAILURE
if (opts_.assert) { FLATBUFFERS_ASSERT(ok); }
if (opts_.assert) { FLATBUFFERS_ASSERT(ok); }
#endif
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
if (!ok)
upper_bound_ = 0;
#endif
// clang-format on
if (TrackVerifierBufferSize) {
if (!ok) {
upper_bound_ = 0;
}
}
return ok;
}
// Verify any range within the buffer.
bool Verify(const size_t elem, const size_t elem_len) const {
if (TrackVerifierBufferSize) {
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
auto upper_bound = elem + elem_len;
if (upper_bound_ < upper_bound) {
upper_bound_ = upper_bound;
}
}
if (upper_bound_ < upper_bound)
upper_bound_ = upper_bound;
#endif
// clang-format on
return Check(elem_len < size_ && elem <= size_ - elem_len);
}
@@ -91,61 +89,59 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
}
// Verify a range indicated by sizeof(T).
template <typename T>
bool Verify(const size_t elem) const {
template<typename T> bool Verify(const size_t elem) const {
return VerifyAlignment(elem, sizeof(T)) && Verify(elem, sizeof(T));
}
bool VerifyFromPointer(const uint8_t* const p, const size_t len) {
bool VerifyFromPointer(const uint8_t *const p, const size_t len) {
return Verify(static_cast<size_t>(p - buf_), len);
}
// Verify relative to a known-good base pointer.
bool VerifyFieldStruct(const uint8_t* const base, const voffset_t elem_off,
bool VerifyFieldStruct(const uint8_t *const base, const voffset_t elem_off,
const size_t elem_len, const size_t align) const {
const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, elem_len);
}
template <typename T>
bool VerifyField(const uint8_t* const base, const voffset_t elem_off,
template<typename T>
bool VerifyField(const uint8_t *const base, const voffset_t elem_off,
const size_t align) const {
const auto f = static_cast<size_t>(base - buf_) + elem_off;
return VerifyAlignment(f, align) && Verify(f, sizeof(T));
}
// Verify a pointer (may be NULL) of a table type.
template <typename T>
bool VerifyTable(const T* const table) {
template<typename T> bool VerifyTable(const T *const table) {
return !table || table->Verify(*this);
}
// Verify a pointer (may be NULL) of any vector type.
template <int&..., typename T, typename LenT>
bool VerifyVector(const Vector<T, LenT>* const vec) const {
template<int &..., typename T, typename LenT>
bool VerifyVector(const Vector<T, LenT> *const vec) const {
return !vec || VerifyVectorOrString<LenT>(
reinterpret_cast<const uint8_t*>(vec), sizeof(T));
reinterpret_cast<const uint8_t *>(vec), sizeof(T));
}
// Verify a pointer (may be NULL) of a vector to struct.
template <int&..., typename T, typename LenT>
bool VerifyVector(const Vector<const T*, LenT>* const vec) const {
return VerifyVector(reinterpret_cast<const Vector<T, LenT>*>(vec));
template<int &..., typename T, typename LenT>
bool VerifyVector(const Vector<const T *, LenT> *const vec) const {
return VerifyVector(reinterpret_cast<const Vector<T, LenT> *>(vec));
}
// Verify a pointer (may be NULL) to string.
bool VerifyString(const String* const str) const {
bool VerifyString(const String *const str) const {
size_t end;
return !str || (VerifyVectorOrString<uoffset_t>(
reinterpret_cast<const uint8_t*>(str), 1, &end) &&
reinterpret_cast<const uint8_t *>(str), 1, &end) &&
Verify(end, 1) && // Must have terminator
Check(buf_[end] == '\0')); // Terminating byte must be 0.
}
// Common code between vectors and strings.
template <typename LenT = uoffset_t>
bool VerifyVectorOrString(const uint8_t* const vec, const size_t elem_size,
size_t* const end = nullptr) const {
template<typename LenT = uoffset_t>
bool VerifyVectorOrString(const uint8_t *const vec, const size_t elem_size,
size_t *const end = nullptr) const {
const auto vec_offset = static_cast<size_t>(vec - buf_);
// Check we can read the size field.
if (!Verify<LenT>(vec_offset)) return false;
@@ -161,7 +157,7 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
}
// Special case for string contents, after the above has been called.
bool VerifyVectorOfStrings(const Vector<Offset<String>>* const vec) const {
bool VerifyVectorOfStrings(const Vector<Offset<String>> *const vec) const {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!VerifyString(vec->Get(i))) return false;
@@ -171,8 +167,8 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
}
// Special case for table contents, after the above has been called.
template <typename T>
bool VerifyVectorOfTables(const Vector<Offset<T>>* const vec) {
template<typename T>
bool VerifyVectorOfTables(const Vector<Offset<T>> *const vec) {
if (vec) {
for (uoffset_t i = 0; i < vec->size(); i++) {
if (!vec->Get(i)->Verify(*this)) return false;
@@ -181,8 +177,8 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
return true;
}
FLATBUFFERS_SUPPRESS_UBSAN("unsigned-integer-overflow")
bool VerifyTableStart(const uint8_t* const table) {
__suppress_ubsan__("unsigned-integer-overflow") bool VerifyTableStart(
const uint8_t *const table) {
// Check the vtable offset.
const auto tableo = static_cast<size_t>(table - buf_);
if (!Verify<soffset_t>(tableo)) return false;
@@ -199,8 +195,8 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
return Check((vsize & 1) == 0) && Verify(vtableo, vsize);
}
template <typename T>
bool VerifyBufferFromStart(const char* const identifier, const size_t start) {
template<typename T>
bool VerifyBufferFromStart(const char *const identifier, const size_t start) {
// Buffers have to be of some size to be valid. The reason it is a runtime
// check instead of static_assert, is that nested flatbuffers go through
// this call and their size is determined at runtime.
@@ -214,19 +210,19 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
// Call T::Verify, which must be in the generated code for this type.
const auto o = VerifyOffset<uoffset_t>(start);
if (!Check(o != 0)) return false;
if (!(reinterpret_cast<const T*>(buf_ + start + o)->Verify(*this))) {
return false;
}
if (TrackVerifierBufferSize) {
if (GetComputedSize() == 0) return false;
}
return true;
return Check(o != 0) &&
reinterpret_cast<const T *>(buf_ + start + o)->Verify(*this)
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
&& GetComputedSize()
#endif
;
// clang-format on
}
template <typename T, int&..., typename SizeT>
bool VerifyNestedFlatBuffer(const Vector<uint8_t, SizeT>* const buf,
const char* const identifier) {
template<typename T, int &..., typename SizeT>
bool VerifyNestedFlatBuffer(const Vector<uint8_t, SizeT> *const buf,
const char *const identifier) {
// Caller opted out of this.
if (!opts_.check_nested_flatbuffers) return true;
@@ -236,32 +232,25 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
// If there is a nested buffer, it must be greater than the min size.
if (!Check(buf->size() >= FLATBUFFERS_MIN_BUFFER_SIZE)) return false;
VerifierTemplate<TrackVerifierBufferSize> nested_verifier(
buf->data(), buf->size(), opts_);
Verifier nested_verifier(buf->data(), buf->size(), opts_);
return nested_verifier.VerifyBuffer<T>(identifier);
}
// Verify this whole buffer, starting with root type T.
template <typename T>
bool VerifyBuffer() {
return VerifyBuffer<T>(nullptr);
}
template<typename T> bool VerifyBuffer() { return VerifyBuffer<T>(nullptr); }
template <typename T>
bool VerifyBuffer(const char* const identifier) {
template<typename T> bool VerifyBuffer(const char *const identifier) {
return VerifyBufferFromStart<T>(identifier, 0);
}
template <typename T, typename SizeT = uoffset_t>
bool VerifySizePrefixedBuffer(const char* const identifier) {
template<typename T, typename SizeT = uoffset_t>
bool VerifySizePrefixedBuffer(const char *const identifier) {
return Verify<SizeT>(0U) &&
// Ensure the prefixed size is within the bounds of the provided
// length.
Check(ReadScalar<SizeT>(buf_) + sizeof(SizeT) <= size_) &&
Check(ReadScalar<SizeT>(buf_) == size_ - sizeof(SizeT)) &&
VerifyBufferFromStart<T>(identifier, sizeof(SizeT));
}
template <typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
template<typename OffsetT = uoffset_t, typename SOffsetT = soffset_t>
size_t VerifyOffset(const size_t start) const {
if (!Verify<OffsetT>(start)) return 0;
const auto o = ReadScalar<OffsetT>(buf_ + start);
@@ -275,8 +264,8 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
return o;
}
template <typename OffsetT = uoffset_t>
size_t VerifyOffset(const uint8_t* const base, const voffset_t start) const {
template<typename OffsetT = uoffset_t>
size_t VerifyOffset(const uint8_t *const base, const voffset_t start) const {
return VerifyOffset<OffsetT>(static_cast<size_t>(base - buf_) + start);
}
@@ -295,37 +284,31 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
return true;
}
// Returns the message size in bytes.
//
// This should only be called after first calling VerifyBuffer or
// VerifySizePrefixedBuffer.
//
// This method should only be called for VerifierTemplate instances
// where the TrackVerifierBufferSize template parameter is true,
// i.e. for SizeVerifier. For instances where TrackVerifierBufferSize
// is false, this fails at runtime or returns zero.
// Returns the message size in bytes
size_t GetComputedSize() const {
if (TrackVerifierBufferSize) {
// clang-format off
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
uintptr_t size = upper_bound_;
// Align the size to uoffset_t
size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1);
return (size > size_) ? 0 : size;
}
// Must use SizeVerifier, or (deprecated) turn on
// FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE, for this to work.
(void)upper_bound_;
FLATBUFFERS_ASSERT(false);
return 0;
return (size > size_) ? 0 : size;
#else
// Must turn on FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE for this to work.
(void)upper_bound_;
FLATBUFFERS_ASSERT(false);
return 0;
#endif
// clang-format on
}
std::vector<uint8_t>* GetFlexReuseTracker() { return flex_reuse_tracker_; }
std::vector<uint8_t> *GetFlexReuseTracker() { return flex_reuse_tracker_; }
void SetFlexReuseTracker(std::vector<uint8_t>* const rt) {
void SetFlexReuseTracker(std::vector<uint8_t> *const rt) {
flex_reuse_tracker_ = rt;
}
private:
const uint8_t* buf_;
const uint8_t *buf_;
const size_t size_;
const Options opts_;
@@ -333,37 +316,14 @@ class VerifierTemplate FLATBUFFERS_FINAL_CLASS {
uoffset_t depth_ = 0;
uoffset_t num_tables_ = 0;
std::vector<uint8_t>* flex_reuse_tracker_ = nullptr;
std::vector<uint8_t> *flex_reuse_tracker_ = nullptr;
};
// Specialization for 64-bit offsets.
template <>
template <>
inline size_t VerifierTemplate<false>::VerifyOffset<uoffset64_t>(
const size_t start) const {
template<>
inline size_t Verifier::VerifyOffset<uoffset64_t>(const size_t start) const {
return VerifyOffset<uoffset64_t, soffset64_t>(start);
}
template <>
template <>
inline size_t VerifierTemplate<true>::VerifyOffset<uoffset64_t>(
const size_t start) const {
return VerifyOffset<uoffset64_t, soffset64_t>(start);
}
// Instance of VerifierTemplate that supports GetComputedSize().
using SizeVerifier = VerifierTemplate</*TrackVerifierBufferSize = */ true>;
// The FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE build configuration macro is
// deprecated, and should not be defined, since it is easy to misuse in ways
// that result in ODR violations. Rather than using Verifier and defining
// FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE, please use SizeVerifier instead.
#ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE // Deprecated, see above.
using Verifier = SizeVerifier;
#else
// Instance of VerifierTemplate that is slightly faster, but does not
// support GetComputedSize().
using Verifier = VerifierTemplate</*TrackVerifierBufferSize = */ false>;
#endif
} // namespace flatbuffers
+1 -1
View File
@@ -10,7 +10,7 @@ if(HAVE_IPP_ICV)
add_definitions(-DICV_BASE)
endif()
file(GLOB lib_srcs ${IPP_IW_PATH}/src/*.c ${IPP_IW_PATH}/src/*.cpp)
file(GLOB lib_srcs ${IPP_IW_PATH}/src/*.c)
file(GLOB lib_hdrs ${IPP_IW_PATH}/include/*.h ${IPP_IW_PATH}/include/iw/*.h ${IPP_IW_PATH}/include/iw++/*.hpp)
# ----------------------------------------------------------------------------------
+9 -17
View File
@@ -2,7 +2,7 @@ function(download_ippicv root_var)
set(${root_var} "" PARENT_SCOPE)
# Commit SHA in the opencv_3rdparty repo
set(IPPICV_COMMIT "c934a2a15a6df020446ac3dfa07e3acf72b63a8f")
set(IPPICV_COMMIT "fd27188235d85e552de31425e7ea0f53ba73ba53")
# Define actual ICV versions
if(APPLE)
set(IPPICV_COMMIT "0cc4aa06bf2bef4b05d237c69a5a96b9cd0cb85a")
@@ -14,29 +14,21 @@ function(download_ippicv root_var)
set(OPENCV_ICV_PLATFORM "linux")
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx")
if(X86_64)
set(OPENCV_ICV_NAME "ippicv_2022.2.0_lnx_intel64_20250730_general.tgz")
set(OPENCV_ICV_HASH "55d18247d8ef707f009b94f69d77b948")
set(OPENCV_ICV_NAME "ippicv_2021.11.0_lnx_intel64_20240201_general.tgz")
set(OPENCV_ICV_HASH "0f2745ff705ecae31176dad437608f6f")
else()
if(ANDROID)
set(IPPICV_COMMIT "c7c6d527dde5fee7cb914ee9e4e20f7436aab3a1")
set(OPENCV_ICV_NAME "ippicv_2021.10.1_lnx_ia32_20231206_general.tgz")
set(OPENCV_ICV_HASH "d9510f3ce08f6074aac472a5c19a3b53")
else()
set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
set(OPENCV_ICV_NAME "ippicv_2021.12.0_lnx_ia32_20240425_general.tgz")
set(OPENCV_ICV_HASH "85ffa2b9ed7802b93c23fa27b0097d36")
endif()
set(OPENCV_ICV_NAME "ippicv_2021.11.0_lnx_ia32_20240201_general.tgz")
set(OPENCV_ICV_HASH "63e381bf08076ca34fd5264203043a45")
endif()
elseif(WIN32 AND NOT ARM)
set(OPENCV_ICV_PLATFORM "windows")
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_win")
if(X86_64)
set(OPENCV_ICV_NAME "ippicv_2022.2.0_win_intel64_20250730_general.zip")
set(OPENCV_ICV_HASH "7c0973976ab0716bc33f03a76a50017f")
set(OPENCV_ICV_NAME "ippicv_2021.11.0_win_intel64_20240201_general.zip")
set(OPENCV_ICV_HASH "59d154bf54a1e3eea20d7248f81a2a8e")
else()
set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
set(OPENCV_ICV_NAME "ippicv_2021.12.0_win_ia32_20240425_general.zip")
set(OPENCV_ICV_HASH "8b1d2a23957d57624d0de8f2a5cae5f1")
set(OPENCV_ICV_NAME "ippicv_2021.11.0_win_ia32_20240201_general.zip")
set(OPENCV_ICV_HASH "7a6d8ac5825c02fea6cbfc1201b521b5")
endif()
else()
return()
+2 -6
View File
@@ -24,6 +24,7 @@ set(ITT_PUBLIC_HDRS
include/ittnotify.h
include/jitprofiling.h
include/libittnotify.h
include/llvm_jit_event_listener.hpp
)
set(ITT_PRIVATE_HDRS
src/ittnotify/disable_warnings.h
@@ -38,11 +39,6 @@ set(ITT_SRCS
add_library(${ITT_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${ITT_SRCS} ${ITT_PUBLIC_HDRS} ${ITT_PRIVATE_HDRS})
file(STRINGS "src/ittnotify/ittnotify_config.h" API_VERSION_NUM REGEX "#define\[ \t]+API_VERSION_NUM[ \t]+([0-9\.]+)")
if(API_VERSION_NUM MATCHES "#define\[ \t]+API_VERSION_NUM[ \t]+([0-9\.]*)")
set(ITTNOTIFY_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "" FORCE)
endif()
if(NOT WIN32)
if(HAVE_DL_LIBRARY)
target_link_libraries(${ITT_LIBRARY} dl)
@@ -68,4 +64,4 @@ if(NOT BUILD_SHARED_LIBS)
ocv_install_target(${ITT_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev OPTIONAL)
endif()
ocv_install_3rdparty_licenses(ittnotify src/ittnotify/BSD-3-Clause.txt src/ittnotify/GPL-2.0-only.txt)
ocv_install_3rdparty_licenses(ittnotify src/ittnotify/LICENSE.BSD src/ittnotify/LICENSE.GPL)
+101 -643
View File
@@ -1,8 +1,60 @@
/*
Copyright (C) 2005-2019 Intel Corporation
/* <copyright>
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
*/
GPL LICENSE SUMMARY
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
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. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution
in the file called LICENSE.GPL.
Contact Information:
http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
BSD LICENSE
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright> */
#ifndef _ITTNOTIFY_H_
#define _ITTNOTIFY_H_
@@ -11,8 +63,7 @@
@brief Public User API functions and types
@mainpage
The Instrumentation and Tracing Technology API (ITT API) is used to
annotate a user's program with additional information
The ITT API is used to annotate a user's program with additional information
that can be used by correctness and performance tools. The user inserts
calls in their program. Those calls generate information that is collected
at runtime, and used by Intel(R) Threading Tools.
@@ -90,10 +141,6 @@ The same ID may not be reused for different instances, unless a previous
# define ITT_OS_FREEBSD 4
#endif /* ITT_OS_FREEBSD */
#ifndef ITT_OS_OPENBSD
# define ITT_OS_OPENBSD 5
#endif /* ITT_OS_OPENBSD */
#ifndef ITT_OS
# if defined WIN32 || defined _WIN32
# define ITT_OS ITT_OS_WIN
@@ -101,8 +148,6 @@ The same ID may not be reused for different instances, unless a previous
# define ITT_OS ITT_OS_MAC
# elif defined( __FreeBSD__ )
# define ITT_OS ITT_OS_FREEBSD
# elif defined( __OpenBSD__)
# define ITT_OS ITT_OS_OPENBSD
# else
# define ITT_OS ITT_OS_LINUX
# endif
@@ -124,10 +169,6 @@ The same ID may not be reused for different instances, unless a previous
# define ITT_PLATFORM_FREEBSD 4
#endif /* ITT_PLATFORM_FREEBSD */
#ifndef ITT_PLATFORM_OPENBSD
# define ITT_PLATFORM_OPENBSD 5
#endif /* ITT_PLATFORM_OPENBSD */
#ifndef ITT_PLATFORM
# if ITT_OS==ITT_OS_WIN
# define ITT_PLATFORM ITT_PLATFORM_WIN
@@ -135,8 +176,6 @@ The same ID may not be reused for different instances, unless a previous
# define ITT_PLATFORM ITT_PLATFORM_MAC
# elif ITT_OS==ITT_OS_FREEBSD
# define ITT_PLATFORM ITT_PLATFORM_FREEBSD
# elif ITT_OS==ITT_OS_OPENBSD
# define ITT_PLATFORM ITT_PLATFORM_OPENBSD
# else
# define ITT_PLATFORM ITT_PLATFORM_POSIX
# endif
@@ -189,12 +228,7 @@ The same ID may not be reused for different instances, unless a previous
#if ITT_PLATFORM==ITT_PLATFORM_WIN
/* use __forceinline (VC++ specific) */
#if defined(__MINGW32__) && !defined(__cplusplus)
#define ITT_INLINE static __inline__ __attribute__((__always_inline__,__gnu_inline__))
#else
#define ITT_INLINE static __forceinline
#endif /* __MINGW32__ */
#define ITT_INLINE __forceinline
#define ITT_INLINE_ATTRIBUTE /* nothing */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/*
@@ -255,20 +289,20 @@ The same ID may not be reused for different instances, unless a previous
#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)
#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)
#define ITTNOTIFY_VOID_D0(n,d) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_VOID_D1(n,d,x) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_VOID_D2(n,d,x,y) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_DATA_D0(n,d) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_DATA_D1(n,d,x) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_DATA_D2(n,d,x,y) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#ifdef ITT_STUB
#undef ITT_STUB
@@ -306,7 +340,7 @@ extern "C" {
* only pauses tracing and analyzing memory access.
* It does not pause tracing or analyzing threading APIs.
* .
* - Intel(R) VTune(TM) Profiler:
* - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE:
* - Does continue to record when new threads are started.
* .
* - Other effects:
@@ -321,143 +355,35 @@ void ITTAPI __itt_resume(void);
/** @brief Detach collection */
void ITTAPI __itt_detach(void);
/**
* @enum __itt_collection_scope
* @brief Enumerator for collection scopes
*/
typedef enum {
__itt_collection_scope_host = 1 << 0,
__itt_collection_scope_offload = 1 << 1,
__itt_collection_scope_all = 0x7FFFFFFF
} __itt_collection_scope;
/** @brief Pause scoped collection */
void ITTAPI __itt_pause_scoped(__itt_collection_scope);
/** @brief Resume scoped collection */
void ITTAPI __itt_resume_scoped(__itt_collection_scope);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, pause, (void))
ITT_STUBV(ITTAPI, void, pause_scoped, (__itt_collection_scope))
ITT_STUBV(ITTAPI, void, resume, (void))
ITT_STUBV(ITTAPI, void, resume_scoped, (__itt_collection_scope))
ITT_STUBV(ITTAPI, void, detach, (void))
#define __itt_pause ITTNOTIFY_VOID(pause)
#define __itt_pause_ptr ITTNOTIFY_NAME(pause)
#define __itt_pause_scoped ITTNOTIFY_VOID(pause_scoped)
#define __itt_pause_scoped_ptr ITTNOTIFY_NAME(pause_scoped)
#define __itt_resume ITTNOTIFY_VOID(resume)
#define __itt_resume_ptr ITTNOTIFY_NAME(resume)
#define __itt_resume_scoped ITTNOTIFY_VOID(resume_scoped)
#define __itt_resume_scoped_ptr ITTNOTIFY_NAME(resume_scoped)
#define __itt_detach ITTNOTIFY_VOID(detach)
#define __itt_detach_ptr ITTNOTIFY_NAME(detach)
ITT_STUBV(ITTAPI, void, pause, (void))
ITT_STUBV(ITTAPI, void, resume, (void))
ITT_STUBV(ITTAPI, void, detach, (void))
#define __itt_pause ITTNOTIFY_VOID(pause)
#define __itt_pause_ptr ITTNOTIFY_NAME(pause)
#define __itt_resume ITTNOTIFY_VOID(resume)
#define __itt_resume_ptr ITTNOTIFY_NAME(resume)
#define __itt_detach ITTNOTIFY_VOID(detach)
#define __itt_detach_ptr ITTNOTIFY_NAME(detach)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_pause()
#define __itt_pause_ptr 0
#define __itt_pause_scoped(scope)
#define __itt_pause_scoped_ptr 0
#define __itt_pause_ptr 0
#define __itt_resume()
#define __itt_resume_ptr 0
#define __itt_resume_scoped(scope)
#define __itt_resume_scoped_ptr 0
#define __itt_resume_ptr 0
#define __itt_detach()
#define __itt_detach_ptr 0
#define __itt_detach_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_pause_ptr 0
#define __itt_pause_scoped_ptr 0
#define __itt_resume_ptr 0
#define __itt_resume_scoped_ptr 0
#define __itt_detach_ptr 0
#define __itt_pause_ptr 0
#define __itt_resume_ptr 0
#define __itt_detach_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/** @} control group */
/** @endcond */
/**
* @defgroup Intel Processor Trace control
* API from this group provides control over collection and analysis of Intel Processor Trace (Intel PT) data
* Information about Intel Processor Trace technology can be found here (Volume 3 chapter 35):
* https://software.intel.com/sites/default/files/managed/39/c5/325462-sdm-vol-1-2abcd-3abcd.pdf
* Use this API to mark particular code regions for loading detailed performance statistics.
* This mode makes your analysis faster and more accurate.
* @{
*/
typedef unsigned char __itt_pt_region;
/**
* @brief function saves a region name marked with Intel PT API and returns a region id.
* Only 7 names can be registered. Attempts to register more names will be ignored and a region id with auto names will be returned.
* For automatic naming of regions pass NULL as function parameter
*/
#if ITT_PLATFORM==ITT_PLATFORM_WIN
__itt_pt_region ITTAPI __itt_pt_region_createA(const char *name);
__itt_pt_region ITTAPI __itt_pt_region_createW(const wchar_t *name);
#if defined(UNICODE) || defined(_UNICODE)
# define __itt_pt_region_create __itt_pt_region_createW
#else /* UNICODE */
# define __itt_pt_region_create __itt_pt_region_createA
#endif /* UNICODE */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
__itt_pt_region ITTAPI __itt_pt_region_create(const char *name);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
#if ITT_PLATFORM==ITT_PLATFORM_WIN
ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createA, (const char *name))
ITT_STUB(ITTAPI, __itt_pt_region, pt_region_createW, (const wchar_t *name))
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
ITT_STUB(ITTAPI, __itt_pt_region, pt_region_create, (const char *name))
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_pt_region_createA ITTNOTIFY_DATA(pt_region_createA)
#define __itt_pt_region_createA_ptr ITTNOTIFY_NAME(pt_region_createA)
#define __itt_pt_region_createW ITTNOTIFY_DATA(pt_region_createW)
#define __itt_pt_region_createW_ptr ITTNOTIFY_NAME(pt_region_createW)
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_pt_region_create ITTNOTIFY_DATA(pt_region_create)
#define __itt_pt_region_create_ptr ITTNOTIFY_NAME(pt_region_create)
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#else /* INTEL_NO_ITTNOTIFY_API */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_pt_region_createA(name) (__itt_pt_region)0
#define __itt_pt_region_createA_ptr 0
#define __itt_pt_region_createW(name) (__itt_pt_region)0
#define __itt_pt_region_createW_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_pt_region_create(name) (__itt_pt_region)0
#define __itt_pt_region_create_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_pt_region_createA_ptr 0
#define __itt_pt_region_createW_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_pt_region_create_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief function contains a special code pattern identified on the post-processing stage and
* marks the beginning of a code region targeted for Intel PT analysis
* @param[in] region - region id, 0 <= region < 8
*/
void __itt_mark_pt_region_begin(__itt_pt_region region);
/**
* @brief function contains a special code pattern identified on the post-processing stage and
* marks the end of a code region targeted for Intel PT analysis
* @param[in] region - region id, 0 <= region < 8
*/
void __itt_mark_pt_region_end(__itt_pt_region region);
/** @} Intel PT control group*/
/**
* @defgroup threads Threads
* @ingroup public
@@ -615,26 +541,14 @@ ITT_STUBV(ITTAPI, void, suppress_pop, (void))
/** @endcond */
/**
* @enum __itt_suppress_mode
* @brief Enumerator for the suppressing modes
* @enum __itt_model_disable
* @brief Enumerator for the disable methods
*/
typedef enum __itt_suppress_mode {
__itt_unsuppress_range,
__itt_suppress_range
} __itt_suppress_mode_t;
/**
* @enum __itt_collection_state
* @brief Enumerator for collection state.
*/
typedef enum {
__itt_collection_uninitialized = 0, /* uninitialized */
__itt_collection_init_fail = 1, /* failed to init */
__itt_collection_collector_absent = 2, /* non work state collector is absent */
__itt_collection_collector_exists = 3, /* work state collector exists */
__itt_collection_init_successful = 4 /* success to init */
} __itt_collection_state;
/**
* @brief Mark a range of memory for error suppression or unsuppression for error types included in mask
*/
@@ -1582,7 +1496,7 @@ ITT_STUBV(ITTAPI, void, heap_allocate_end, (__itt_heap_function h, void** addr,
/** @endcond */
/**
* @brief Record a free begin occurrence.
* @brief Record an free begin occurrence.
*/
void ITTAPI __itt_heap_free_begin(__itt_heap_function h, void* addr);
@@ -1602,7 +1516,7 @@ ITT_STUBV(ITTAPI, void, heap_free_begin, (__itt_heap_function h, void* addr))
/** @endcond */
/**
* @brief Record a free end occurrence.
* @brief Record an free end occurrence.
*/
void ITTAPI __itt_heap_free_end(__itt_heap_function h, void* addr);
@@ -1622,7 +1536,7 @@ ITT_STUBV(ITTAPI, void, heap_free_end, (__itt_heap_function h, void* addr))
/** @endcond */
/**
* @brief Record a reallocation begin occurrence.
* @brief Record an reallocation begin occurrence.
*/
void ITTAPI __itt_heap_reallocate_begin(__itt_heap_function h, void* addr, size_t new_size, int initialized);
@@ -1642,7 +1556,7 @@ ITT_STUBV(ITTAPI, void, heap_reallocate_begin, (__itt_heap_function h, void* add
/** @endcond */
/**
* @brief Record a reallocation end occurrence.
* @brief Record an reallocation end occurrence.
*/
void ITTAPI __itt_heap_reallocate_end(__itt_heap_function h, void* addr, void** new_addr, size_t new_size, int initialized);
@@ -2778,7 +2692,7 @@ ITT_STUB(ITTAPI, __itt_clock_domain*, clock_domain_create, (__itt_get_clock_info
/**
* @ingroup clockdomains
* @brief Recalculate clock domains frequencies and clock base timestamps.
* @brief Recalculate clock domains frequences and clock base timestamps.
*/
void ITTAPI __itt_clock_domain_reset(void);
@@ -3683,12 +3597,11 @@ ITT_STUBV(ITTAPI, void, enable_attach, (void))
/** @endcond */
/**
* @brief Module load notification
* This API is used to report necessary information in case of bypassing default system loader.
* Notification should be done immidiatelly after this module is loaded to process memory.
* @param[in] start_addr - module start address
* @param[in] end_addr - module end address
* @param[in] path - file system full path to the module
* @brief Module load info
* This API is used to report necessary information in case of module relocation
* @param[in] start_addr - relocated module start address
* @param[in] end_addr - relocated module end address
* @param[in] path - file system path to the module
*/
#if ITT_PLATFORM==ITT_PLATFORM_WIN
void ITTAPI __itt_module_loadA(void *start_addr, void *end_addr, const char *path);
@@ -3743,462 +3656,7 @@ ITT_STUB(ITTAPI, void, module_load, (void *start_addr, void *end_addr, const ch
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief Report module unload
* This API is used to report necessary information in case of bypassing default system loader.
* Notification should be done just before the module is unloaded from process memory.
* @param[in] addr - base address of loaded module
*/
void ITTAPI __itt_module_unload(void *addr);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, module_unload, (void *addr))
#define __itt_module_unload ITTNOTIFY_VOID(module_unload)
#define __itt_module_unload_ptr ITTNOTIFY_NAME(module_unload)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_module_unload(addr)
#define __itt_module_unload_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_module_unload_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/** @cond exclude_from_documentation */
typedef enum
{
__itt_module_type_unknown = 0,
__itt_module_type_elf,
__itt_module_type_coff
} __itt_module_type;
/** @endcond */
/** @cond exclude_from_documentation */
typedef enum
{
itt_section_type_unknown,
itt_section_type_bss, /* notifies that the section contains uninitialized data. These are the relevant section types and the modules that contain them:
* ELF module: SHT_NOBITS section type
* COFF module: IMAGE_SCN_CNT_UNINITIALIZED_DATA section type
*/
itt_section_type_data, /* notifies that section contains initialized data. These are the relevant section types and the modules that contain them:
* ELF module: SHT_PROGBITS section type
* COFF module: IMAGE_SCN_CNT_INITIALIZED_DATA section type
*/
itt_section_type_text /* notifies that the section contains executable code. These are the relevant section types and the modules that contain them:
* ELF module: SHT_PROGBITS section type
* COFF module: IMAGE_SCN_CNT_CODE section type
*/
} __itt_section_type;
/** @endcond */
/**
* @hideinitializer
* @brief bit-mask, detects a section attribute that indicates whether a section can be executed as code:
* These are the relevant section attributes and the modules that contain them:
* ELF module: PF_X section attribute
* COFF module: IMAGE_SCN_MEM_EXECUTE attribute
*/
#define __itt_section_exec 0x20000000
/**
* @hideinitializer
* @brief bit-mask, detects a section attribute that indicates whether a section can be read.
* These are the relevant section attributes and the modules that contain them:
* ELF module: PF_R attribute
* COFF module: IMAGE_SCN_MEM_READ attribute
*/
#define __itt_section_read 0x40000000
/**
* @hideinitializer
* @brief bit-mask, detects a section attribute that indicates whether a section can be written to.
* These are the relevant section attributes and the modules that contain them:
* ELF module: PF_W attribute
* COFF module: IMAGE_SCN_MEM_WRITE attribute
*/
#define __itt_section_write 0x80000000
/** @cond exclude_from_documentation */
#pragma pack(push, 8)
typedef struct ___itt_section_info
{
const char* name; /*!< Section name in UTF8 */
__itt_section_type type; /*!< Section content and semantics description */
size_t flags; /*!< Section bit flags that describe attributes using bit mask
* Zero if disabled, non-zero if enabled
*/
void* start_addr; /*!< Section load(relocated) start address */
size_t size; /*!< Section file offset */
size_t file_offset; /*!< Section size */
} __itt_section_info;
#pragma pack(pop)
/** @endcond */
/** @cond exclude_from_documentation */
#pragma pack(push, 8)
typedef struct ___itt_module_object
{
unsigned int version; /*!< API version*/
__itt_id module_id; /*!< Unique identifier. This is unchanged for sections that belong to the same module */
__itt_module_type module_type; /*!< Binary module format */
const char* module_name; /*!< Unique module name or path to module in UTF8
* Contains module name when module_bufer and module_size exist
* Contains module path when module_bufer and module_size absent
* module_name remains the same for the certain module_id
*/
void* module_buffer; /*!< Module buffer content */
size_t module_size; /*!< Module buffer size */
/*!< If module_buffer and module_size exist, the binary module is dumped onto the system.
* If module_buffer and module_size do not exist,
* the binary module exists on the system already.
* The module_name parameter contains the path to the module.
*/
__itt_section_info* section_array; /*!< Reference to section information */
size_t section_number;
} __itt_module_object;
#pragma pack(pop)
/** @endcond */
/**
* @brief Load module content and its loaded(relocated) sections.
* This API is useful to save a module, or specify its location on the system and report information about loaded sections.
* The target module is saved on the system if module buffer content and size are available.
* If module buffer content and size are unavailable, the module name contains the path to the existing binary module.
* @param[in] module_obj - provides module and section information, along with unique module identifiers (name,module ID)
* which bind the binary module to particular sections.
*/
void ITTAPI __itt_module_load_with_sections(__itt_module_object* module_obj);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, module_load_with_sections, (__itt_module_object* module_obj))
#define __itt_module_load_with_sections ITTNOTIFY_VOID(module_load_with_sections)
#define __itt_module_load_with_sections_ptr ITTNOTIFY_NAME(module_load_with_sections)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_module_load_with_sections(module_obj)
#define __itt_module_load_with_sections_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_module_load_with_sections_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief Unload a module and its loaded(relocated) sections.
* This API notifies that the module and its sections were unloaded.
* @param[in] module_obj - provides module and sections information, along with unique module identifiers (name,module ID)
* which bind the binary module to particular sections.
*/
void ITTAPI __itt_module_unload_with_sections(__itt_module_object* module_obj);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, module_unload_with_sections, (__itt_module_object* module_obj))
#define __itt_module_unload_with_sections ITTNOTIFY_VOID(module_unload_with_sections)
#define __itt_module_unload_with_sections_ptr ITTNOTIFY_NAME(module_unload_with_sections)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_module_unload_with_sections(module_obj)
#define __itt_module_unload_with_sections_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_module_unload_with_sections_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/** @cond exclude_from_documentation */
#pragma pack(push, 8)
typedef struct ___itt_histogram
{
const __itt_domain* domain; /*!< Domain of the histogram*/
const char* nameA; /*!< Name of the histogram */
#if defined(UNICODE) || defined(_UNICODE)
const wchar_t* nameW;
#else /* UNICODE || _UNICODE */
void* nameW;
#endif /* UNICODE || _UNICODE */
__itt_metadata_type x_type; /*!< Type of the histogram X axis */
__itt_metadata_type y_type; /*!< Type of the histogram Y axis */
int extra1; /*!< Reserved to the runtime */
void* extra2; /*!< Reserved to the runtime */
struct ___itt_histogram* next;
} __itt_histogram;
#pragma pack(pop)
/** @endcond */
/**
* @brief Create a typed histogram instance with given name/domain.
* @param[in] domain The domain controlling the call.
* @param[in] name The name of the histogram.
* @param[in] x_type The type of the X axis in histogram (may be 0 to calculate batch statistics).
* @param[in] y_type The type of the Y axis in histogram.
*/
#if ITT_PLATFORM==ITT_PLATFORM_WIN
__itt_histogram* ITTAPI __itt_histogram_createA(const __itt_domain* domain, const char* name, __itt_metadata_type x_type, __itt_metadata_type y_type);
__itt_histogram* ITTAPI __itt_histogram_createW(const __itt_domain* domain, const wchar_t* name, __itt_metadata_type x_type, __itt_metadata_type y_type);
#if defined(UNICODE) || defined(_UNICODE)
# define __itt_histogram_create __itt_histogram_createW
# define __itt_histogram_create_ptr __itt_histogram_createW_ptr
#else /* UNICODE */
# define __itt_histogram_create __itt_histogram_createA
# define __itt_histogram_create_ptr __itt_histogram_createA_ptr
#endif /* UNICODE */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
__itt_histogram* ITTAPI __itt_histogram_create(const __itt_domain* domain, const char* name, __itt_metadata_type x_type, __itt_metadata_type y_type);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
#if ITT_PLATFORM==ITT_PLATFORM_WIN
ITT_STUB(ITTAPI, __itt_histogram*, histogram_createA, (const __itt_domain* domain, const char* name, __itt_metadata_type x_type, __itt_metadata_type y_type))
ITT_STUB(ITTAPI, __itt_histogram*, histogram_createW, (const __itt_domain* domain, const wchar_t* name, __itt_metadata_type x_type, __itt_metadata_type y_type))
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
ITT_STUB(ITTAPI, __itt_histogram*, histogram_create, (const __itt_domain* domain, const char* name, __itt_metadata_type x_type, __itt_metadata_type y_type))
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_histogram_createA ITTNOTIFY_DATA(histogram_createA)
#define __itt_histogram_createA_ptr ITTNOTIFY_NAME(histogram_createA)
#define __itt_histogram_createW ITTNOTIFY_DATA(histogram_createW)
#define __itt_histogram_createW_ptr ITTNOTIFY_NAME(histogram_createW)
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_histogram_create ITTNOTIFY_DATA(histogram_create)
#define __itt_histogram_create_ptr ITTNOTIFY_NAME(histogram_create)
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#else /* INTEL_NO_ITTNOTIFY_API */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_histogram_createA(domain, name, x_type, y_type) (__itt_histogram*)0
#define __itt_histogram_createA_ptr 0
#define __itt_histogram_createW(domain, name, x_type, y_type) (__itt_histogram*)0
#define __itt_histogram_createW_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_histogram_create(domain, name, x_type, y_type) (__itt_histogram*)0
#define __itt_histogram_create_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_histogram_createA_ptr 0
#define __itt_histogram_createW_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_histogram_create_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief Submit statistics for a histogram instance.
* @param[in] hist Pointer to the histogram instance to which the histogram statistic is to be dumped.
* @param[in] length The number of elements in dumped axis data array.
* @param[in] x_data The X axis dumped data itself (may be NULL to calculate batch statistics).
* @param[in] y_data The Y axis dumped data itself.
*/
void ITTAPI __itt_histogram_submit(__itt_histogram* hist, size_t length, void* x_data, void* y_data);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, histogram_submit, (__itt_histogram* hist, size_t length, void* x_data, void* y_data))
#define __itt_histogram_submit ITTNOTIFY_VOID(histogram_submit)
#define __itt_histogram_submit_ptr ITTNOTIFY_NAME(histogram_submit)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_histogram_submit(hist, length, x_data, y_data)
#define __itt_histogram_submit_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_histogram_submit_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/**
* @brief function allows to obtain the current collection state at the moment
* @return collection state as a enum __itt_collection_state
*/
__itt_collection_state __itt_get_collection_state(void);
/**
* @brief function releases resources allocated by ITT API static part
* this API should be called from the library destructor
* @return void
*/
void __itt_release_resources(void);
/** @endcond */
/**
* @brief Create a typed counter with given domain pointer, string name and counter type
*/
#if ITT_PLATFORM==ITT_PLATFORM_WIN
__itt_counter ITTAPI __itt_counter_createA_v3(const __itt_domain* domain, const char* name, __itt_metadata_type type);
__itt_counter ITTAPI __itt_counter_createW_v3(const __itt_domain* domain, const wchar_t* name, __itt_metadata_type type);
#if defined(UNICODE) || defined(_UNICODE)
# define __itt_counter_create_v3 __itt_counter_createW_v3
# define __itt_counter_create_v3_ptr __itt_counter_createW_v3_ptr
#else /* UNICODE */
# define __itt_counter_create_v3 __itt_counter_createA_v3
# define __itt_counter_create_v3_ptr __itt_counter_createA_v3_ptr
#endif /* UNICODE */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
__itt_counter ITTAPI __itt_counter_create_v3(const __itt_domain* domain, const char* name, __itt_metadata_type type);
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
#if ITT_PLATFORM==ITT_PLATFORM_WIN
ITT_STUB(ITTAPI, __itt_counter, counter_createA_v3, (const __itt_domain* domain, const char* name, __itt_metadata_type type))
ITT_STUB(ITTAPI, __itt_counter, counter_createW_v3, (const __itt_domain* domain, const wchar_t* name, __itt_metadata_type type))
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
ITT_STUB(ITTAPI, __itt_counter, counter_create_v3, (const __itt_domain* domain, const char* name, __itt_metadata_type type))
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_counter_createA_v3 ITTNOTIFY_DATA(counter_createA_v3)
#define __itt_counter_createA_v3_ptr ITTNOTIFY_NAME(counter_createA_v3)
#define __itt_counter_createW_v3 ITTNOTIFY_DATA(counter_createW_v3)
#define __itt_counter_createW_v3_ptr ITTNOTIFY_NAME(counter_createW_v3)
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_counter_create_v3 ITTNOTIFY_DATA(counter_create_v3)
#define __itt_counter_create_v3_ptr ITTNOTIFY_NAME(counter_create_v3)
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#else /* INTEL_NO_ITTNOTIFY_API */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_counter_createA_v3(domain, name, type) (__itt_counter)0
#define __itt_counter_createA_v3_ptr 0
#define __itt_counter_createW_v3(domain, name, type) (__itt_counter)0
#define __itt_counter_create_typedW_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_counter_create_v3(domain, name, type) (__itt_counter)0
#define __itt_counter_create_v3_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#if ITT_PLATFORM==ITT_PLATFORM_WIN
#define __itt_counter_createA_v3_ptr 0
#define __itt_counter_createW_v3_ptr 0
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#define __itt_counter_create_v3_ptr 0
#endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief Set the counter value api
*/
void ITTAPI __itt_counter_set_value_v3(__itt_counter counter, void *value_ptr);
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, counter_set_value_v3, (__itt_counter counter, void *value_ptr))
#define __itt_counter_set_value_v3 ITTNOTIFY_VOID(counter_set_value_v3)
#define __itt_counter_set_value_v3_ptr ITTNOTIFY_NAME(counter_set_value_v3)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_counter_set_value_v3(counter, value_ptr)
#define __itt_counter_set_value_v3_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_counter_set_value_v3_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/**
* @brief describes the type of context metadata
*/
typedef enum {
__itt_context_unknown = 0, /*!< Undefined type */
__itt_context_nameA, /*!< ASCII string char* type */
__itt_context_nameW, /*!< Unicode string wchar_t* type */
__itt_context_deviceA, /*!< ASCII string char* type */
__itt_context_deviceW, /*!< Unicode string wchar_t* type */
__itt_context_unitsA, /*!< ASCII string char* type */
__itt_context_unitsW, /*!< Unicode string wchar_t* type */
__itt_context_pci_addrA, /*!< ASCII string char* type */
__itt_context_pci_addrW, /*!< Unicode string wchar_t* type */
__itt_context_tid, /*!< Unsigned 64-bit integer type */
__itt_context_max_val, /*!< Unsigned 64-bit integer type */
__itt_context_bandwidth_flag, /*!< Unsigned 64-bit integer type */
__itt_context_latency_flag, /*!< Unsigned 64-bit integer type */
__itt_context_occupancy_flag, /*!< Unsigned 64-bit integer type */
__itt_context_on_thread_flag, /*!< Unsigned 64-bit integer type */
__itt_context_is_abs_val_flag, /*!< Unsigned 64-bit integer type */
__itt_context_cpu_instructions_flag, /*!< Unsigned 64-bit integer type */
__itt_context_cpu_cycles_flag /*!< Unsigned 64-bit integer type */
} __itt_context_type;
#if defined(UNICODE) || defined(_UNICODE)
# define __itt_context_name __itt_context_nameW
# define __itt_context_device __itt_context_deviceW
# define __itt_context_units __itt_context_unitsW
# define __itt_context_pci_addr __itt_context_pci_addrW
#else /* UNICODE || _UNICODE */
# define __itt_context_name __itt_context_nameA
# define __itt_context_device __itt_context_deviceA
# define __itt_context_units __itt_context_unitsA
# define __itt_context_pci_addr __itt_context_pci_addrA
#endif /* UNICODE || _UNICODE */
/** @cond exclude_from_documentation */
#pragma pack(push, 8)
typedef struct ___itt_context_metadata
{
__itt_context_type type; /*!< Type of the context metadata value */
void* value; /*!< Pointer to context metadata value itself */
} __itt_context_metadata;
#pragma pack(pop)
/** @endcond */
/** @cond exclude_from_documentation */
#pragma pack(push, 8)
typedef struct ___itt_counter_metadata
{
__itt_counter counter; /*!< Associated context metadata counter */
__itt_context_type type; /*!< Type of the context metadata value */
const char* str_valueA; /*!< String context metadata value */
#if defined(UNICODE) || defined(_UNICODE)
const wchar_t* str_valueW;
#else /* UNICODE || _UNICODE */
void* str_valueW;
#endif /* UNICODE || _UNICODE */
unsigned long long value; /*!< Numeric context metadata value */
int extra1; /*!< Reserved to the runtime */
void* extra2; /*!< Reserved to the runtime */
struct ___itt_counter_metadata* next;
} __itt_counter_metadata;
#pragma pack(pop)
/** @endcond */
/**
* @brief Bind context metadata to counter instance
* @param[in] counter Pointer to the counter instance to which the context metadata is to be associated.
* @param[in] length The number of elements in context metadata array.
* @param[in] metadata The context metadata itself.
*/
void ITTAPI __itt_bind_context_metadata_to_counter(__itt_counter counter, size_t length, __itt_context_metadata* metadata);
/** @cond exclude_from_documentation */
#ifndef INTEL_NO_MACRO_BODY
#ifndef INTEL_NO_ITTNOTIFY_API
ITT_STUBV(ITTAPI, void, bind_context_metadata_to_counter, (__itt_counter counter, size_t length, __itt_context_metadata* metadata))
#define __itt_bind_context_metadata_to_counter ITTNOTIFY_VOID(bind_context_metadata_to_counter)
#define __itt_bind_context_metadata_to_counter_ptr ITTNOTIFY_NAME(bind_context_metadata_to_counter)
#else /* INTEL_NO_ITTNOTIFY_API */
#define __itt_bind_context_metadata_to_counter(counter, length, metadata)
#define __itt_bind_context_metadata_to_counter_ptr 0
#endif /* INTEL_NO_ITTNOTIFY_API */
#else /* INTEL_NO_MACRO_BODY */
#define __itt_bind_context_metadata_to_counter_ptr 0
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
#ifdef __cplusplus
}
@@ -4547,7 +4005,7 @@ ITT_STUB(ITTAPI, __itt_caller, stack_caller_create, (void))
/** @endcond */
/**
* @brief Destroy the information about stitch point identified by the pointer previously returned by __itt_stack_caller_create()
* @brief Destroy the inforamtion about stitch point identified by the pointer previously returned by __itt_stack_caller_create()
*/
void ITTAPI __itt_stack_caller_destroy(__itt_caller id);
+75 -23
View File
@@ -1,8 +1,60 @@
/*
Copyright (C) 2005-2019 Intel Corporation
/* <copyright>
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
*/
GPL LICENSE SUMMARY
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
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. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution
in the file called LICENSE.GPL.
Contact Information:
http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
BSD LICENSE
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright> */
#ifndef __JITPROFILING_H__
#define __JITPROFILING_H__
@@ -14,7 +66,7 @@
* generated code that can be used by performance tools. The user inserts
* calls in the code generator to report information before JIT-compiled
* code goes to execution. This information is collected at runtime and used
* by tools like Intel(R) VTune(TM) Profiler to display performance metrics
* by tools like Intel(R) VTune(TM) Amplifier to display performance metrics
* associated with JIT-compiled code.
*
* These APIs can be used to\n
@@ -45,16 +97,16 @@
* * Expected behavior:
* * If any iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED event overwrites an
* already reported method, then such a method becomes invalid and its
* memory region is treated as unloaded. VTune Profiler displays the metrics
* memory region is treated as unloaded. VTune Amplifier displays the metrics
* collected by the method until it is overwritten.
* * If supplied line number information contains multiple source lines for
* the same assembly instruction (code location), then VTune Profiler picks up
* the same assembly instruction (code location), then VTune Amplifier picks up
* the first line number.
* * Dynamically generated code can be associated with a module name.
* Use the iJIT_Method_Load_V2 structure.\n
* Clarification of some cases:
* * If you register a function with the same method ID multiple times,
* specifying different module names, then the VTune Profiler picks up
* specifying different module names, then the VTune Amplifier picks up
* the module name registered first. If you want to distinguish the same
* function between different JIT engines, supply different method IDs for
* each function. Other symbolic information (for example, source file)
@@ -91,18 +143,18 @@
* belonging to the same method. Symbolic information (method name,
* source file name) will be taken from the first notification, and all
* subsequent notifications with the same method ID will be processed
* only for line number table information. So, the VTune Profiler will map
* only for line number table information. So, the VTune Amplifier will map
* samples to a source line using the line number table from the current
* notification while taking the source file name from the very first one.\n
* Clarification of some cases:\n
* * If you register a second code region with a different source file
* name and the same method ID, then this information will be saved and
* will not be considered as an extension of the first code region, but
* VTune Profiler will use the source file of the first code region and map
* VTune Amplifier will use the source file of the first code region and map
* performance metrics incorrectly.
* * If you register a second code region with the same source file as
* for the first region and the same method ID, then the source file will be
* discarded but VTune Profiler will map metrics to the source file correctly.
* discarded but VTune Amplifier will map metrics to the source file correctly.
* * If you register a second code region with a null source file and
* the same method ID, then provided line number info will be associated
* with the source file of the first code region.
@@ -241,7 +293,7 @@ typedef enum _iJIT_IsProfilingActiveFlags
* @brief Description of a single entry in the line number information of a code region.
* @details A table of line number entries gives information about how the reported code region
* is mapped to source file.
* Intel(R) VTune(TM) Profiler uses line number information to attribute
* Intel(R) VTune(TM) Amplifier uses line number information to attribute
* the samples (virtual address) to a line number. \n
* It is acceptable to report different code addresses for the same source line:
* @code
@@ -252,7 +304,7 @@ typedef enum _iJIT_IsProfilingActiveFlags
* 18 1
* 21 30
*
* VTune Profiler constructs the following table using the client data
* VTune Amplifier constructs the following table using the client data
*
* Code subrange Line number
* 0-1 2
@@ -376,7 +428,7 @@ typedef struct _iJIT_Method_Load_V2
char* module_name; /**<\brief Module name. Can be NULL.
The module name can be useful for distinguishing among
different JIT engines. VTune Profiler will display
different JIT engines. VTune Amplifier will display
reported methods grouped by specific module. */
} *piJIT_Method_Load_V2, iJIT_Method_Load_V2;
@@ -428,7 +480,7 @@ typedef struct _iJIT_Method_Load_V3
char* module_name; /**<\brief Module name. Can be NULL.
* The module name can be useful for distinguishing among
* different JIT engines. VTune Profiler will display
* different JIT engines. VTune Amplifier will display
* reported methods grouped by specific module. */
iJIT_CodeArchitecture module_arch; /**<\brief Architecture of the method's code region.
@@ -438,9 +490,9 @@ typedef struct _iJIT_Method_Load_V3
* engine generates 64-bit code.
*
* If JIT engine reports both 32-bit and 64-bit types
* of methods then VTune Profiler splits the methods
* of methods then VTune Amplifier splits the methods
* with the same module name but with different
* architectures in two different modules. VTune Profiler
* architectures in two different modules. VTune Amplifier
* modifies the original name provided with a 64-bit method
* version by ending it with '(64)' */
@@ -509,9 +561,9 @@ typedef enum _iJIT_SegmentType
iJIT_CT_CODE, /**<\brief Executable code. */
iJIT_CT_DATA, /**<\brief Data (not executable code).
* VTune Profiler uses the format string
* VTune Amplifier uses the format string
* (see iJIT_Method_Update) to represent
* this data in the VTune Profiler GUI */
* this data in the VTune Amplifier GUI */
iJIT_CT_KEEP, /**<\brief Use the previous markup for the trace.
* Can be used for the following
@@ -528,11 +580,11 @@ typedef enum _iJIT_SegmentType
* structure to describe the update of the content within a JIT-compiled method,
* use iJVM_EVENT_TYPE_METHOD_UPDATE_V2 as an event type to report it.
*
* On the first Update event, VTune Profiler copies the original code range reported by
* On the first Update event, VTune Amplifier copies the original code range reported by
* the iJVM_EVENT_TYPE_METHOD_LOAD event, then modifies it with the supplied bytes and
* adds the modified range to the original method. For next update events, VTune Profiler
* adds the modified range to the original method. For next update events, VTune Amplifier
* does the same but it uses the latest modified version of a code region for update.
* Eventually, VTune Profiler GUI displays multiple code ranges for the method reported by
* Eventually, VTune Amplifier GUI displays multiple code ranges for the method reported by
* the iJVM_EVENT_TYPE_METHOD_LOAD event.
* Notes:
* - Multiple update events with different types for the same trace are allowed
@@ -621,7 +673,7 @@ iJIT_IsProfilingActiveFlags JITAPI iJIT_IsProfilingActive(void);
* @brief Reports infomation about JIT-compiled code to the agent.
*
* The reported information is used to attribute samples obtained from any
* Intel(R) VTune(TM) Profiler collector. This API needs to be called
* Intel(R) VTune(TM) Amplifier collector. This API needs to be called
* after JIT compilation and before the first entry into the JIT-compiled
* code.
*
+74 -39
View File
@@ -1,8 +1,60 @@
/*
Copyright (C) 2005-2019 Intel Corporation
/* <copyright>
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
*/
GPL LICENSE SUMMARY
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
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. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution
in the file called LICENSE.GPL.
Contact Information:
http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
BSD LICENSE
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright> */
#ifndef _LEGACY_ITTNOTIFY_H_
#define _LEGACY_ITTNOTIFY_H_
@@ -28,10 +80,6 @@
# define ITT_OS_FREEBSD 4
#endif /* ITT_OS_FREEBSD */
#ifndef ITT_OS_OPENBSD
# define ITT_OS_OPENBSD 5
#endif /* ITT_OS_OPENBSD */
#ifndef ITT_OS
# if defined WIN32 || defined _WIN32
# define ITT_OS ITT_OS_WIN
@@ -39,8 +87,6 @@
# define ITT_OS ITT_OS_MAC
# elif defined( __FreeBSD__ )
# define ITT_OS ITT_OS_FREEBSD
# elif defined( __OpenBSD__ )
# define ITT_OS ITT_OS_OPENBSD
# else
# define ITT_OS ITT_OS_LINUX
# endif
@@ -62,10 +108,6 @@
# define ITT_PLATFORM_FREEBSD 4
#endif /* ITT_PLATFORM_FREEBSD */
#ifndef ITT_PLATFORM_OPENBSD
# define ITT_PLATFORM_OPENBSD 5
#endif /* ITT_PLATFORM_OPENBSD */
#ifndef ITT_PLATFORM
# if ITT_OS==ITT_OS_WIN
# define ITT_PLATFORM ITT_PLATFORM_WIN
@@ -73,8 +115,6 @@
# define ITT_PLATFORM ITT_PLATFORM_MAC
# elif ITT_OS==ITT_OS_FREEBSD
# define ITT_PLATFORM ITT_PLATFORM_FREEBSD
# elif ITT_OS==ITT_OS_OPENBSD
# define ITT_PLATFORM ITT_PLATFORM_OPENBSD
# else
# define ITT_PLATFORM ITT_PLATFORM_POSIX
# endif
@@ -127,12 +167,7 @@
#if ITT_PLATFORM==ITT_PLATFORM_WIN
/* use __forceinline (VC++ specific) */
#if defined(__MINGW32__) && !defined(__cplusplus)
#define ITT_INLINE static __inline__ __attribute__((__always_inline__,__gnu_inline__))
#else
#define ITT_INLINE static __forceinline
#endif /* __MINGW32__ */
#define ITT_INLINE __forceinline
#define ITT_INLINE_ATTRIBUTE /* nothing */
#else /* ITT_PLATFORM==ITT_PLATFORM_WIN */
/*
@@ -184,20 +219,20 @@
#define ITTNOTIFY_VOID(n) (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)
#define ITTNOTIFY_DATA(n) (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)
#define ITTNOTIFY_VOID_D0(n,d) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_VOID_D1(n,d,x) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_VOID_D2(n,d,x,y) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (d == NULL) ? (void)0 : (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_DATA_D0(n,d) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_DATA_D1(n,d,x) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_DATA_D2(n,d,x,y) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (d == NULL) ? 0 : (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_VOID_D0(n,d) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_VOID_D1(n,d,x) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_VOID_D2(n,d,x,y) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_VOID_D3(n,d,x,y,z) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_VOID_D4(n,d,x,y,z,a) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_VOID_D5(n,d,x,y,z,a,b) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_VOID_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? (void)0 : (!ITTNOTIFY_NAME(n)) ? (void)0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#define ITTNOTIFY_DATA_D0(n,d) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d)
#define ITTNOTIFY_DATA_D1(n,d,x) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x)
#define ITTNOTIFY_DATA_D2(n,d,x,y) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y)
#define ITTNOTIFY_DATA_D3(n,d,x,y,z) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z)
#define ITTNOTIFY_DATA_D4(n,d,x,y,z,a) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a)
#define ITTNOTIFY_DATA_D5(n,d,x,y,z,a,b) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b)
#define ITTNOTIFY_DATA_D6(n,d,x,y,z,a,b,c) (!(d)->flags) ? 0 : (!ITTNOTIFY_NAME(n)) ? 0 : ITTNOTIFY_NAME(n)(d,x,y,z,a,b,c)
#ifdef ITT_STUB
#undef ITT_STUB
@@ -234,7 +269,7 @@ extern "C" {
* only pauses tracing and analyzing memory access.
* It does not pause tracing or analyzing threading APIs.
* .
* - Intel(R) VTune(TM) Profiler:
* - Intel(R) Parallel Amplifier and Intel(R) VTune(TM) Amplifier XE:
* - Does continue to record when new threads are started.
* .
* - Other effects:
@@ -970,9 +1005,9 @@ ITT_STUB(ITTAPI, __itt_frame, frame_create, (const char *domain))
#endif /* INTEL_NO_MACRO_BODY */
/** @endcond */
/** @brief Record a frame begin occurrence. */
/** @brief Record an frame begin occurrence. */
void ITTAPI __itt_frame_begin(__itt_frame frame);
/** @brief Record a frame end occurrence. */
/** @brief Record an frame end occurrence. */
void ITTAPI __itt_frame_end (__itt_frame frame);
/** @cond exclude_from_documentation */
+56 -4
View File
@@ -1,8 +1,60 @@
/*
Copyright (C) 2005-2019 Intel Corporation
/* <copyright>
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
*/
GPL LICENSE SUMMARY
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
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. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution
in the file called LICENSE.GPL.
Contact Information:
http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
BSD LICENSE
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright> */
#ifndef _LIBITTNOTIFY_H_
#define _LIBITTNOTIFY_H_
+241
View File
@@ -0,0 +1,241 @@
/* <copyright>
This file is provided under a dual BSD/GPLv2 license. When using or
redistributing this file, you may do so under either license.
GPL LICENSE SUMMARY
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
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. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution
in the file called LICENSE.GPL.
Contact Information:
http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/
BSD LICENSE
Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</copyright> */
/*
* This file implements an interface bridge from Low-Level Virtual Machine
* llvm::JITEventListener to Intel JIT Profiling API. It passes the function
* and line information to the appropriate functions in the JIT profiling
* interface so that any LLVM-based JIT engine can emit the JIT code
* notifications that the profiler will receive.
*
* Usage model:
*
* 1. Register the listener implementation instance with the execution engine:
*
* #include <llvm_jit_event_listener.hpp>
* ...
* ExecutionEngine *TheExecutionEngine;
* ...
* TheExecutionEngine = EngineBuilder(TheModule).create();
* ...
* __itt_llvm_jit_event_listener jitListener;
* TheExecutionEngine->RegisterJITEventListener(&jitListener);
* ...
*
* 2. When compiling make sure to add the ITT API include directory to the
* compiler include directories, ITT API library directory to the linker
* library directories and link with jitprofling static library.
*/
#ifndef __ITT_LLVM_JIT_EVENT_LISTENER_HPP__
#define __ITT_LLVM_JIT_EVENT_LISTENER_HPP__
#include "jitprofiling.h"
#include <llvm/Function.h>
#include <llvm/ExecutionEngine/JITEventListener.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Analysis/DebugInfo.h>
#include <map>
#include <cassert>
// Uncomment the line below to turn on logging to stderr
#define JITPROFILING_DEBUG_ENABLE
// Some elementary logging support
#ifdef JITPROFILING_DEBUG_ENABLE
#include <cstdio>
#include <cstdarg>
static void _jit_debug(const char* format, ...)
{
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
// Use the macro as JITDEBUG(("foo: %d", foo_val));
#define JITDEBUG(x) \
do { \
_jit_debug("jit-listener: "); \
_jit_debug x; \
} \
while (0)
#else
#define JITDEBUG(x)
#endif
// LLVM JIT event listener, translates the notifications to the JIT profiling
// API information.
class __itt_llvm_jit_event_listener : public llvm::JITEventListener
{
public:
__itt_llvm_jit_event_listener() {}
public:
virtual void NotifyFunctionEmitted(const llvm::Function &F,
void *Code, size_t Size, const EmittedFunctionDetails &Details)
{
std::string name = F.getName().str();
JITDEBUG(("function jitted:\n"));
JITDEBUG((" addr=0x%08x\n", (int)Code));
JITDEBUG((" name=`%s'\n", name.c_str()));
JITDEBUG((" code-size=%d\n", (int)Size));
JITDEBUG((" line-infos-count=%d\n", Details.LineStarts.size()));
// The method must not be in the map - the entry must have been cleared
// from the map in NotifyFreeingMachineCode in case of rejitting.
assert(m_addr2MethodId.find(Code) == m_addr2MethodId.end());
int mid = iJIT_GetNewMethodID();
m_addr2MethodId[Code] = mid;
iJIT_Method_Load mload;
memset(&mload, 0, sizeof mload);
mload.method_id = mid;
// Populate the method size and name information
// TODO: The JIT profiling API should have members as const char pointers.
mload.method_name = (char*)name.c_str();
mload.method_load_address = Code;
mload.method_size = (unsigned int)Size;
// Populate line information now.
// From the JIT API documentation it is not quite clear whether the
// line information can be given in ranges, so we'll populate it for
// every byte of the function, hmm.
std::string srcFilePath;
std::vector<LineNumberInfo> lineInfos;
char *addr = (char*)Code;
char *lineAddr = addr; // Exclusive end point at which current
// line info changes.
const llvm::DebugLoc* loc = 0; // Current line info
int lineIndex = -1; // Current index into the line info table
for (int i = 0; i < Size; ++i, ++addr) {
while (addr >= lineAddr) {
if (lineIndex >= 0 && lineIndex < Details.LineStarts.size()) {
loc = &Details.LineStarts[lineIndex].Loc;
std::string p = getSrcFilePath(F.getContext(), *loc);
assert(srcFilePath.empty() || p == srcFilePath);
srcFilePath = p;
} else {
loc = NULL;
}
lineIndex++;
if (lineIndex >= 0 && lineIndex < Details.LineStarts.size()) {
lineAddr = (char*)Details.LineStarts[lineIndex].Address;
} else {
lineAddr = addr + Size;
}
}
if (loc) {
int line = loc->getLine();
LineNumberInfo info = { i, line };
lineInfos.push_back(info);
JITDEBUG((" addr 0x%08x -> line %d\n", addr, line));
}
}
if (!lineInfos.empty()) {
mload.line_number_size = lineInfos.size();
JITDEBUG((" translated to %d line infos to JIT", (int)lineInfos.size()));
mload.line_number_table = &lineInfos[0];
mload.source_file_name = (char*)srcFilePath.c_str();
}
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &mload);
}
virtual void NotifyFreeingMachineCode(void *OldPtr)
{
JITDEBUG(("function unjitted\n"));
JITDEBUG((" addr=0x%08x\n", (int)OldPtr));
Addr2MethodId::iterator it = m_addr2MethodId.find(OldPtr);
assert(it != m_addr2MethodId.end());
iJIT_Method_Id mid = { it->second };
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_UNLOAD_START, &mid);
m_addr2MethodId.erase(it);
}
private:
std::string getSrcFilePath(const llvm::LLVMContext& ctx, const llvm::DebugLoc& loc)
{
llvm::MDNode* node = loc.getAsMDNode(ctx);
llvm::DILocation srcLoc(node);
return srcLoc.getDirectory().str() + "/" + srcLoc.getFilename().str();
}
private:
/// Don't copy
__itt_llvm_jit_event_listener(const __itt_llvm_jit_event_listener&);
__itt_llvm_jit_event_listener& operator=(const __itt_llvm_jit_event_listener&);
private:
typedef std::vector<LineNumberInfo> LineInfoList;
// The method unload notification in VTune JIT profiling API takes the
// method ID, not method address so have to maintain the mapping. Is
// there a more efficient and simple way to do this like attaching the
// method ID information somehow to the LLVM function instance?
//
// TODO: It would be more convenient for the JIT API to take the method
// address, not method ID.
typedef std::map<const void*, int> Addr2MethodId;
Addr2MethodId m_addr2MethodId;
};
#endif // Header guard
@@ -1,8 +1,7 @@
Copyright (c) 2019 Intel Corporation. All rights reserved.
Copyright (c) 2011, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
• Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,103 +1,65 @@
GNU GENERAL PUBLIC LICENSE
The GNU General Public License (GPL)
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and an idea of what it does.>
Copyright (C) < yyyy> <name of author>
One line to give the program's name and a brief idea of what it does.
Copyright (C) <year> <name of author>
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; either version 2 of the License, or (at your option) any later version.
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. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.
signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.

Some files were not shown because too many files have changed in this diff Show More