os/include: use C++20 function template syntax

Issue #5227
This commit is contained in:
Norman Feske 2024-05-22 17:22:53 +02:00 committed by Christian Helmuth
parent 5e862b2cd3
commit cfd013a01a
32 changed files with 183 additions and 293 deletions

View File

@ -98,8 +98,7 @@ class Block::Request_stream : Genode::Noncopyable
* If the request does not carry any payload, 'fn' is not
* called.
*/
template <typename FN>
void with_content(Block::Request request, FN const &fn) const
void with_content(Block::Request request, auto const &fn) const
{
if (_valid_range_and_alignment(request))
fn(_request_ptr(request), _request_size(request));
@ -148,8 +147,7 @@ class Block::Request_stream : Genode::Noncopyable
* The 'Payload' interface allows the functor to access the content
* of a request by calling 'Payload::with_content'.
*/
template <typename FN>
void with_payload(FN const &fn) const { fn(_payload); }
void with_payload(auto const &fn) const { fn(_payload); }
/**
* Call functor 'fn' with the pointer and size to the 'request' content
@ -158,8 +156,7 @@ class Block::Request_stream : Genode::Noncopyable
* in situations where the 'Payload' interface does not need to be
* propagated as argument.
*/
template <typename FN>
void with_content(Request const &request, FN const &fn) const
void with_content(Request const &request, auto const &fn) const
{
_payload.with_content(request, fn);
}
@ -174,8 +171,7 @@ class Block::Request_stream : Genode::Noncopyable
* packet stream. If the request could not be accepted, the iteration
* aborts and the request packet stays in the packet stream.
*/
template <typename FN>
void with_requests(FN const &fn)
void with_requests(auto const &fn)
{
Tx_sink &tx_sink = *_tx.sink();
@ -287,8 +283,7 @@ class Block::Request_stream : Genode::Noncopyable
* iteration stops when the acknowledgement queue is fully populated or if
* the functor does not call 'Ack::submit'.
*/
template <typename FN>
void try_acknowledge(FN const &fn)
void try_acknowledge(auto const &fn)
{
Tx_sink &tx_sink = *_tx.sink();

View File

@ -118,8 +118,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
_operation.count - _position) };
}
template <typename FN>
static void _with_offset_and_length(Job &job, FN const &fn)
static void _with_offset_and_length(Job &job, auto const &fn)
{
if (!Operation::has_payload(job._operation.type))
return;
@ -131,8 +130,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
Genode::min(job._payload.bytes, operation.count * block_size));
}
template <typename POLICY>
void _submit(POLICY &policy, _JOB &job, Tx::Source &tx)
void _submit(auto &policy, _JOB &job, Tx::Source &tx)
{
if (!_tag.constructed())
return;
@ -210,16 +208,14 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
*
* \return true if progress was made
*/
template <typename POLICY>
bool _try_process_ack(POLICY &, Tx::Source &);
bool _try_process_ack(auto &, Tx::Source &);
/**
* Submit next pending job to server, if possible
*
* \return true if a job was successfully submitted
*/
template <typename POLICY>
bool _try_submit_pending_job(POLICY &, Tx::Source &);
bool _try_submit_pending_job(auto &, Tx::Source &);
public:
@ -260,8 +256,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
*
* \return true if progress was made
*/
template <typename POLICY>
bool update_jobs(POLICY &policy)
bool update_jobs(auto &policy)
{
Tx::Source &tx = *_tx.source();
@ -330,8 +325,7 @@ struct Block::Connection : Genode::Connection<Session>, Session_client
* This method is intended for the destruction of the jobs associated
* with the connection before destructing the 'Connection' object.
*/
template <typename FN>
void dissolve_all_jobs(FN const &fn)
void dissolve_all_jobs(auto const &fn)
{
_pending.dequeue_all([&] (Genode::Fifo_element<_JOB> &elem) {
fn(elem.object()); });

View File

@ -98,8 +98,7 @@ struct Capture::Session : Genode::Session
Rect rects[NUM_RECTS];
template <typename FN>
void for_each_rect(FN const &fn) const
void for_each_rect(auto const &fn) const
{
for (unsigned i = 0; i < NUM_RECTS; i++)
if (rects[i].valid())

View File

@ -83,11 +83,7 @@ class Capture::Connection::Screen
size(size), _connection(connection), _ds(rm, _connection.dataspace())
{ }
template <typename FN>
void with_texture(FN const &fn) const
{
fn(_texture);
}
void with_texture(auto const &fn) const { fn(_texture); }
void apply_to_surface(Surface<Pixel> &surface)
{

View File

@ -85,8 +85,7 @@ class Decorator::Window_stack : public Window_base::Draw_behind_fn
return result;
}
template <typename FN>
inline void update_model(Xml_node root_node, FN const &flush);
inline void update_model(Xml_node root_node, auto const &flush_fn);
bool schedule_animated_windows()
{
@ -107,8 +106,7 @@ class Decorator::Window_stack : public Window_base::Draw_behind_fn
*
* The functor is called with 'Window_base &' as argument.
*/
template <typename FUNC>
void for_each_window(FUNC const &func) { _windows.for_each(func); }
void for_each_window(auto const &fn) { _windows.for_each(fn); }
void update_gui_views()
{
@ -186,9 +184,8 @@ void Decorator::Window_stack::_draw_rec(Decorator::Canvas_base &canvas,
}
template <typename FN>
void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
FN const &flush_window_stack_changes)
auto const &flush_window_stack_changes_fn)
{
Abandoned_windows _abandoned_windows { };
@ -280,7 +277,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
* Apply window-creation operations before destroying windows to prevent
* flickering.
*/
flush_window_stack_changes();
flush_window_stack_changes_fn();
/*
* Destroy abandoned window objects

View File

@ -90,8 +90,7 @@ class Event::Session_client : public Genode::Rpc_client<Session>
_ds(local_rm, call<Rpc_dataspace>())
{ }
template <typename FN>
void with_batch(FN const &fn)
void with_batch(auto const &fn)
{
Batch_impl batch { *this };

View File

@ -39,14 +39,13 @@ struct File_system::Connection : Genode::Connection<Session>, Session_client
*
* \noapi
*/
template <typename FUNC>
auto _retry(FUNC func) -> decltype(func())
auto _retry(auto const &fn) -> decltype(fn())
{
enum { UPGRADE_ATTEMPTS = ~0U };
return Genode::retry<Out_of_ram>(
[&] () {
return Genode::retry<Out_of_caps>(
[&] () { return func(); },
[&] () { return fn(); },
[&] () { File_system::Connection::upgrade_caps(2); },
UPGRADE_ATTEMPTS);
},

View File

@ -248,8 +248,7 @@ class File_system::Packet_descriptor : public Genode::Packet_descriptor
size_t length() const { return _op != Opcode::WRITE_TIMESTAMP ? _length : 0; }
bool succeeded() const { return _success; }
template <typename FN>
void with_timestamp(FN const &fn) const
void with_timestamp(auto const &fn) const
{
if (_op == Opcode::WRITE_TIMESTAMP)
fn(_modification_time);

View File

@ -97,11 +97,8 @@ class Gui::Session_client : public Genode::Rpc_client<Session>
* Only in the corner case when there is not space left in the command
* buffer, the 'execute' is called to make room in the buffer.
*/
template <typename CMD, typename... ARGS>
void enqueue(ARGS... args)
{
enqueue(Command( CMD { args... } ));
}
template <typename CMD>
void enqueue(auto &&... args) { enqueue(Command( CMD { args... } )); }
void enqueue(Command const &command)
{

View File

@ -55,8 +55,7 @@ struct I2c::Session : public Genode::Session
Message() {}
template<typename ... ARGS>
Message(Type type, ARGS ... args)
Message(Type type, auto ... args)
: Byte_array(args...), type(type) {}
};

View File

@ -146,71 +146,61 @@ class Input::Event
return release() && _attr.release.key == key;
}
template <typename FN>
void handle_press(FN const &fn) const
void handle_press(auto const &fn) const
{
if (press() && _valid(_attr.press.key))
fn(_attr.press.key, _attr.press.codepoint);
}
template <typename FN>
void handle_repeat(FN const &fn) const
void handle_repeat(auto const &fn) const
{
if (key_press(KEY_UNKNOWN) && _attr.press.codepoint.valid())
fn(_attr.press.codepoint);
}
template <typename FN>
void handle_release(FN const &fn) const
void handle_release(auto const &fn) const
{
if (release() && _valid(_attr.release.key))
fn(_attr.release.key);
}
template <typename FN>
void handle_relative_motion(FN const &fn) const
void handle_relative_motion(auto const &fn) const
{
if (relative_motion())
fn(_attr.rel_motion.x, _attr.rel_motion.y);
}
template <typename FN>
void handle_absolute_motion(FN const &fn) const
void handle_absolute_motion(auto const &fn) const
{
if (absolute_motion())
fn(_attr.abs_motion.x, _attr.abs_motion.y);
}
template <typename FN>
void handle_wheel(FN const &fn) const
void handle_wheel(auto const &fn) const
{
if (wheel())
fn(_attr.wheel.x, _attr.wheel.y);
}
template <typename FN>
void handle_touch(FN const &fn) const
void handle_touch(auto const &fn) const
{
if (touch())
fn(_attr.touch.id, _attr.touch.x, _attr.touch.y);
}
template <typename FN>
void handle_touch_release(FN const &fn) const
void handle_touch_release(auto const &fn) const
{
if (touch_release())
fn(_attr.touch_release.id);
}
template <typename FN>
void handle_seq_number(FN const &fn) const
void handle_seq_number(auto const &fn) const
{
if (seq_number())
fn(_attr.seq_number);
}
template <typename FN>
void handle_axis(FN const &fn) const
void handle_axis(auto const &fn) const
{
if (axis())
fn(_attr.axis.id, _attr.axis.value);

View File

@ -56,17 +56,16 @@ class Input::Session_client : public Genode::Rpc_client<Session>
/**
* Flush and apply functor to pending events
*
* \param func functor in the form of f(Event const &e)
* \param fn functor in the form of f(Event const &e)
* \return number of events processed
*/
template <typename FUNC>
void for_each_event(FUNC const &func)
void for_each_event(auto const &fn)
{
Genode::size_t const n = Genode::min((Genode::size_t)call<Rpc_flush>(), _max_events);
Event const *ev_buf = _event_ds.local_addr<const Event>();
for (Genode::size_t i = 0; i < n; ++i)
func(ev_buf[i]);
fn(ev_buf[i]);
}
};

View File

@ -25,8 +25,7 @@ namespace Genode {
struct Genode::Gdb_hex : Hex
{
template <typename T>
explicit Gdb_hex(T value) : Hex(value, OMIT_PREFIX, PAD) { }
explicit Gdb_hex(auto value) : Hex(value, OMIT_PREFIX, PAD) { }
};

View File

@ -217,13 +217,12 @@ class Net::Dhcp_packet
Dns_server(Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
template <typename FUNC>
void for_each_address(FUNC && func) const
void for_each_address(auto const &fn) const
{
for (unsigned idx = 0;
idx < len() / sizeof(_dns_servers[0]); idx++) {
func(_dns_servers[idx]);
fn(_dns_servers[idx]);
}
}
};
@ -243,10 +242,9 @@ class Net::Dhcp_packet
Domain_name (Genode::size_t len) : Option(CODE, (Genode::uint8_t)len) { }
template <typename FUNC>
void with_string(FUNC && func) const
void with_string(auto const &fn) const
{
func(_name, Option::len());
fn(_name, Option::len());
}
};
@ -427,12 +425,11 @@ class Net::Dhcp_packet
_size_guard(size_guard)
{ }
template <typename OPTION, typename... ARGS>
void append_option(ARGS &&... args)
template <typename OPTION>
void append_option(auto &&... args)
{
_size_guard.consume_head(sizeof(OPTION));
Genode::construct_at<OPTION>((void *)_base,
static_cast<ARGS &&>(args)...);
Genode::construct_at<OPTION>((void *)_base, args...);
_base += sizeof(OPTION);
}
@ -479,10 +476,9 @@ class Net::Dhcp_packet
/*
* Call 'functor' of type 'FUNC' for each option (except END options)
* Call 'fn' of type 'FUNC' for each option (except END options)
*/
template <typename FUNC>
void for_each_option(FUNC && functor) const
void for_each_option(auto const &fn) const
{
for (unsigned i = 0; ; ) {
Option &opt = *(Option*)&_opts[i];
@ -491,7 +487,7 @@ class Net::Dhcp_packet
{
return;
}
functor(opt);
fn(opt);
i += 2 + opt.len();
}
}

View File

@ -53,8 +53,7 @@ class Genode::Buffered_xml
*
* \throw Allocation::Out_of_memory
*/
template <typename FN>
Allocation _generate(char const *node_name, FN const &fn, size_t size)
Allocation _generate(char const *node_name, auto const &fn, size_t size)
{
Allocation allocation { };
@ -103,14 +102,12 @@ class Genode::Buffered_xml
*
* \throw Allocator::Out_of_memory
*/
template <typename FN>
Buffered_xml(Allocator &alloc, char const *name, FN const &fn, Min_size size)
Buffered_xml(Allocator &alloc, char const *name, auto const &fn, Min_size size)
:
_alloc(alloc), _allocation(_generate(name, fn, size.value))
{ }
template <typename FN>
Buffered_xml(Allocator &alloc, char const *name, FN const &fn)
Buffered_xml(Allocator &alloc, char const *name, auto const &fn)
:
Buffered_xml(alloc, name, fn, Min_size{4000})
{ }
@ -125,8 +122,7 @@ class Genode::Buffered_xml
/**
* Call functor 'fn' with 'Xml_node const &' as argument
*/
template <typename FN>
void with_xml_node(FN const &fn) const { fn(_xml); }
void with_xml_node(auto const &fn) const { fn(_xml); }
};
#endif /* _OS__BUFFERED_XML_H_ */

View File

@ -124,13 +124,12 @@ class Genode::Reporter
*/
struct Xml_generator : public Genode::Xml_generator
{
template <typename FUNC>
Xml_generator(Reporter &reporter, FUNC const &func)
Xml_generator(Reporter &reporter, auto const &fn)
:
Genode::Xml_generator(reporter._base(),
reporter._size(),
reporter._xml_name.string(),
func)
fn)
{
if (reporter.enabled())
reporter._conn->report.submit(used());
@ -188,8 +187,7 @@ class Genode::Expanding_reporter
: _env(env), _type(type), _label(label), _buffer_size(size.value)
{ _construct(); }
template <typename FN>
void generate(FN const &fn)
void generate(auto const &fn)
{
retry<Xml_generator::Buffer_exceeded>(

View File

@ -24,9 +24,9 @@ namespace Genode {
struct Xml_node_label_score;
template <size_t N, typename MATCH_FN, typename NO_MATCH_FN>
template <size_t N>
void with_matching_policy(String<N> const &, Xml_node const &,
MATCH_FN const &, NO_MATCH_FN const &);
auto const &, auto const &);
class Session_policy;
}
@ -169,11 +169,11 @@ struct Genode::Xml_node_label_score
* argmument
* \param no_match_fn functor called if no matching policy exists
*/
template <Genode::size_t N, typename MATCH_FN, typename NO_MATCH_FN>
void Genode::with_matching_policy(String<N> const &label,
Xml_node const &policies,
MATCH_FN const &match_fn,
NO_MATCH_FN const &no_match_fn)
template <Genode::size_t N>
void Genode::with_matching_policy(String<N> const &label,
Xml_node const &policies,
auto const &match_fn,
auto const &no_match_fn)
{
/*
* Find policy node that matches best

View File

@ -37,12 +37,8 @@ namespace Genode {
}
template <typename>
class Watch_handler;
template <typename FN>
void with_raw_file_content(Readonly_file const &,
Byte_range_ptr const &, FN const &);
template <typename FN>
void with_xml_file_content(Readonly_file const &,
Byte_range_ptr const &, FN const &);
void with_raw_file_content(Readonly_file const &, Byte_range_ptr const &, auto const &);
void with_xml_file_content(Readonly_file const &, Byte_range_ptr const &, auto const &);
}
@ -188,8 +184,7 @@ struct Genode::Directory : Noncopyable, Interface
~Directory() { if (_handle) _handle->ds().close(_handle); }
template <typename FN>
void for_each_entry(FN const &fn)
void for_each_entry(auto const &fn)
{
for (unsigned i = 0;; i++) {
@ -231,8 +226,7 @@ struct Genode::Directory : Noncopyable, Interface
}
}
template <typename FN>
void for_each_entry(FN const &fn) const
void for_each_entry(auto const &fn) const
{
auto const_fn = [&] (Entry const &e) { fn(e); };
const_cast<Directory &>(*this).for_each_entry(const_fn);
@ -608,9 +602,8 @@ class Genode::Readonly_file : public File
*
* \throw Truncated_during_read
*/
template <typename FN>
void Genode::with_raw_file_content(Readonly_file const &file,
Byte_range_ptr const &range, FN const &fn)
Byte_range_ptr const &range, auto const &fn)
{
if (range.num_bytes == 0)
return;
@ -628,9 +621,8 @@ void Genode::with_raw_file_content(Readonly_file const &file,
* If the file does not contain valid XML, 'fn' is called with an
* '<empty/>' node as argument.
*/
template <typename FN>
void Genode::with_xml_file_content(Readonly_file const &file,
Byte_range_ptr const &range, FN const &fn)
Byte_range_ptr const &range, auto const &fn)
{
with_raw_file_content(file, range, [&] (char const *ptr, size_t num_bytes) {
@ -713,8 +705,7 @@ class Genode::File_content
* If the file does not contain valid XML, 'fn' is called with an
* '<empty/>' node as argument.
*/
template <typename FN>
void xml(FN const &fn) const
void xml(auto const &fn) const
{
try {
if (_buffer.size) {
@ -732,8 +723,8 @@ class Genode::File_content
*
* \param STRING string type used for the line
*/
template <typename STRING, typename FN>
void for_each_line(FN const &fn) const
template <typename STRING>
void for_each_line(auto const &fn) const
{
char const *src = _buffer.ptr;
char const *curr_line = src;
@ -766,8 +757,7 @@ class Genode::File_content
*
* If the buffer has a size of zero, 'fn' is not called.
*/
template <typename FN>
void bytes(FN const &fn) const
void bytes(auto const &fn) const
{
if (_buffer.size)
fn((char const *)_buffer.ptr, _buffer.size);

View File

@ -625,8 +625,7 @@ struct Pci::Config : Genode::Mmio<0x45>
read<Base_class_code>() == Base_class_code::BRIDGE;
}
template <typename MEM_FN, typename IO_FN>
void for_each_bar(MEM_FN const & memory, IO_FN const & io)
void for_each_bar(auto const &memory_fn, auto const &io_fn)
{
Genode::size_t const reg_cnt =
(read<Header_type::Type>()) ? BASE_ADDRESS_COUNT_TYPE_1
@ -637,10 +636,10 @@ struct Pci::Config : Genode::Mmio<0x45>
if (!reg0.valid())
continue;
if (reg0.memory()) {
memory(reg0.addr(), reg0.size(), i, reg0.prefetchable());
memory_fn(reg0.addr(), reg0.size(), i, reg0.prefetchable());
if (reg0.bit64()) i++;
} else
io(reg0.addr(), reg0.size(), i);
io_fn(reg0.addr(), reg0.size(), i);
}
};

View File

@ -55,8 +55,7 @@ class Platform::Connection : public Genode::Connection<Session>,
void _handle_io() {}
template <typename FN>
Capability<Device_interface> _wait_for_device(FN const & fn)
Capability<Device_interface> _wait_for_device(auto const &fn)
{
for (;;) {
/* repeatedly check for availability of device */
@ -117,8 +116,7 @@ class Platform::Connection : public Genode::Connection<Session>,
return Client::alloc_dma_buffer(size, cache); });
}
template <typename FN>
void with_xml(FN const & fn)
void with_xml(auto const &fn)
{
try {
if (_ds.constructed() && _ds->local_addr<void const>()) {

View File

@ -146,18 +146,16 @@ struct Genode::Smbios_entry_point
namespace Genode::Smbios_table
{
template <typename PHY_MEM_FUNC,
typename EP_FUNC>
bool smbios_3(addr_t const anchor,
addr_t const ep_phy,
PHY_MEM_FUNC const &phy_mem,
EP_FUNC const &handle_ep)
bool smbios_3(addr_t const anchor,
addr_t const ep_phy,
auto const &phy_mem_fn,
auto const &handle_ep_fn)
{
if (memcmp((char *)anchor, "_SM3_", 5)) {
return false;
}
Smbios_3_entry_point const &ep { *(Smbios_3_entry_point *)
phy_mem(ep_phy, sizeof(Smbios_3_entry_point)) };
phy_mem_fn(ep_phy, sizeof(Smbios_3_entry_point)) };
if (!ep.length_valid()) {
warning("SMBIOS 3 entry point has bad length");
@ -172,22 +170,20 @@ namespace Genode::Smbios_table
return false;
}
log("SMBIOS 3 table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
handle_ep(ep);
handle_ep_fn(ep);
return true;
}
template <typename PHY_MEM_FUNC,
typename EP_FUNC>
bool smbios(addr_t const anchor,
addr_t const ep_phy,
PHY_MEM_FUNC const &phy_mem,
EP_FUNC const &handle_ep)
bool smbios(addr_t const anchor,
addr_t const ep_phy,
auto const &phy_mem_fn,
auto const &handle_ep_fn)
{
if (memcmp((char *)anchor, "_SM_", 4)) {
return false;
}
Smbios_entry_point const &ep { *(Smbios_entry_point *)
phy_mem(ep_phy, sizeof(Smbios_entry_point)) };
phy_mem_fn(ep_phy, sizeof(Smbios_entry_point)) };
if (!ep.length_valid()) {
warning("SMBIOS entry point has bad length");
@ -206,87 +202,77 @@ namespace Genode::Smbios_table
return false;
}
log("SMBIOS table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
handle_ep(ep);
handle_ep_fn(ep);
return true;
}
template <typename PHY_MEM_FUNC,
typename EP_FUNC>
bool dmi(addr_t const anchor,
addr_t const ep_phy,
PHY_MEM_FUNC const &phy_mem,
EP_FUNC const &handle_ep)
bool dmi(addr_t const anchor,
addr_t const ep_phy,
auto const &phy_mem_fn,
auto const &handle_ep_fn)
{
if (memcmp((char *)anchor, "_DMI_", 5)) {
return false;
}
Dmi_entry_point const &ep { *(Dmi_entry_point *)
phy_mem(ep_phy, sizeof(Dmi_entry_point)) };
phy_mem_fn(ep_phy, sizeof(Dmi_entry_point)) };
if (!ep.checksum_correct()) {
warning("DMI entry point has bad checksum");
return false;
}
log("DMI table (entry point: ", Hex(anchor), " structures: ", Hex(ep.struct_table_addr), ")");
handle_ep(ep);
handle_ep_fn(ep);
return true;
}
template <typename PHY_MEM_FUNC,
typename SMBIOS_3_FUNC,
typename SMBIOS_FUNC,
typename DMI_FUNC>
void from_scan(PHY_MEM_FUNC const &phy_mem,
SMBIOS_3_FUNC const &handle_smbios_3_ep,
SMBIOS_FUNC const &handle_smbios_ep,
DMI_FUNC const &handle_dmi_ep)
void from_scan(auto const &phy_mem_fn,
auto const &handle_smbios_3_ep_fn,
auto const &handle_smbios_ep_fn,
auto const &handle_dmi_ep_fn)
{
enum { SCAN_BASE_PHY = 0xf0000 };
enum { SCAN_SIZE = 0x10000 };
enum { SCAN_SIZE_SMBIOS = 0xfff0 };
enum { SCAN_STEP = 0x10 };
addr_t const scan_base { (addr_t)phy_mem(SCAN_BASE_PHY, SCAN_SIZE) };
addr_t const scan_base { (addr_t)phy_mem_fn(SCAN_BASE_PHY, SCAN_SIZE) };
try {
addr_t const scan_end { scan_base + SCAN_SIZE };
size_t const scan_end_smbios { scan_base + SCAN_SIZE_SMBIOS };
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
if (smbios_3(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_smbios_3_ep)) {
if (smbios_3(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_smbios_3_ep_fn)) {
return;
}
}
for (addr_t curr { scan_base }; curr < scan_end_smbios; curr += SCAN_STEP ) {
if (smbios(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_smbios_ep)) {
if (smbios(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_smbios_ep_fn)) {
return;
}
}
for (addr_t curr { scan_base }; curr < scan_end; curr += SCAN_STEP ) {
if (dmi(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem, handle_dmi_ep)) {
if (dmi(curr, SCAN_BASE_PHY + (curr - scan_base), phy_mem_fn, handle_dmi_ep_fn)) {
return;
}
}
} catch (...) { }
}
template <typename PHY_MEM_FUNC,
typename SMBIOS_3_FUNC,
typename SMBIOS_FUNC,
typename DMI_FUNC>
void from_pointer(addr_t const table_phy,
PHY_MEM_FUNC const &phy_mem,
SMBIOS_3_FUNC const &handle_smbios_3_ep,
SMBIOS_FUNC const &handle_smbios_ep,
DMI_FUNC const &handle_dmi_ep)
void from_pointer(addr_t const table_phy,
auto const &phy_mem_fn,
auto const &handle_smbios_3_ep_fn,
auto const &handle_smbios_ep_fn,
auto const &handle_dmi_ep_fn)
{
addr_t const anchor { (addr_t)phy_mem(table_phy, 5) };
if (smbios_3(anchor, table_phy, phy_mem, handle_smbios_3_ep)) {
addr_t const anchor { (addr_t)phy_mem_fn(table_phy, 5) };
if (smbios_3(anchor, table_phy, phy_mem_fn, handle_smbios_3_ep_fn)) {
return;
}
if (smbios(anchor, table_phy, phy_mem, handle_smbios_ep)) {
if (smbios(anchor, table_phy, phy_mem_fn, handle_smbios_ep_fn)) {
return;
}
dmi(anchor, table_phy, phy_mem, handle_dmi_ep);
dmi(anchor, table_phy, phy_mem_fn, handle_dmi_ep_fn);
}
};

View File

@ -57,9 +57,7 @@ namespace Terminal {
flush_ok();
}
template <typename... ARGS>
void print(ARGS &&... args) {
Output::out_args(*this, args...); }
void print(auto &&... args) { Output::out_args(*this, args...); }
};
struct Ascii

View File

@ -37,8 +37,7 @@ class Trace_buffer
/**
* Call functor for each entry that wasn't yet processed
*/
template <typename FUNC>
void for_each_new_entry(FUNC && functor, bool update = true)
void for_each_new_entry(auto const &fn, bool update = true)
{
using namespace Genode;
@ -72,7 +71,7 @@ class Trace_buffer
continue;
/* functor may return false to continue processing later on */
if (!functor(entry))
if (!fn(entry))
break;
}

View File

@ -42,8 +42,7 @@ class Usb::Connection : public Genode::Connection<Session>, public Usb::Client
void _handle_io() { }
template <typename FN>
Device_capability _wait_for_device(FN const & fn)
Device_capability _wait_for_device(auto const & fn)
{
for (;;) {
/* repeatedly check for availability of device */
@ -84,8 +83,7 @@ class Usb::Connection : public Genode::Connection<Session>, public Usb::Client
void sigh(Signal_context_capability sigh) { _rom.sigh(sigh); }
template <typename FN>
void with_xml(FN const & fn)
void with_xml(auto const & fn)
{
update();
try {

View File

@ -129,13 +129,11 @@ class Usb::Urb_handler
: 0;
}
template <typename URB,
typename OUT_FN,
typename ISOC_OUT_FN>
void _submit(URB &urb,
Tx::Source &tx,
OUT_FN const &out_fn,
ISOC_OUT_FN const &isoc_out_fn)
template <typename URB>
void _submit(URB &urb,
Tx::Source &tx,
auto const &out_fn,
auto const &isoc_out_fn)
{
if (!_tag.constructed())
return;
@ -169,14 +167,12 @@ class Usb::Urb_handler
tx.try_submit_packet(p);
}
template <typename URB,
typename IN_FN,
typename ISOC_IN_FN>
template <typename URB>
void _in_results(URB &urb,
Packet_descriptor p,
Tx::Source &tx,
IN_FN const &in_fn,
ISOC_IN_FN const &isoc_in_fn)
auto const &in_fn,
auto const &isoc_in_fn)
{
if (!_isoc_packets) {
Const_byte_range_ptr src { (const char*)tx.packet_content(p),
@ -235,18 +231,12 @@ class Usb::Urb_handler
Id_space<Urb> _tags { };
Fifo<Fifo_element<Urb>> _pending { };
template <typename URB,
typename IN_FN,
typename ISOC_IN_FN,
typename CPL_FN>
bool _try_process_ack(Tx::Source &, IN_FN const &,
ISOC_IN_FN const &, CPL_FN const &);
template <typename>
bool _try_process_ack(Tx::Source &, auto const &,
auto const &, auto const &);
template <typename URB,
typename OUT_FN,
typename ISOC_OUT_FN>
bool _try_submit_pending_urb(Tx::Source &, OUT_FN const &,
ISOC_OUT_FN const &);
template <typename>
bool _try_submit_pending_urb(Tx::Source &, auto const &, auto const &);
public:
@ -261,17 +251,12 @@ class Usb::Urb_handler
*
* \return true if progress was made
*/
template <typename URB,
typename OUT_FN,
typename IN_FN,
typename ISOC_OUT_FN,
typename ISOC_IN_FN,
typename CPL_FN>
bool update_urbs(OUT_FN const &out_fn,
IN_FN const &in_fn,
ISOC_OUT_FN const &isoc_out_fn,
ISOC_IN_FN const &isoc_in_fn,
CPL_FN const &complete_fn)
template <typename URB>
bool update_urbs(auto const &out_fn,
auto const &in_fn,
auto const &isoc_out_fn,
auto const &isoc_in_fn,
auto const &complete_fn)
{
typename Tx::Source &tx = *_tx.source();
@ -411,17 +396,12 @@ class Usb::Interface
void sigh(Signal_context_capability cap) {
_urb_handler.sigh(cap); }
template <typename URB,
typename OUT_FN,
typename IN_FN,
typename ISOC_OUT_FN,
typename ISOC_IN_FN,
typename CPL_FN>
bool update_urbs(OUT_FN const &out_fn,
IN_FN const &in_fn,
ISOC_OUT_FN const &isoc_out_fn,
ISOC_IN_FN const &isoc_in_fn,
CPL_FN const &complete_fn)
template <typename URB>
bool update_urbs(auto const &out_fn,
auto const &in_fn,
auto const &isoc_out_fn,
auto const &isoc_in_fn,
auto const &complete_fn)
{
return _urb_handler.update_urbs<URB>(out_fn, in_fn, isoc_out_fn,
isoc_in_fn, complete_fn);
@ -575,12 +555,11 @@ struct Usb::Interface::Alt_setting : Device::Urb
template <typename SESSION>
template <typename URB, typename IN_FN, typename ISOC_IN_FN, typename CPL_FN>
bool
Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
IN_FN const &in_fn,
ISOC_IN_FN const &isoc_in,
CPL_FN const &complete_fn)
template <typename URB>
bool Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
auto const &in_fn,
auto const &isoc_in,
auto const &complete_fn)
{
if (!tx.ack_avail())
return false;
@ -610,11 +589,10 @@ Usb::Urb_handler<SESSION>::_try_process_ack(Tx::Source &tx,
template <typename SESSION>
template <typename URB, typename OUT_FN, typename ISOC_FN>
bool
Usb::Urb_handler<SESSION>::_try_submit_pending_urb(Tx::Source &tx,
OUT_FN const &out_fn,
ISOC_FN const &isoc_fn)
template <typename URB>
bool Usb::Urb_handler<SESSION>::_try_submit_pending_urb(Tx::Source &tx,
auto const &out_fn,
auto const &isoc_fn)
{
if (_pending.empty())
return false;
@ -732,8 +710,7 @@ inline Usb::Device::Name Usb::Device::_first_device_name()
}
template <typename FN>
void Usb::Device::_for_each_iface(FN const & fn)
void Usb::Device::_for_each_iface(auto const & fn)
{
_session.with_xml([&] (Xml_node & xml) {
xml.for_each_sub_node("device", [&] (Xml_node node) {

View File

@ -17,18 +17,17 @@
/**
* Calculate quadratic bezier curve
*
* \param draw_line functor to be called to draw a line segment
* \param levels number of sub divisions
* \param draw_line_fn functor to be called to draw a line segment
* \param levels number of sub divisions
*
* The coordinates are specified in clock-wise order with point 1 being
* the start and point 3 the end of the curve.
*/
template <typename FUNC>
static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
FUNC const &draw_line, unsigned levels)
auto const &draw_line_fn, unsigned levels)
{
if (levels-- == 0) {
draw_line(x1, y1, x3, y3);
draw_line_fn(x1, y1, x3, y3);
return;
}
@ -36,8 +35,8 @@ static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
x23 = (x2 + x3) / 2, y23 = (y2 + y3) / 2,
x123 = (x12 + x23) / 2, y123 = (y12 + y23) / 2;
bezier(x1, y1, x12, y12, x123, y123, draw_line, levels);
bezier(x123, y123, x23, y23, x3, y3, draw_line, levels);
bezier(x1, y1, x12, y12, x123, y123, draw_line_fn, levels);
bezier(x123, y123, x23, y23, x3, y3, draw_line_fn, levels);
}
@ -47,13 +46,12 @@ static inline void bezier(long x1, long y1, long x2, long y2, long x3, long y3,
* The arguments correspond to those of the quadratic version but with point 4
* being the end of the curve.
*/
template <typename FUNC>
static inline void bezier(long x1, long y1, long x2, long y2,
long x3, long y3, long x4, long y4,
FUNC const &draw_line, unsigned levels)
auto const &draw_line_fn, unsigned levels)
{
if (levels-- == 0) {
draw_line(x1, y1, x4, y4);
draw_line_fn(x1, y1, x4, y4);
return;
}
@ -64,8 +62,8 @@ static inline void bezier(long x1, long y1, long x2, long y2,
x234 = (x23 + x34) / 2, y234 = (y23 + y34) / 2,
x1234 = (x123 + x234) / 2, y1234 = (y123 + y234) / 2;
bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, draw_line, levels);
bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, draw_line, levels);
bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, draw_line_fn, levels);
bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, draw_line_fn, levels);
}
#endif /* _INCLUDE__GEMS__BEZIER_H_ */

View File

@ -77,8 +77,7 @@ class Genode::Dirty_rect
* The functor 'fn' takes a 'Rect const &' as argument.
* This method resets the dirty rectangles.
*/
template <typename FN>
void flush(FN const &fn)
void flush(auto const &fn)
{
/*
* Merge rectangles if their compound is smaller than sum of their

View File

@ -29,8 +29,7 @@ namespace Genode {
/**
* Return the number of characters needed when rendering 'args' as text
*/
template <typename... ARGS>
static unsigned printed_length(ARGS &&... args)
static unsigned printed_length(auto &&... args)
{
struct _Output : Output
{

View File

@ -170,9 +170,9 @@ class Vfs::Dir_file_system : public File_system
* \param fn functor that takes a file-system reference and
* the path as arguments
*/
template <typename RES, typename FN>
template <typename RES>
RES _dir_op(RES const no_entry, RES const no_perm, RES const ok,
char const *path, FN const &fn)
char const *path, auto const &fn)
{
path = _sub_path(path);

View File

@ -149,9 +149,8 @@ class Vfs::Vfs_handle
*
* XXX: may not be necesarry if the method above is virtual.
*/
template <typename FUNC>
void apply_handler(FUNC const &func) const {
if (_handler_ptr) func(*_handler_ptr); }
void apply_handler(auto const &fn) const {
if (_handler_ptr) fn(*_handler_ptr); }
/**
* Notify application through response handler

View File

@ -104,8 +104,7 @@ class Virtio::Device
Device_mmio _isr { _bar_range("irq_status") };
size_t _notify_offset_multiplier { 0 };
template <typename FN>
void with_virtio_range(String<16> type, FN const & fn)
void with_virtio_range(String<16> type, auto const &fn)
{
_plat.update();
_plat.with_xml([&] (Xml_node xml) {

View File

@ -429,8 +429,7 @@ class Virtio::Queue
return true;
}
template <typename FN>
void read_data(FN const &fn)
void read_data(auto const &fn)
{
if (!has_used_buffers())
return;
@ -470,12 +469,12 @@ class Virtio::Queue
return *((Header_type *)(desc_data));
}
template <typename REPLY_TYPE, typename WAIT_REPLY_FN, typename REPLY_FN>
bool write_data_read_reply(Header_type const &header,
char const *data,
size_t data_size,
WAIT_REPLY_FN const &wait_for_reply,
REPLY_FN const &read_reply)
template <typename REPLY_TYPE>
bool write_data_read_reply(Header_type const &header,
char const *data,
size_t data_size,
auto const &wait_for_reply_fn,
auto const &read_reply_fn)
{
static_assert(!TRAITS::device_write_only);
static_assert(TRAITS::has_data_payload);
@ -521,7 +520,7 @@ class Virtio::Queue
_avail->idx = _avail->idx + 1;
_avail->flags = Avail::Flags::NO_INTERRUPT;
wait_for_reply();
wait_for_reply_fn();
/*
* Make sure wait call did what it was supposed to do.
@ -536,16 +535,16 @@ class Virtio::Queue
*/
ack_all_transfers();
return read_reply(*reinterpret_cast<REPLY_TYPE const *>(reply_buffer.local_addr));
return read_reply_fn(*reinterpret_cast<REPLY_TYPE const *>(reply_buffer.local_addr));
}
template <typename REPLY_TYPE, typename WAIT_REPLY_FN, typename REPLY_FN>
bool write_data_read_reply(Header_type const &header,
WAIT_REPLY_FN const &wait_for_reply,
REPLY_FN const &read_reply)
template <typename REPLY_TYPE>
bool write_data_read_reply(Header_type const &header,
auto const &wait_for_reply_fn,
auto const &read_reply_fn)
{
return write_data_read_reply<REPLY_TYPE>(
header, nullptr, 0, wait_for_reply, read_reply);
header, nullptr, 0, wait_for_reply_fn, read_reply_fn);
}
void print(Output& output) const