From 52e736eaa2cba88397ab5e5197e704e89a36ddca Mon Sep 17 00:00:00 2001 From: "Berk D. Demir" Date: Wed, 9 Jul 2025 22:05:32 -0700 Subject: [PATCH] Fix compiler warnings: Unused functions Move function definitions in include/blisp_util.h to lib/blisp_util.c. Defining them as static leads to internal linkage, accessible in that translation unit, hence the warning. Their references are to be handled in other translation units, so they shouldn't be static. --- CMakeLists.txt | 4 +++- include/blisp_util.h | 46 +++++++----------------------------------- lib/blisp_util.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 lib/blisp_util.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2a972..43462e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,10 @@ option(COMPILE_TESTS "Compile the tests" OFF) add_library(libblisp_obj OBJECT lib/blisp.c + lib/blisp_easy.c + lib/blisp_util.c lib/chip/blisp_chip_bl60x.c - lib/chip/blisp_chip_bl70x.c lib/blisp_easy.c) + lib/chip/blisp_chip_bl70x.c) target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/) diff --git a/include/blisp_util.h b/include/blisp_util.h index f1f4d8f..1f00480 100644 --- a/include/blisp_util.h +++ b/include/blisp_util.h @@ -2,35 +2,18 @@ #ifndef _BLISP_UTIL_H #define _BLISP_UTIL_H -#include -#include +#include #ifdef WIN32 -#include +# include #else -#include +# include #endif -static void blisp_dlog(const char* format, ...) -{ - fflush(stdout); - va_list args; - va_start(args, format); - vfprintf(stderr, format, args); - va_end(args); - fputc('\n', stderr); -} +void blisp_dlog(const char* format, ...); +void sleep_ms(int milliseconds); -static void sleep_ms(int milliseconds) { -#ifdef WIN32 - Sleep(milliseconds); -#else - struct timespec ts; - ts.tv_sec = milliseconds / 1000; - ts.tv_nsec = (milliseconds % 1000) * 1000000; - nanosleep(&ts, NULL); -#endif -} +uint32_t crc32_calculate(const void *data, size_t data_len); /** * * Generated on Mon Jan 9 19:56:36 2023 @@ -80,19 +63,4 @@ static const uint32_t crc_table[256] = { 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -static uint32_t crc32_calculate(const void *data, size_t data_len) -{ - uint32_t crc = 0xffffffff; - const unsigned char *d = (const unsigned char *)data; - unsigned int tbl_idx; - - while (data_len--) { - tbl_idx = (crc ^ *d) & 0xff; - crc = (crc_table[tbl_idx] ^ (crc >> 8)) & 0xffffffff; - d++; - } - return (crc & 0xffffffff) ^ 0xffffffff; -} - - -#endif \ No newline at end of file +#endif diff --git a/lib/blisp_util.c b/lib/blisp_util.c new file mode 100644 index 0000000..27bca4f --- /dev/null +++ b/lib/blisp_util.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +#include +#include +#include + +#ifdef WIN32 +# include +#else +# include +#endif + +#include "blisp_util.h" + +void blisp_dlog(const char* format, ...) +{ + fflush(stdout); + va_list args; + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); + fputc('\n', stderr); +} + + +void sleep_ms(int milliseconds) { +#ifdef WIN32 + Sleep(milliseconds); +#else + struct timespec ts; + ts.tv_sec = milliseconds / 1000; + ts.tv_nsec = (milliseconds % 1000) * 1000000; + nanosleep(&ts, NULL); +#endif +} + +uint32_t crc32_calculate(const void *data, size_t data_len) +{ + uint32_t crc = 0xffffffff; + const unsigned char *d = (const unsigned char *)data; + unsigned int tbl_idx; + + while (data_len--) { + tbl_idx = (crc ^ *d) & 0xff; + crc = (crc_table[tbl_idx] ^ (crc >> 8)) & 0xffffffff; + d++; + } + return (crc & 0xffffffff) ^ 0xffffffff; +}