1 /* 2 * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __COAP_PLATFORM_OS_H__ 6 #define __COAP_PLATFORM_OS_H__ 7 8 #include <stdio.h> 9 10 #include "iotx_coap_internal.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif /* __cplusplus */ 15 16 #ifdef INFRA_MEM_STATS 17 #include "linkkit/infra/infra_mem_stats.h" 18 #define coap_malloc(size) LITE_malloc(size, MEM_MAGIC, "coap.local") 19 #define coap_free(ptr) LITE_free(ptr) 20 #else 21 #define coap_malloc(size) HAL_Malloc(size) 22 #define coap_free(ptr) \ 23 { \ 24 HAL_Free((void *)ptr); \ 25 ptr = NULL; \ 26 } 27 #endif 28 29 #ifdef INFRA_LOG 30 #include "linkkit/infra/infra_log.h" 31 #define COAP_ERR(...) log_err("coap_local", __VA_ARGS__) 32 #define COAP_WRN(...) log_warning("coap_local", __VA_ARGS__) 33 #define COAP_INFO(...) log_info("coap_local", __VA_ARGS__) 34 #define COAP_TRC(...) log_debug("coap_local", __VA_ARGS__) 35 #define COAP_DUMP(...) log_debug("coap_local", __VA_ARGS__) 36 #define COAP_DEBUG(...) log_debug("coap_local", __VA_ARGS__) 37 #define COAP_FLOW(...) log_flow("coap_local", __VA_ARGS__) 38 #else 39 #define COAP_ERR(...) \ 40 do { \ 41 HAL_Printf(__VA_ARGS__); \ 42 HAL_Printf("\r\n"); \ 43 } while (0) 44 #define COAP_WRN(...) \ 45 do { \ 46 HAL_Printf(__VA_ARGS__); \ 47 HAL_Printf("\r\n"); \ 48 } while (0) 49 #define COAP_INFO(...) \ 50 do { \ 51 HAL_Printf(__VA_ARGS__); \ 52 HAL_Printf("\r\n"); \ 53 } while (0) 54 #define COAP_TRC(...) \ 55 do { \ 56 HAL_Printf(__VA_ARGS__); \ 57 HAL_Printf("\r\n"); \ 58 } while (0) 59 #define COAP_DUMP(...) \ 60 do { \ 61 HAL_Printf(__VA_ARGS__); \ 62 HAL_Printf("\r\n"); \ 63 } while (0) 64 #define COAP_DEBUG(...) \ 65 do { \ 66 HAL_Printf(__VA_ARGS__); \ 67 HAL_Printf("\r\n"); \ 68 } while (0) 69 #define COAP_FLOW(...) \ 70 do { \ 71 HAL_Printf(__VA_ARGS__); \ 72 HAL_Printf("\r\n"); \ 73 } while (0) 74 #endif 75 76 int platform_is_multicast(const char *ip_str); 77 78 #ifdef __cplusplus 79 } 80 #endif /* __cplusplus */ 81 82 #endif 83