From nobody Thu Mar 16 14:06:11 2023 X-Original-To: freebsd-arch@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Pcpvp2Dt1z3y9Dl for ; Thu, 16 Mar 2023 14:06:14 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Pcpvp08g1z3HTY for ; Thu, 16 Mar 2023 14:06:14 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678975574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JIKF1n1HvTdvUS6JMPkVdquBzemFhmFxzxKUQLPvIa4=; b=scAloWCZ73ucJ7shXnYNgMhAuZNAl3dJf7+n/eLTtYu7R5st4ymSJH2RIDzbiFOHz3b9l9 VjrGNBB3soAT/4pwskomDQt0VIjiZthGUS5xez6Z9XetsM7D+DHpHQoTqBCZeCrtCS6KqV tC70FL3KJny34ml8g+TWPQXlaxzPZz/rr0A2YM4V+yh3L4mDd62547/ktKAsAKegEAPANi TPTOBjqdoVuqy5YQGFJfD5DPO30aINJAkqpFq7l3W0Gw7ryLd4VGjLPgYscYSwJVekSatC DuoCVz6g6TfbHrKY3d2lwDuIASd4buvzayBgw4w5VbMdfSD0SDsQ+FVMD60rtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678975574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JIKF1n1HvTdvUS6JMPkVdquBzemFhmFxzxKUQLPvIa4=; b=HPG+a/fJsZEN2DwBgV4z4KxmpWoMFUMIdnInIBPWS1DRMX/WKOvPlgVMvYi0FFnNL2v4o1 hpvGu6NxK/ruFPdFS+6hMbRuyQ2T4LWdauDuWfNvAGxI1vPe8l/aJ1ihB6KiFi6fpOMcAV 41ijiY7hOw5z0x3033eYJBNboGPSXQ1zrR9U37y0R51RxOPzjar91ZjLe5FVJ18Ahh/ZSd 9h6yDNGmapG0Nh84qCE1CGVr4Mwn5PE15v/WbFoaNKRxw43VRd3WbP1tsdYjLTfOnd9K5k joYh2YsAkJRDtFbQ3TiMQEjaPmqnGnd8N8dKKkCHIkER7Tz/2K44RRwOkbKiuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678975574; a=rsa-sha256; cv=none; b=OAxkaelMj7niYZPfv5oIIAYVyFspRD/mtbvAWD/buK1TZf+hfr8MoVd09Sj54dLGfFswob ub/dJGiWAQ4fLEjpBbWFQ585WsdxJVr9ALrP5YkLfz5g2Di2RtKSgIw6UiJj+k13sNf01j gPtKuVV87jYNYfz1VTBHQ54zAk+CSV+tDK+jAwSDdZ9A+A/kwtWDDi/fJCssigbjI4XAQX tPSrD08nl1M5n+TN7oCMBe2GXo9a27Iw/kTC1vv9SA7X0p881zAr6Dkfr7bhUpG3dCo/zp LO/p9ZpYQqGfDKtxYcUJ/glc5rORDAm4CUrMQKtvzIVqSeAZIjEl9QJY4TcU5Q== Received: from gonegalt.net (ip-163-182-7-56.dynamic.fuse.net [163.182.7.56]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhibbits) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Pcpvn5WgVzXWY for ; Thu, 16 Mar 2023 14:06:13 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Date: Thu, 16 Mar 2023 10:06:11 -0400 From: Justin Hibbits To: freebsd-arch@freebsd.org Subject: Blocks runtime in the kernel Message-ID: <20230316100611.4892008c@gonegalt.net> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.34; powerpc64le-unknown-linux-gnu) List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N 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