1 /** 2 * @file cstl_public_inner.h 3 * @copyright Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 16 * @brief cstl_public_cstl公共模块定义 17 * @details cstl公共定义实现源码 18 * @date 2021-05-14 19 * @version v0.1.0 20 * ******************************************************************************************* 21 * @par 修改日志: 22 * <table> 23 * <tr><th>Date <th>Version <th>Author <th>Description 24 * </table> 25 * ******************************************************************************************* 26 */ 27 28 #ifndef CSTL_PUBLIC_INNER_H 29 #define CSTL_PUBLIC_INNER_H 30 31 #include <stdint.h> 32 #include <stdbool.h> 33 #include <sys/types.h> 34 #include <stdio.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #ifdef CSTL_DEBUG 41 #define CSTL_STATIC 42 #ifndef CSTL_PRINTF 43 #define CSTL_PRINTF printf 44 #endif 45 #else 46 #define CSTL_STATIC static 47 #ifndef CSTL_PRINTF 48 #define CSTL_PRINTF(format, ...) 49 #endif 50 #endif 51 52 /* 后根遍历删除avl和rawavl时,栈容量的极值 */ 53 #define CSTL_AVL_STACK_SIZE 64U 54 55 /* -0xC 内存不足。 */ 56 #define CSTL_ERRNO_NOMEM (-12) 57 58 /* -0x16 入参无效。 */ 59 #define CSTL_ERRNO_INVAL (-22) 60 61 typedef struct { 62 uintptr_t inputData; /* 用户实际输入的数据 */ 63 size_t dataSize; /* 实际输入的大小 */ 64 } CstlUserData; 65 66 /* 判断两数相乘在当前系统下会否溢出 */ 67 bool IsMultiOverflow(size_t x, size_t y); 68 69 /* 判断两数相加在当前系统下会否溢出 */ 70 bool IsAddOverflow(size_t x, size_t y); 71 72 /** 73 * @details 默认比较函数 74 */ 75 int32_t CstlIntCmpFunc(uintptr_t data1, uintptr_t data2); 76 77 #ifndef SIZE_MAX 78 #define SIZE_MAX __SIZE_MAX__ 79 #endif 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif /* CSTL_PUBLIC_INNER_H */ 86 87