From 8e0e00d21146a84c18f9cf9409e187b4fb0248aa Mon Sep 17 00:00:00 2001 From: Riku Nomoto Date: Thu, 19 Nov 2020 12:45:32 +0900 Subject: Init basesystem source codes. Signed-off-by: Riku Nomoto Change-Id: I55aa2f1406ce7f751ae14140b613b53b68995528 --- .../library/src/_pbSum.cpp | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 video_in_hal/vehicleservice/positioning_base_library/library/src/_pbSum.cpp (limited to 'video_in_hal/vehicleservice/positioning_base_library/library/src/_pbSum.cpp') diff --git a/video_in_hal/vehicleservice/positioning_base_library/library/src/_pbSum.cpp b/video_in_hal/vehicleservice/positioning_base_library/library/src/_pbSum.cpp new file mode 100755 index 0000000..2964db7 --- /dev/null +++ b/video_in_hal/vehicleservice/positioning_base_library/library/src/_pbSum.cpp @@ -0,0 +1,95 @@ +/* + * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. + * + * 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. + */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + File name : _pbSum.cpp + System name : + Subsystem name : System common functions + Title : System APIs Asynchronous Data HDD Backup Processing + -------------------------------------------------------------------------------------- +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include + +/* + Function prototype declarations +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * MODULE : Sum() + * ABSTRACT : SUM calculation process + * NOTE : Calculate the SUM value for the specified size from the SUM calculation start address. + * ARGUMENT : void *p SUM calculation start address + * int32 size Size (bytes) + * u_int8 type Calculation width Byte :sizeof(u_char) + * Word :sizeof(u_int16) + * Long-word:sizeof(u_int32) + * NOTE : Calculate the SUM value from the SUM calculation start address by the size specified by the calculation width. + * RETURN : u_int32 SUM value + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +u_int32 Sum(void *p, int32 size, u_int8 type) { // LCOV_EXCL_START 8:dead code + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + u_int32 sum = 0; /* SUM value */ + u_int32 loop_cnt; /* Loop counter */ + u_int32 loop_num; /* Number of loops */ + + /* Pointer size check */ + if ((p == NULL) || (size == 0)) { + /* nop */ + } else { + /* When the calculation width is "Long word" */ + if (type == sizeof(int32)) { + u_int32 * ptr32 = reinterpret_cast(p); /* Long word pointer */ + + /* Calculate the number of processes and loop for the number of Times to compute the Sum value. */ + loop_num = static_cast(size / sizeof(u_int32)); + for (loop_cnt = 0; loop_cnt < loop_num; loop_cnt++) { + sum += *ptr32; + ptr32++; + } + } else if (type == sizeof(int16)) { + /* For "Word" */ + u_int16 * ptr16 = reinterpret_cast(p); /* Word pointer */ + + loop_num = static_cast(size / sizeof(u_int16)); + for (loop_cnt = 0; loop_cnt < loop_num; loop_cnt++) { + sum += *ptr16; + ptr16++; + } + } else if (type == sizeof(char)) { + /* For "Byte" */ + u_char * ptr8 = reinterpret_cast(p); /* Byte pointer */ + + loop_num = static_cast(size / sizeof(u_char)); + for (loop_cnt = 0; loop_cnt < loop_num; loop_cnt++) { + sum += *ptr8; + ptr8++; + } + } else { + /* For other than above */ + /* No processing */ + } + } + return sum; +} +// LCOV_EXCL_STOP + +/* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + End of File : Sum.cpp +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +*/ + -- cgit 1.2.3-korg