From a2b0553c51d675fcce84a543f8cd0d26ced6d522 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 28 Jun 2024 16:05:26 +0200 Subject: [PATCH] base-*: use C++20 function template syntax Issue #5227 --- repos/base-hw/src/bootstrap/platform.h | 9 ++-- .../src/bootstrap/spec/x86_64/multiboot2.h | 12 ++---- repos/base-hw/src/core/kernel/cpu.h | 5 +-- repos/base-hw/src/core/kernel/ipc_node.h | 8 ++-- repos/base-hw/src/core/kernel/object.h | 7 +--- repos/base-hw/src/core/kernel/scheduler.h | 8 ++-- repos/base-hw/src/core/kernel/thread.h | 5 +-- repos/base-hw/src/core/object.h | 9 ++-- repos/base-hw/src/core/platform.h | 3 +- repos/base-hw/src/core/spec/arm/cpu.cc | 11 +++-- .../src/core/spec/arm/kernel/thread_caches.cc | 9 ++-- repos/base-hw/src/core/spec/arm_v8/cpu.cc | 9 ++-- .../src/core/spec/x86_64/kernel/panic.h | 4 +- .../src/core/spec/x86_64/virtualization/ept.h | 3 +- .../src/include/base/internal/align_at.h | 3 +- .../base-hw/src/include/base/internal/cache.h | 6 +-- repos/base-hw/src/include/hw/memory_map.h | 5 +-- .../src/include/hw/spec/arm_64/memory_map.h | 3 +- .../src/include/hw/spec/riscv/page_table.h | 13 +++--- .../base-hw/src/include/hw/spec/x86_64/acpi.h | 20 +++------ .../src/include/hw/spec/x86_64/page_table.h | 27 ++++++------ repos/base-hw/src/test/cpu_scheduler/main.cc | 4 +- repos/base-linux/src/core/include/pager.h | 5 +-- .../base/internal/capability_space_tpl.h | 6 +-- .../src/include/base/internal/native_thread.h | 3 +- .../include/base/internal/region_map_mmap.h | 3 +- .../base-nova/include/nova/syscall-generic.h | 10 ++--- repos/base-nova/src/core/include/nova_util.h | 5 +-- repos/base-nova/src/core/include/platform.h | 3 +- .../base-nova/src/core/pd_session_support.cc | 11 ++--- .../src/core/vm_session_component.cc | 5 +-- repos/base-nova/src/lib/base/vm.cc | 4 +- repos/base-nova/src/test/nova/main.cc | 5 ++- .../src/core/include/initial_untyped_pool.h | 18 ++++---- .../src/core/include/page_table_registry.h | 13 +++--- repos/base-sel4/src/core/include/vm_space.h | 6 +-- .../base/internal/capability_space_sel4.h | 6 +-- repos/base/include/base/allocator_avl.h | 5 +-- repos/base/include/base/thread.h | 6 --- .../spec/x86_64/page_table/page_table_base.h | 42 +++++++++---------- .../src/core/include/synced_range_allocator.h | 6 +-- .../base/internal/capability_space_tpl.h | 6 +-- repos/base/src/include/base/internal/output.h | 28 ++++++------- .../base/internal/unmanaged_singleton.h | 8 ++-- repos/base/src/lib/base/allocator_avl.cc | 6 +-- repos/base/src/lib/base/root_proxy.cc | 3 +- repos/base/src/lib/ldso/include/config.h | 3 +- repos/base/src/lib/ldso/include/dynamic.h | 3 +- repos/base/src/lib/ldso/include/file.h | 3 +- repos/base/src/lib/ldso/include/linker.h | 15 +++---- .../src/lib/ldso/include/relocation_generic.h | 3 +- 51 files changed, 170 insertions(+), 253 deletions(-) diff --git a/repos/base-hw/src/bootstrap/platform.h b/repos/base-hw/src/bootstrap/platform.h index 5ec4a4e58f..5756c71af9 100644 --- a/repos/base-hw/src/bootstrap/platform.h +++ b/repos/base-hw/src/bootstrap/platform.h @@ -83,13 +83,12 @@ class Bootstrap::Platform void add(Memory_region const &); void remove(Memory_region const &); - template - void for_each_free_region(FUNC functor) + void for_each_free_region(auto const &fn) { _block_tree().for_each([&] (Block const & b) { if (!b.used()) - functor(Memory_region(b.addr(), b.size())); + fn(Memory_region(b.addr(), b.size())); }); } }; @@ -117,13 +116,13 @@ class Bootstrap::Platform { Elf(addr_t const addr) : Genode::Elf_binary(addr) { } - template void for_each_segment(T functor) + void for_each_segment(auto const &fn) { Genode::Elf_segment segment; for (unsigned i = 0; (segment = get_segment(i)).valid(); i++) { if (segment.flags().skip) continue; if (segment.mem_size() == 0) continue; - functor(segment); + fn(segment); } } }; diff --git a/repos/base-hw/src/bootstrap/spec/x86_64/multiboot2.h b/repos/base-hw/src/bootstrap/spec/x86_64/multiboot2.h index 0dae4949fd..3fb5fdf4ad 100644 --- a/repos/base-hw/src/bootstrap/spec/x86_64/multiboot2.h +++ b/repos/base-hw/src/bootstrap/spec/x86_64/multiboot2.h @@ -72,14 +72,10 @@ class Genode::Multiboot2_info : Mmio<0x8> Multiboot2_info(addr_t mbi) : Mmio({(char *)mbi, Mmio::SIZE}) { } - template - void for_each_tag(FUNC_MEM mem_fn, - FUNC_ACPI acpi_fn, - FUNC_FB fb_fn, - FUNC_SYSTAB64 systab64_fn) + void for_each_tag(auto const &mem_fn, + auto const &acpi_fn, + auto const &fb_fn, + auto const &systab64_fn) { addr_t const size = read(); diff --git a/repos/base-hw/src/core/kernel/cpu.h b/repos/base-hw/src/core/kernel/cpu.h index 40fb9f1354..baf3da3584 100644 --- a/repos/base-hw/src/core/kernel/cpu.h +++ b/repos/base-hw/src/core/kernel/cpu.h @@ -260,10 +260,9 @@ class Kernel::Cpu_pool */ Cpu & executing_cpu() { return cpu(Cpu::executing_id()); } - template - void for_each_cpu(FUNC const &func) + void for_each_cpu(auto const &fn) { - for (unsigned i = 0; i < _nr_of_cpus; i++) func(cpu(i)); + for (unsigned i = 0; i < _nr_of_cpus; i++) fn(cpu(i)); } Inter_processor_work_list & work_list() { diff --git a/repos/base-hw/src/core/kernel/ipc_node.h b/repos/base-hw/src/core/kernel/ipc_node.h index 06eb8ee047..df9f3d7d19 100644 --- a/repos/base-hw/src/core/kernel/ipc_node.h +++ b/repos/base-hw/src/core/kernel/ipc_node.h @@ -113,15 +113,15 @@ class Kernel::Ipc_node Thread &helping_destination(); /** - * Call function 'f' of type 'void (Ipc_node *)' for each helper + * Call 'fn' of type 'void (Ipc_node *)' for each helper */ - template void for_each_helper(F f) + void for_each_helper(auto const &fn) { - _in.queue.for_each([f] (Queue_item &item) { + _in.queue.for_each([fn] (Queue_item &item) { Ipc_node &node { item.object() }; if (node._helping()) - f(node._thread); + fn(node._thread); }); } diff --git a/repos/base-hw/src/core/kernel/object.h b/repos/base-hw/src/core/kernel/object.h index 441ce618a3..0c242bad55 100644 --- a/repos/base-hw/src/core/kernel/object.h +++ b/repos/base-hw/src/core/kernel/object.h @@ -265,9 +265,7 @@ class Kernel::Core_object : public T, Kernel::Core_object_identity /** * Constructor used for objects other than the Core PD */ - template - Core_object(Pd &core_pd, - ARGS &&... args) + Core_object(Pd &core_pd, auto &&... args) : T(args...), Core_object_identity(core_pd, *static_cast(this)) @@ -276,8 +274,7 @@ class Kernel::Core_object : public T, Kernel::Core_object_identity /** * Constructor used for Core PD object */ - template - Core_object(ARGS &&... args) + Core_object(auto &&... args) : T(args...), Core_object_identity(*static_cast(this)) diff --git a/repos/base-hw/src/core/kernel/scheduler.h b/repos/base-hw/src/core/kernel/scheduler.h index 7273027894..7727b24995 100644 --- a/repos/base-hw/src/core/kernel/scheduler.h +++ b/repos/base-hw/src/core/kernel/scheduler.h @@ -106,13 +106,13 @@ class Kernel::Scheduler public: - template void for_each(F const &fn) + void for_each(auto const &fn) { for (List_element * le = _list.first(); le; le = le->next()) fn(*le->object()); } - template void for_each(F const &fn) const + void for_each(auto const &fn) const { for (List_element const * le = _list.first(); le; le = le->next()) fn(*le->object()); @@ -176,10 +176,10 @@ class Kernel::Scheduler Context &_idle; Context *_current { nullptr }; - template void _each_prio_until(F f) + void _each_prio_until(auto const &fn) { for (unsigned p = Priority::max(); p != Priority::min()-1; p--) - if (f(p)) + if (fn(p)) return; } diff --git a/repos/base-hw/src/core/kernel/thread.h b/repos/base-hw/src/core/kernel/thread.h index 6e4f159722..5feedebdf8 100644 --- a/repos/base-hw/src/core/kernel/thread.h +++ b/repos/base-hw/src/core/kernel/thread.h @@ -307,15 +307,14 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout void _call_exception_state(); void _call_single_step(); - template - void _call_new(ARGS &&... args) + template + void _call_new(auto &&... args) { Core::Kernel_object & kobj = *(Core::Kernel_object*)user_arg_1(); kobj.construct(_core_pd, args...); user_arg_0(kobj->core_capid()); } - template void _call_delete() { diff --git a/repos/base-hw/src/core/object.h b/repos/base-hw/src/core/object.h index e143c3aff9..c972e265c5 100644 --- a/repos/base-hw/src/core/object.h +++ b/repos/base-hw/src/core/object.h @@ -49,8 +49,7 @@ class Core::Kernel_object : public Constructible> /** * Creates a kernel object via a syscall */ - template - Kernel_object(Called_from_core, ARGS &&... args) + Kernel_object(Called_from_core, auto &&... args) : _cap(Capability_space::import(T::syscall_create(*this, args...))) { } @@ -58,8 +57,7 @@ class Core::Kernel_object : public Constructible> /** * Creates a kernel object directly */ - template - Kernel_object(Called_from_kernel, ARGS &&... args) + Kernel_object(Called_from_kernel, auto &&... args) : _cap(Capability_space::import(Kernel::cap_id_invalid())) { @@ -77,8 +75,7 @@ class Core::Kernel_object : public Constructible> /** * Create the kernel object explicitely via this function */ - template - bool create(ARGS &&... args) + bool create(auto &&... args) { if (Constructible>::constructed()) return false; diff --git a/repos/base-hw/src/core/platform.h b/repos/base-hw/src/core/platform.h index 1a42cb13dd..de24fa5150 100644 --- a/repos/base-hw/src/core/platform.h +++ b/repos/base-hw/src/core/platform.h @@ -151,8 +151,7 @@ class Core::Platform : public Platform_generic static addr_t core_main_thread_phys_utcb(); - template - static void apply_with_boot_info(T const &fn) + static void apply_with_boot_info(auto const &fn) { fn(_boot_info()); } diff --git a/repos/base-hw/src/core/spec/arm/cpu.cc b/repos/base-hw/src/core/spec/arm/cpu.cc index b38b877d5b..06e6f1baf5 100644 --- a/repos/base-hw/src/core/spec/arm/cpu.cc +++ b/repos/base-hw/src/core/spec/arm/cpu.cc @@ -109,18 +109,17 @@ void Arm_cpu::switch_to(Arm_cpu::Mmu_context & ctx) } -template -static inline void cache_maintainance(addr_t const base, - size_t const size, - size_t const cache_line_size, - FUNC & func) +static inline void cache_maintainance(addr_t const base, + size_t const size, + size_t const cache_line_size, + auto const &fn) { /* align the start address to catch all related cache lines */ addr_t start = base & ~(cache_line_size-1); addr_t const end = base + size; /* iterate over all cachelines of the given region and apply the functor */ - for (; start < end; start += cache_line_size) func(start); + for (; start < end; start += cache_line_size) fn(start); } diff --git a/repos/base-hw/src/core/spec/arm/kernel/thread_caches.cc b/repos/base-hw/src/core/spec/arm/kernel/thread_caches.cc index c9c7d4c38e..27a18d3b20 100644 --- a/repos/base-hw/src/core/spec/arm/kernel/thread_caches.cc +++ b/repos/base-hw/src/core/spec/arm/kernel/thread_caches.cc @@ -19,11 +19,10 @@ using namespace Kernel; -template -static void for_cachelines(addr_t base, - size_t const size, - Kernel::Thread & thread, - FN const & fn) +static void for_cachelines(addr_t base, + size_t const size, + Kernel::Thread &thread, + auto const &fn) { /** * sanity check that only one small page is affected, diff --git a/repos/base-hw/src/core/spec/arm_v8/cpu.cc b/repos/base-hw/src/core/spec/arm_v8/cpu.cc index d8ab97df57..e64e9f88e9 100644 --- a/repos/base-hw/src/core/spec/arm_v8/cpu.cc +++ b/repos/base-hw/src/core/spec/arm_v8/cpu.cc @@ -90,15 +90,14 @@ size_t Cpu::cache_line_size() } -template -static inline void cache_maintainance(addr_t const base, - size_t const size, - FUNC & func) +static inline void cache_maintainance(addr_t const base, + size_t const size, + auto const &fn) { /* align the start address to catch all related cache lines */ addr_t start = (addr_t)base & ~(Cpu::cache_line_size()-1UL); addr_t const end = base + size; - for (; start < end; start += Cpu::cache_line_size()) func(start); + for (; start < end; start += Cpu::cache_line_size()) fn(start); } diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/panic.h b/repos/base-hw/src/core/spec/x86_64/kernel/panic.h index cc9f4fc4cc..94249ee461 100644 --- a/repos/base-hw/src/core/spec/x86_64/kernel/panic.h +++ b/repos/base-hw/src/core/spec/x86_64/kernel/panic.h @@ -18,8 +18,8 @@ #include namespace Kernel { - template - inline void panic(ARGS &&... args) + + inline void panic(auto &&... args) { Genode::error("Kernel panic: ", args...); /* This is CPU local, but should be sufficient for now. */ diff --git a/repos/base-hw/src/core/spec/x86_64/virtualization/ept.h b/repos/base-hw/src/core/spec/x86_64/virtualization/ept.h index cb54126afe..e097f11772 100644 --- a/repos/base-hw/src/core/spec/x86_64/virtualization/ept.h +++ b/repos/base-hw/src/core/spec/x86_64/virtualization/ept.h @@ -29,7 +29,7 @@ namespace Hw { * Table 29-2. Format of an EPT PML4 Entry (PML4E) that References an * EPT Page-Directory-Pointer Table */ - struct Ept_common_descriptor : Genode::Register<64> + struct Ept_common_descriptor : Genode::Register<64> { struct R : Bitfield< 0,1> { }; /* Read */ struct W : Bitfield< 1,1> { }; /* Write */ @@ -61,7 +61,6 @@ namespace Hw { }; - template struct Pml4e_table_descriptor : Ept_common_descriptor { diff --git a/repos/base-hw/src/include/base/internal/align_at.h b/repos/base-hw/src/include/base/internal/align_at.h index 9ae3dd6943..cf837bf1ac 100644 --- a/repos/base-hw/src/include/base/internal/align_at.h +++ b/repos/base-hw/src/include/base/internal/align_at.h @@ -39,8 +39,7 @@ class Genode::Align_at public: - template - Align_at(ARGS &&... args) + Align_at(auto &&... args) : _obj(*construct_at(_start_addr(), args...)) { } ~Align_at() { _obj.~T(); } diff --git a/repos/base-hw/src/include/base/internal/cache.h b/repos/base-hw/src/include/base/internal/cache.h index 54a3752f53..488be58ee7 100644 --- a/repos/base-hw/src/include/base/internal/cache.h +++ b/repos/base-hw/src/include/base/internal/cache.h @@ -18,10 +18,9 @@ #include #include -template static inline void for_each_page(Genode::addr_t addr, Genode::size_t size, - FN const & fn) + auto const &fn) { using namespace Genode; @@ -36,10 +35,9 @@ static inline void for_each_page(Genode::addr_t addr, } -template static inline void for_each_cache_line(Genode::addr_t addr, Genode::size_t size, - FN const & fn) + auto const &fn) { using namespace Genode; diff --git a/repos/base-hw/src/include/hw/memory_map.h b/repos/base-hw/src/include/hw/memory_map.h index 0503e1af4a..002b0c2044 100644 --- a/repos/base-hw/src/include/hw/memory_map.h +++ b/repos/base-hw/src/include/hw/memory_map.h @@ -41,12 +41,11 @@ struct Hw::Mmio_space : Hw::Memory_region_array { using Hw::Memory_region_array::Memory_region_array; - template - void for_each_mapping(FUNC f) const + void for_each_mapping(auto const &fn) const { addr_t virt_base = Mm::core_mmio().base; auto lambda = [&] (unsigned, Memory_region const & r) { - f(Mapping { r.base, virt_base, r.size, Genode::PAGE_FLAGS_KERN_IO }); + fn(Mapping { r.base, virt_base, r.size, Genode::PAGE_FLAGS_KERN_IO }); virt_base += r.size + get_page_size(); }; for_each(lambda); diff --git a/repos/base-hw/src/include/hw/spec/arm_64/memory_map.h b/repos/base-hw/src/include/hw/spec/arm_64/memory_map.h index e6ec5afda1..ad944b8c9e 100644 --- a/repos/base-hw/src/include/hw/spec/arm_64/memory_map.h +++ b/repos/base-hw/src/include/hw/spec/arm_64/memory_map.h @@ -19,8 +19,7 @@ namespace Hw { namespace Mm { - template - Genode::addr_t el2_addr(T t) + Genode::addr_t el2_addr(auto t) { static constexpr Genode::addr_t OFF = 0xffffff8000000000UL; return (Genode::addr_t)t - OFF; diff --git a/repos/base-hw/src/include/hw/spec/riscv/page_table.h b/repos/base-hw/src/include/hw/spec/riscv/page_table.h index 5d94406d3d..fa92026d8c 100644 --- a/repos/base-hw/src/include/hw/spec/riscv/page_table.h +++ b/repos/base-hw/src/include/hw/spec/riscv/page_table.h @@ -184,8 +184,7 @@ class Sv39::Level_x_translation_table return align_addr(region, (unsigned)alignment) / (1UL << alignment); } - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { /* sanity check vo bits 38 to 63 must be equal */ addr_t sanity = vo >> 38; @@ -202,7 +201,7 @@ class Sv39::Level_x_translation_table addr_t end = (vo + BLOCK_SIZE) & BLOCK_MASK; size_t sz = min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* flush cached table entry address */ _translation_added((addr_t)&_entries[i], sz); @@ -228,7 +227,7 @@ class Sv39::Level_x_translation_table void operator () (addr_t const vo, addr_t const pa, size_t const size, - typename Descriptor::access_t &desc) + typename Descriptor::access_t &desc) const { using Td = Table_descriptor; @@ -280,7 +279,7 @@ class Sv39::Level_x_translation_table void operator () (addr_t const vo, addr_t const /* pa */, size_t const size, - typename Descriptor::access_t &desc) + typename Descriptor::access_t &desc) const { using Td = Table_descriptor; @@ -375,7 +374,7 @@ namespace Sv39 { void operator () (addr_t const vo, addr_t const pa, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { if ((vo & ~BLOCK_MASK) || (pa & ~BLOCK_MASK) || size < BLOCK_SIZE) { @@ -401,7 +400,7 @@ namespace Sv39 { void operator () (addr_t /* vo */, addr_t /* pa */, size_t /* size */, - Descriptor::access_t &desc) { + Descriptor::access_t &desc) const { desc = 0; } }; } diff --git a/repos/base-hw/src/include/hw/spec/x86_64/acpi.h b/repos/base-hw/src/include/hw/spec/x86_64/acpi.h index 0f853ec962..354146e3e7 100644 --- a/repos/base-hw/src/include/hw/spec/x86_64/acpi.h +++ b/repos/base-hw/src/include/hw/spec/x86_64/acpi.h @@ -23,14 +23,9 @@ namespace Hw { struct Acpi_fadt; struct Acpi_facs; - template - void for_each_rsdt_entry(Hw::Acpi_generic &, FUNC); - - template - void for_each_xsdt_entry(Hw::Acpi_generic &, FUNC); - - template - void for_each_apic_struct(Acpi_generic &, FUNC); + void for_each_rsdt_entry (Hw::Acpi_generic &, auto const &); + void for_each_xsdt_entry (Hw::Acpi_generic &, auto const &); + void for_each_apic_struct(Acpi_generic &, auto const &); } @@ -378,8 +373,7 @@ struct Hw::Acpi_facs : Genode::Mmio<64> }; -template -void Hw::for_each_rsdt_entry(Hw::Acpi_generic &rsdt, FUNC fn) +void Hw::for_each_rsdt_entry(Hw::Acpi_generic &rsdt, auto const &fn) { if (Genode::memcmp(rsdt.signature, "RSDT", 4)) return; @@ -395,8 +389,7 @@ void Hw::for_each_rsdt_entry(Hw::Acpi_generic &rsdt, FUNC fn) } -template -void Hw::for_each_xsdt_entry(Hw::Acpi_generic &xsdt, FUNC fn) +void Hw::for_each_xsdt_entry(Hw::Acpi_generic &xsdt, auto const &fn) { if (Genode::memcmp(xsdt.signature, "XSDT", 4)) return; @@ -412,8 +405,7 @@ void Hw::for_each_xsdt_entry(Hw::Acpi_generic &xsdt, FUNC fn) } -template -void Hw::for_each_apic_struct(Hw::Acpi_generic &apic_madt, FUNC fn) +void Hw::for_each_apic_struct(Hw::Acpi_generic &apic_madt, auto const &fn) { if (Genode::memcmp(apic_madt.signature, "APIC", 4)) return; diff --git a/repos/base-hw/src/include/hw/spec/x86_64/page_table.h b/repos/base-hw/src/include/hw/spec/x86_64/page_table.h index f85a64dc90..acc4911d8b 100644 --- a/repos/base-hw/src/include/hw/spec/x86_64/page_table.h +++ b/repos/base-hw/src/include/hw/spec/x86_64/page_table.h @@ -143,7 +143,7 @@ class Hw::Level_4_translation_table void operator () (addr_t const vo, addr_t const pa, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { if ((vo & ~PAGE_MASK) || (pa & ~PAGE_MASK) || size < PAGE_SIZE) @@ -165,12 +165,11 @@ class Hw::Level_4_translation_table struct Remove_func { void operator () (addr_t /* vo */, addr_t /* pa */, size_t /* size */, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { desc = 0; } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = vo >> PAGE_SIZE_LOG2; size > 0; i = vo >> PAGE_SIZE_LOG2) { @@ -178,7 +177,7 @@ class Hw::Level_4_translation_table addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; @@ -352,7 +351,7 @@ class Hw::Page_directory void operator () (addr_t const vo, addr_t const pa, size_t const size, - typename Descriptor::access_t &desc) + typename Descriptor::access_t &desc) const { using Td = Table_descriptor; using access_t = typename Descriptor::access_t; @@ -397,7 +396,7 @@ class Hw::Page_directory void operator () (addr_t const vo, addr_t /* pa */, size_t const size, - typename Base_descriptor::access_t &desc) + typename Base_descriptor::access_t &desc) const { if (Base_descriptor::present(desc)) { if (Base_descriptor::maps_page(desc)) { @@ -418,8 +417,7 @@ class Hw::Page_directory } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = vo >> PAGE_SIZE_LOG2; size > 0; i = vo >> PAGE_SIZE_LOG2) @@ -428,7 +426,7 @@ class Hw::Page_directory addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; @@ -553,7 +551,7 @@ class Hw::Pml4_table void operator () (addr_t const vo, addr_t const pa, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { /* we need to use a next level table */ if (!Descriptor::present(desc)) { @@ -577,7 +575,7 @@ class Hw::Pml4_table void operator () (addr_t const vo, addr_t /* pa */, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { if (Descriptor::present(desc)) { /* use allocator to retrieve virt address of table */ @@ -592,8 +590,7 @@ class Hw::Pml4_table } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = (vo & SIZE_MASK) >> PAGE_SIZE_LOG2; size > 0; i = (vo & SIZE_MASK) >> PAGE_SIZE_LOG2) { @@ -601,7 +598,7 @@ class Hw::Pml4_table addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; diff --git a/repos/base-hw/src/test/cpu_scheduler/main.cc b/repos/base-hw/src/test/cpu_scheduler/main.cc index 9f673e198d..1eba863af6 100644 --- a/repos/base-hw/src/test/cpu_scheduler/main.cc +++ b/repos/base-hw/src/test/cpu_scheduler/main.cc @@ -60,10 +60,10 @@ class Scheduler_test::Context : public Kernel::Scheduler::Context struct Scheduler_test::Scheduler : Kernel::Scheduler { - template void _each_prio_until(F f) const + void _each_prio_until(auto const &fn) const { for (unsigned p = Priority::max(); p != Priority::min()-1; p--) - if (f(p)) + if (fn(p)) return; } diff --git a/repos/base-linux/src/core/include/pager.h b/repos/base-linux/src/core/include/pager.h index 4e806da244..e41adf9ced 100644 --- a/repos/base-linux/src/core/include/pager.h +++ b/repos/base-linux/src/core/include/pager.h @@ -54,9 +54,8 @@ struct Core::Pager_entrypoint { Pager_entrypoint(Rpc_cap_factory &) { } - template - auto apply(Pager_capability, FUNC f) -> decltype(f(nullptr)) { - return f(nullptr); } + auto apply(Pager_capability, auto const &fn) -> decltype(fn(nullptr)) { + return fn(nullptr); } Pager_capability manage(Pager_object &) { return Pager_capability(); } diff --git a/repos/base-linux/src/include/base/internal/capability_space_tpl.h b/repos/base-linux/src/include/base/internal/capability_space_tpl.h index b4c8666ed4..52008d94b2 100644 --- a/repos/base-linux/src/include/base/internal/capability_space_tpl.h +++ b/repos/base-linux/src/include/base/internal/capability_space_tpl.h @@ -89,8 +89,7 @@ class Genode::Capability_space_tpl : Noncopyable */ struct Tree_managed_data : Data, Avl_node { - template - Tree_managed_data(ARGS... args) : Data(args...) { } + Tree_managed_data(auto &&... args) : Data(args...) { } Tree_managed_data() { } @@ -142,8 +141,7 @@ class Genode::Capability_space_tpl : Noncopyable * The arguments are passed to the constructor of the * 'Native_capability::Data' type. */ - template - Native_capability::Data &_create_capability_unsynchronized(ARGS &&... args) + Native_capability::Data &_create_capability_unsynchronized(auto &&... args) { addr_t const index = _alloc.alloc(); diff --git a/repos/base-linux/src/include/base/internal/native_thread.h b/repos/base-linux/src/include/base/internal/native_thread.h index e921e837f1..9f7740fd39 100644 --- a/repos/base-linux/src/include/base/internal/native_thread.h +++ b/repos/base-linux/src/include/base/internal/native_thread.h @@ -80,8 +80,7 @@ class Genode::Native_thread /* * Execute functor 'fn' in the context of the 'poll' method. */ - template - void _exec_control(FN const &); + void _exec_control(auto const &fn); public: diff --git a/repos/base-linux/src/include/base/internal/region_map_mmap.h b/repos/base-linux/src/include/base/internal/region_map_mmap.h index 345485ab28..3be5ca4a4c 100644 --- a/repos/base-linux/src/include/base/internal/region_map_mmap.h +++ b/repos/base-linux/src/include/base/internal/region_map_mmap.h @@ -114,8 +114,7 @@ class Genode::Region_map_mmap : public Region_map, public Dataspace Region_map_mmap(bool sub_rm, size_t size = ~0) : _sub_rm(sub_rm), _size(size), _base(0) { } - template - void with_attached_sub_rm_base_ptr(FN const &fn) + void with_attached_sub_rm_base_ptr(auto const &fn) { if (_sub_rm && _is_attached()) fn((void *)_base); diff --git a/repos/base-nova/include/nova/syscall-generic.h b/repos/base-nova/include/nova/syscall-generic.h index 4aca61e523..7842e48f18 100644 --- a/repos/base-nova/include/nova/syscall-generic.h +++ b/repos/base-nova/include/nova/syscall-generic.h @@ -228,8 +228,7 @@ namespace Nova { /** * Iterate over all CPUs in a _ever_ _consistent_ order. */ - template - bool for_all_cpus(FUNC const &func) const + bool for_all_cpus(auto const &fn) const { for (uint16_t package = 0; package <= 255; package++) { for (uint16_t core = 0; core <= 255; core++) { @@ -246,7 +245,7 @@ namespace Nova { cpu->thread == thread)) continue; - bool done = func(*cpu, i); + bool done = fn(*cpu, i); if (done) return done; } @@ -256,14 +255,13 @@ namespace Nova { return false; } - template - void for_each_enabled_cpu(FUNC const &func) const + void for_each_enabled_cpu(auto const &fn) const { for (unsigned i = 0; i < cpu_max(); i++) { Cpu_desc const * cpu = cpu_desc_of_cpu(i); if (!is_cpu_enabled(i)) continue; if (!cpu) return; - func(*cpu, i); + fn(*cpu, i); } } diff --git a/repos/base-nova/src/core/include/nova_util.h b/repos/base-nova/src/core/include/nova_util.h index 25187b2b5e..006c0743e6 100644 --- a/repos/base-nova/src/core/include/nova_util.h +++ b/repos/base-nova/src/core/include/nova_util.h @@ -219,12 +219,11 @@ inline void unmap_local(Nova::Utcb &, Genode::addr_t start, } -template -inline Nova::uint8_t syscall_retry(Core::Pager_object &pager, FUNC func) +inline Nova::uint8_t syscall_retry(Core::Pager_object &pager, auto const &fn) { Nova::uint8_t res; do { - res = func(); + res = fn(); } while (res == Nova::NOVA_PD_OOM && Nova::NOVA_OK == pager.handle_oom()); return res; diff --git a/repos/base-nova/src/core/include/platform.h b/repos/base-nova/src/core/include/platform.h index b914a81f85..7674a6ec68 100644 --- a/repos/base-nova/src/core/include/platform.h +++ b/repos/base-nova/src/core/include/platform.h @@ -131,8 +131,7 @@ class Core::Platform : public Platform_generic */ unsigned core_pd_sel() const { return _core_pd_sel; } - template - void for_each_location(FUNC const &fn) + void for_each_location(auto const &fn) { for (unsigned x = 0; x < _cpus.width(); x++) { for (unsigned y = 0; y < _cpus.height(); y++) { diff --git a/repos/base-nova/src/core/pd_session_support.cc b/repos/base-nova/src/core/pd_session_support.cc index 93b9df4e0f..e76e939256 100644 --- a/repos/base-nova/src/core/pd_session_support.cc +++ b/repos/base-nova/src/core/pd_session_support.cc @@ -20,12 +20,11 @@ using namespace Core; -template -inline Nova::uint8_t retry_syscall(addr_t pd_sel, FUNC func) +inline Nova::uint8_t retry_syscall(addr_t pd_sel, auto const &fn) { Nova::uint8_t res; do { - res = func(); + res = fn(); } while (res == Nova::NOVA_PD_OOM && Nova::NOVA_OK == Pager_object::handle_oom(Pager_object::SRC_CORE_PD, pd_sel, @@ -127,8 +126,7 @@ class System_control_impl : public Core::System_control System_control_component objects [Core::Platform::MAX_SUPPORTED_CPUS] { }; - template - auto with_location(auto const &location, T const &fn) + auto with_location(auto const &location, auto const &fn) { unsigned const index = platform_specific().pager_index(location); @@ -138,8 +136,7 @@ class System_control_impl : public Core::System_control return Capability { }; } - template - auto with_location(auto const &location, T const &fn) const + auto with_location(auto const &location, auto const &fn) const { unsigned const index = platform_specific().pager_index(location); diff --git a/repos/base-nova/src/core/vm_session_component.cc b/repos/base-nova/src/core/vm_session_component.cc index dd937ae156..b137080ecd 100644 --- a/repos/base-nova/src/core/vm_session_component.cc +++ b/repos/base-nova/src/core/vm_session_component.cc @@ -66,13 +66,12 @@ static Nova::uint8_t kernel_quota_upgrade(addr_t const pd_target) } -template static uint8_t _with_kernel_quota_upgrade(addr_t const pd_target, - FUNC const &func) + auto const &fn) { uint8_t res; do { - res = func(); + res = fn(); } while (res == Nova::NOVA_PD_OOM && Nova::NOVA_OK == kernel_quota_upgrade(pd_target)); return res; diff --git a/repos/base-nova/src/lib/base/vm.cc b/repos/base-nova/src/lib/base/vm.cc index d67ab14311..871ab1e27e 100644 --- a/repos/base-nova/src/lib/base/vm.cc +++ b/repos/base-nova/src/lib/base/vm.cc @@ -638,8 +638,7 @@ void Nova_vcpu::with_state(Call_with_state &cw) } -template -static void nova_reply(Thread &myself, Nova::Utcb &utcb, ARGS &&... args) +static void nova_reply(Thread &myself, Nova::Utcb &utcb, auto &&... args) { Receive_window &rcv_window = myself.native_thread().server_rcv_window; @@ -649,6 +648,7 @@ static void nova_reply(Thread &myself, Nova::Utcb &utcb, ARGS &&... args) Nova::reply(myself.stack_top(), args...); } + void Nova_vcpu::_exit_entry(addr_t badge) { Thread &myself = *Thread::myself(); diff --git a/repos/base-nova/src/test/nova/main.cc b/repos/base-nova/src/test/nova/main.cc index 5f62b9532b..2408639b82 100644 --- a/repos/base-nova/src/test/nova/main.cc +++ b/repos/base-nova/src/test/nova/main.cc @@ -636,8 +636,7 @@ class Greedy : public Genode::Thread { }; -template -void check(uint8_t res, ARGS &&... args) +void check(uint8_t res, auto &&... args) { String<128> msg(args...); @@ -649,6 +648,7 @@ void check(uint8_t res, ARGS &&... args) log("res=", res, " ", msg); } + struct Main { Genode::Env &env; @@ -657,6 +657,7 @@ struct Main Main(Env &env); }; + Main::Main(Env &env) : env(env) { log("testing base-nova platform"); diff --git a/repos/base-sel4/src/core/include/initial_untyped_pool.h b/repos/base-sel4/src/core/include/initial_untyped_pool.h index c4995ace15..89093c486b 100644 --- a/repos/base-sel4/src/core/include/initial_untyped_pool.h +++ b/repos/base-sel4/src/core/include/initial_untyped_pool.h @@ -72,7 +72,7 @@ class Core::Initial_untyped_pool /** * Calculate free index after allocation */ - addr_t _align_offset(Range &range, unsigned size_log2) + addr_t _align_offset(Range const &range, unsigned size_log2) { /* * The seL4 kernel naturally aligns allocations within untuped @@ -90,13 +90,12 @@ class Core::Initial_untyped_pool * * The functor is called with 'Range &' as argument. */ - template - void for_each_range(FUNC const &func) + void for_each_range(auto const &fn) { seL4_BootInfo const &bi = sel4_boot_info(); for (addr_t sel = bi.untyped.start; sel < bi.untyped.end; sel++) { Range range(*this, (unsigned)sel); - func(range); + fn(range); } } @@ -124,7 +123,7 @@ class Core::Initial_untyped_pool * Go through the known initial untyped memory ranges to find * a range that is able to host a kernel object of 'size'. */ - for_each_range([&] (Range &range) { + for_each_range([&] (Range const &range) { /* ignore device memory */ if (range.device) return; @@ -176,13 +175,12 @@ class Core::Initial_untyped_pool * Convert (remainder) of the initial untyped memory into untyped * objects of size_log2 and up to a maximum as specified by max_memory */ - template void turn_into_untyped_object(addr_t const node_index, - FUNC const & func, + auto const &fn, size_t const size_log2 = get_page_size_log2(), addr_t max_memory = 0UL - 0x1000UL) { - for_each_range([&] (Range &range) { + for_each_range([&] (Range const &range) { /* * The kernel limits the maximum number of kernel objects to @@ -226,8 +224,8 @@ class Core::Initial_untyped_pool } /* invoke callback about the range */ - bool const used = func(phys_addr, num_pages << size_log2, - range.device); + bool const used = fn(phys_addr, num_pages << size_log2, + range.device); if (!used) return; diff --git a/repos/base-sel4/src/core/include/page_table_registry.h b/repos/base-sel4/src/core/include/page_table_registry.h index a352fd8313..134771b729 100644 --- a/repos/base-sel4/src/core/include/page_table_registry.h +++ b/repos/base-sel4/src/core/include/page_table_registry.h @@ -186,8 +186,8 @@ class Core::Page_table_registry } } - template - void _flush_high(FN const &fn, Avl_tree &tree, Allocator &alloc) + template + void _flush_high(auto const &fn, Avl_tree &tree, Allocator &alloc) { for (T *element; (element = tree.first());) { @@ -248,8 +248,7 @@ class Core::Page_table_registry * The functor is called with the selector of the page table entry * (the copy of the phys frame selector) as argument. */ - template - void flush_page(addr_t vaddr, FN const &fn) + void flush_page(addr_t vaddr, auto const &fn) { Frame * frame = Frame::lookup(_frames, vaddr, LEVEL_0); if (!frame) @@ -260,8 +259,7 @@ class Core::Page_table_registry destroy(_alloc_frames, frame); } - template - void flush_pages(FN const &fn) + void flush_pages(auto const &fn) { Avl_tree tmp; @@ -282,8 +280,7 @@ class Core::Page_table_registry } } - template - void flush_all(PG const &pages, LV const &level) + void flush_all(auto const &pages, auto const &level) { flush_pages(pages); _flush_high(level, _level1, _alloc_high); diff --git a/repos/base-sel4/src/core/include/vm_space.h b/repos/base-sel4/src/core/include/vm_space.h index 80c09da314..9554943ca7 100644 --- a/repos/base-sel4/src/core/include/vm_space.h +++ b/repos/base-sel4/src/core/include/vm_space.h @@ -169,8 +169,7 @@ class Core::Vm_space return Cap_sel((uint32_t)((_id << 20) | idx)); } - template - void _flush(bool const flush_support, FN const &fn) + void _flush(bool const flush_support, auto const &fn) { if (!flush_support) { warning("mapping cache full, but can't flush"); @@ -183,9 +182,8 @@ class Core::Vm_space _page_table_registry.flush_pages(fn); } - template bool _map_frame(addr_t const from_phys, addr_t const to_dest, - Map_attr const attr, bool guest, FN const &fn) + Map_attr const attr, bool guest, auto const &fn) { if (_page_table_registry.page_frame_at(to_dest)) { /* diff --git a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h index 1c414d8b00..c4c91bccb6 100644 --- a/repos/base-sel4/src/include/base/internal/capability_space_sel4.h +++ b/repos/base-sel4/src/include/base/internal/capability_space_sel4.h @@ -147,8 +147,7 @@ class Genode::Capability_space_sel4 */ struct Tree_managed_data : Data, Avl_node { - template - Tree_managed_data(ARGS... args) : Data(args...) { } + Tree_managed_data(auto &&... args) : Data(args...) { } Tree_managed_data() { } @@ -210,8 +209,7 @@ class Genode::Capability_space_sel4 * The arguments following the selector are passed to the constructor * of the 'Native_capability::Data' type. */ - template - Native_capability::Data &create_capability(Cap_sel cap_sel, ARGS... args) + Native_capability::Data &create_capability(Cap_sel cap_sel, auto &&... args) { addr_t const sel = cap_sel.value(); diff --git a/repos/base/include/base/allocator_avl.h b/repos/base/include/base/allocator_avl.h index ebcd07136f..cead57ce4a 100644 --- a/repos/base/include/base/allocator_avl.h +++ b/repos/base/include/base/allocator_avl.h @@ -384,10 +384,9 @@ class Genode::Allocator_avl_tpl : public Allocator_avl_base /** * Construct meta-data object in place * - * \param ARGS arguments passed to the meta-data constuctor + * \param args arguments passed to the meta-data constuctor */ - template - void construct_metadata(void *addr, ARGS &&... args) + void construct_metadata(void *addr, auto &&... args) { Block * const b = static_cast(_find_by_address((addr_t)addr)); if (b) construct_at(static_cast(b), args...); diff --git a/repos/base/include/base/thread.h b/repos/base/include/base/thread.h index c47a874301..567500e11b 100644 --- a/repos/base/include/base/thread.h +++ b/repos/base/include/base/thread.h @@ -28,7 +28,6 @@ namespace Genode { class Thread; class Stack; class Env; - template class Thread_deprecated; } @@ -169,11 +168,6 @@ class Genode::Thread * * \noapi * - * FIXME: With type = Forked_main_thread the stack allocation - * gets skipped but we should at least set Stack::ds_cap in a - * way that it references the dataspace of the already attached - * stack. - * * \deprecated superseded by the 'Thread(Env &...' constructor */ Thread(size_t weight, const char *name, size_t stack_size, diff --git a/repos/base/include/spec/x86_64/page_table/page_table_base.h b/repos/base/include/spec/x86_64/page_table/page_table_base.h index d4938bbcc5..37b3df98dc 100644 --- a/repos/base/include/spec/x86_64/page_table/page_table_base.h +++ b/repos/base/include/spec/x86_64/page_table/page_table_base.h @@ -90,7 +90,7 @@ class Genode::Final_table void operator () (addr_t const vo, addr_t const pa, size_t const size, - DESCRIPTOR::access_t &desc) + DESCRIPTOR::access_t &desc) const { if ((vo & ~PAGE_MASK) || (pa & ~PAGE_MASK) || size < PAGE_SIZE) @@ -119,7 +119,7 @@ class Genode::Final_table Remove_func(bool flush) : flush(flush) { } void operator () (addr_t /* vo */, addr_t /* pa */, size_t /* size */, - DESCRIPTOR::access_t &desc) + DESCRIPTOR::access_t &desc) const { desc = 0; @@ -128,15 +128,14 @@ class Genode::Final_table } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = vo >> PAGE_SIZE_LOG2; size > 0; i = vo >> PAGE_SIZE_LOG2) { addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; @@ -173,8 +172,7 @@ class Genode::Final_table return true; } - template - void for_each_entry(FN && fn) + void for_each_entry(auto const &fn) { for (unsigned long i = 0; i < MAX_ENTRIES; i++) { if (Descriptor::present(_entries[i])) @@ -257,7 +255,7 @@ class Genode::Page_directory void operator () (addr_t const vo, addr_t const pa, size_t const size, - typename Descriptor::access_t &desc) + typename Descriptor::access_t &desc) const { using Td = Descriptor::Table; using access_t = typename Descriptor::access_t; @@ -316,7 +314,7 @@ class Genode::Page_directory void operator () (addr_t const vo, addr_t /* pa */, size_t const size, - typename Descriptor::access_t &desc) + typename Descriptor::access_t &desc) const { if (Descriptor::present(desc)) { if (Descriptor::maps_page(desc)) { @@ -348,8 +346,7 @@ class Genode::Page_directory } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = vo >> PAGE_SIZE_LOG2; size > 0; i = vo >> PAGE_SIZE_LOG2) @@ -357,7 +354,7 @@ class Genode::Page_directory addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; @@ -392,8 +389,7 @@ class Genode::Page_directory return true; } - template - void for_each_entry(FN && fn) + void for_each_entry(auto const &fn) { for (unsigned long i = 0; i < MAX_ENTRIES; i++) if (Descriptor::present(_entries[i])) @@ -417,9 +413,11 @@ class Genode::Page_directory void insert_translation(addr_t vo, addr_t pa, size_t size, Page_flags const & flags, ALLOCATOR & alloc, bool flush = false, - uint32_t supported_sizes = (1U << 30 | 1U << 21 | 1U << 12)) { + uint32_t supported_sizes = (1U << 30 | 1U << 21 | 1U << 12)) + { _range_op(vo, pa, size, - Insert_func(flags, alloc, flush, supported_sizes)); } + Insert_func(flags, alloc, flush, supported_sizes)); + } /** * Remove translations that overlap with a given virtual region @@ -472,7 +470,7 @@ class Genode::Pml4_table void operator () (addr_t const vo, addr_t const pa, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { /* we need to use a next level table */ if (!Descriptor::present(desc)) { @@ -510,7 +508,7 @@ class Genode::Pml4_table void operator () (addr_t const vo, addr_t /* pa */, size_t const size, - Descriptor::access_t &desc) + Descriptor::access_t &desc) const { if (Descriptor::present(desc)) { /* use allocator to retrieve virt address of table */ @@ -535,15 +533,14 @@ class Genode::Pml4_table } }; - template - void _range_op(addr_t vo, addr_t pa, size_t size, FUNC &&func) + void _range_op(addr_t vo, addr_t pa, size_t size, auto const &fn) { for (size_t i = (vo & SIZE_MASK) >> PAGE_SIZE_LOG2; size > 0; i = (vo & SIZE_MASK) >> PAGE_SIZE_LOG2) { addr_t end = (vo + PAGE_SIZE) & PAGE_MASK; size_t sz = Genode::min(size, end-vo); - func(vo, pa, sz, _entries[i]); + fn(vo, pa, sz, _entries[i]); /* check whether we wrap */ if (end < vo) return; @@ -596,8 +593,7 @@ class Genode::Pml4_table return true; } - template - void for_each_entry(FN && fn) + void for_each_entry(auto const &fn) { for (unsigned long i = 0; i < MAX_ENTRIES; i++) { if (Descriptor::present(_entries[i])) diff --git a/repos/base/src/core/include/synced_range_allocator.h b/repos/base/src/core/include/synced_range_allocator.h index d47ebfe7f3..1ca37e1f0d 100644 --- a/repos/base/src/core/include/synced_range_allocator.h +++ b/repos/base/src/core/include/synced_range_allocator.h @@ -51,12 +51,10 @@ class Core::Synced_range_allocator : public Range_allocator using Guard = typename Synced_interface::Guard; - template - Synced_range_allocator(Mutex &mutex, ARGS &&... args) + Synced_range_allocator(Mutex &mutex, auto &&... args) : _mutex(mutex), _alloc(args...), _synced_object(_mutex, &_alloc) { } - template - Synced_range_allocator(ARGS &&... args) + Synced_range_allocator(auto &&... args) : _alloc(args...), _synced_object(_mutex, &_alloc) { } Guard operator () () { return _synced_object(); } diff --git a/repos/base/src/include/base/internal/capability_space_tpl.h b/repos/base/src/include/base/internal/capability_space_tpl.h index 7b2f9d083a..17486f81a6 100644 --- a/repos/base/src/include/base/internal/capability_space_tpl.h +++ b/repos/base/src/include/base/internal/capability_space_tpl.h @@ -90,8 +90,7 @@ class Genode::Capability_space_tpl */ struct Tree_managed_data : Data, Avl_node { - template - Tree_managed_data(ARGS... args) : Data(args...) { } + Tree_managed_data(auto... args) : Data(args...) { } Tree_managed_data() { } @@ -143,8 +142,7 @@ class Genode::Capability_space_tpl * The arguments are passed to the constructor of the * 'Native_capability::Data' type. */ - template - Native_capability::Data &create_capability(ARGS... args) + Native_capability::Data &create_capability(auto... args) { Mutex::Guard guard(_mutex); diff --git a/repos/base/src/include/base/internal/output.h b/repos/base/src/include/base/internal/output.h index ada980e5c7..297b993419 100644 --- a/repos/base/src/include/base/internal/output.h +++ b/repos/base/src/include/base/internal/output.h @@ -32,8 +32,7 @@ static inline char ascii(int digit, int uppercase = 0) /** * Output signed value with the specified base */ -template -static inline void out_signed(T value, unsigned base, OUT_CHAR_FN const &out_char) +static inline void out_signed(auto value, unsigned base, auto const &out_char_fn) { /** * for base 8, the number of digits is the number of value bytes times 3 @@ -61,20 +60,19 @@ static inline void out_signed(T value, unsigned base, OUT_CHAR_FN const &out_cha /* add sign to buffer for negative values */ if (neg) - out_char('-'); + out_char_fn('-'); /* output buffer in reverse order */ for (; i--; ) - out_char(buf[i]); + out_char_fn(buf[i]); } /** * Output unsigned value with the specified base and padding */ -template -static inline void out_unsigned(T value, unsigned base, int pad, - OUT_CHAR_FN const &out_char) +static inline void out_unsigned(auto value, unsigned base, int pad, + auto const &out_char_fn) { /** * for base 8, the number of digits is the number of value bytes times 3 @@ -97,19 +95,19 @@ static inline void out_unsigned(T value, unsigned base, int pad, /* add padding zeros */ for (; pad-- > 0; ) - out_char(ascii(0)); + out_char_fn(ascii(0)); /* output buffer in reverse order */ for (; i--; ) - out_char(buf[i]); + out_char_fn(buf[i]); } /** * Output floating point value */ -template -static inline void out_float(T value, unsigned base, unsigned length, OUT_CHAR_FN const &out_char) +template +static inline void out_float(T value, unsigned base, unsigned length, auto const &out_char_fn) { using namespace Genode; @@ -136,10 +134,10 @@ static inline void out_float(T value, unsigned base, unsigned length, OUT_CHAR_F uint64_t integer = (uint64_t)volatile_value; if (neg) - out_char('-'); + out_char_fn('-'); - out_unsigned(integer, base, 0, out_char); - out_char('.'); + out_unsigned(integer, base, 0, out_char_fn); + out_char_fn('.'); if (length) { do { @@ -147,7 +145,7 @@ static inline void out_float(T value, unsigned base, unsigned length, OUT_CHAR_F volatile_value = (T)(volatile_value * (T)base); integer = (uint64_t)volatile_value; - out_char(ascii((int)integer)); + out_char_fn(ascii((int)integer)); length--; } while (length && (volatile_value > 0.0)); diff --git a/repos/base/src/include/base/internal/unmanaged_singleton.h b/repos/base/src/include/base/internal/unmanaged_singleton.h index 3ad243a810..0909cd5d71 100644 --- a/repos/base/src/include/base/internal/unmanaged_singleton.h +++ b/repos/base/src/include/base/internal/unmanaged_singleton.h @@ -54,8 +54,8 @@ struct Unmanaged_singleton_constructor /** * Call the constructor of 'T' with arguments 'args' at 'dst' */ - template - static void call(char * const dst, ARGS &&... args) { new (dst) T(args...); } + template + static void call(char * const dst, auto &&... args) { new (dst) T(args...); } }; /** @@ -67,8 +67,8 @@ struct Unmanaged_singleton_constructor * * \return object pointer */ -template -static inline T * unmanaged_singleton(ARGS &&... args) +template +static inline T * unmanaged_singleton(auto &&... args) { /* * Each instantiation of the function template with a different type 'T' diff --git a/repos/base/src/lib/base/allocator_avl.cc b/repos/base/src/lib/base/allocator_avl.cc index 816a9d92ab..b5b9998a3e 100644 --- a/repos/base/src/lib/base/allocator_avl.cc +++ b/repos/base/src/lib/base/allocator_avl.cc @@ -171,8 +171,7 @@ void Allocator_avl_base::_cut_from_block(Block &b, addr_t addr, size_t size, Two } -template -bool Allocator_avl_base::_revert_block_ranges(FN const &any_block_fn) +bool Allocator_avl_base::_revert_block_ranges(auto const &any_block_fn) { size_t blocks = 0; for (bool loop = true; loop; blocks++) { @@ -309,10 +308,9 @@ Allocator_avl_base::Range_result Allocator_avl_base::remove_range(addr_t base, s } -template Allocator::Alloc_result Allocator_avl_base::_allocate(size_t const size, unsigned align, Range range, - SEARCH_FN const &search_fn) + auto const &search_fn) { return _alloc_two_blocks_metadata().convert( diff --git a/repos/base/src/lib/base/root_proxy.cc b/repos/base/src/lib/base/root_proxy.cc index 9d55b9e295..b642aa2c07 100644 --- a/repos/base/src/lib/base/root_proxy.cc +++ b/repos/base/src/lib/base/root_proxy.cc @@ -72,8 +72,7 @@ namespace { /** * Call functor 'fn' with root capability for a given service name */ - template - void apply(Service::Name const &name, FUNC const &fn) + void apply(Service::Name const &name, auto const &fn) { /* * Protect '_services' but execute 'fn' with the mutex released. diff --git a/repos/base/src/lib/ldso/include/config.h b/repos/base/src/lib/ldso/include/config.h index 2ad11c87a2..c5851d77a0 100644 --- a/repos/base/src/lib/ldso/include/config.h +++ b/repos/base/src/lib/ldso/include/config.h @@ -65,8 +65,7 @@ class Linker::Config : Noncopyable * * The functor 'fn' is called with 'Rom_name', 'Keep' as arguments. */ - template - void for_each_library(FN const &fn) const + void for_each_library(auto const &fn) const { _config.with_optional_sub_node("ld", [&] (Xml_node ld) { diff --git a/repos/base/src/lib/ldso/include/dynamic.h b/repos/base/src/lib/ldso/include/dynamic.h index 7b298dcb9f..d31247a70f 100644 --- a/repos/base/src/lib/ldso/include/dynamic.h +++ b/repos/base/src/lib/ldso/include/dynamic.h @@ -307,8 +307,7 @@ class Linker::Dynamic /** * Call functor for each dependency, passing the path as argument */ - template - void for_each_dependency(FUNC const &fn) const + void for_each_dependency(auto const &fn) const { _needed.for_each([&] (Needed &n) { fn(n.path(_strtab)); }); diff --git a/repos/base/src/lib/ldso/include/file.h b/repos/base/src/lib/ldso/include/file.h index b5a807a62f..b9d8e94859 100644 --- a/repos/base/src/lib/ldso/include/file.h +++ b/repos/base/src/lib/ldso/include/file.h @@ -74,8 +74,7 @@ struct Linker::File unsigned elf_phdr_count() const { return phdr.count; } - template - void with_rw_phdr(FN const &fn) const + void with_rw_phdr(auto const &fn) const { for (unsigned i = 0; i < phdr.count; i++) { if (is_rw(phdr.phdr[i])) { diff --git a/repos/base/src/lib/ldso/include/linker.h b/repos/base/src/lib/ldso/include/linker.h index 4fe1234b8a..2820c171bc 100644 --- a/repos/base/src/lib/ldso/include/linker.h +++ b/repos/base/src/lib/ldso/include/linker.h @@ -197,18 +197,16 @@ class Linker::Object : private Fifo::Element, _fifo.remove(obj); } - template - void for_each(FUNC const &func) + void for_each(auto const &fn) { Mutex::Guard guard(_mutex); - _fifo.for_each(func); + _fifo.for_each(fn); } }; - template - static void with_object_list(FUNC const func) + static void with_object_list(auto const &fn) { - func(_object_list()); + fn(_object_list()); } virtual ~Object() { } @@ -267,11 +265,10 @@ namespace Linker { /** * Apply func to each object */ - template - void for_each_object(FUNC const &func) + void for_each_object(auto const &fn) { Object::with_object_list([&] (Object::Object_list &list) { - list.for_each(func); }); + list.for_each(fn); }); } } diff --git a/repos/base/src/lib/ldso/include/relocation_generic.h b/repos/base/src/lib/ldso/include/relocation_generic.h index f19cd4e840..c20ad2da56 100644 --- a/repos/base/src/lib/ldso/include/relocation_generic.h +++ b/repos/base/src/lib/ldso/include/relocation_generic.h @@ -106,8 +106,7 @@ class Linker::Reloc_non_plt_generic * safely here since all other DSO are loaded, relocated, and constructed at * this point */ - template - void _copy(REL const *rel, Elf::Addr *addr) + void _copy(auto const *rel, Elf::Addr *addr) { if (!_dep.obj().is_binary()) { error("LD: copy relocation in DSO "