Date: Thu, 16 Mar 2023 10:06:11 -0400 From: Justin Hibbits <jhibbits@FreeBSD.org> To: freebsd-arch@freebsd.org Subject: Blocks runtime in the kernel Message-ID: <20230316100611.4892008c@gonegalt.net>
index | next in thread | raw e-mail
Most probably know I've been working on the IfAPI conversion of all
network drivers in order to hide the contents of `struct ifnet`. I'm
pretty much done with the development, and it's all in review.
However, there's one bit that I've thought is very clunky since I added
it, the if_foreach() iterator function, which iterates over all
interfaces in the current VNET, and calls a callback to operate on each
interface. I've noticed that oftentimes I end up with a 2 line
callback, which just calls if_foreach_addr_type(), so I end up with
just trivial callback functions, which seems like a waste.
All that backstory to say, would it be beneficial to anyone else to
add a (very basic) blocks runtime to the kernel for doing things like
this? The rough change to the IfAPI becomes:
int if_foreach_b(int (^)(if_t));
__block int foo = 0;
if_foreach_b(^(if_t ifp) {
if (if_getlinkstate(ifp) == LINK_STATE_UP)
foo++;
});
The same could be done for other *_foreach KPIs as well, if this proves
out. I think I could have something working in the next several days.
The only technical snag I see with this would be other compilers. I'm
not sure if GCC still supports blocks, it did at one point.
What do you think?
- Justin
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20230316100611.4892008c>
