diff options
60 files changed, 652 insertions, 617 deletions
diff --git a/3rd-party/COPYING.wiznet-dhcp.txt b/3rd-party/COPYING.wiznet-dhcp.txt new file mode 100644 index 0000000..363bc9c --- /dev/null +++ b/3rd-party/COPYING.wiznet-dhcp.txt @@ -0,0 +1,60 @@ +----------------------------------------------------------------------------- +https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Internet/DHCP/dhcp.c +https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Internet/DHCP/dhcp.h + +Copyright (c) 2013, WIZnet Co., LTD. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + * Neither the name of the <ORGANIZATION> nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +SPDX-License-Identifier: BSD-3-Clause + +----------------------------------------------------------------------------- +https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/license.txt + +Copyright (c) 2014 WIZnet Co.,Ltd. +Copyright (c) WIZnet ioLibrary Project. +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +SPDX-License-Identifier: MIT diff --git a/3rd-party/pico-fmt b/3rd-party/pico-fmt -Subproject beaecdcba7fdf0d584d245a9d0ad6be6bdc94a1 +Subproject a69f6e22e9bf3da849b128d3a0ed3e77da5997d diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fa048f..659f530 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,12 @@ if ((PICO_PLATFORM STREQUAL "host") AND (NOT PICO_NO_GC_SECTIONS)) add_link_options("LINKER:--gc-sections") endif() +# Use modern C... +set(CMAKE_C_STANDARD 23) +# ... but with some misfeatures disabled. +add_compile_options(-Werror=vla) + +# Have the compiler help detect mistakes. add_compile_options(-Wall -Wextra -Wswitch-enum -Werror) string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_cmake_build_type) @@ -118,7 +124,6 @@ function(add_lib_test arg_libname arg_testname) endfunction() add_subdirectory(libmisc) -add_subdirectory(libobj) add_subdirectory(libfmt) add_subdirectory(libcr) add_subdirectory(libcr_ipc) diff --git a/GNUmakefile b/GNUmakefile index 8636973..e5e59b2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -55,12 +55,14 @@ libusb/include/libusb/tusb_helpers.h 3rd-party/MS-LCID.pdf 3rd-party/MS-LCID.txt generate/files += build-aux/sources.mk ifeq ($(INNER),) +nonsource/files = $(generate/files) +nonsource/files += 3rd-party/COPYING.wiznet-dhcp.txt build-aux/sources.mk: $(if $(wildcard .git),FORCE) - git ls-files | grep -vFx $(foreach f,$(generate/files),-e $f) \ - | sed 's,^,$(CURDIR)/,' | xargs editorconfig \ - | sed -nE -e 's,\[$(CURDIR)/(.*)\],\1,p' -e 's/^_mode=//p' \ - | sed -E '{N;s/(.*)\n(.*)/sources_\2 += \1/;}' \ - | sort \ + git ls-files | grep -vFx $(foreach f,$(nonsource/files),-e $f) \ + | sed 's,^,$(CURDIR)/,' | xargs editorconfig \ + | sed -nE -e 's,\[$(CURDIR)/(.*)\],\1,p' -e 's/^_mode=//p' \ + | sed -E '{N;s/(.*)\n(.*)/sources_\2 += \1/;}' \ + | sort \ >$@.tmp if ! cmp -s $@.tmp $@; then mv $@.tmp $@; fi @echo '################################################################################' @@ -7,11 +7,10 @@ # Source Layout -Our own "flavor" of C: GNU C plus `-fplan9-extensions`, making use of: +Our own "flavor" of C: GNU C, plus making use of: - - `libobj/`: For Go-like object-oriented programming - - `libmisc/`: Low-level C programming utilities; sort of an augmented - "libc" + - `libmisc/`: Low-level C programming utilities (including Go-like + object-oriented programming); sort of an augmented "libc" Our own tiny cooperative-multitasking OS: diff --git a/build-aux/measurestack/app_main.py b/build-aux/measurestack/app_main.py index 7573146..c670325 100644 --- a/build-aux/measurestack/app_main.py +++ b/build-aux/measurestack/app_main.py @@ -27,8 +27,8 @@ def main( # sbc-harness #################################################### - libobj_plugin = app_plugins.LibObjPlugin(arg_c_fnames) - lib9p_plugin = app_plugins.Lib9PPlugin(arg_base_dir, arg_c_fnames, libobj_plugin) + libmisc_plugin = app_plugins.LibMiscPlugin(arg_c_fnames) + lib9p_plugin = app_plugins.Lib9PPlugin(arg_base_dir, arg_c_fnames, libmisc_plugin) def sbc_is_thread(name: QName) -> int: if str(name).endswith("_cr") and name.base() != BaseName("lib9p_srv_read_cr"): @@ -47,13 +47,12 @@ def main( plugins += [ app_plugins.CmdPlugin(), - libobj_plugin, + libmisc_plugin, app_plugins.PicoFmtPlugin(arg_pico_platform), - app_plugins.LibHWPlugin(arg_pico_platform, libobj_plugin), + app_plugins.LibHWPlugin(arg_pico_platform, libmisc_plugin), app_plugins.LibCRPlugin(), app_plugins.LibCRIPCPlugin(), lib9p_plugin, - app_plugins.LibMiscPlugin(), ] # pico-sdk ####################################################### diff --git a/build-aux/measurestack/app_plugins.py b/build-aux/measurestack/app_plugins.py index bbb0eae..ae2dba9 100644 --- a/build-aux/measurestack/app_plugins.py +++ b/build-aux/measurestack/app_plugins.py @@ -14,7 +14,6 @@ from .util import synthetic_node # pylint: disable=unused-variable __all__ = [ "CmdPlugin", - "LibObjPlugin", "LibHWPlugin", "LibCRPlugin", "LibCRIPCPlugin", @@ -66,7 +65,7 @@ re_lo_implementation = re.compile( re_call_objcall = re.compile(r"LO_CALL\((?P<obj>[^,]+), (?P<meth>[^,)]+)[,)].*") -class LibObjPlugin: +class LibMiscPlugin: objcalls: dict[str, set[QName]] # method_name => {method_impls} def __init__(self, arg_c_fnames: typing.Collection[str]) -> None: @@ -120,7 +119,6 @@ class LibObjPlugin: def indirect_callees( self, loc: str, line: str ) -> tuple[typing.Collection[QName], bool] | None: - if "/3rd-party/" in loc: return None if m := re_call_objcall.fullmatch(line): @@ -132,16 +130,29 @@ class LibObjPlugin: return None def skipmodels(self) -> dict[BaseName, analyze.SkipModel]: - return {} + return { + BaseName("__assert_msg_fail"): analyze.SkipModel( + {BaseName("__assert_msg_fail")}, self._skipmodel___assert_msg_fail + ), + } + + def _skipmodel___assert_msg_fail( + self, chain: typing.Sequence[QName], call: QName + ) -> bool: + if call.base() in [BaseName("__lm_printf"), BaseName("__lm_light_printf")]: + return any( + c.base() == BaseName("__assert_msg_fail") for c in reversed(chain[:-1]) + ) + return False class LibHWPlugin: pico_platform: str - libobj: LibObjPlugin + libmisc: LibMiscPlugin - def __init__(self, arg_pico_platform: str, libobj: LibObjPlugin) -> None: + def __init__(self, arg_pico_platform: str, libmisc: LibMiscPlugin) -> None: self.pico_platform = arg_pico_platform - self.libobj = libobj + self.libmisc = libmisc def is_intrhandler(self, name: QName) -> bool: return name.base() in [ @@ -175,11 +186,11 @@ class LibHWPlugin: "io_readwritev", ]: if f"{fn}(" in line: - return self.libobj.indirect_callees(loc, f"LO_CALL(x, {fn[3:]})") + return self.libmisc.indirect_callees(loc, f"LO_CALL(x, {fn[3:]})") if "io_read(" in line: - return self.libobj.indirect_callees(loc, "LO_CALL(x, readv)") + return self.libmisc.indirect_callees(loc, "LO_CALL(x, readv)") if "io_writev(" in line: - return self.libobj.indirect_callees(loc, "LO_CALL(x, writev)") + return self.libmisc.indirect_callees(loc, "LO_CALL(x, writev)") if "trigger->cb(trigger->cb_arg)" in line: ret = [ QName("alarmclock_sleep_intrhandler"), @@ -280,11 +291,11 @@ class Lib9PPlugin: self, arg_base_dir: str, arg_c_fnames: typing.Collection[str], - libobj_plugin: LibObjPlugin, + libmisc_plugin: LibMiscPlugin, ) -> None: self.formatters = { x.base() - for x in libobj_plugin.objcalls["format"] + for x in libmisc_plugin.objcalls["format"] if str(x.base()).startswith("lib9p_") } @@ -426,41 +437,6 @@ class Lib9PPlugin: return False -class LibMiscPlugin: - def is_intrhandler(self, name: QName) -> bool: - return False - - def init_array(self) -> typing.Collection[QName]: - return [] - - def extra_includes(self) -> typing.Collection[BaseName]: - return [] - - def extra_nodes(self) -> typing.Collection[Node]: - return [] - - def indirect_callees( - self, loc: str, line: str - ) -> tuple[typing.Collection[QName], bool] | None: - return None - - def skipmodels(self) -> dict[BaseName, analyze.SkipModel]: - return { - BaseName("__assert_msg_fail"): analyze.SkipModel( - {BaseName("__assert_msg_fail")}, self._skipmodel___assert_msg_fail - ), - } - - def _skipmodel___assert_msg_fail( - self, chain: typing.Sequence[QName], call: QName - ) -> bool: - if call.base() in [BaseName("__lm_printf"), BaseName("__lm_light_printf")]: - return any( - c.base() == BaseName("__assert_msg_fail") for c in reversed(chain[:-1]) - ) - return False - - class PicoFmtPlugin: known_fct: dict[BaseName, BaseName] diff --git a/cmd/sbc_harness/CMakeLists.txt b/cmd/sbc_harness/CMakeLists.txt index 6e722d7..878e151 100644 --- a/cmd/sbc_harness/CMakeLists.txt +++ b/cmd/sbc_harness/CMakeLists.txt @@ -72,10 +72,11 @@ pico_set_program_url(sbc_harness "https://git.lukeshu.com/sbc-harness") target_embed_sources(sbc_harness_objs sbc_harness static.h static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS.md static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/agpl-3.0.txt + static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/dhcp.bsd3-mit.txt + static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/newlib.txt static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/pico-sdk.bsd3.txt static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/printf.mit.txt static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/tinyusb.mit.txt - static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/newlib.txt static/Documentation/harness_rom_bin.txt static/Documentation/harness_flash_bin.txt static/Documentation/harness_uptime_txt.txt diff --git a/cmd/sbc_harness/fs_harness_flash_bin.c b/cmd/sbc_harness/fs_harness_flash_bin.c index 5920b85..f353ddd 100644 --- a/cmd/sbc_harness/fs_harness_flash_bin.c +++ b/cmd/sbc_harness/fs_harness_flash_bin.c @@ -41,7 +41,7 @@ static_assert(DATA_HSIZE % FLASH_SECTOR_SIZE == 0); [[noreturn]] static void __no_inline_not_in_flash_func(ab_flash_finalize)(uint8_t *buf) { assert(buf); - infof("copying upper flash to lower flash..."); + log_infof("copying upper flash to lower flash..."); cr_save_and_disable_interrupts(); @@ -53,7 +53,7 @@ static_assert(DATA_HSIZE % FLASH_SECTOR_SIZE == 0); flash_range_program(off, buf, FLASH_SECTOR_SIZE); } - infof("rebooting..."); + log_infof("rebooting..."); watchdog_reboot(0, 0, 300); @@ -71,7 +71,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) { memset(buf, 0, FLASH_SECTOR_SIZE); - infof("zeroing upper flash..."); + log_infof("zeroing upper flash..."); for (size_t off = DATA_HSIZE; off < DATA_SIZE; off += FLASH_SECTOR_SIZE) { if (memcmp(buf, DATA_START+off, FLASH_SECTOR_SIZE) == 0) continue; @@ -84,7 +84,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) { flash_range_program(off, buf, FLASH_SECTOR_SIZE); cr_restore_interrupts(saved); } - debugf("... zeroed"); + log_debugf("... zeroed"); } /** @@ -95,7 +95,7 @@ static void ab_flash_initialize_zero(uint8_t *buf) { static void ab_flash_initialize(uint8_t *buf) { assert(buf); - infof("initializing upper flash..."); + log_infof("initializing upper flash..."); for (size_t off = 0; off < DATA_HSIZE; off += FLASH_SECTOR_SIZE) { memcpy(buf, DATA_START+off, FLASH_SECTOR_SIZE); if (memcmp(buf, DATA_START+DATA_HSIZE+off, FLASH_SECTOR_SIZE) == 0) @@ -105,7 +105,7 @@ static void ab_flash_initialize(uint8_t *buf) { flash_range_program(DATA_HSIZE+off, buf, FLASH_SECTOR_SIZE); cr_restore_interrupts(saved); } - debugf("... initialized"); + log_debugf("... initialized"); } /** @@ -123,14 +123,14 @@ static void ab_flash_write_sector(size_t pos, uint8_t *dat) { pos += DATA_HSIZE; - infof("write flash sector @ %zu...", pos); + log_infof("write flash sector @ %zu...", pos); if (memcmp(dat, DATA_START+pos, FLASH_SECTOR_SIZE) != 0) { bool saved = cr_save_and_disable_interrupts(); flash_range_erase(pos, FLASH_SECTOR_SIZE); flash_range_program(pos, dat, FLASH_SECTOR_SIZE); cr_restore_interrupts(saved); } - debugf("... written"); + log_debugf("... written"); } /* srv_file *******************************************************************/ diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 5630e83..b6f485f 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -71,6 +71,12 @@ struct lib9p_srv_file root = STATIC_FILE("agpl-3.0.txt", .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_agpl_3_0_txt_start, .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_agpl_3_0_txt_end), + STATIC_FILE("dhcp.bsd3-mit.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_dhcp_bsd3_mit_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_dhcp_bsd3_mit_txt_end), + STATIC_FILE("newlib.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_end), STATIC_FILE("pico-sdk.bsd3.txt", .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_start, .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_end), @@ -80,9 +86,6 @@ struct lib9p_srv_file root = STATIC_FILE("tinyusb.mit.txt", .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_start, .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_end), - STATIC_FILE("newlib.txt", - .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_start, - .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_end), ), STATIC_FILE("harness_rom_bin.txt", .data_start = _binary_static_Documentation_harness_rom_bin_txt_start, @@ -129,7 +132,7 @@ static COROUTINE hello_world_cr(void *_chan) { for (size_t i = 0;; i = (i+1) % strlen(msg)) { int result = usb_keyboard_rpc_send_req(chan, (uint32_t)msg[i]); if (result < 1) { - errorf("error sending rune U+%d", (uint32_t)msg[i]); + log_errorf("error sending rune U+%d", (uint32_t)msg[i]); break; } } @@ -246,7 +249,7 @@ int main() { bootclock = rp2040_hwtimer(0); stdio_uart_init(); /* char *hdr = "=" * (80-strlen("info : MAIN: ")); */ - infof("==================================================================="); + log_infof("==================================================================="); coroutine_add("init", init_cr, NULL); coroutine_main(); assert_notreached("all coroutines exited"); diff --git a/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/dhcp.bsd3-mit.txt b/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/dhcp.bsd3-mit.txt new file mode 120000 index 0000000..0277bc8 --- /dev/null +++ b/cmd/sbc_harness/static/Documentation/YOUR_RIGHTS_AND_OBLIGATIONS/dhcp.bsd3-mit.txt @@ -0,0 +1 @@ +../../../../../3rd-party/COPYING.wiznet-dhcp.txt
\ No newline at end of file diff --git a/cmd/sbc_harness/tusb_log.c b/cmd/sbc_harness/tusb_log.c index 4c6b7df..fe2c688 100644 --- a/cmd/sbc_harness/tusb_log.c +++ b/cmd/sbc_harness/tusb_log.c @@ -1,6 +1,6 @@ /* sbc_harness/tusb_log.c - Logger for tusb_config.h * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -9,7 +9,7 @@ void _libmisc_tu_mess_failed(const char *expr, const char *file, unsigned int line, const char *func) { - errorf("%s:%u:%s(): assertion \"%s\" failed", - file, line, func, - expr); + log_errorf("%s:%u:%s(): assertion \"%s\" failed", + file, line, func, + expr); } diff --git a/lib9p/core_gen/c.py b/lib9p/core_gen/c.py index b0ff871..393766b 100644 --- a/lib9p/core_gen/c.py +++ b/lib9p/core_gen/c.py @@ -23,7 +23,6 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: ret = f"""/* Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */ -#include <stdbool.h> #include <stddef.h> /* for size_t */ #include <inttypes.h> /* for PRI* macros */ #include <string.h> /* for memset() */ @@ -36,9 +35,9 @@ def gen_c(versions: set[str], typs: list[idl.UserType]) -> str: #include "core_tables.h" #include "core_utf8.h" """ - # libobj vtables ########################################################### + # libmisc/obj.h vtables #################################################### ret += """ -/* libobj vtables *************************************************************/ +/* libmisc/obj.h vtables ******************************************************/ """ for typ in typs: ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions)) diff --git a/lib9p/core_gen/c_unmarshal.py b/lib9p/core_gen/c_unmarshal.py index 1afbe1d..206a85b 100644 --- a/lib9p/core_gen/c_unmarshal.py +++ b/lib9p/core_gen/c_unmarshal.py @@ -123,9 +123,9 @@ def gen_c_unmarshal(versions: set[str], typs: list[idl.UserType]) -> str: assert isinstance(typ, idl.Struct) ret += "\n" ret += cutil.ifdef_push(1, c9util.ver_ifdef(typ.in_versions)) - ret += f"static void unmarshal_{typ.typname}([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {{\n" + ret += f"static void unmarshal_{typ.typname}([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) {{\n" ret += f"\t{c9util.typename(typ)} *out = out_buf;\n" - ret += "\t[[gnu::unused]] void *extra = &out[1];\n" + ret += "\t[[maybe_unused]] void *extra = &out[1];\n" ret += "\tuint32_t net_offset = 0;\n" indent_stack = [IndentLevel(ifdef=True)] diff --git a/lib9p/core_generated.c b/lib9p/core_generated.c index 1de7c67..2532d12 100644 --- a/lib9p/core_generated.c +++ b/lib9p/core_generated.c @@ -1,6 +1,5 @@ /* Generated by `lib9p/core.gen lib9p/idl/0000-uninitialized.9p lib9p/idl/2002-9P2000.9p lib9p/idl/2003-9P2000.p9p.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2010-9P2000.L.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */ -#include <stdbool.h> #include <stddef.h> /* for size_t */ #include <inttypes.h> /* for PRI* macros */ #include <string.h> /* for memset() */ @@ -13,7 +12,7 @@ #include "core_tables.h" #include "core_utf8.h" -/* libobj vtables *************************************************************/ +/* libmisc/obj.h vtables ******************************************************/ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized LO_IMPLEMENTATION_C(fmt_formatter, lib9p_tag_t, lib9p_tag, static); LO_IMPLEMENTATION_C(fmt_formatter, lib9p_fid_t, lib9p_fid, static); @@ -1931,9 +1930,9 @@ static ssize_t validate_Rswrite(struct lib9p_ctx *ctx, uint32_t net_size, uint8_ net_offset += 8; #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_stat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_stat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_stat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 2; UNMARSHAL_U16LE(ctx, out->fstype); @@ -1966,9 +1965,9 @@ static void unmarshal_stat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_b #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void unmarshal_Tversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tversion([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tversion *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -1978,9 +1977,9 @@ static void unmarshal_Tversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_BYTES(ctx, out->version.utf8, out->version.len); } -static void unmarshal_Rversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rversion([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rversion *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -1992,9 +1991,9 @@ static void unmarshal_Rversion([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tauth([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tauth *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2011,9 +2010,9 @@ static void unmarshal_Tauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ } -static void unmarshal_Rauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rauth([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rauth *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2023,9 +2022,9 @@ static void unmarshal_Rauth([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U64LE(ctx, out->aqid.path); } -static void unmarshal_Tattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tattach([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tattach *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2043,9 +2042,9 @@ static void unmarshal_Tattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #endif /* CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_u */ } -static void unmarshal_Rattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rattach([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rattach *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2057,9 +2056,9 @@ static void unmarshal_Rattach([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized -static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rerror([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rerror *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2075,9 +2074,9 @@ static void unmarshal_Rerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_uninitialized */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tflush([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tflush *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2085,18 +2084,18 @@ static void unmarshal_Tflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U16LE(ctx, out->oldtag); } -static void unmarshal_Rflush([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rflush([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rflush *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Twalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Twalk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Twalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2112,9 +2111,9 @@ static void unmarshal_Twalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ } } -static void unmarshal_Rwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2131,9 +2130,9 @@ static void unmarshal_Rwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Topen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Topen([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Topen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2142,9 +2141,9 @@ static void unmarshal_Topen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U8LE(ctx, out->mode); } -static void unmarshal_Ropen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Ropen([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Ropen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2155,9 +2154,9 @@ static void unmarshal_Ropen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U32LE(ctx, out->iounit); } -static void unmarshal_Tcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2169,9 +2168,9 @@ static void unmarshal_Tcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U8LE(ctx, out->mode); } -static void unmarshal_Rcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2184,9 +2183,9 @@ static void unmarshal_Rcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tread([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2196,9 +2195,9 @@ static void unmarshal_Tread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U32LE(ctx, out->count); } -static void unmarshal_Rread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rread([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2207,9 +2206,9 @@ static void unmarshal_Rread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_BYTES(ctx, out->data, out->count); } -static void unmarshal_Twrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Twrite([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Twrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2220,9 +2219,9 @@ static void unmarshal_Twrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_BYTES(ctx, out->data, out->count); } -static void unmarshal_Rwrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rwrite([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rwrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2230,9 +2229,9 @@ static void unmarshal_Rwrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->count); } -static void unmarshal_Tclunk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tclunk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tclunk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2240,18 +2239,18 @@ static void unmarshal_Tclunk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->fid); } -static void unmarshal_Rclunk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rclunk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rclunk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Tremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tremove([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tremove *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2259,9 +2258,9 @@ static void unmarshal_Tremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U32LE(ctx, out->fid); } -static void unmarshal_Rremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rremove([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rremove *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2270,9 +2269,9 @@ static void unmarshal_Rremove([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_L || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u -static void unmarshal_Tstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tstat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2280,9 +2279,9 @@ static void unmarshal_Tstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U32LE(ctx, out->fid); } -static void unmarshal_Rstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rstat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2317,9 +2316,9 @@ static void unmarshal_Rstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -static void unmarshal_Twstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Twstat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Twstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2355,9 +2354,9 @@ static void unmarshal_Twstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net #endif /* CONFIG_9P_ENABLE_9P2000_u */ } -static void unmarshal_Rwstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rwstat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rwstat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2366,9 +2365,9 @@ static void unmarshal_Rwstat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net #endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_p9p || CONFIG_9P_ENABLE_9P2000_u */ #if CONFIG_9P_ENABLE_9P2000_p9p -static void unmarshal_Topenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Topenfd([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Topenfd *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2377,9 +2376,9 @@ static void unmarshal_Topenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U8LE(ctx, out->mode); } -static void unmarshal_Ropenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Ropenfd([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Ropenfd *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2393,9 +2392,9 @@ static void unmarshal_Ropenfd([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne #endif /* CONFIG_9P_ENABLE_9P2000_p9p */ #if CONFIG_9P_ENABLE_9P2000_L -static void unmarshal_Rlerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rlerror([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rlerror *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2403,9 +2402,9 @@ static void unmarshal_Rlerror([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U32LE(ctx, out->errnum); } -static void unmarshal_Tstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tstatfs([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tstatfs *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2413,9 +2412,9 @@ static void unmarshal_Tstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U32LE(ctx, out->fid); } -static void unmarshal_Rstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rstatfs([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rstatfs *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2431,9 +2430,9 @@ static void unmarshal_Rstatfs([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_U32LE(ctx, out->namelen); } -static void unmarshal_Tlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tlopen([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tlopen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2442,9 +2441,9 @@ static void unmarshal_Tlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->flags); } -static void unmarshal_Rlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rlopen([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rlopen *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2455,9 +2454,9 @@ static void unmarshal_Rlopen([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->iounit); } -static void unmarshal_Tlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tlcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tlcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2470,9 +2469,9 @@ static void unmarshal_Tlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U32LE(ctx, out->gid); } -static void unmarshal_Rlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rlcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rlcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2483,9 +2482,9 @@ static void unmarshal_Rlcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U32LE(ctx, out->iounit); } -static void unmarshal_Tsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tsymlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tsymlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2498,9 +2497,9 @@ static void unmarshal_Tsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U32LE(ctx, out->gid); } -static void unmarshal_Rsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rsymlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rsymlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2510,9 +2509,9 @@ static void unmarshal_Rsymlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U64LE(ctx, out->qid.path); } -static void unmarshal_Tmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tmknod([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tmknod *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2526,9 +2525,9 @@ static void unmarshal_Tmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->gid); } -static void unmarshal_Rmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rmknod([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rmknod *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2538,9 +2537,9 @@ static void unmarshal_Rmknod([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U64LE(ctx, out->qid.path); } -static void unmarshal_Trename([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Trename([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Trename *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2551,18 +2550,18 @@ static void unmarshal_Trename([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); } -static void unmarshal_Rrename([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rrename([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rrename *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Treadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Treadlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Treadlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2570,9 +2569,9 @@ static void unmarshal_Treadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t * UNMARSHAL_U32LE(ctx, out->fid); } -static void unmarshal_Rreadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rreadlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rreadlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2581,9 +2580,9 @@ static void unmarshal_Rreadlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t * UNMARSHAL_BYTES(ctx, out->target.utf8, out->target.len); } -static void unmarshal_Tgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tgetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tgetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2592,9 +2591,9 @@ static void unmarshal_Tgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U64LE(ctx, out->request_mask); } -static void unmarshal_Rgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rgetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rgetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2623,9 +2622,9 @@ static void unmarshal_Rgetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U64LE(ctx, out->data_version); } -static void unmarshal_Tsetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tsetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tsetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2642,18 +2641,18 @@ static void unmarshal_Tsetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U64LE(ctx, out->mtime_nsec); } -static void unmarshal_Rsetattr([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rsetattr([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rsetattr *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Txattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Txattrwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Txattrwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2664,9 +2663,9 @@ static void unmarshal_Txattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); } -static void unmarshal_Rxattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rxattrwalk([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rxattrwalk *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2674,9 +2673,9 @@ static void unmarshal_Rxattrwalk([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t UNMARSHAL_U64LE(ctx, out->attr_size); } -static void unmarshal_Txattrcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Txattrcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Txattrcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2688,18 +2687,18 @@ static void unmarshal_Txattrcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_ UNMARSHAL_U32LE(ctx, out->flags); } -static void unmarshal_Rxattrcreate([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rxattrcreate([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rxattrcreate *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Treaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Treaddir([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Treaddir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2709,9 +2708,9 @@ static void unmarshal_Treaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U32LE(ctx, out->count); } -static void unmarshal_Rreaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rreaddir([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rreaddir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2720,9 +2719,9 @@ static void unmarshal_Rreaddir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_BYTES(ctx, out->data, out->count); } -static void unmarshal_Tfsync([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tfsync([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tfsync *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2731,18 +2730,18 @@ static void unmarshal_Tfsync([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->datasync); } -static void unmarshal_Rfsync([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rfsync([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rfsync *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Tlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tlock([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2757,9 +2756,9 @@ static void unmarshal_Tlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); } -static void unmarshal_Rlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rlock([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2767,9 +2766,9 @@ static void unmarshal_Rlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_U8LE(ctx, out->status); } -static void unmarshal_Tgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tgetlock([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tgetlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2783,9 +2782,9 @@ static void unmarshal_Tgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); } -static void unmarshal_Rgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rgetlock([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rgetlock *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2798,9 +2797,9 @@ static void unmarshal_Rgetlock([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_BYTES(ctx, out->client_id.utf8, out->client_id.len); } -static void unmarshal_Tlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2811,18 +2810,18 @@ static void unmarshal_Tlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_ UNMARSHAL_BYTES(ctx, out->name.utf8, out->name.len); } -static void unmarshal_Rlink([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rlink([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rlink *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Tmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tmkdir([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tmkdir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2834,9 +2833,9 @@ static void unmarshal_Tmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U32LE(ctx, out->gid); } -static void unmarshal_Rmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rmkdir([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rmkdir *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2846,9 +2845,9 @@ static void unmarshal_Rmkdir([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_U64LE(ctx, out->qid.path); } -static void unmarshal_Trenameat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Trenameat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Trenameat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2861,18 +2860,18 @@ static void unmarshal_Trenameat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t * UNMARSHAL_BYTES(ctx, out->newname.utf8, out->newname.len); } -static void unmarshal_Rrenameat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rrenameat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rrenameat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Tunlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tunlinkat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tunlinkat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2883,9 +2882,9 @@ static void unmarshal_Tunlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t * UNMARSHAL_U32LE(ctx, out->flags); } -static void unmarshal_Runlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Runlinkat([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Runlinkat *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2894,9 +2893,9 @@ static void unmarshal_Runlinkat([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t * #endif /* CONFIG_9P_ENABLE_9P2000_L */ #if CONFIG_9P_ENABLE_9P2000_e -static void unmarshal_Tsession([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tsession([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tsession *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2904,18 +2903,18 @@ static void unmarshal_Tsession([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *n UNMARSHAL_U64LE(ctx, out->key); } -static void unmarshal_Rsession([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rsession([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rsession *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; UNMARSHAL_U16LE(ctx, out->tag); } -static void unmarshal_Tsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tsread([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tsread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2930,9 +2929,9 @@ static void unmarshal_Tsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net } } -static void unmarshal_Rsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rsread([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rsread *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2941,9 +2940,9 @@ static void unmarshal_Rsread([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net UNMARSHAL_BYTES(ctx, out->data, out->count); } -static void unmarshal_Tswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Tswrite([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Tswrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; @@ -2960,9 +2959,9 @@ static void unmarshal_Tswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *ne UNMARSHAL_BYTES(ctx, out->data, out->count); } -static void unmarshal_Rswrite([[gnu::unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { +static void unmarshal_Rswrite([[maybe_unused]] struct lib9p_ctx *ctx, uint8_t *net_bytes, void *out_buf) { struct lib9p_msg_Rswrite *out = out_buf; - [[gnu::unused]] void *extra = &out[1]; + [[maybe_unused]] void *extra = &out[1]; uint32_t net_offset = 0; net_offset += 4; net_offset += 1; diff --git a/lib9p/core_include/lib9p/core.h b/lib9p/core_include/lib9p/core.h index 549411f..aa470de 100644 --- a/lib9p/core_include/lib9p/core.h +++ b/lib9p/core_include/lib9p/core.h @@ -7,7 +7,6 @@ #ifndef _LIB9P_CORE_H_ #define _LIB9P_CORE_H_ -#include <stdbool.h> #include <sys/types.h> /* for ssize_t */ #include <libmisc/assert.h> diff --git a/lib9p/srv.c b/lib9p/srv.c index 6d9d992..12124af 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -54,12 +54,12 @@ void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { ctx->flush_acknowledged = true; } -#define req_debugf(fmt, ...) \ - debugf("cid=%zu: %s(tag=%"PRIu16"): " fmt, \ - cr_getcid(), \ - lib9p_msgtype_str(ctx->basectx.version, ctx->net_bytes[4]), \ - ctx->tag \ - __VA_OPT__(,) __VA_ARGS__) +#define req_debugf(fmt, ...) \ + log_debugf("cid=%zu: %s(tag=%"PRIu16"): " fmt, \ + cr_getcid(), \ + lib9p_msgtype_str(ctx->basectx.version, ctx->net_bytes[4]), \ + ctx->tag \ + __VA_OPT__(,) __VA_ARGS__) /* structs ********************************************************************/ @@ -176,7 +176,7 @@ static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_srv_stat *st return mode & action; } -[[gnu::unused]] +[[maybe_unused]] static struct lib9p_srv_userid *srv_userid_new(struct lib9p_s name #if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L , lib9p_nuid_t num @@ -361,7 +361,7 @@ static void srv_msglog(struct srv_req *req, enum lib9p_msg_type typ, void *hostm #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat" #pragma GCC diagnostic ignored "-Wformat-extra-args" - infof("%c %v", typ % 2 ? '<' : '>', lo_box_lib9p_msg_as_fmt_formatter(&req->basectx, typ, hostmsg)); + log_infof("%c %v", typ % 2 ? '<' : '>', lo_box_lib9p_msg_as_fmt_formatter(&req->basectx, typ, hostmsg)); #pragma GCC diagnostic pop } @@ -373,7 +373,7 @@ static ssize_t srv_write_Rmsg(struct srv_req *req, struct lib9p_Rmsg_send_buf *r return r; } -#define srv_nonrespond_errorf errorf +#define srv_nonrespond_errorf log_errorf static void srv_respond_error(struct srv_req *req) { #if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L @@ -707,10 +707,10 @@ static inline void _srv_respond(struct srv_req *ctx, enum lib9p_msg_type resp_ty /* handle_T* ******************************************************************/ -#define srv_handler_common(ctx, typ, req) \ - assert(ctx); \ - assert(req); \ - struct lib9p_msg_T##typ *_typecheck_req [[gnu::unused]] = req; \ +#define srv_handler_common(ctx, typ, req) \ + assert(ctx); \ + assert(req); \ + struct lib9p_msg_T##typ *_typecheck_req [[maybe_unused]] = req; \ struct lib9p_msg_R##typ resp = { .tag = ctx->tag } static void handle_Tversion(struct srv_req *ctx, diff --git a/lib9p/srv_include/lib9p/srv.h b/lib9p/srv_include/lib9p/srv.h index ca80e7b..c40c85a 100644 --- a/lib9p/srv_include/lib9p/srv.h +++ b/lib9p/srv_include/lib9p/srv.h @@ -12,8 +12,8 @@ #include <libcr_ipc/rpc.h> #include <libhw/generic/net.h> #include <libmisc/assert.h> +#include <libmisc/obj.h> #include <libmisc/private.h> -#include <libobj/obj.h> #include <lib9p/core.h> diff --git a/lib9p/tests/test_compile.c b/lib9p/tests/test_compile.c index e53b738..e814bf9 100644 --- a/lib9p/tests/test_compile.c +++ b/lib9p/tests/test_compile.c @@ -2,7 +2,7 @@ #include <lib9p/core.h> int main(void) { - [[gnu::unused]] uint64_t x; + [[maybe_unused]] uint64_t x; #ifdef LIB9P_B4_FALSE x = LIB9P_B4_FALSE; #endif diff --git a/lib9p/tests/test_compile.c.gen b/lib9p/tests/test_compile.c.gen index eb89c54..c57ce9f 100755 --- a/lib9p/tests/test_compile.c.gen +++ b/lib9p/tests/test_compile.c.gen @@ -12,7 +12,7 @@ outfile=$2 echo echo "#include <lib9p/core.h>" echo 'int main(void) {' - echo ' [[gnu::unused]] uint64_t x;' + echo ' [[maybe_unused]] uint64_t x;' <"$generated_h" sed -nE 's/^\s*#\s*define\s*(\S[^ (]*)\s.*/\1/p' | LC_COLLATE=C sort -u | sed 's/.*/#ifdef &\n x = &;\n#endif/' echo ' return 0;' echo '}' diff --git a/lib9p_util/include/util9p/static.h b/lib9p_util/include/util9p/static.h index 0b391b8..5454c24 100644 --- a/lib9p_util/include/util9p/static.h +++ b/lib9p_util/include/util9p/static.h @@ -20,7 +20,7 @@ /* Common *********************************************************************/ -typedef struct { +struct _util9p_static_common { char *u_name; uint32_t u_num; char *g_name; @@ -32,7 +32,7 @@ typedef struct { char *name; lib9p_dm_t perm; uint32_t atime, mtime; -} _util9p_static_common; +}; #define UTIL9P_STATIC_COMMON(PATH, STRNAME, MODE) \ { \ @@ -50,7 +50,7 @@ typedef struct { /* Dir ************************************************************************/ struct util9p_static_dir { - _util9p_static_common; + struct _util9p_static_common c; /* NULL-terminated */ lo_interface lib9p_srv_file members[]; @@ -58,16 +58,16 @@ struct util9p_static_dir { LO_IMPLEMENTATION_H(lib9p_srv_file, struct util9p_static_dir, util9p_static_dir); #define lo_box_util9p_static_dir_as_lib9p_srv_file(obj) util9p_box(util9p_static_dir, obj) -#define UTIL9P_STATIC_DIR(PATH, STRNAME, ...) \ - lo_box_util9p_static_dir_as_lib9p_srv_file(&((struct util9p_static_dir){ \ - ._util9p_static_common = UTIL9P_STATIC_COMMON(PATH, STRNAME, 0555), \ - .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ +#define UTIL9P_STATIC_DIR(PATH, STRNAME, ...) \ + lo_box_util9p_static_dir_as_lib9p_srv_file(&((struct util9p_static_dir){ \ + .c = UTIL9P_STATIC_COMMON(PATH, STRNAME, 0555), \ + .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ })) /* File ***********************************************************************/ struct util9p_static_file { - _util9p_static_common; + struct _util9p_static_common c; char *data_start; /* must not be NULL */ char *data_end; /* may be NULL, in which case data_size is used */ @@ -76,10 +76,10 @@ struct util9p_static_file { LO_IMPLEMENTATION_H(lib9p_srv_file, struct util9p_static_file, util9p_static_file); #define lo_box_util9p_static_file_as_lib9p_srv_file(obj) util9p_box(util9p_static_file, obj) -#define UTIL9P_STATIC_FILE(PATH, STRNAME, ...) \ - lo_box_util9p_static_file_as_lib9p_srv_file(&((struct util9p_static_file){ \ - ._util9p_static_common = UTIL9P_STATIC_COMMON(PATH, STRNAME, 0444), \ - __VA_ARGS__ \ +#define UTIL9P_STATIC_FILE(PATH, STRNAME, ...) \ + lo_box_util9p_static_file_as_lib9p_srv_file(&((struct util9p_static_file){ \ + .c = UTIL9P_STATIC_COMMON(PATH, STRNAME, 0444), \ + __VA_ARGS__ \ })) #endif /* _UTIL9P_STATIC_H_ */ diff --git a/lib9p_util/static.c b/lib9p_util/static.c index 1726319..c35d28c 100644 --- a/lib9p_util/static.c +++ b/lib9p_util/static.c @@ -29,7 +29,7 @@ static struct lib9p_qid util9p_static_dir_qid(struct util9p_static_dir *self) { return (struct lib9p_qid){ .type = LIB9P_QT_DIR, .vers = 1, - .path = self->pathnum, + .path = self->c.pathnum, }; } @@ -39,14 +39,14 @@ static struct lib9p_srv_stat util9p_static_dir_stat(struct util9p_static_dir *se return (struct lib9p_srv_stat){ .qid = util9p_static_dir_qid(self), - .mode = LIB9P_DM_DIR | (self->perm & 0555), - .atime_sec = self->atime, - .mtime_sec = self->mtime, + .mode = LIB9P_DM_DIR | (self->c.perm & 0555), + .atime_sec = self->c.atime, + .mtime_sec = self->c.mtime, .size = 0, - .name = lib9p_str(self->name), - .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num }, - .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num }, - .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num }, + .name = lib9p_str(self->c.name), + .owner_uid = { .name = lib9p_str(self->c.u_name), .num = self->c.u_num }, + .owner_gid = { .name = lib9p_str(self->c.g_name), .num = self->c.g_num }, + .last_modifier_uid = { .name = lib9p_str(self->c.m_name), .num = self->c.m_num }, .extension = lib9p_str(NULL), }; } @@ -135,7 +135,7 @@ static struct lib9p_qid util9p_static_file_qid(struct util9p_static_file *self) return (struct lib9p_qid){ .type = LIB9P_QT_FILE, .vers = 1, - .path = self->pathnum, + .path = self->c.pathnum, }; } @@ -157,14 +157,14 @@ static struct lib9p_srv_stat util9p_static_file_stat(struct util9p_static_file * return (struct lib9p_srv_stat){ .qid = util9p_static_file_qid(self), - .mode = self->perm & 0444, - .atime_sec = self->atime, - .mtime_sec = self->mtime, + .mode = self->c.perm & 0444, + .atime_sec = self->c.atime, + .mtime_sec = self->c.mtime, .size = (uint64_t)util9p_static_file_size(self), - .name = lib9p_str(self->name), - .owner_uid = { .name = lib9p_str(self->u_name), .num = self->u_num }, - .owner_gid = { .name = lib9p_str(self->g_name), .num = self->g_num }, - .last_modifier_uid = { .name = lib9p_str(self->m_name), .num = self->m_num }, + .name = lib9p_str(self->c.name), + .owner_uid = { .name = lib9p_str(self->c.u_name), .num = self->c.u_num }, + .owner_gid = { .name = lib9p_str(self->c.g_name), .num = self->c.g_num }, + .last_modifier_uid = { .name = lib9p_str(self->c.m_name), .num = self->c.m_num }, .extension = lib9p_str(NULL), }; } diff --git a/libcr/coroutine.c b/libcr/coroutine.c index bf44219..cf63122 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -349,7 +349,7 @@ static_assert(CONFIG_COROUTINE_NUM > 1); uintptr_t sp; #endif } cr_plat_jmp_buf; - static void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[gnu::unused]]) { + static void _cr_plat_setjmp_pre(cr_plat_jmp_buf *env [[maybe_unused]]) { #if CONFIG_COROUTINE_MEASURE_STACK env->sp = cr_plat_get_sp(); #endif @@ -556,8 +556,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, assert_cid_state(parent, state == CR_RUNNING); assert(stack_size); assert(fn); - debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...", - stack_size, name, fn, args); + log_debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...", + stack_size, name, fn, args); if (!coroutine_initialized) { cr_plat_init(); @@ -567,7 +567,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cid_t child = coroutine_allocate_cid(); if (!child) return 0; - debugf("...child=%zu", child); + log_debugf("...child=%zu", child); /* 1. state *************************************************/ coroutine_table[child-1].state = CR_INITIALIZING; @@ -580,13 +580,13 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, /* 3. stack *************************************************/ coroutine_table[child-1].stack_size = stack_size + 2*CR_STACK_GUARD_SIZE; - infof("allocing \"%s\" stack with size %zu+2*%zu=%zu", - name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size); + log_infof("allocing \"%s\" stack with size %zu+2*%zu=%zu", + name, stack_size, CR_STACK_GUARD_SIZE, coroutine_table[child-1].stack_size); coroutine_table[child-1].stack = aligned_alloc(CR_PLAT_STACK_ALIGNMENT, coroutine_table[child-1].stack_size); - infof("... done, stack is [0x%p,0x%p)", - coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE, - coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size); + log_infof("... done, stack is [0x%p,0x%p)", + coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE, + coroutine_table[child-1].stack + CR_STACK_GUARD_SIZE + stack_size); #if CONFIG_COROUTINE_MEASURE_STACK || CONFIG_COROUTINE_PROTECT_STACK for (size_t i = 0; i < coroutine_table[child-1].stack_size; i++) ((uint8_t *)coroutine_table[child-1].stack)[i] = @@ -608,8 +608,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, + stack_size #endif ; - debugf("...stack =%p", coroutine_table[child-1].stack); - debugf("...stack_base=%p", stack_base); + log_debugf("...stack =%p", coroutine_table[child-1].stack); + log_debugf("...stack_base=%p", stack_base); /* run until cr_begin() */ cr_plat_call_with_stack(stack_base, fn, args); assert_notreached("should cr_begin() instead of returning"); @@ -630,7 +630,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, /* coroutine_main() ***********************************************************/ void coroutine_main(void) { - debugf("coroutine_main()"); + log_debugf("coroutine_main()"); if (!coroutine_initialized) { cr_plat_init(); coroutine_initialized = true; @@ -675,7 +675,7 @@ void coroutine_main(void) { /* cr_*() *********************************************************************/ void cr_begin(void) { - debugf("cid=%zu: cr_begin()", coroutine_running); + log_debugf("cid=%zu: cr_begin()", coroutine_running); assert_cid_state(coroutine_running, state == CR_INITIALIZING); bool saved = cr_save_and_disable_interrupts(); @@ -707,7 +707,7 @@ static inline void _cr_yield() { } void cr_yield(void) { - debugf("cid=%zu: cr_yield()", coroutine_running); + log_debugf("cid=%zu: cr_yield()", coroutine_running); assert(!cr_plat_is_in_intrhandler()); assert_cid_state(coroutine_running, state == CR_RUNNING); @@ -719,7 +719,7 @@ void cr_yield(void) { } void cr_pause_and_yield(void) { - debugf("cid=%zu: cr_pause_and_yield()", coroutine_running); + log_debugf("cid=%zu: cr_pause_and_yield()", coroutine_running); assert(!cr_plat_is_in_intrhandler()); assert_cid_state(coroutine_running, state == CR_RUNNING); @@ -730,7 +730,7 @@ void cr_pause_and_yield(void) { } [[noreturn]] void cr_exit(void) { - debugf("cid=%zu: cr_exit()", coroutine_running); + log_debugf("cid=%zu: cr_exit()", coroutine_running); assert(!cr_plat_is_in_intrhandler()); assert_cid_state(coroutine_running, state == CR_RUNNING); @@ -747,7 +747,7 @@ static void _cr_unpause(cid_t cid) { } void cr_unpause(cid_t cid) { - debugf("cr_unpause(%zu)", cid); + log_debugf("cr_unpause(%zu)", cid); assert(!cr_plat_is_in_intrhandler()); assert_cid_state(coroutine_running, state == CR_RUNNING); @@ -757,7 +757,7 @@ void cr_unpause(cid_t cid) { } void cr_unpause_from_intrhandler(cid_t cid) { - debugf("cr_unpause_from_intrhandler(%zu)", cid); + log_debugf("cr_unpause_from_intrhandler(%zu)", cid); assert(cr_plat_is_in_intrhandler()); _cr_unpause(cid); diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index 2505782..f72dc96 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -27,7 +27,6 @@ #define _LIBCR_COROUTINE_H_ #include <stddef.h> /* for size_t */ -#include <stdbool.h> /* for bool */ /* Configuration **************************************************************/ diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h index c57979a..09d269f 100644 --- a/libcr_ipc/include/libcr_ipc/chan.h +++ b/libcr_ipc/include/libcr_ipc/chan.h @@ -7,7 +7,6 @@ #ifndef _LIBCR_IPC_CHAN_H_ #define _LIBCR_IPC_CHAN_H_ -#include <stdbool.h> /* for bool */ #include <stddef.h> /* for size_t */ #include <libmisc/linkedlist.h> /* for DLIST_DECLARE() */ diff --git a/libcr_ipc/include/libcr_ipc/mutex.h b/libcr_ipc/include/libcr_ipc/mutex.h index e5f43c8..05a6b2e 100644 --- a/libcr_ipc/include/libcr_ipc/mutex.h +++ b/libcr_ipc/include/libcr_ipc/mutex.h @@ -7,8 +7,6 @@ #ifndef _LIBCR_IPC_MUTEX_H_ #define _LIBCR_IPC_MUTEX_H_ -#include <stdbool.h> /* for bool */ - #include <libmisc/linkedlist.h> /* for SLIST_DECLARE() */ #include <libmisc/private.h> diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h index bfa0a04..c5336cd 100644 --- a/libcr_ipc/include/libcr_ipc/rpc.h +++ b/libcr_ipc/include/libcr_ipc/rpc.h @@ -7,8 +7,6 @@ #ifndef _LIBCR_IPC_RPC_H_ #define _LIBCR_IPC_RPC_H_ -#include <stdbool.h> /* for bool */ - #include <libmisc/linkedlist.h> /* for SLIST_DECLARE() */ /** diff --git a/libcr_ipc/include/libcr_ipc/rwmutex.h b/libcr_ipc/include/libcr_ipc/rwmutex.h index 8ccae63..12ee863 100644 --- a/libcr_ipc/include/libcr_ipc/rwmutex.h +++ b/libcr_ipc/include/libcr_ipc/rwmutex.h @@ -7,8 +7,6 @@ #ifndef _LIBCR_IPC_RWMUTEX_H_ #define _LIBCR_IPC_RWMUTEX_H_ -#include <stdbool.h> - #include <libmisc/linkedlist.h> /* for SLIST_DECLARE() */ #include <libmisc/private.h> diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h index 8b5ac5b..236e9af 100644 --- a/libcr_ipc/include/libcr_ipc/sema.h +++ b/libcr_ipc/include/libcr_ipc/sema.h @@ -7,8 +7,6 @@ #ifndef _LIBCR_IPC_SEMA_H_ #define _LIBCR_IPC_SEMA_H_ -#include <stdbool.h> - #include <libmisc/linkedlist.h> /* for SLIST_DECLARE() */ #include <libmisc/private.h> diff --git a/libdhcp/dhcp_client.c b/libdhcp/dhcp_client.c index 8ec3647..2d0ebe6 100644 --- a/libdhcp/dhcp_client.c +++ b/libdhcp/dhcp_client.c @@ -460,11 +460,11 @@ static bool dhcp_client_send(struct dhcp_client *client, uint8_t msgtyp, const c /**********************************************************************\ * Send * \**********************************************************************/ - debugf("state %s: sending DHCP %s", state_strs[client->state], dhcp_msgtyp_str(msgtyp)); + log_debugf("state %s: sending DHCP %s", state_strs[client->state], dhcp_msgtyp_str(msgtyp)); ssize_t r = LO_CALL(client->sock, sendto, scratch_msg, DHCP_MSG_BASE_SIZE + optlen, client_broadcasts ? net_ip4_addr_broadcast : client->lease_server_id, DHCP_PORT_SERVER); if (r < 0) { - debugf("error: sendto: %zd", r); + log_debugf("error: sendto: %zd", r); return true; } client->last_sent_msgtyp = msgtyp; @@ -704,7 +704,7 @@ static ssize_t dhcp_client_recv(struct dhcp_client *client, struct dhcp_recv_msg static bool dhcp_check_conflict(lo_interface net_packet_conn sock, struct net_ip4_addr addr) { assert(!LO_IS_NULL(sock)); ssize_t v = LO_CALL(sock, sendto, "CHECK_IP_CONFLICT", 17, addr, 5000); - debugf("check_ip_conflict => %zd", v); + log_debugf("check_ip_conflict => %zd", v); return v != -NET_EARP_TIMEOUT; } @@ -740,10 +740,10 @@ static void dhcp_client_take_lease(struct dhcp_client *client, struct dhcp_recv_ client->lease_time_ns_end = (dur_ns_end == DHCP_INFINITY * NS_PER_S) ? 0 : client->time_ns_init + dur_ns_end; if (ifup) { - infof("applying configuration to "PRI_net_eth_addr, ARG_net_eth_addr(client->self_eth_addr)); - infof(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_client_addr)); - infof(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.gateway_addr)); - infof(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.subnet_mask)); + log_infof("applying configuration to "PRI_net_eth_addr, ARG_net_eth_addr(client->self_eth_addr)); + log_infof(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_client_addr)); + log_infof(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.gateway_addr)); + log_infof(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(client->lease_auxdata.subnet_mask)); LO_CALL(client->iface, ifup, (struct net_iface_config){ .addr = client->lease_client_addr, .gateway_addr = client->lease_auxdata.gateway_addr, @@ -767,7 +767,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, /* State transition diagram: https://datatracker.ietf.org/doc/html/rfc2131#page-35 */ for (;;) { - debugf("loop: state=%s", state_strs[client->state]); + log_debugf("loop: state=%s", state_strs[client->state]); switch (client->state) { case STATE_INIT: client->xid = rand_uint63n(UINT32_MAX); @@ -793,7 +793,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; default: assert(r < 0); - debugf("error: recvfrom: %d", r); + log_debugf("error: recvfrom: %d", r); } break; case STATE_REQUESTING: @@ -806,8 +806,8 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; case DHCP_MSGTYP_ACK: if (dhcp_check_conflict(client->sock, client->lease_client_addr)) { - debugf("IP "PRI_net_ip4_addr" is already in use", - ARG_net_ip4_addr(client->lease_client_addr)); + log_debugf("IP "PRI_net_ip4_addr" is already in use", + ARG_net_ip4_addr(client->lease_client_addr)); dhcp_client_setstate(client, STATE_INIT, DHCP_MSGTYP_DECLINE, "IP is already in use", scratch_msg); } else { dhcp_client_take_lease(client, scratch_msg, true); @@ -820,7 +820,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; default: assert(r < 0); - debugf("error: recvfrom: %d", r); + log_debugf("error: recvfrom: %d", r); } break; case STATE_BOUND: @@ -834,7 +834,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; default: assert(r < 0); - debugf("error: recvfrom: %d", r); + log_debugf("error: recvfrom: %d", r); } break; case STATE_RENEWING: @@ -863,7 +863,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; default: assert(r < 0); - debugf("error: recvfrom: %d", r); + log_debugf("error: recvfrom: %d", r); } break; case STATE_REBINDING: @@ -889,7 +889,7 @@ static void dhcp_client_setstate(struct dhcp_client *client, break; default: assert(r < 0); - debugf("error: recvfrom: %d", r); + log_debugf("error: recvfrom: %d", r); } break; case STATE_INIT_REBOOT: diff --git a/libfmt/CMakeLists.txt b/libfmt/CMakeLists.txt index f65d462..dc626f7 100644 --- a/libfmt/CMakeLists.txt +++ b/libfmt/CMakeLists.txt @@ -7,11 +7,9 @@ add_library(libfmt INTERFACE) target_include_directories(libfmt PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_sources(libfmt INTERFACE libmisc.c - libobj.c quote.c ) target_link_libraries(libfmt INTERFACE pico_fmt libmisc - libobj ) diff --git a/libfmt/include/libfmt/fmt.h b/libfmt/include/libfmt/fmt.h index 1b5bde1..692abf2 100644 --- a/libfmt/include/libfmt/fmt.h +++ b/libfmt/include/libfmt/fmt.h @@ -10,7 +10,7 @@ #include <pico/fmt_printf.h> #include <pico/fmt_install.h> -#include <libobj/obj.h> +#include <libmisc/obj.h> /** * An object that implements fmt_formatter can be printed using diff --git a/libfmt/libmisc.c b/libfmt/libmisc.c index 803b281..134b9f0 100644 --- a/libfmt/libmisc.c +++ b/libfmt/libmisc.c @@ -61,3 +61,13 @@ int __lm_light_printf(const char *format, ...) { va_end(va); return ret; } + +static void libfmt_conv_formatter(struct fmt_state *state) { + lo_interface fmt_formatter obj = va_arg(*state->args, lo_interface fmt_formatter); + LO_CALL(obj, format, state); +} + +[[gnu::constructor]] +static void libfmt_install_formatter(void) { + fmt_install('v', libfmt_conv_formatter); +} diff --git a/libfmt/libobj.c b/libfmt/libobj.c deleted file mode 100644 index e4b833b..0000000 --- a/libfmt/libobj.c +++ /dev/null @@ -1,17 +0,0 @@ -/* libfmt/libobj.c - Integrate pico-fmt with libobj - * - * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com> - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -#include <libfmt/fmt.h> - -static void libfmt_conv_formatter(struct fmt_state *state) { - lo_interface fmt_formatter obj = va_arg(*state->args, lo_interface fmt_formatter); - LO_CALL(obj, format, state); -} - -[[gnu::constructor]] -static void libfmt_install_formatter(void) { - fmt_install('v', libfmt_conv_formatter); -} diff --git a/libhw_cr/host_include/libhw/host_alarmclock.h b/libhw_cr/host_include/libhw/host_alarmclock.h index 0cb8d30..3cc43c1 100644 --- a/libhw_cr/host_include/libhw/host_alarmclock.h +++ b/libhw_cr/host_include/libhw/host_alarmclock.h @@ -7,7 +7,6 @@ #ifndef _LIBHW_HOST_ALARMCLOCK_H_ #define _LIBHW_HOST_ALARMCLOCK_H_ -#include <stdbool.h> /* for bool */ #include <time.h> /* for clockid_t, timer_t */ #include <libmisc/private.h> diff --git a/libhw_cr/host_net.c b/libhw_cr/host_net.c index 03cf7db..01f4370 100644 --- a/libhw_cr/host_net.c +++ b/libhw_cr/host_net.c @@ -22,7 +22,7 @@ #include <libmisc/alloc.h> #include <libmisc/assert.h> #include <libmisc/macro.h> -#include <libobj/obj.h> +#include <libmisc/obj.h> #include <libhw/generic/alarmclock.h> diff --git a/libhw_cr/rp2040_dma.c b/libhw_cr/rp2040_dma.c index 69116bf..47d5cd3 100644 --- a/libhw_cr/rp2040_dma.c +++ b/libhw_cr/rp2040_dma.c @@ -4,8 +4,6 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdbool.h> - #include <hardware/irq.h> /* for irq_set_exclusive_handler() */ #include "rp2040_dma.h" diff --git a/libhw_cr/rp2040_hwspi.c b/libhw_cr/rp2040_hwspi.c index 29a7bac..c0b4fa4 100644 --- a/libhw_cr/rp2040_hwspi.c +++ b/libhw_cr/rp2040_hwspi.c @@ -70,7 +70,7 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self, assert(self); assert(baudrate_hz); uint32_t clk_peri_hz = clock_get_hz(clk_peri); - debugf("clk_peri = %"PRIu32"Hz", clk_peri_hz); + log_debugf("clk_peri = %"PRIu32"Hz", clk_peri_hz); assert(baudrate_hz*2 <= clk_peri_hz); assert_4distinct(pin_miso, pin_mosi, pin_clk, pin_cs); assert_4distinct(dma1, dma2, dma3, dma4); @@ -97,7 +97,7 @@ void _rp2040_hwspi_init(struct rp2040_hwspi *self, } actual_baudrate_hz = spi_init(inst, baudrate_hz); - debugf("baudrate = %uHz", actual_baudrate_hz); + log_debugf("baudrate = %uHz", actual_baudrate_hz); assert(actual_baudrate_hz == baudrate_hz); spi_set_format(inst, 8, (mode & 0b10) ? SPI_CPOL_1 : SPI_CPOL_0, diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c index c04e344..e676364 100644 --- a/libhw_cr/w5500.c +++ b/libhw_cr/w5500.c @@ -79,7 +79,7 @@ #include <libhw/generic/alarmclock.h> /* for sleep_*() */ #define LOG_NAME W5500 -#include <libmisc/log.h> /* for errorf(), debugf(), const_byte_str() */ +#include <libmisc/log.h> /* for log_errorf(), log_debugf(), const_byte_str() */ #define IMPLEMENTATION_FOR_LIBHW_W5500_H YES #include <libhw/w5500.h> @@ -124,7 +124,7 @@ static const char *w5500_state_str(uint8_t state) { } } -/* libobj *********************************************************************/ +/* libmisc/obj.h **************************************************************/ LO_IMPLEMENTATION_C(io_closer, struct _w5500_socket, w5500_tcplist, static); LO_IMPLEMENTATION_C(net_stream_listener, struct _w5500_socket, w5500_tcplist, static); @@ -187,7 +187,7 @@ static COROUTINE w5500_irq_cr(void *_chip) { bool had_intr = false; uint8_t chipintr = w5500ll_read_common_reg(chip->spidev, chip_interrupt); - n_debugf(W5500_LL, "w5500_irq_cr(): chipintr=%"PRIu8, chipintr); + log_n_debugf(W5500_LL, "w5500_irq_cr(): chipintr=%"PRIu8, chipintr); had_intr = had_intr || (chipintr != 0); if (chipintr) w5500ll_write_common_reg(chip->spidev, chip_interrupt, 0xFF); @@ -196,7 +196,7 @@ static COROUTINE w5500_irq_cr(void *_chip) { struct _w5500_socket *socket = &chip->sockets[socknum]; uint8_t sockintr = w5500ll_read_sock_reg(chip->spidev, socknum, interrupt); - n_debugf(W5500_LL, "w5500_irq_cr(): sockintr[%"PRIu8"]=%"PRIu8, socknum, sockintr); + log_n_debugf(W5500_LL, "w5500_irq_cr(): sockintr[%"PRIu8"]=%"PRIu8, socknum, sockintr); had_intr = had_intr || (sockintr != 0); switch (socket->mode) { @@ -208,15 +208,15 @@ static COROUTINE w5500_irq_cr(void *_chip) { recv_bits = sockintr & (SOCKINTR_RECV_DAT|SOCKINTR_RECV_FIN); if (listen_bits) { - debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->listen_sema", socknum); + log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->listen_sema", socknum); cr_sema_signal(&socket->listen_sema); } if (recv_bits) { - debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->read_sema", socknum); + log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->read_sema", socknum); cr_sema_signal(&socket->read_sema); } if (send_bits) { - debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->write_ch", socknum); + log_debugf("w5500_irq_cr(): signal sock[%"PRIu8"]->write_ch", socknum); cr_chan_send(&socket->write_ch, send_bits); } break; @@ -228,7 +228,7 @@ static COROUTINE w5500_irq_cr(void *_chip) { cr_mutex_unlock(&chip->mu); if (!had_intr && gpio_get(chip->pin_intr)) { - debugf("w5500_irq_cr(): looks like all interrupts have been processed, sleeping..."); + log_debugf("w5500_irq_cr(): looks like all interrupts have been processed, sleeping..."); cr_sema_wait(&chip->intr); } else cr_yield(); @@ -283,7 +283,7 @@ static inline void w5500_socket_close(struct _w5500_socket *socket) { static void w5500_intrhandler(void *_chip, uint LM_UNUSED(gpio), enum gpio_irq_level LM_UNUSED(event)) { struct w5500 *chip = _chip; - debugf("w5500_intrhandler()"); + log_debugf("w5500_intrhandler()"); cr_sema_signal_from_intrhandler(&chip->intr); } @@ -322,7 +322,7 @@ void _w5500_init(struct w5500 *chip, w5500ll_write_sock_reg(chip->spidev, 0, mode, a); uint8_t b = w5500ll_read_sock_reg(chip->spidev, 0, mode); if (b != a) { - errorf("SPI to W5500 does not appear to be functional: wrote:0x%02"PRIx16" != read:0x%02"PRIx8, a, b); + log_errorf("SPI to W5500 does not appear to be functional: wrote:0x%02"PRIx16" != read:0x%02"PRIx8, a, b); spi_ok = false; } } @@ -427,15 +427,15 @@ static void _w5500_if_up(struct w5500 *chip, struct net_iface_config cfg) { } static void w5500_if_ifup(struct w5500 *chip, struct net_iface_config cfg) { - debugf("if_up()"); - debugf(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.addr)); - debugf(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.gateway_addr)); - debugf(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.subnet_mask)); + log_debugf("if_up()"); + log_debugf(":: addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.addr)); + log_debugf(":: gateway_addr = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.gateway_addr)); + log_debugf(":: subnet_mask = "PRI_net_ip4_addr, ARG_net_ip4_addr(cfg.subnet_mask)); _w5500_if_up(chip, cfg); } static void w5500_if_ifdown(struct w5500 *chip) { - debugf("if_down()"); + log_debugf("if_down()"); _w5500_if_up(chip, (struct net_iface_config){0}); } @@ -444,10 +444,10 @@ static lo_interface net_stream_listener w5500_if_tcp_listen(struct w5500 *chip, struct _w5500_socket *sock = w5500_alloc_socket(chip); if (!sock) { - debugf("tcp_listen() => no sock"); + log_debugf("tcp_listen() => no sock"); return LO_NULL(net_stream_listener); } - debugf("tcp_listen() => sock[%"PRIu8"]", sock->socknum); + log_debugf("tcp_listen() => sock[%"PRIu8"]", sock->socknum); if (!local_port) local_port = w5500_alloc_local_port(chip); @@ -470,11 +470,11 @@ static lo_interface net_stream_conn w5500_if_tcp_dial(struct w5500 *chip, struct _w5500_socket *socket = w5500_alloc_socket(chip); if (!socket) { - debugf("tcp_dial() => no sock"); + log_debugf("tcp_dial() => no sock"); return LO_NULL(net_stream_conn); } uint8_t socknum = socket->socknum; - debugf("tcp_dial() => sock[%"PRIu8"]", socknum); + log_debugf("tcp_dial() => sock[%"PRIu8"]", socknum); uint16_t local_port = w5500_alloc_local_port(chip); @@ -502,7 +502,7 @@ static lo_interface net_stream_conn w5500_if_tcp_dial(struct w5500 *chip, cr_mutex_unlock(&chip->mu); for (;;) { uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state); - debugf("tcp_dial(): state=%s", w5500_state_str(state)); + log_debugf("tcp_dial(): state=%s", w5500_state_str(state)); switch (state) { case STATE_TCP_SYNSENT: cr_yield(); @@ -520,11 +520,11 @@ static lo_interface net_packet_conn w5500_if_udp_conn(struct w5500 *chip, uint16 struct _w5500_socket *socket = w5500_alloc_socket(chip); if (!socket) { - debugf("udp_conn() => no sock"); + log_debugf("udp_conn() => no sock"); return LO_NULL(net_packet_conn); } uint8_t socknum = socket->socknum; - debugf("udp_conn() => sock[%"PRIu8"]", socknum); + log_debugf("udp_conn() => sock[%"PRIu8"]", socknum); if (!local_port) local_port = w5500_alloc_local_port(chip); @@ -554,7 +554,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s restart: if (!socket->list_open) { - debugf("tcp_listener.accept() => already closed"); + log_debugf("tcp_listener.accept() => already closed"); return LO_NULL(net_stream_conn); } @@ -573,7 +573,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s cr_mutex_unlock(&chip->mu); for (;;) { uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state); - debugf("tcp_listener.accept() => state=%s", w5500_state_str(state)); + log_debugf("tcp_listener.accept() => state=%s", w5500_state_str(state)); switch (state) { case STATE_TCP_LISTEN: case STATE_TCP_SYNRECV: @@ -592,7 +592,7 @@ static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *s } static int w5500_tcplist_close(struct _w5500_socket *socket) { - debugf("tcp_listener.close()"); + log_debugf("tcp_listener.close()"); ASSERT_SELF(stream_listener, TCP); socket->list_open = false; @@ -608,7 +608,7 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec size_t count = 0; for (int i = 0; i < iovcnt; i++) count += iov[i].iov_len; - debugf("tcp_conn.write(%zu)", count); + log_debugf("tcp_conn.write(%zu)", count); ASSERT_SELF(stream_conn, TCP); if (count == 0) return 0; @@ -636,14 +636,14 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec size_t done = 0; while (done < count) { if (!socket->write_open) { - debugf(" => soft closed"); + log_debugf(" => soft closed"); return -NET_ECLOSED; } cr_mutex_lock(&chip->mu); uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state); if (state != STATE_TCP_ESTABLISHED && state != STATE_TCP_CLOSE_WAIT) { cr_mutex_unlock(&chip->mu); - debugf(" => hard closed"); + log_debugf(" => hard closed"); return -NET_ECLOSED; } @@ -668,11 +668,11 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec cr_mutex_unlock(&chip->mu); switch (cr_chan_recv(&socket->write_ch)) { case SOCKINTR_SEND_OK: - debugf(" => sent %zu", freesize); + log_debugf(" => sent %zu", freesize); done += freesize; break; case SOCKINTR_SEND_TIMEOUT: - debugf(" => ACK timeout"); + log_debugf(" => ACK timeout"); return -NET_EACK_TIMEOUT; case SOCKINTR_SEND_OK|SOCKINTR_SEND_TIMEOUT: assert_notreached("send both OK and timed out?"); @@ -680,12 +680,12 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec assert_notreached("invalid write_ch bits"); } } - debugf(" => send finished"); + log_debugf(" => send finished"); return done; } static void w5500_tcp_set_read_deadline(struct _w5500_socket *socket, uint64_t ns) { - debugf("tcp_conn.set_read_deadline(%"PRIu64")", ns); + log_debugf("tcp_conn.set_read_deadline(%"PRIu64")", ns); ASSERT_SELF(stream_conn, TCP); socket->read_deadline_ns = ns; } @@ -701,7 +701,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec size_t count = 0; for (int i = 0; i < iovcnt; i++) count += iov[i].iov_len; - debugf("tcp_conn.read(%zu)", count); + log_debugf("tcp_conn.read(%zu)", count); ASSERT_SELF(stream_conn, TCP); if (count == 0) return 0; @@ -718,12 +718,12 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec for (;;) { if (!socket->read_open) { LO_CALL(bootclock, del_trigger, &trigger); - debugf(" => soft closed"); + log_debugf(" => soft closed"); return -NET_ECLOSED; } if (socket->read_deadline_ns && socket->read_deadline_ns <= LO_CALL(bootclock, get_time_ns)) { LO_CALL(bootclock, del_trigger, &trigger); - debugf(" => recv timeout"); + log_debugf(" => recv timeout"); return -NET_ERECV_TIMEOUT; } cr_mutex_lock(&chip->mu); @@ -736,7 +736,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec default: LO_CALL(bootclock, del_trigger, &trigger); cr_mutex_unlock(&chip->mu); - debugf(" => hard closed"); + log_debugf(" => hard closed"); return -NET_ECLOSED; } @@ -747,7 +747,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec if (state == STATE_TCP_CLOSE_WAIT) { LO_CALL(bootclock, del_trigger, &trigger); cr_mutex_unlock(&chip->mu); - debugf(" => EOF"); + log_debugf(" => EOF"); return 0; } @@ -755,7 +755,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec cr_sema_wait(&socket->read_sema); } assert(avail); - debugf(" => received %"PRIu16" bytes", avail); + log_debugf(" => received %"PRIu16" bytes", avail); uint16_t ptr = uint16be_unmarshal(w5500ll_read_sock_reg(chip->spidev, socknum, rx_read_pointer)); /* Read the data. */ if ((size_t)avail > count) @@ -771,7 +771,7 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec } static int w5500_tcp_close_inner(struct _w5500_socket *socket, bool rd, bool wr) { - debugf("tcp_conn.close(rd=%s, wr=%s)", rd ? "true" : "false", wr ? "true" : "false"); + log_debugf("tcp_conn.close(rd=%s, wr=%s)", rd ? "true" : "false", wr ? "true" : "false"); ASSERT_SELF(stream_conn, TCP); if (rd) @@ -809,14 +809,14 @@ static int w5500_tcp_close_write(struct _w5500_socket *socket) { return w5500_tc static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t count, struct net_ip4_addr node, uint16_t port) { - debugf("udp_conn.sendto()"); + log_debugf("udp_conn.sendto()"); ASSERT_SELF(packet_conn, UDP); assert(buf); assert(count); uint16_t bufsize = ((uint16_t)w5500ll_read_sock_reg(chip->spidev, socknum, tx_buf_size))*1024; if (count > bufsize) { - debugf(" => msg too large"); + log_debugf(" => msg too large"); return -NET_EMSGSIZE; } @@ -825,7 +825,7 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state); if (state != STATE_UDP) { cr_mutex_unlock(&chip->mu); - debugf(" => closed"); + log_debugf(" => closed"); return -NET_ECLOSED; } @@ -855,10 +855,10 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t cr_mutex_unlock(&chip->mu); switch (cr_chan_recv(&socket->write_ch)) { case SOCKINTR_SEND_OK: - debugf(" => sent"); + log_debugf(" => sent"); return count; case SOCKINTR_SEND_TIMEOUT: - debugf(" => ARP timeout"); + log_debugf(" => ARP timeout"); return -NET_EARP_TIMEOUT; case SOCKINTR_SEND_OK|SOCKINTR_SEND_TIMEOUT: assert_notreached("send both OK and timed out?"); @@ -868,7 +868,7 @@ static ssize_t w5500_udp_sendto(struct _w5500_socket *socket, void *buf, size_t } static void w5500_udp_set_recv_deadline(struct _w5500_socket *socket, uint64_t ns) { - debugf("udp_conn.set_recv_deadline(%"PRIu64")", ns); + log_debugf("udp_conn.set_recv_deadline(%"PRIu64")", ns); ASSERT_SELF(packet_conn, UDP); socket->read_deadline_ns = ns; } @@ -880,7 +880,7 @@ static void w5500_udp_alarm_handler(void *_arg) { static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_t count, struct net_ip4_addr *ret_node, uint16_t *ret_port) { - debugf("udp_conn.recvfrom()"); + log_debugf("udp_conn.recvfrom()"); ASSERT_SELF(packet_conn, UDP); assert(buf); assert(count); @@ -897,14 +897,14 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_ for (;;) { if (socket->read_deadline_ns && socket->read_deadline_ns <= LO_CALL(bootclock, get_time_ns)) { LO_CALL(bootclock, del_trigger, &trigger); - debugf(" => recv timeout"); + log_debugf(" => recv timeout"); return -NET_ERECV_TIMEOUT; } cr_mutex_lock(&chip->mu); uint8_t state = w5500ll_read_sock_reg(chip->spidev, socknum, state); if (state != STATE_UDP) { LO_CALL(bootclock, del_trigger, &trigger); - debugf(" => hard closed"); + log_debugf(" => hard closed"); return -NET_ECLOSED; } @@ -935,7 +935,7 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_ if (ret_port) *ret_port = uint16be_decode(&hdr[4]); uint16_t len = uint16be_decode(&hdr[6]); - debugf(" => received %"PRIu16" bytes%s", len, len < avail-8 ? " (plus more messages)" : ""); + log_debugf(" => received %"PRIu16" bytes%s", len, len < avail-8 ? " (plus more messages)" : ""); /* Now read the actual data. */ if (count > len) count = len; @@ -953,7 +953,7 @@ static ssize_t w5500_udp_recvfrom(struct _w5500_socket *socket, void *buf, size_ } static int w5500_udp_close(struct _w5500_socket *socket) { - debugf("udp_conn.close()"); + log_debugf("udp_conn.close()"); ASSERT_SELF(packet_conn, UDP); w5500_socket_close(socket); diff --git a/libhw_cr/w5500_ll.h b/libhw_cr/w5500_ll.h index 8b98f9d..738a7f1 100644 --- a/libhw_cr/w5500_ll.h +++ b/libhw_cr/w5500_ll.h @@ -83,9 +83,9 @@ w5500ll_writev( assert(iov); assert(iovcnt > 0); #if CONFIG_W5500_LL_DEBUG - n_debugf(W5500_LL, - "%s(): w5500ll_write(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)", - func, addr, ARG_ctl_block(block), iovcnt); + log_n_debugf(W5500_LL, + "%s(): w5500ll_write(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)", + func, addr, ARG_ctl_block(block), iovcnt); #endif uint8_t header[] = { @@ -120,9 +120,9 @@ w5500ll_readv( assert(iov); assert(iovcnt > 0); #if CONFIG_W5500_LL_DEBUG - n_debugf(W5500_LL, - "%s(): w5500ll_read(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)", - func, addr, ARG_ctl_block(block), iovcnt); + log_n_debugf(W5500_LL, + "%s(): w5500ll_read(spidev, addr=%#04x, block="PRI_ctl_block", iov, iovcnt=%d)", + func, addr, ARG_ctl_block(block), iovcnt); #endif uint8_t header[] = { diff --git a/libhw_generic/CMakeLists.txt b/libhw_generic/CMakeLists.txt index 603f30b..602168b 100644 --- a/libhw_generic/CMakeLists.txt +++ b/libhw_generic/CMakeLists.txt @@ -7,7 +7,6 @@ add_library(libhw_generic INTERFACE) target_include_directories(libhw_generic PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_link_libraries(libhw_generic INTERFACE libmisc - libobj ) target_sources(libhw_generic INTERFACE diff --git a/libhw_generic/include/libhw/generic/alarmclock.h b/libhw_generic/include/libhw/generic/alarmclock.h index 02789f5..6ce2513 100644 --- a/libhw_generic/include/libhw/generic/alarmclock.h +++ b/libhw_generic/include/libhw/generic/alarmclock.h @@ -7,11 +7,10 @@ #ifndef _LIBHW_GENERIC_ALARMCLOCK_H_ #define _LIBHW_GENERIC_ALARMCLOCK_H_ -#include <stdbool.h> /* for bool */ #include <stdint.h> /* for uint{n}_t and UINT{n}_C */ +#include <libmisc/obj.h> #include <libmisc/private.h> -#include <libobj/obj.h> /* Useful constants ***********************************************************/ diff --git a/libhw_generic/include/libhw/generic/io.h b/libhw_generic/include/libhw/generic/io.h index 62ddbb3..6adce8c 100644 --- a/libhw_generic/include/libhw/generic/io.h +++ b/libhw_generic/include/libhw/generic/io.h @@ -11,7 +11,7 @@ #include <stdint.h> /* for uintptr_t */ #include <sys/types.h> /* for ssize_t */ -#include <libobj/obj.h> +#include <libmisc/obj.h> /* structs ********************************************************************/ diff --git a/libhw_generic/include/libhw/generic/net.h b/libhw_generic/include/libhw/generic/net.h index 4af574b..1052392 100644 --- a/libhw_generic/include/libhw/generic/net.h +++ b/libhw_generic/include/libhw/generic/net.h @@ -8,7 +8,6 @@ #define _LIBHW_GENERIC_NET_H_ #include <inttypes.h> /* for PRI{u,x}{n} */ -#include <stdbool.h> /* for bool */ #include <stddef.h> /* for size_t */ #include <stdint.h> /* for uint{n}_t} */ #include <sys/types.h> /* for ssize_t */ diff --git a/libmisc/CMakeLists.txt b/libmisc/CMakeLists.txt index fdbe949..8c9fa57 100644 --- a/libmisc/CMakeLists.txt +++ b/libmisc/CMakeLists.txt @@ -12,7 +12,6 @@ target_sources(libmisc INTERFACE log.c map.c ) -target_compile_options(libmisc INTERFACE "$<$<COMPILE_LANGUAGE:C>:-fplan9-extensions>") add_lib_test(libmisc test_assert) add_lib_test(libmisc test_assert_min) @@ -21,5 +20,7 @@ add_lib_test(libmisc test_hash) add_lib_test(libmisc test_log) add_lib_test(libmisc test_macro) add_lib_test(libmisc test_map) +add_lib_test(libmisc test_obj) +add_lib_test(libmisc test_obj_nest) add_lib_test(libmisc test_private) add_lib_test(libmisc test_rand) diff --git a/libmisc/assert.c b/libmisc/assert.c index fdd8154..540d2fd 100644 --- a/libmisc/assert.c +++ b/libmisc/assert.c @@ -4,10 +4,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdbool.h> /* for bool, true, false */ - #define LOG_NAME ASSERT -#include <libmisc/log.h> /* for errorf() */ +#include <libmisc/log.h> /* for log_errorf() */ #include <libmisc/assert.h> @@ -19,10 +17,10 @@ void __assert_msg_fail(const char *expr, static bool in_fail = false; if (!in_fail) { in_fail = true; - errorf("%s:%u:%s(): assertion \"%s\" failed%s%s", - file, line, func, - expr, - msg ? ": " : "", msg ?: ""); + log_errorf("%s:%u:%s(): assertion \"%s\" failed%s%s", + file, line, func, + expr, + msg ? ": " : "", msg ?: ""); in_fail = false; } __lm_abort(); diff --git a/libmisc/include/libmisc/log.h b/libmisc/include/libmisc/log.h index 79c0ab6..4529946 100644 --- a/libmisc/include/libmisc/log.h +++ b/libmisc/include/libmisc/log.h @@ -20,15 +20,15 @@ const char *const_byte_str(uint8_t b); -#define n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) -#define n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) -#define n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ - __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) +#define log_n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) +#define log_n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) +#define log_n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ + __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) #endif /* _LIBMISC_LOG_H_ */ -#if defined(LOG_NAME) && !defined(errorf) -#define errorf(fmt, ...) n_errorf(LOG_NAME, fmt, __VA_ARGS__) -#define infof(fmt, ...) n_infof(LOG_NAME, fmt, __VA_ARGS__) -#define debugf(fmt, ...) n_debugf(LOG_NAME, fmt, __VA_ARGS__) +#if defined(LOG_NAME) && !defined(log_errorf) +#define log_errorf(fmt, ...) log_n_errorf(LOG_NAME, fmt, __VA_ARGS__) +#define log_infof(fmt, ...) log_n_infof(LOG_NAME, fmt, __VA_ARGS__) +#define log_debugf(fmt, ...) log_n_debugf(LOG_NAME, fmt, __VA_ARGS__) #endif diff --git a/libmisc/include/libmisc/macro.h b/libmisc/include/libmisc/macro.h index a95ac82..ae204ae 100644 --- a/libmisc/include/libmisc/macro.h +++ b/libmisc/include/libmisc/macro.h @@ -9,6 +9,8 @@ #include <libmisc/assert.h> +#define LM_FORCE_SEMICOLON static_assert(1, "force semicolon") + /* for function definitions */ #define LM_UNUSED(argname) @@ -108,4 +110,21 @@ #define _LM_EVAL__2(...) _LM_EVAL__1(_LM_EVAL__1(__VA_ARGS__)) #define _LM_EVAL__1(...) __VA_ARGS__ +/** The same as LM_FOREACH_TUPLE(), but callable from inside of LM_FOREACH_TUPLE(). */ +#define LM_FOREACH_TUPLE2(tuples, func, ...) \ + LM_IF(LM_TUPLES_NONEMPTY(tuples))( \ + _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \ + _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \ + )() +#define LM_FOREACH_TUPLE3(tuples, func, ...) \ + LM_IF(LM_TUPLES_NONEMPTY(tuples))( \ + _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \ + _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \ + )() +#define LM_FOREACH_TUPLE4(tuples, func, ...) \ + LM_IF(LM_TUPLES_NONEMPTY(tuples))( \ + _LM_DEFER2(func)(__VA_ARGS__ __VA_OPT__(,) LM_EXPAND LM_TUPLES_HEAD(tuples)) \ + _LM_DEFER2(_LM_FOREACH_TUPLE_indirect)()(LM_TUPLES_TAIL(tuples), func, __VA_ARGS__) \ + )() + #endif /* _LIBMISC_MACRO_H_ */ diff --git a/libmisc/include/libmisc/map.h b/libmisc/include/libmisc/map.h index 6622595..113bc0e 100644 --- a/libmisc/include/libmisc/map.h +++ b/libmisc/include/libmisc/map.h @@ -7,7 +7,6 @@ #ifndef _LIBMISC_MAP_H_ #define _LIBMISC_MAP_H_ -#include <stdbool.h> #include <stddef.h> /* for size_t */ #include <stdint.h> /* for uint8_t */ diff --git a/libmisc/include/libmisc/obj.h b/libmisc/include/libmisc/obj.h new file mode 100644 index 0000000..76dde91 --- /dev/null +++ b/libmisc/include/libmisc/obj.h @@ -0,0 +1,173 @@ +/* libmisc/obj.h - A simple Go-ish object system + * + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +#ifndef _LIBMISC_OBJ_H_ +#define _LIBMISC_OBJ_H_ + +#include <libmisc/macro.h> + +/** + * Use `lo_interface` similarly to how you would use + * `struct`/`enum`/`union` when writing the type of an interface + * value. + */ +#define lo_interface struct + +/** + * Use `LO_INTERFACE` in a .h file to define an interface. + * + * First define a macro named `{iface_name}_LO_IFACE` consisting of a + * series of calls to LO_NEST and/or LO_FUNC, then call + * `LO_INTERFACE({iface_name})`: + * + * #define myiface_LO_IFACE \ + * LO_NEST(wrapped_iface_name) \ + * LO_FUNC(ret_type, func_name, args...) + * LO_INTERFACE(myiface) + * + * Use `lo_interface {iface_name}` as the type of this interface; it + * should not be a pointer type. + * + * If there are any LO_NEST interfaces, this will define a + * `lo_box_{iface_name}_as_{wrapped_iface_name}(obj)` function for + * each. + */ +#define LO_NEST(_ARG_child_iface_name) \ + (lo_nest, _ARG_child_iface_name) +#define LO_FUNC(_ARG_ret_type, _ARG_func_name, ...) \ + (lo_func, _ARG_ret_type, _ARG_func_name __VA_OPT__(,) __VA_ARGS__) +#define LO_INTERFACE(_ARG_iface_name) \ + struct _lo_##_ARG_iface_name##_vtable { \ + LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ + _LO_IFACE_VTABLE) \ + }; \ + struct _ARG_iface_name { \ + void *self; \ + const struct _lo_##_ARG_iface_name##_vtable *vtable; \ + }; \ + LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ + _LO_IFACE_PROTO, _ARG_iface_name) \ + extern int LM_CAT2_(_HIDDEN_BOGUS_, __COUNTER__) + +#define _LO_IFACE_VTABLE(_tuple_typ, ...) _LO_IFACE_VTABLE_##_tuple_typ(__VA_ARGS__) +#define _LO_IFACE_VTABLE_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE2(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE2) +#define _LO_IFACE_VTABLE_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__); + +#define _LO_IFACE_VTABLE2(_tuple_typ, ...) _LO_IFACE_VTABLE2_##_tuple_typ(__VA_ARGS__) +#define _LO_IFACE_VTABLE2_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE3(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE3) +#define _LO_IFACE_VTABLE2_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__); + +#define _LO_IFACE_VTABLE3(_tuple_typ, ...) _LO_IFACE_VTABLE3_##_tuple_typ(__VA_ARGS__) +#define _LO_IFACE_VTABLE3_lo_nest(_ARG_child_iface_name) const struct _lo_##_ARG_child_iface_name##_vtable *_lo_##_ARG_child_iface_name##_vtable; LM_FOREACH_TUPLE4(_ARG_child_iface_name##_LO_IFACE, _LO_IFACE_VTABLE4) +#define _LO_IFACE_VTABLE3_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__); + +#define _LO_IFACE_VTABLE4(_tuple_typ, ...) _LO_IFACE_VTABLE4_##_tuple_typ(__VA_ARGS__) +#define _LO_IFACE_VTABLE4_lo_nest(_ARG_child_iface_name) static_assert(0, "BUG: libmisc/obj.h cannot nest interfaces more than 4 deep"); +#define _LO_IFACE_VTABLE4_lo_func(_ARG_ret_type, _ARG_func_name, ...) _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__); + +#define _LO_IFACE_PROTO(_ARG_iface_name, _tuple_typ, ...) _LO_IFACE_PROTO_##_tuple_typ(_ARG_iface_name, __VA_ARGS__) +#define _LO_IFACE_PROTO_lo_nest(_ARG_iface_name, _ARG_child_iface_name) \ + LM_ALWAYS_INLINE static lo_interface _ARG_child_iface_name \ + box_##_ARG_iface_name##_as_##_ARG_child_iface_name(lo_interface _ARG_iface_name obj) { \ + return (lo_interface _ARG_child_iface_name){ \ + .self = obj.self, \ + .vtable = obj.vtable->_lo_##_ARG_child_iface_name##_vtable, \ + }; \ + } +#define _LO_IFACE_PROTO_lo_func(_ARG_iface_name, _ARG_ret_type, _ARG_func_name, ...) \ + /* empty */ + +/** + * `LO_NULL(iface_name)` is the null/nil/zero value for `lo_interface {iface_name}`. + */ +#define LO_NULL(_ARG_iface_name) ((lo_interface _ARG_iface_name){0}) + +/** + * `LO_IS_NULL(iface_val)` returns whether `iface_val` is LO_NULL. + */ +#define LO_IS_NULL(_ARG_iface_val) ((_ARG_iface_val).vtable == NULL) + +/** + * `LO_IFACE_EQ(a, b)` returns whether the interface values `a` and + * `b` are the same object. + */ +#define LO_EQ(_ARG_iface_val_a, _ARG_iface_val_b) \ + ((_ARG_iface_val_a).self == (_ARG_iface_val_b).self) + +/** + * Use LO_CALL(obj, method_name, args...) to call a method on an `lo_interface`. + */ +#define LO_CALL(_ARG_obj, _ARG_meth, ...) \ + (_ARG_obj).vtable->_ARG_meth((_ARG_obj).self __VA_OPT__(,) __VA_ARGS__) + +/** + * Use `LO_IMPLEMENTATION_H(iface_name, impl_type, impl_name)` in a .h + * file to declare that `{impl_type}` implements the `{iface_name}` + * interface with functions named `{impl_name}_{method_name}`. + * + * This will also define a `lo_box_{impl_name}_as_{iface_name}(obj)` + * function. + * + * You must also call the LO_IMPLEMENTATION_C in a single .c file. + */ +#define LO_IMPLEMENTATION_H(_ARG_iface_name, _ARG_impl_type, _ARG_impl_name) \ + /* Vtable. */ \ + extern const struct _lo_##_ARG_iface_name##_vtable \ + _lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable; \ + /* Boxing. */ \ + LM_ALWAYS_INLINE static lo_interface _ARG_iface_name \ + lo_box_##_ARG_impl_name##_as_##_ARG_iface_name(_ARG_impl_type *self) { \ + return (lo_interface _ARG_iface_name){ \ + .self = self, \ + .vtable = &_lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable, \ + }; \ + } \ + LM_FORCE_SEMICOLON + +/** + * Use `LO_IMPLEMENTATION_C(iface_name, impl_type, impl_name[, static])` in a .c + * file to declare that `{impl_type}` implements the `{iface_name}` interface + * with functions named `{impl_name}_{method_name}`. + * + * You must also call the LO_IMPLEMENTATION_H in the corresponding .h file. + * + * If `iface_name` contains a nested interface, then the + * implementation of the nested interfaces must be declared with + * `LO_IMPLEMENTATION_C` first. + */ +#define LO_IMPLEMENTATION_C(_ARG_iface_name, _ARG_impl_type, _ARG_impl_name, ...) \ + /* Method prototypes. */ \ + LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ + _LO_IMPL_PROTO, _ARG_impl_type, _ARG_impl_name, __VA_ARGS__) \ + /* Vtable. */ \ + const struct _lo_##_ARG_iface_name##_vtable \ + _lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable = { \ + LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ + _LO_IMPL_VTABLE, _ARG_impl_name) \ + } + +#define _LO_IMPL_PROTO( _ARG_impl_type, _ARG_impl_name, _ARG_quals, _tuple_typ, ...) _LO_IMPL_PROTO_##_tuple_typ(_ARG_impl_type, _ARG_impl_name, _ARG_quals, __VA_ARGS__) +#define _LO_IMPL_PROTO_lo_nest(_ARG_impl_type, _ARG_impl_name, _ARG_quals, _ARG_child_iface_name) /* empty */ +#define _LO_IMPL_PROTO_lo_func(_ARG_impl_type, _ARG_impl_name, _ARG_quals, _ARG_ret_type, _ARG_func_name, ...) _ARG_quals _ARG_ret_type _ARG_impl_name##_##_ARG_func_name(_ARG_impl_type * __VA_OPT__(,) __VA_ARGS__); + +#define _LO_IMPL_VTABLE(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE_##_tuple_typ(_ARG_impl_name, __VA_ARGS__) +#define _LO_IMPL_VTABLE_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE2(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE2, _ARG_impl_name) +#define _LO_IMPL_VTABLE_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name, + +#define _LO_IMPL_VTABLE2(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE2_##_tuple_typ(_ARG_impl_name, __VA_ARGS__) +#define _LO_IMPL_VTABLE2_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE3(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE3, _ARG_impl_name) +#define _LO_IMPL_VTABLE2_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name, + +#define _LO_IMPL_VTABLE3(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE3_##_tuple_typ(_ARG_impl_name, __VA_ARGS__) +#define _LO_IMPL_VTABLE3_lo_nest(_ARG_impl_name, _ARG_child_iface_name) ._lo_##_ARG_child_iface_name##_vtable = &_lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, LM_FOREACH_TUPLE4(_ARG_child_iface_name##_LO_IFACE, _LO_IMPL_VTABLE4, _ARG_impl_name) +#define _LO_IMPL_VTABLE3_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name, + +#define _LO_IMPL_VTABLE4(_ARG_impl_name, _tuple_typ, ...) _LO_IMPL_VTABLE4_##_tuple_typ(_ARG_impl_name, __VA_ARGS__) +#define _LO_IMPL_VTABLE4_lo_nest(_ARG_impl_name, _ARG_child_iface_name) static_assert(0, "BUG: libmisc/obj.h cannot nest interfaces more than 4 deep"); +#define _LO_IMPL_VTABLE4_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name, + + +#endif /* _LIBMISC_OBJ_H_ */ diff --git a/libmisc/include/libmisc/private.h b/libmisc/include/libmisc/private.h index 5518d1f..5a8777c 100644 --- a/libmisc/include/libmisc/private.h +++ b/libmisc/include/libmisc/private.h @@ -11,7 +11,7 @@ #define YES LM_SENTINEL() #define IS_IMPLEMENTATION_FOR(name) LM_IS_SENTINEL(IMPLEMENTATION_FOR_##name) -#define BEGIN_PRIVATE(name) LM_IF(IS_IMPLEMENTATION_FOR(name))()(struct {) struct {} LM_CAT2_(_PRIVATE_FORCE_SEMICOLON_, __COUNTER__) -#define END_PRIVATE(name) LM_IF(IS_IMPLEMENTATION_FOR(name))(struct {} LM_CAT2_(_PRIVATE_FORCE_SEMICOLON_, __COUNTER__))(} LM_CAT2_(_PRIVATE_, __COUNTER__)) +#define BEGIN_PRIVATE(name) LM_IF(IS_IMPLEMENTATION_FOR(name))()(struct {) LM_FORCE_SEMICOLON +#define END_PRIVATE(name) LM_IF(IS_IMPLEMENTATION_FOR(name))(LM_FORCE_SEMICOLON)(} LM_CAT2_(_PRIVATE_, __COUNTER__)) #endif /* _LIBMISC_PRIVATE_H_ */ diff --git a/libmisc/tests/test_assert.c b/libmisc/tests/test_assert.c index 15f9446..c6d2dc1 100644 --- a/libmisc/tests/test_assert.c +++ b/libmisc/tests/test_assert.c @@ -6,7 +6,6 @@ #include <setjmp.h> #include <stdarg.h> /* for va_list, va_start(), va_end() */ -#include <stdbool.h> #include <stdlib.h> #include <string.h> diff --git a/libmisc/tests/test_log.c b/libmisc/tests/test_log.c index 49a76ca..02b95d6 100644 --- a/libmisc/tests/test_log.c +++ b/libmisc/tests/test_log.c @@ -1,6 +1,6 @@ /* libmisc/tests/test_log.c - Tests for <libmisc/log.h> * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -54,17 +54,17 @@ int __lm_printf(const char *format, ...) { int main() { should_print("error: FROBNICATE: val=42\n", - errorf("val=%d", 42)); + log_errorf("val=%d", 42)); should_print("info : FROBNICATE: val=0\n", - infof("val=%d", 0)); + log_infof("val=%d", 0)); #ifndef NDEBUG #define CONFIG_FROBNICATE_DEBUG 1 should_print("debug: FROBNICATE: val=-2\n", - debugf("val=%d", -2)); + log_debugf("val=%d", -2)); #undef CONFIG_FROBNICATE_DEBUG #define CONFIG_FROBNICATE_DEBUG 0 should_print(NULL, - debugf("val=%d", -2)); + log_debugf("val=%d", -2)); #endif return 0; } diff --git a/libobj/tests/test_obj.c b/libmisc/tests/test_obj.c index d6861dc..687ad4e 100644 --- a/libobj/tests/test_obj.c +++ b/libmisc/tests/test_obj.c @@ -1,10 +1,10 @@ -/* libobj/tests/test_obj.c - Tests for <libobj/obj.h> +/* libmisc/tests/test_obj.c - Tests for <libmisc/obj.h> * * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <libobj/obj.h> +#include <libmisc/obj.h> #include "test.h" diff --git a/libobj/tests/test_nest.c b/libmisc/tests/test_obj_nest.c index f18b018..bb9d6de 100644 --- a/libobj/tests/test_nest.c +++ b/libmisc/tests/test_obj_nest.c @@ -1,4 +1,4 @@ -/* libobj/tests/test_nest.c - Tests for <libobj/obj.h> +/* libmisc/tests/test_obj_nest.c - Tests for <libmisc/obj.h> nesting * * Copyright (C) 2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later @@ -6,7 +6,7 @@ #include <string.h> /* for memcpy() */ -#include <libobj/obj.h> +#include <libmisc/obj.h> #include "test.h" diff --git a/libmisc/tests/test_rand.c b/libmisc/tests/test_rand.c index 8076155..3596d94 100644 --- a/libmisc/tests/test_rand.c +++ b/libmisc/tests/test_rand.c @@ -1,10 +1,9 @@ /* libmisc/tests/test_rand.c - Tests for <libmisc/rand.h> * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdbool.h> #include <setjmp.h> #include <libmisc/rand.h> diff --git a/libobj/CMakeLists.txt b/libobj/CMakeLists.txt deleted file mode 100644 index e4d8095..0000000 --- a/libobj/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# libobj/CMakeLists.txt - A simple Go-ish object system built on GCC -fplan9-extensions -# -# Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> -# SPDX-License-Identifier: AGPL-3.0-or-later - -add_library(libobj INTERFACE) -target_include_directories(libobj PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(libobj INTERFACE - libmisc -) -target_compile_options(libobj INTERFACE "$<$<COMPILE_LANGUAGE:C>:-fplan9-extensions>") - -add_lib_test(libobj test_obj) -add_lib_test(libobj test_nest) diff --git a/libobj/include/libobj/obj.h b/libobj/include/libobj/obj.h deleted file mode 100644 index 7a9041e..0000000 --- a/libobj/include/libobj/obj.h +++ /dev/null @@ -1,156 +0,0 @@ -/* libobj/obj.h - A simple Go-ish object system - * - * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -#ifndef _LIBOBJ_OBJ_H_ -#define _LIBOBJ_OBJ_H_ - -#include <libmisc/macro.h> - -/** - * Use `lo_interface` similarly to how you would use - * `struct`/`enum`/`union` when writing the type of an interface - * value. - */ -#define lo_interface struct - -/** - * Use `LO_INTERFACE` in a .h file to define an interface. - * - * First define a macro named `{iface_name}_LO_IFACE` consisting of a - * series of calls to LO_NEST and/or LO_FUNC, then call - * `LO_INTERFACE({iface_name})`: - * - * #define myiface_LO_IFACE \ - * LO_NEST(wrapped_iface_name) \ - * LO_FUNC(ret_type, func_name, args...) - * LO_INTERFACE(myiface) - * - * Use `lo_interface {iface_name}` as the type of this interface; it - * should not be a pointer type. - * - * If there are any LO_NEST interfaces, this will define a - * `lo_box_{iface_name}_as_{wrapped_iface_name}(obj)` function for - * each. - */ -#define LO_NEST(_ARG_child_iface_name) \ - (lo_nest, _ARG_child_iface_name) -#define LO_FUNC(_ARG_ret_type, _ARG_func_name, ...) \ - (lo_func, _ARG_ret_type, _ARG_func_name __VA_OPT__(,) __VA_ARGS__) -#define LO_INTERFACE(_ARG_iface_name) \ - typedef struct { \ - LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ - _LO_IFACE_VTABLE) \ - } _lo_##_ARG_iface_name##_vtable; \ - struct _ARG_iface_name { \ - void *self; \ - const _lo_##_ARG_iface_name##_vtable *vtable; \ - }; \ - LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ - _LO_IFACE_PROTO, _ARG_iface_name) \ - extern int LM_CAT2_(_HIDDEN_BOGUS_, __COUNTER__) -#define _LO_IFACE_VTABLE(_tuple_typ, ...) \ - _LO_IFACE_VTABLE_##_tuple_typ(__VA_ARGS__) -#define _LO_IFACE_VTABLE_lo_nest(_ARG_child_iface_name) \ - _lo_##_ARG_child_iface_name##_vtable; -#define _LO_IFACE_VTABLE_lo_func(_ARG_ret_type, _ARG_func_name, ...) \ - _ARG_ret_type (*_ARG_func_name)(void * __VA_OPT__(,) __VA_ARGS__); -#define _LO_IFACE_PROTO(_ARG_iface_name, _tuple_typ, ...) \ - _LO_IFACE_PROTO_##_tuple_typ(_ARG_iface_name, __VA_ARGS__) -#define _LO_IFACE_PROTO_lo_nest(_ARG_iface_name, _ARG_child_iface_name) \ - LM_ALWAYS_INLINE static lo_interface _ARG_child_iface_name \ - box_##_ARG_iface_name##_as_##_ARG_child_iface_name(lo_interface _ARG_iface_name obj) { \ - return (lo_interface _ARG_child_iface_name){ \ - .self = obj.self, \ - .vtable = &obj.vtable->_lo_##_ARG_child_iface_name##_vtable, \ - }; \ - } -#define _LO_IFACE_PROTO_lo_func(_ARG_iface_name, _ARG_ret_type, _ARG_func_name, ...) \ - /* empty */ - -/** - * `LO_NULL(iface_name)` is the null/nil/zero value for `lo_interface {iface_name}`. - */ -#define LO_NULL(_ARG_iface_name) ((lo_interface _ARG_iface_name){0}) - -/** - * `LO_IS_NULL(iface_val)` returns whether `iface_val` is LO_NULL. - */ -#define LO_IS_NULL(_ARG_iface_val) ((_ARG_iface_val).vtable == NULL) - -/** - * `LO_IFACE_EQ(a, b)` returns whether the interface values `a` and - * `b` are the same object. - */ -#define LO_EQ(_ARG_iface_val_a, _ARG_iface_val_b) \ - ((_ARG_iface_val_a).self == (_ARG_iface_val_b).self) - -/** - * Use LO_CALL(obj, method_name, args...) to call a method on an `lo_interface`. - */ -#define LO_CALL(_ARG_obj, _ARG_meth, ...) \ - (_ARG_obj).vtable->_ARG_meth((_ARG_obj).self __VA_OPT__(,) __VA_ARGS__) - -/** - * Use `LO_IMPLEMENTATION_H(iface_name, impl_type, impl_name)` in a .h - * file to declare that `{impl_type}` implements the `{iface_name}` - * interface with functions named `{impl_name}_{method_name}`. - * - * This will also define a `lo_box_{impl_name}_as_{iface_name}(obj)` - * function. - * - * You must also call the LO_IMPLEMENTATION_C in a single .c file. - */ -#define LO_IMPLEMENTATION_H(_ARG_iface_name, _ARG_impl_type, _ARG_impl_name) \ - /* Vtable. */ \ - extern const _lo_##_ARG_iface_name##_vtable \ - _lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable; \ - /* Boxing. */ \ - LM_ALWAYS_INLINE static lo_interface _ARG_iface_name \ - lo_box_##_ARG_impl_name##_as_##_ARG_iface_name(_ARG_impl_type *self) { \ - return (lo_interface _ARG_iface_name){ \ - .self = self, \ - .vtable = &_lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable, \ - }; \ - } \ - extern int LM_CAT2_(_LO_FORCE_SEMICOLON_, __COUNTER__) - -/** - * Use `LO_IMPLEMENTATION_C(iface_name, impl_type, impl_name[, static])` in a .c - * file to declare that `{impl_type}` implements the `{iface_name}` interface - * with functions named `{impl_name}_{method_name}`. - * - * You must also call the LO_IMPLEMENTATION_H in the corresponding .h file. - * - * If `iface_name` contains a nested interface, then the - * implementation of the nested interfaces must be declared with - * `LO_IMPLEMENTATION_C` first. - */ -#define LO_IMPLEMENTATION_C(_ARG_iface_name, _ARG_impl_type, _ARG_impl_name, ...) \ - /* Method prototypes. */ \ - LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ - _LO_IMPL_PROTO, _ARG_impl_type, _ARG_impl_name, __VA_ARGS__) \ - /* Vtable. */ \ - const _lo_##_ARG_iface_name##_vtable \ - _lo_##_ARG_impl_name##_##_ARG_iface_name##_vtable = { \ - LM_FOREACH_TUPLE(_ARG_iface_name##_LO_IFACE, \ - _LO_IMPL_VTABLE, _ARG_impl_name) \ - } - -#define _LO_IMPL_PROTO(_ARG_impl_type, _ARG_impl_name, _ARG_quals, _tuple_typ, ...) \ - _LO_IMPL_PROTO_##_tuple_typ(_ARG_impl_type, _ARG_impl_name, _ARG_quals, __VA_ARGS__) -#define _LO_IMPL_PROTO_lo_nest(_ARG_impl_type, _ARG_impl_name, _ARG_quals, _ARG_child_iface_name) \ - /* empty */ -#define _LO_IMPL_PROTO_lo_func(_ARG_impl_type, _ARG_impl_name, _ARG_quals, _ARG_ret_type, _ARG_func_name, ...) \ - _ARG_quals _ARG_ret_type _ARG_impl_name##_##_ARG_func_name(_ARG_impl_type * __VA_OPT__(,) __VA_ARGS__); - -#define _LO_IMPL_VTABLE(_ARG_impl_name, _tuple_typ, ...) \ - _LO_IMPL_VTABLE_##_tuple_typ(_ARG_impl_name, __VA_ARGS__) -#define _LO_IMPL_VTABLE_lo_nest(_ARG_impl_name, _ARG_child_iface_name) \ - ._lo_##_ARG_child_iface_name##_vtable = _lo_##_ARG_impl_name##_##_ARG_child_iface_name##_vtable, -#define _LO_IMPL_VTABLE_lo_func(_ARG_impl_name, _ARG_ret_type, _ARG_func_name, ...) \ - ._ARG_func_name = (void*)_ARG_impl_name##_##_ARG_func_name, - -#endif /* _LIBOBJ_OBJ_H_ */ diff --git a/libobj/tests/test.h b/libobj/tests/test.h deleted file mode 120000 index 2fb1bd5..0000000 --- a/libobj/tests/test.h +++ /dev/null @@ -1 +0,0 @@ -../../libmisc/tests/test.h
\ No newline at end of file diff --git a/libusb/usb_common.c b/libusb/usb_common.c index 29dec42..efd12bc 100644 --- a/libusb/usb_common.c +++ b/libusb/usb_common.c @@ -1,6 +1,6 @@ /* libusb/usb_common.c - Common framework for implementing multiple USB devices at once * - * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> + * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later */ @@ -68,12 +68,12 @@ uint16_t const *tud_descriptor_string_cb(uint8_t strid, uint16_t langid) { memcpy(desc.bString, globals.serial, bytelen); break; default: - debugf("GET STRING: unknown string id=%"PRIu8, strid); + log_debugf("GET STRING: unknown string id=%"PRIu8, strid); return NULL; } break; default: - debugf("GET STRING: unknown LANGID=%"PRIx16, langid); + log_debugf("GET STRING: unknown LANGID=%"PRIx16, langid); return NULL; } } |