1 /* 2 * Percepio Trace Recorder for Tracealyzer v4.8.1 3 * Copyright 2023 Percepio AB 4 * www.percepio.com 5 * 6 * SPDX-License-Identifier: Apache-2.0 7 * 8 * The interface for trace utility functions. 9 */ 10 11 #ifndef TRC_UTILITY_H 12 #define TRC_UTILITY_H 13 14 #ifndef TRC_MEMCPY 15 #define TRC_MEMCPY(dst, src, size) \ 16 { \ 17 uint32_t __i; \ 18 for (__i = 0; __i < size; __i++) { \ 19 ((uint8_t*)(dst))[__i] = ((uint8_t*)(src))[__i]; \ 20 } \ 21 } 22 #endif 23 24 #define TRC_STRCAT(dst, dst_size, pDstLength, src) \ 25 { \ 26 TraceUnsignedBaseType_t uxTRC_STRCAT_INDEX = 0; \ 27 while (*(pDstLength) < (dst_size)) \ 28 { \ 29 dst[*(pDstLength)] = src[uxTRC_STRCAT_INDEX]; \ 30 if (dst[*(pDstLength)] == 0) \ 31 break; \ 32 (*(pDstLength))++; \ 33 uxTRC_STRCAT_INDEX++; \ 34 } \ 35 } 36 37 #if (defined(TRC_CFG_USE_GCC_STATEMENT_EXPR) && TRC_CFG_USE_GCC_STATEMENT_EXPR == 1) || __GNUC__ || __IAR_SYSTEMS_ICC__ || __TI_ARM__ 38 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1(e1) __extension__({e1;}) 39 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(e1, e2) __extension__({e1; e2;}) 40 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3(e1, e2, e3) __extension__({e1; e2; e3;}) 41 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4(e1, e2, e3, e4) __extension__({e1; e2; e3; e4;}) 42 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_5(e1, e2, e3, e4, e5) __extension__({e1; e2; e3; e4; e5;}) 43 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_6(e1, e2, e3, e4, e5, e6) __extension__({e1; e2; e3; e4; e5; e6;}) 44 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_7(e1, e2, e3, e4, e5, e6, e7) __extension__({e1; e2; e3; e4; e5; e6; e7;}) 45 #else 46 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_1(e1) (e1) 47 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_2(e1, e2) (e1, e2) 48 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_3(e1, e2, e3) (e1, e2, e3) 49 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_4(e1, e2, e3, e4) (e1, e2, e3, e4) 50 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_5(e1, e2, e3, e4, e5) (e1, e2, e3, e4, e5) 51 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_6(e1, e2, e3, e4, e5, e6) (e1, e2, e3, e4, e5, e6) 52 #define TRC_COMMA_EXPR_TO_STATEMENT_EXPR_7(e1, e2, e3, e4, e5, e6, e7) (e1, e2, e3, e4, e5, e6, e7) 53 #endif 54 55 #endif /* TRC_UTILITY_H */ 56