shtr_c.h (2264B)
1 /* Copyright (C) 2022, 2025, 2026 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2025, 2026 Université de Lorraine 3 * Copyright (C) 2022 Centre National de la Recherche Scientifique 4 * Copyright (C) 2022 Université Paul Sabatier 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 19 #ifndef SHTR_C_H 20 #define SHTR_C_H 21 22 #include <rsys/logger.h> 23 #include <rsys/ref_count.h> 24 25 #define MSG_INFO_PREFIX "" 26 #define MSG_ERROR_PREFIX "error: " 27 #define MSG_WARNING_PREFIX "warning: " 28 29 /* Helper macros for logging */ 30 #define LOG__(Dev, Lvl, Type, ...) { \ 31 if ((Dev)->verbose >= (Lvl)) \ 32 logger_print((Dev)->logger, Type, __VA_ARGS__); \ 33 } (void)0 34 #define ERROR(Dev, ...) LOG__(Dev, 1, LOG_ERROR, MSG_ERROR_PREFIX __VA_ARGS__) 35 #define WARN(Dev, ...) LOG__(Dev, 2, LOG_WARNING, MSG_WARNING_PREFIX __VA_ARGS__) 36 #define INFO(Dev, ...) LOG__(Dev, 3, LOG_OUTPUT, MSG_INFO_PREFIX __VA_ARGS__) 37 38 struct mem_allocator; 39 40 struct shtr { 41 struct mem_allocator* allocator; 42 struct logger* logger; 43 struct logger logger__; /* Default logger */ 44 int verbose; 45 ref_T ref; 46 }; 47 48 /* Conversion of a double-precision floating-point representation to a 49 * fixed-point representation */ 50 extern LOCAL_SYM int64_t 51 float2fix 52 (const double fp, 53 const int ipl, /* Length (in bits) of the integer part */ 54 const int fpl); /* Length (in bits) of the fractional part */ 55 56 /* Conversion of a fixed-point representation to a double-precision 57 * floating-point representation */ 58 extern LOCAL_SYM double 59 fix2float 60 (const int64_t fix, 61 const int ipl, /* Length (in bits) of the integer part */ 62 const int fpl); /* Length (in bits) of the fractional part */ 63 64 #endif /* SHTR_C_H */