1 /** 2 * Copyright 2021 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_CORE_MINDRT_RUNTIME_THREADPOOL_LOG_H_ 18 #define MINDSPORE_CORE_MINDRT_RUNTIME_THREADPOOL_LOG_H_ 19 20 namespace mindspore { 21 #ifdef THREAD_POOL_DEBUG 22 #include <stdio.h> 23 #define THREAD_DEBUG(content, args...) \ 24 { printf("[DEBUG] %s|%d: " #content "\r\n", __func__, __LINE__, ##args); } 25 #define THREAD_INFO(content, args...) \ 26 { printf("[INFO] %s|%d: " #content "\r\n", __func__, __LINE__, ##args); } 27 #define THREAD_ERROR(content, args...) \ 28 { printf("[ERROR] %s|%d: " #content "\r\n", __func__, __LINE__, ##args); } 29 #else 30 #define THREAD_DEBUG(content, ...) 31 #define THREAD_INFO(content, ...) 32 #if defined(__ANDROID__) 33 #include <android/log.h> 34 #define THREAD_ERROR(content, args...) \ 35 { __android_log_print(ANDROID_LOG_ERROR, "MS_LITE", "%s|%d: " #content "\r\n", __func__, __LINE__, ##args); } 36 #else 37 #define THREAD_ERROR(content, ...) 38 #endif 39 #endif 40 41 #define THREAD_ERROR_IF_NULL(ptr) \ 42 do { \ 43 if ((ptr) == nullptr) { \ 44 return THREAD_ERROR; \ 45 } \ 46 } while (0) 47 48 #define THREAD_RETURN_IF_NULL(ptr) \ 49 do { \ 50 if ((ptr) == nullptr) { \ 51 return; \ 52 } \ 53 } while (0) 54 55 enum ThreadRet { THREAD_OK = 0, THREAD_ERROR = 1 }; 56 } // namespace mindspore 57 #endif // MINDSPORE_CORE_MINDRT_RUNTIME_THREADPOOL_LOG_H_ 58