1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 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 17 #ifndef MINDSPORE_LITE_SRC_COMMON_LOG_UTIL_H_ 18 #define MINDSPORE_LITE_SRC_COMMON_LOG_UTIL_H_ 19 20 #include "src/common/log_adapter.h" 21 #include "include/errorcode.h" 22 23 #define MSLITE_CHECK_PTR(ptr) \ 24 do { \ 25 if ((ptr) == nullptr) { \ 26 MS_LOG(ERROR) << ": The pointer[" << #ptr << "] is null."; \ 27 return mindspore::lite::RET_ERROR; \ 28 } \ 29 } while (0) 30 31 #define CHECK_MALLOC_RES(ptr, errcode) \ 32 do { \ 33 if ((ptr) == nullptr) { \ 34 MS_LOG(ERROR) << "malloc data failed."; \ 35 return errcode; \ 36 } \ 37 } while (0) 38 39 #ifndef ENABLE_HIGH_PERFORMANCE 40 #define CHECK_NULL_RETURN(ptr) \ 41 do { \ 42 if ((ptr) == nullptr) { \ 43 MS_LOG(ERROR) << #ptr << " must not be null!"; \ 44 return mindspore::lite::RET_NULL_PTR; \ 45 } \ 46 } while (0) 47 48 #define CHECK_LESS_RETURN(size1, size2) \ 49 do { \ 50 if ((size1) < (size2)) { \ 51 MS_LOG(ERROR) << #size1 << " must not less than " << #size2; \ 52 return mindspore::lite::RET_ERROR; \ 53 } \ 54 } while (0) 55 56 #else 57 #define CHECK_NULL_RETURN(ptr) 58 #define CHECK_LESS_RETURN(size1, size2) 59 #endif 60 #endif // MINDSPORE_LITE_SRC_COMMON_LOG_UTIL_H_ 61