diff --git a/scripts/build/gen_syscalls.py b/scripts/build/gen_syscalls.py index 352130caf8333..8a603989f9d5e 100755 --- a/scripts/build/gen_syscalls.py +++ b/scripts/build/gen_syscalls.py @@ -201,7 +201,6 @@ class SyscallParseException(Exception): def typename_split(item): - item = item.strip().replace("\n", " ") if "[" in item: raise SyscallParseException( "Please pass arrays to syscalls as pointers, unable to process '%s'" % @@ -414,7 +413,7 @@ def analyze_fn(match_group, fn, userspace_only): if args == "void": args = [] else: - args = [typename_split(a) for a in args.split(",")] + args = [typename_split(a.strip()) for a in args.split(",")] func_type, func_name = typename_split(func) except SyscallParseException: diff --git a/scripts/build/parse_syscalls.py b/scripts/build/parse_syscalls.py index b748bb1c21089..60b91e0f026b9 100755 --- a/scripts/build/parse_syscalls.py +++ b/scripts/build/parse_syscalls.py @@ -127,8 +127,11 @@ def analyze_headers(include_dir, scan_dir, file_list): try: to_emit = syscall_files[one_file]["emit"] | args.emit_all_syscalls - syscall_result = [(mo.groups(), fn, to_emit) - for mo in syscall_regex.finditer(contents)] + syscall_result = [] + for mo in syscall_regex.finditer(contents): + groups = mo.groups() + groups = [re.sub(r'\s+', ' ', group) for group in groups] + syscall_result.append((groups, fn, to_emit,)) for tag in struct_tags: tagged_struct_update(tagged_ret[tag], tag, contents) except Exception: diff --git a/tests/cmake/syscalls/CMakeLists.txt b/tests/cmake/syscalls/CMakeLists.txt new file mode 100644 index 0000000000000..e618c1d4c46b9 --- /dev/null +++ b/tests/cmake/syscalls/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (c) 2025 Renesas Electronics Corporation +# SPDX-License-Identifier: Apache-2.0 +cmake_minimum_required(VERSION 3.28) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(app C) +target_sources(app PRIVATE main.c) diff --git a/tests/cmake/syscalls/main.c b/tests/cmake/syscalls/main.c new file mode 100644 index 0000000000000..75e502185a9de --- /dev/null +++ b/tests/cmake/syscalls/main.c @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2025 Renesas Electronics Corporation + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "main.h" + +int main(void) { return 0; } diff --git a/tests/cmake/syscalls/main.h b/tests/cmake/syscalls/main.h new file mode 100644 index 0000000000000..f67f82ac51e22 --- /dev/null +++ b/tests/cmake/syscalls/main.h @@ -0,0 +1,16 @@ +#pragma once + +/* + * Copyright (c) 2025 Renesas Electronics Corporation + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +/* Newline between return type and function name */ +/* clang-format off */ +__syscall void +test_wrapped(int foo); +/* clang-format on */ + +#include diff --git a/tests/cmake/syscalls/prj.conf b/tests/cmake/syscalls/prj.conf new file mode 100644 index 0000000000000..4a540805c30eb --- /dev/null +++ b/tests/cmake/syscalls/prj.conf @@ -0,0 +1,3 @@ +# Copyright (c) 2025 Renesas Electronics Corporation +# SPDX-License-Identifier: Apache-2.0 +CONFIG_APPLICATION_DEFINED_SYSCALL=y diff --git a/tests/cmake/syscalls/testcase.yaml b/tests/cmake/syscalls/testcase.yaml new file mode 100644 index 0000000000000..b29143be68de5 --- /dev/null +++ b/tests/cmake/syscalls/testcase.yaml @@ -0,0 +1,6 @@ +# Copyright (c) 2025 Renesas Electronics Corporation +# SPDX-License-Identifier: Apache-2.0 +tests: + buildsystem.syscalls: + build_only: true + platform_allow: native_sim